-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
464 additions
and
17 deletions.
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.