(
name: string,
scenarioFactory: ScenarioFactory,
)
| 61 | } |
| 62 | |
| 63 | async runScenario( |
| 64 | name: string, |
| 65 | scenarioFactory: ScenarioFactory, |
| 66 | ): Promise<EndpointStats> { |
| 67 | debug('Starting scenario %j', name); |
| 68 | const {worker, url} = await startWorker(); |
| 69 | debug('Worker started - pid=%s url=%s', worker.pid, url); |
| 70 | |
| 71 | const client = new Client(url); |
| 72 | const autocannon = this.cannonFactory(url); |
| 73 | |
| 74 | const runner = new scenarioFactory(); |
| 75 | debug('Setting up the scenario'); |
| 76 | await runner.setup(client); |
| 77 | debug('Pinging the app'); |
| 78 | await client.ping(); |
| 79 | debug('Starting the stress test.'); |
| 80 | const result = await runner.execute(autocannon); |
| 81 | debug('Stats: %j', result); |
| 82 | |
| 83 | await closeWorker(worker); |
| 84 | debug('Worker stopped, done.'); |
| 85 | |
| 86 | this.logger(name, result); |
| 87 | |
| 88 | return result; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | function startWorker() { |
no test coverage detected