Skip to content

PHPLIB-718: APM spec tests for serverConnectionId #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions tests/UnifiedSpecTests/EventObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 */
Expand Down
3 changes: 0 additions & 3 deletions tests/UnifiedSpecTests/UnifiedSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
1 change: 0 additions & 1 deletion tests/UnifiedSpecTests/UnifiedTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down