From 92d7108d0330d849023033d5a1a4bb54457ae375 Mon Sep 17 00:00:00 2001 From: Aleksandr Rudo Date: Tue, 10 May 2022 02:27:40 +0300 Subject: [PATCH 1/4] Syncing specification tests. --- .../command-monitoring/pre-42-server-connection-id.json | 2 +- .../command-monitoring/server-connection-id.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json b/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json index 141fbe584..76d139e5f 100644 --- a/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json +++ b/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json @@ -98,4 +98,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json b/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json index a8f27637f..5ae914245 100644 --- a/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json +++ b/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json @@ -98,4 +98,4 @@ ] } ] -} +} \ No newline at end of file From 5f025e1128963498e50c277ddb84a282dec5335d Mon Sep 17 00:00:00 2001 From: Aleksandr Rudo Date: Tue, 17 May 2022 00:21:52 +0300 Subject: [PATCH 2/4] Updating events with new serverConnectionId --- tests/UnifiedSpecTests/EventObserver.php | 21 ++++++++++++++++++--- tests/UnifiedSpecTests/UnifiedSpecTest.php | 3 --- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/UnifiedSpecTests/EventObserver.php b/tests/UnifiedSpecTests/EventObserver.php index 651d21b2d..842dfb89a 100644 --- a/tests/UnifiedSpecTests/EventObserver.php +++ b/tests/UnifiedSpecTests/EventObserver.php @@ -262,7 +262,7 @@ private function assertEvent($actual, stdClass $expected, string $message) private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->command)) { assertIsObject($expected->command); @@ -284,11 +284,16 @@ private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->reply)) { assertIsObject($expected->reply); @@ -305,11 +310,16 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->commandName)) { assertIsString($expected->commandName); @@ -320,6 +330,11 @@ private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $ assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } /** @param CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent $event */ diff --git a/tests/UnifiedSpecTests/UnifiedSpecTest.php b/tests/UnifiedSpecTests/UnifiedSpecTest.php index 5db237cbb..80b531255 100644 --- a/tests/UnifiedSpecTests/UnifiedSpecTest.php +++ b/tests/UnifiedSpecTests/UnifiedSpecTest.php @@ -59,9 +59,6 @@ class UnifiedSpecTest extends FunctionalTestCase 'valid-pass/entity-client-cmap-events: events are captured during an operation' => 'PHPC does not implement CMAP', 'valid-pass/expectedEventsForClient-eventType: eventType can be set to command and cmap' => 'PHPC does not implement CMAP', 'valid-pass/expectedEventsForClient-eventType: eventType defaults to command if unset' => 'PHPC does not implement CMAP', - // Command monitoring event serverConnectionId is not yet implemented - 'command-monitoring/pre-42-server-connection-id: command events do not include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)', - 'command-monitoring/server-connection-id: command events include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)', // Change stream "comment" option is not yet implemented 'change-streams/change-streams: Test with document comment' => 'Not yet implemented (PHPLIB-749)', 'change-streams/change-streams: Test with document comment - pre 4.4' => 'Not yet implemented (PHPLIB-749)', From 4a14d468f9d93e508e14a564fe686b917f210c5c Mon Sep 17 00:00:00 2001 From: Aleksandr Rudo Date: Tue, 17 May 2022 11:17:27 +0300 Subject: [PATCH 3/4] Removing unwanted changes. --- .../command-monitoring/pre-42-server-connection-id.json | 2 +- .../command-monitoring/server-connection-id.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json b/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json index 76d139e5f..141fbe584 100644 --- a/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json +++ b/tests/UnifiedSpecTests/command-monitoring/pre-42-server-connection-id.json @@ -98,4 +98,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json b/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json index 5ae914245..a8f27637f 100644 --- a/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json +++ b/tests/UnifiedSpecTests/command-monitoring/server-connection-id.json @@ -98,4 +98,4 @@ ] } ] -} \ No newline at end of file +} From 6451c2b0f45b233b6c62e887c1afafdbd39418ec Mon Sep 17 00:00:00 2001 From: Aleksandr Rudo Date: Tue, 17 May 2022 14:18:23 +0300 Subject: [PATCH 4/4] Removing outdated TODO comment. --- tests/UnifiedSpecTests/UnifiedTestRunner.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/UnifiedSpecTests/UnifiedTestRunner.php b/tests/UnifiedSpecTests/UnifiedTestRunner.php index 5a2718223..a378f7996 100644 --- a/tests/UnifiedSpecTests/UnifiedTestRunner.php +++ b/tests/UnifiedSpecTests/UnifiedTestRunner.php @@ -60,7 +60,6 @@ final class UnifiedTestRunner public const MIN_SCHEMA_VERSION = '1.0'; - // Note: schema version 1.6 is not yet implemented (see: PHPLIB-718) public const MAX_SCHEMA_VERSION = '1.7'; /** @var MongoDB\Client */