-
Notifications
You must be signed in to change notification settings - Fork 261
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
Fix CursorId
and Event::getServer()
deprecation in tests
#1423
Conversation
…rver is deprecated
…::getServer is deprecated
I added fixes for calls to
mongo-php-library/tests/UnifiedSpecTests/FailPointObserver.php Lines 46 to 49 in b27a61d
Tracked in PHPLIB-1531 |
3408927
to
de7948b
Compare
@@ -120,7 +120,7 @@ private function handleCommandMonitoringEvent($event): void | |||
'name' => self::getEventName($event), | |||
'observedAt' => microtime(true), | |||
'commandName' => $event->getCommandName(), | |||
'connectionId' => self::getConnectionId($event), | |||
'connectionId' => $event->getServerConnectionId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logs and the $eventList
property are never used. They can be useful for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoting the Workload Executor Specification from drivers-atlas-testing:
each object is expected to have a name string field and an observedAt numeric field, in addition to any other fields specific to the event's type.
The only other field here that corresponds to an existing field in the Unified Test Format spec's expectedEvent section is commandName
. That said, I think the original intention of connectionId
here was from the client's perspective, so this should also change to a host/port combination. I'd also propose renaming this to server
and adding serverConnectionId
(which may not have existed at the time we implemented Atlas testing). I'll address that in my forthcoming PR to address my other feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: #1428
CursorId
and Event::getServer()
deprecation in tests
de7948b
to
e3a370d
Compare
@@ -65,7 +64,8 @@ public function testRetryOnDifferentMongos(): void | |||
|
|||
// Step 4: Enable failed command event monitoring for client | |||
$subscriber = new class implements CommandSubscriber { | |||
public $commandFailedServers = []; | |||
/** @var int[] */ | |||
public array $commandFailedServers = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later, this was used for the following assertion:
/* Step 6: Assert that two failed command events occurred. Assert that
* the failed command events occurred on different mongoses. */
Per getServerConnectionId()
, the connection ID is unique within the context of a single server. It is also only reported by MongoDB 4.2+. I think the correct change here would have been to replace getServer()
with a concatenation of the server host/port. I'll make the change in a subsequent PR.
As-is, I think this might sometimes fail if both mongoses reported the same connection ID or if we test on mongos 4.0.
public Server $commandSucceededServer; | ||
public Server $commandFailedServer; | ||
public ?int $commandSucceededServer = null; | ||
public ?int $commandFailedServer = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relates the following assertion:
/* Step 6: Assert that exactly one failed command event and one
* succeeded command event occurred. Assert that both events occurred on
* the same mongos. */
Those rely on assertNotNull()
, so this could also fail on a 4.0 server where connection IDs are not reported.
Related to #1366