mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-03-13 09:26:40 -04:00
[ci skip] progress on performance logging in tests
This commit is contained in:
parent
27a102bf7c
commit
33456c8437
3
veilid-wasm/tests/.gitignore
vendored
3
veilid-wasm/tests/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
coverage
|
coverage
|
||||||
|
test_results
|
@ -1,6 +1,4 @@
|
|||||||
import { expect } from '@wdio/globals';
|
import { expect } from '@wdio/globals';
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
veilidCoreInitConfig,
|
veilidCoreInitConfig,
|
||||||
@ -114,15 +112,14 @@ describe('VeilidRoutingContext', () => {
|
|||||||
describe('DHT stress tests', () => {
|
describe('DHT stress tests', () => {
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await browser.cdp("Profiler", "enable")
|
await browser.startTracing({})
|
||||||
await browser.cdp("Profiler", "start")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should inspect in parallel without delay', async () => {
|
it('should inspect in parallel without delay', async () => {
|
||||||
|
|
||||||
const recordCount = 16;
|
const recordCount = 2;
|
||||||
const subkeyCount = 32;
|
const subkeyCount = 4;
|
||||||
const inspectCount = 10;
|
const inspectCount = 4;
|
||||||
const data = textEncoder.encode('🚀 This example DHT data with unicode a Ā 𐀀 文 🚀');
|
const data = textEncoder.encode('🚀 This example DHT data with unicode a Ā 𐀀 文 🚀');
|
||||||
|
|
||||||
let a = Array();
|
let a = Array();
|
||||||
@ -146,7 +143,7 @@ describe('VeilidRoutingContext', () => {
|
|||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(performance.measure(measureName, measureName + "-start").toJSON())
|
performance.measure(measureName, measureName + "-start")
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +159,7 @@ describe('VeilidRoutingContext', () => {
|
|||||||
"SyncSet",
|
"SyncSet",
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(performance.measure(measureName, measureName + "-start").toJSON())
|
performance.measure(measureName, measureName + "-start")
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,11 +170,11 @@ describe('VeilidRoutingContext', () => {
|
|||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
|
||||||
let profile = await browser.cdp("Profiler", "stop")
|
const events = await browser.endTracing()
|
||||||
|
if (events) {
|
||||||
|
await browser.writeFile("profile-dht-stress-test.json", events);
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(path.join(__dirname, "profile.json"), JSON.stringify(profile));
|
|
||||||
|
|
||||||
await browser.cdp("Profiler", "disable")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
78
veilid-wasm/tests/src/services/FileService.ts
Normal file
78
veilid-wasm/tests/src/services/FileService.ts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import type { Services } from '@wdio/types';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace WebdriverIO {
|
||||||
|
interface Browser {
|
||||||
|
/**
|
||||||
|
* Write data to a file
|
||||||
|
* @param filename The path to the file to write
|
||||||
|
* @param data The data to write to the file (string, Buffer, or object)
|
||||||
|
* @returns Promise that resolves when the file has been written
|
||||||
|
*/
|
||||||
|
writeFile(filename: string, data: string | Buffer | object): Promise<void>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FileService implements Services.ServiceInstance {
|
||||||
|
/**
|
||||||
|
* Constructor for the FileService
|
||||||
|
* @param _options Service options (unused)
|
||||||
|
* @param _capabilities WebdriverIO capabilities (unused)
|
||||||
|
* @param _config WebdriverIO config (unused)
|
||||||
|
*/
|
||||||
|
constructor(
|
||||||
|
private _options: Record<string, any> = {},
|
||||||
|
private _capabilities: WebdriverIO.Capabilities = {},
|
||||||
|
private _config: WebdriverIO.Config = { capabilities: [{}] }
|
||||||
|
) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before hook that gets executed before test execution begins
|
||||||
|
* This is where we add our custom commands to the browser object
|
||||||
|
*/
|
||||||
|
before(
|
||||||
|
_capabilities: WebdriverIO.Capabilities,
|
||||||
|
_specs: string[],
|
||||||
|
browser: WebdriverIO.Browser
|
||||||
|
): void {
|
||||||
|
/**
|
||||||
|
* Add a writeFile command to the browser object
|
||||||
|
* @param filename The path to the file to write
|
||||||
|
* @param data The data to write to the file
|
||||||
|
* @returns Promise that resolves when the file has been written
|
||||||
|
*/
|
||||||
|
browser.addCommand('writeFile', async function (
|
||||||
|
filename: string,
|
||||||
|
data: string | Buffer | object
|
||||||
|
): Promise<void> {
|
||||||
|
const fullPath = path.resolve(__dirname, '../../', filename);
|
||||||
|
// Ensure the directory exists
|
||||||
|
const dirname = path.dirname(fullPath);
|
||||||
|
if (!fs.existsSync(dirname)) {
|
||||||
|
fs.mkdirSync(dirname, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// If data is an object, stringify it
|
||||||
|
const content = typeof data === 'object' && !(data instanceof Buffer)
|
||||||
|
? JSON.stringify(data, null, 2)
|
||||||
|
: data;
|
||||||
|
|
||||||
|
// Write the file
|
||||||
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
fs.writeFile(filename, content, (err: NodeJS.ErrnoException | null) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
0
veilid-wasm/tests/test_results/.gitkeep
Normal file
0
veilid-wasm/tests/test_results/.gitkeep
Normal file
@ -1,6 +1,8 @@
|
|||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
/// <reference types="@wdio/types" />
|
/// <reference types="@wdio/types" />
|
||||||
|
|
||||||
|
import { FileService } from './src/services/FileService';
|
||||||
|
|
||||||
export const config: WebdriverIO.Config = {
|
export const config: WebdriverIO.Config = {
|
||||||
//
|
//
|
||||||
// ====================
|
// ====================
|
||||||
@ -101,10 +103,8 @@ export const config: WebdriverIO.Config = {
|
|||||||
// - @wdio/sumologic-reporter
|
// - @wdio/sumologic-reporter
|
||||||
// - @wdio/cli, @wdio/config, @wdio/utils
|
// - @wdio/cli, @wdio/config, @wdio/utils
|
||||||
// Level of logging verbosity: trace | debug | info | warn | error | silent
|
// Level of logging verbosity: trace | debug | info | warn | error | silent
|
||||||
// logLevels: {
|
logLevels: {
|
||||||
// webdriver: 'info',
|
},
|
||||||
// '@wdio/appium-service': 'info'
|
|
||||||
// },
|
|
||||||
//
|
//
|
||||||
// If you only want to run your tests until a specific amount of tests have failed use
|
// If you only want to run your tests until a specific amount of tests have failed use
|
||||||
// bail (default is 0 - don't bail, run all tests).
|
// bail (default is 0 - don't bail, run all tests).
|
||||||
@ -130,7 +130,7 @@ export const config: WebdriverIO.Config = {
|
|||||||
// Services take over a specific job you don't want to take care of. They enhance
|
// Services take over a specific job you don't want to take care of. They enhance
|
||||||
// your test setup with almost no effort. Unlike plugins, they don't add new
|
// your test setup with almost no effort. Unlike plugins, they don't add new
|
||||||
// commands. Instead, they hook themselves up into the test process.
|
// commands. Instead, they hook themselves up into the test process.
|
||||||
services: ['devtools'],
|
services: ['devtools', [FileService as any, {}]],
|
||||||
//
|
//
|
||||||
// Framework you want to run your specs with.
|
// Framework you want to run your specs with.
|
||||||
// The following are supported: Mocha, Jasmine, and Cucumber
|
// The following are supported: Mocha, Jasmine, and Cucumber
|
||||||
|
Loading…
x
Reference in New Issue
Block a user