Skip to content
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

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 19, 2024

Related to #1366

@GromNaN GromNaN requested a review from a team as a code owner September 19, 2024 07:05
@GromNaN GromNaN enabled auto-merge (squash) September 19, 2024 07:09
@GromNaN
Copy link
Member Author

GromNaN commented Sep 19, 2024

I added fixes for calls to Event::getServer(), using getServerConnectionId() instead.
But for the FailPointsOberver, I need an actual Server instance. This requires a larger refactoring.

$this->failPointsAndServers[] = [$command->configureFailPoint, $event->getServer()];

foreach ($this->failPointsAndServers as [$failPoint, $server]) {
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
$operation->execute($server);
}

Tracked in PHPLIB-1531

@@ -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(),
Copy link
Member Author

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.

Copy link
Member

@jmikola jmikola Sep 19, 2024

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #1428

@GromNaN GromNaN changed the title Fix CursorId deprecation in tests Fix CursorId and Event::getServer() deprecation in tests Sep 19, 2024
@GromNaN GromNaN merged commit 50d1db7 into mongodb:v1.20 Sep 19, 2024
34 of 36 checks passed
@GromNaN GromNaN deleted the cursorid-deprecation branch September 19, 2024 09:41
@@ -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 = [];
Copy link
Member

@jmikola jmikola Sep 19, 2024

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;
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants