From 3027c11e73cddf323aadbb0fa2d49d97172e9765 Mon Sep 17 00:00:00 2001 From: Don Hardman Date: Wed, 30 Oct 2024 14:23:47 +0700 Subject: [PATCH] Fix issue with elastic tests and improve output --- composer.lock | 8 ++++---- src/Plugin/Insert/Handler.php | 1 + test/Plugin/CliTable/CliTableHandlerTest.php | 5 +---- test/src/Trait/TestFunctionalTrait.php | 8 ++++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index d2489db4..bf78ba1f 100644 --- a/composer.lock +++ b/composer.lock @@ -715,12 +715,12 @@ "source": { "type": "git", "url": "https://github.com/manticoresoftware/buddy-core.git", - "reference": "80914a10da96af10588ab506721809143568a586" + "reference": "c3040639645815898f1e2909b6ed3daf4fe6f2e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/manticoresoftware/buddy-core/zipball/80914a10da96af10588ab506721809143568a586", - "reference": "80914a10da96af10588ab506721809143568a586", + "url": "https://api.github.com/repos/manticoresoftware/buddy-core/zipball/c3040639645815898f1e2909b6ed3daf4fe6f2e6", + "reference": "c3040639645815898f1e2909b6ed3daf4fe6f2e6", "shasum": "" }, "require": { @@ -758,7 +758,7 @@ "issues": "https://github.com/manticoresoftware/buddy-core/issues", "source": "https://github.com/manticoresoftware/buddy-core/tree/feature/cli-table-output" }, - "time": "2024-10-30T05:10:11+00:00" + "time": "2024-10-30T07:22:41+00:00" }, { "name": "manticoresoftware/manticoresearch-backup", diff --git a/src/Plugin/Insert/Handler.php b/src/Plugin/Insert/Handler.php index 2a131ce8..82a08fc3 100644 --- a/src/Plugin/Insert/Handler.php +++ b/src/Plugin/Insert/Handler.php @@ -61,6 +61,7 @@ public function run(): Task { $taskFn = static function (Payload $payload, Client $manticoreClient): TaskResult { for ($i = 0, $maxI = sizeof($payload->queries) - 1; $i <= $maxI; $i++) { $query = $payload->queries[$i]; + $resp = $manticoreClient->sendRequest($query, $i === 0 ? null : $payload->path); } diff --git a/test/Plugin/CliTable/CliTableHandlerTest.php b/test/Plugin/CliTable/CliTableHandlerTest.php index a1ed5984..7d246809 100644 --- a/test/Plugin/CliTable/CliTableHandlerTest.php +++ b/test/Plugin/CliTable/CliTableHandlerTest.php @@ -15,7 +15,6 @@ use Manticoresearch\Buddy\Core\ManticoreSearch\Endpoint as ManticoreEndpoint; use Manticoresearch\Buddy\Core\ManticoreSearch\RequestFormat; use Manticoresearch\Buddy\Core\Network\Request; -use Manticoresearch\Buddy\Core\Plugin\TableFormatter; use Manticoresearch\Buddy\Core\Tool\Buddy; use Manticoresearch\Buddy\CoreTest\Trait\TestHTTPServerTrait; use Manticoresearch\Buddy\CoreTest\Trait\TestInEnvironmentTrait; @@ -55,20 +54,18 @@ public function testCliTableOk(): void { $serverUrl = self::setUpMockManticoreServer(false); $manticoreClient = new HTTPClient($serverUrl); $manticoreClient->setForceSync(true); - $tableFormatter = new TableFormatter(); Payload::$type = 'queries'; $payload = Payload::fromRequest($request); $handler = new Handler($payload); $refCls = new ReflectionClass($handler); $refCls->getProperty('manticoreClient')->setValue($handler, $manticoreClient); - $refCls->getProperty('tableFormatter')->setValue($handler, $tableFormatter); go( function () use ($handler, $respBody) { $task = $handler->run(); $task->wait(true); $this->assertEquals(true, $task->isSucceed()); - $result = $task->getResult()->getStruct(); + $result = $task->getResult()->getTableFormatted(0); $this->assertIsString($result); $this->assertStringContainsString($respBody, $result); self::finishMockManticoreServer(); diff --git a/test/src/Trait/TestFunctionalTrait.php b/test/src/Trait/TestFunctionalTrait.php index 213b1ed6..3434f23b 100644 --- a/test/src/Trait/TestFunctionalTrait.php +++ b/test/src/Trait/TestFunctionalTrait.php @@ -309,10 +309,10 @@ protected static function runHttpQuery( ? 'Content-type: application/x-www-form-urlencoded' : 'Content-type: application/json' ); - exec( - "curl -s 127.0.0.1:$port/$path -H '$header' --data-binary @$payloadFile $redirect", - $output - ); + + $command = "curl -s 127.0.0.1:$port/$path -H '$header' --data-binary @$payloadFile $redirect"; + echo 'Commmand: ' . $command . PHP_EOL; + exec($command, $output); /** @var array{error:string}|array>,total?:string,columns?:string}> $result */ $result = match ($path) {