-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
test(NODE-3049): drivers atlas testing #3805
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { runUnifiedSuite } from '../tools/unified-spec-runner/runner'; | ||
|
||
describe('Node Driver Atlas Testing', async function () { | ||
// Astrolabe can, well, take some time. In some cases up to 800s to | ||
// reconfigure clusters. | ||
this.timeout(0); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const spec = JSON.parse(process.env.WORKLOAD_SPECIFICATION!); | ||
runUnifiedSuite([spec]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/tools/unified-spec-runner/astrolabe_results_writer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { writeFile } from 'node:fs/promises'; | ||
|
||
import * as path from 'path'; | ||
|
||
import type { EntitiesMap } from './entities'; | ||
import { trace } from './runner'; | ||
|
||
/** | ||
* Writes the entities saved from the loop operations run in the | ||
* Astrolabe workload executor to the required files. | ||
*/ | ||
export class AstrolabeResultsWriter { | ||
constructor(private entities: EntitiesMap) { | ||
this.entities = entities; | ||
} | ||
|
||
async write(): Promise<void> { | ||
// Write the events.json to the execution directory. | ||
const errors = this.entities.getEntity('errors', 'errors', false); | ||
const failures = this.entities.getEntity('failures', 'failures', false); | ||
const events = this.entities.getEntity('events', 'events', false); | ||
const iterations = this.entities.getEntity('iterations', 'iterations', false); | ||
const successes = this.entities.getEntity('successes', 'successes', false); | ||
|
||
// Write the events.json to the execution directory. | ||
trace('writing events.json'); | ||
await writeFile( | ||
path.join(process.env.OUTPUT_DIRECTORY ?? '', 'events.json'), | ||
JSON.stringify({ events: events ?? [], errors: errors ?? [], failures: failures ?? [] }) | ||
); | ||
|
||
// Write the results.json to the execution directory. | ||
trace('writing results.json'); | ||
await writeFile( | ||
path.join(process.env.OUTPUT_DIRECTORY ?? '', 'results.json'), | ||
JSON.stringify({ | ||
numErrors: errors?.length ?? 0, | ||
numFailures: failures?.length ?? 0, | ||
numSuccesses: successes ?? 0, | ||
numIterations: iterations ?? 0 | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
COMMAND_FAILED, | ||
COMMAND_STARTED, | ||
COMMAND_SUCCEEDED, | ||
CONNECTION_CHECK_OUT_FAILED, | ||
CONNECTION_CHECK_OUT_STARTED, | ||
CONNECTION_CHECKED_IN, | ||
CONNECTION_CHECKED_OUT, | ||
CONNECTION_CLOSED, | ||
CONNECTION_CREATED, | ||
CONNECTION_POOL_CLEARED, | ||
CONNECTION_POOL_CLOSED, | ||
CONNECTION_POOL_CREATED, | ||
CONNECTION_POOL_READY, | ||
CONNECTION_READY | ||
} from '../../mongodb'; | ||
import { type EntitiesMap, type UnifiedMongoClient } from './entities'; | ||
import { type ClientEntity } from './schema'; | ||
|
||
/** | ||
* Maps the names of the events the unified runner passes and maps | ||
* them to the names of the events emitted in the driver. | ||
*/ | ||
const MAPPINGS = { | ||
PoolCreatedEvent: CONNECTION_POOL_CREATED, | ||
PoolReadyEvent: CONNECTION_POOL_READY, | ||
PoolClearedEvent: CONNECTION_POOL_CLEARED, | ||
PoolClosedEvent: CONNECTION_POOL_CLOSED, | ||
ConnectionCreatedEvent: CONNECTION_CREATED, | ||
ConnectionReadyEvent: CONNECTION_READY, | ||
ConnectionClosedEvent: CONNECTION_CLOSED, | ||
ConnectionCheckOutStartedEvent: CONNECTION_CHECK_OUT_STARTED, | ||
ConnectionCheckOutFailedEvent: CONNECTION_CHECK_OUT_FAILED, | ||
ConnectionCheckedOutEvent: CONNECTION_CHECKED_OUT, | ||
ConnectionCheckedInEvent: CONNECTION_CHECKED_IN, | ||
CommandStartedEvent: COMMAND_STARTED, | ||
CommandSucceededEvent: COMMAND_SUCCEEDED, | ||
CommandFailedEvent: COMMAND_FAILED | ||
}; | ||
|
||
/** | ||
* Registers events that need to be stored in the entities map, since | ||
* the UnifiedMongoClient does not contain a cyclical dependency on the | ||
* entities map itself. | ||
*/ | ||
export class EntityEventRegistry { | ||
constructor( | ||
private client: UnifiedMongoClient, | ||
private clientEntity: ClientEntity, | ||
private entitiesMap: EntitiesMap | ||
) { | ||
this.client = client; | ||
this.clientEntity = clientEntity; | ||
this.entitiesMap = entitiesMap; | ||
} | ||
|
||
/** | ||
* Connect the event listeners on the client and the entities map. | ||
*/ | ||
register(): void { | ||
if (this.clientEntity.storeEventsAsEntities) { | ||
for (const { id, events } of this.clientEntity.storeEventsAsEntities) { | ||
this.entitiesMap.set(id, []); | ||
for (const eventName of events) { | ||
// Need to map the event names to the Node event names. | ||
this.client.on(MAPPINGS[eventName], () => { | ||
this.entitiesMap.getEntity('events', id).push({ | ||
name: eventName, | ||
observedAt: Date.now() | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since we have
ClientEncryption
in the driver now, I fixed this while I was in the area.