@vpalmisano/webrtcperf 4.4.9 → 4.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.min.js +1 -1
- package/build/src/docker.js +25 -11
- package/build/src/docker.js.map +1 -1
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -1
- package/build/src/scenarios.d.ts +166 -0
- package/build/src/scenarios.js +245 -0
- package/build/src/scenarios.js.map +1 -0
- package/build/src/utils.d.ts +0 -18
- package/build/src/utils.js +0 -59
- package/build/src/utils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -15
- package/src/docker.ts +26 -11
- package/src/index.ts +2 -0
- package/src/scenarios.ts +262 -0
- package/src/utils.ts +0 -73
package/build/src/docker.js
CHANGED
|
@@ -9,29 +9,40 @@ const utils_1 = require("./utils");
|
|
|
9
9
|
const config_1 = require("./config");
|
|
10
10
|
const throttler_1 = require("@vpalmisano/throttler");
|
|
11
11
|
const os_1 = __importDefault(require("os"));
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
const log = (0, utils_1.logger)('webrtcperf:docker');
|
|
13
14
|
async function runWithDocker(argv) {
|
|
14
15
|
const docker = new dockerode_1.default();
|
|
15
16
|
const configPath = argv[0];
|
|
16
17
|
if (!configPath)
|
|
17
18
|
throw new Error('No configuration file specified');
|
|
18
|
-
const
|
|
19
|
+
const configs = await (0, config_1.loadConfig)(configPath);
|
|
20
|
+
if (!configs.length)
|
|
21
|
+
throw new Error('Failed to load configuration file');
|
|
19
22
|
const startTimestamp = Date.now();
|
|
20
23
|
const dataDir = process.cwd();
|
|
21
|
-
const
|
|
24
|
+
const tmpDir = os_1.default.tmpdir();
|
|
25
|
+
const jsonConfigPath = `${tmpDir}/webrtcperf-config-${startTimestamp}.json`;
|
|
26
|
+
await fs_1.default.promises.writeFile(jsonConfigPath, JSON.stringify(configs), 'utf-8');
|
|
27
|
+
const binds = [
|
|
28
|
+
'/dev/shm:/dev/shm',
|
|
29
|
+
`${dataDir}:/data`,
|
|
30
|
+
`${tmpDir}/webrtcperf-cache:/root/.webrtcperf`,
|
|
31
|
+
`${jsonConfigPath}:/tmp/config.json:ro`,
|
|
32
|
+
];
|
|
22
33
|
if (process.env.DEBUG_SRC) {
|
|
23
34
|
binds.push(`${(0, utils_1.resolvePackagePath)('app.min.js')}:/app/app.min.js:ro`);
|
|
24
35
|
}
|
|
25
36
|
const portBindings = {};
|
|
26
37
|
const exposedPorts = {};
|
|
27
|
-
if (
|
|
28
|
-
for (let i = 0; i <
|
|
29
|
-
const port = `${
|
|
30
|
-
portBindings[port] = [{ HostPort: `${
|
|
38
|
+
if (configs[0].debuggingPort) {
|
|
39
|
+
for (let i = 0; i < configs[0].sessions; i++) {
|
|
40
|
+
const port = `${configs[0].debuggingPort + i}/tcp`;
|
|
41
|
+
portBindings[port] = [{ HostPort: `${configs[0].debuggingPort + i}` }];
|
|
31
42
|
exposedPorts[port] = {};
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
|
-
if (
|
|
45
|
+
if (configs[0].throttleConfig && os_1.default.platform() === 'linux') {
|
|
35
46
|
await (0, throttler_1.runShellCommand)('sudo modprobe ifb numifbs=1');
|
|
36
47
|
}
|
|
37
48
|
const env = [
|
|
@@ -43,19 +54,21 @@ async function runWithDocker(argv) {
|
|
|
43
54
|
'SERVER_DATA=/data',
|
|
44
55
|
`START_TIMESTAMP=${startTimestamp}`,
|
|
45
56
|
];
|
|
46
|
-
if (
|
|
57
|
+
if (configs[0].prometheusPushgateway.startsWith('http://localhost')) {
|
|
47
58
|
env.push('PROMETHEUS_PUSHGATEWAY=http://pushgateway:9091');
|
|
48
59
|
}
|
|
49
60
|
const containerConfig = {
|
|
50
61
|
Image: 'ghcr.io/vpalmisano/webrtcperf:devel',
|
|
51
62
|
name: 'webrtcperf',
|
|
52
63
|
WorkingDir: '/data',
|
|
53
|
-
Cmd:
|
|
64
|
+
Cmd: ['/tmp/config.json'],
|
|
54
65
|
HostConfig: {
|
|
55
66
|
Binds: binds,
|
|
56
67
|
PortBindings: portBindings,
|
|
57
|
-
CapAdd:
|
|
58
|
-
NetworkMode:
|
|
68
|
+
CapAdd: configs[0].throttleConfig && os_1.default.platform() === 'linux' ? ['NET_ADMIN'] : [],
|
|
69
|
+
NetworkMode: configs[0].prometheusPushgateway.startsWith('http://localhost')
|
|
70
|
+
? 'prometheus-stack_default'
|
|
71
|
+
: 'bridge',
|
|
59
72
|
ExtraHosts: process.env.EXTRA_HOSTS ? process.env.EXTRA_HOSTS.split(',').map(h => h.trim()) : [],
|
|
60
73
|
},
|
|
61
74
|
Env: env,
|
|
@@ -103,5 +116,6 @@ async function runWithDocker(argv) {
|
|
|
103
116
|
log.error('Docker operation failed:', error);
|
|
104
117
|
throw error;
|
|
105
118
|
}
|
|
119
|
+
await fs_1.default.promises.unlink(jsonConfigPath);
|
|
106
120
|
}
|
|
107
121
|
//# sourceMappingURL=docker.js.map
|
package/build/src/docker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../src/docker.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../src/docker.ts"],"names":[],"mappings":";;;;;AASA,sCAsHC;AA/HD,0DAA8B;AAC9B,mCAAoD;AACpD,qCAAqC;AACrC,qDAAuD;AACvD,4CAAmB;AACnB,4CAAmB;AAEnB,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,mBAAmB,CAAC,CAAA;AAEhC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,MAAM,MAAM,GAAG,IAAI,mBAAM,EAAE,CAAA;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACnE,MAAM,OAAO,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AC1B,SAAS,CAAC,IAAI,CAAC,CAAC,GAAU,EAAE,IAA4B,EAAE,EAAE;gBAC1D,IAAI,GAAG;oBAAE,GAAG,CAAC,KAAK,CAAC,8BAA8B,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;gBACnE,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,MAAM,SAAS,CAAC,MAAM,EAAE,CAAA;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;QAC5C,MAAM,KAAK,CAAA;IACb,CAAC;IAED,MAAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import Docker from 'dockerode'\nimport { logger, resolvePackagePath } from './utils'\nimport { loadConfig } from './config'\nimport { runShellCommand } from '@vpalmisano/throttler'\nimport os from 'os'\nimport fs from 'fs'\n\nconst log = logger('webrtcperf:docker')\n\nexport async function runWithDocker(argv: string[]) {\n const docker = new Docker()\n const configPath = argv[0]\n if (!configPath) throw new Error('No configuration file specified')\n const configs = await loadConfig(configPath)\n if (!configs.length) throw new Error('Failed to load configuration file')\n\n const startTimestamp = Date.now()\n const dataDir = process.cwd()\n const tmpDir = os.tmpdir()\n\n const jsonConfigPath = `${tmpDir}/webrtcperf-config-${startTimestamp}.json`\n await fs.promises.writeFile(jsonConfigPath, JSON.stringify(configs), 'utf-8')\n\n const binds: string[] = [\n '/dev/shm:/dev/shm',\n `${dataDir}:/data`,\n `${tmpDir}/webrtcperf-cache:/root/.webrtcperf`,\n `${jsonConfigPath}:/tmp/config.json:ro`,\n ]\n\n if (process.env.DEBUG_SRC) {\n binds.push(`${resolvePackagePath('app.min.js')}:/app/app.min.js:ro`)\n }\n\n const portBindings: Docker.PortMap = {}\n const exposedPorts: { [portAndProtocol: string]: object } = {}\n if (configs[0].debuggingPort) {\n for (let i = 0; i < configs[0].sessions; i++) {\n const port = `${configs[0].debuggingPort + i}/tcp`\n portBindings[port] = [{ HostPort: `${configs[0].debuggingPort + i}` }]\n exposedPorts[port] = {}\n }\n }\n\n if (configs[0].throttleConfig && os.platform() === 'linux') {\n await runShellCommand('sudo modprobe ifb numifbs=1')\n }\n\n const env = [\n `DEBUG_LEVEL=${process.env.DEBUG_LEVEL || 'info'}`,\n 'SHOW_PAGE_LOG=false',\n 'SHOW_STATS=false',\n 'SERVER_PORT=5000',\n 'SERVER_USE_HTTPS=true',\n 'SERVER_DATA=/data',\n `START_TIMESTAMP=${startTimestamp}`,\n ]\n\n if (configs[0].prometheusPushgateway.startsWith('http://localhost')) {\n env.push('PROMETHEUS_PUSHGATEWAY=http://pushgateway:9091')\n }\n\n const containerConfig: Docker.ContainerCreateOptions = {\n Image: 'ghcr.io/vpalmisano/webrtcperf:devel',\n name: 'webrtcperf',\n WorkingDir: '/data',\n Cmd: ['/tmp/config.json'],\n HostConfig: {\n Binds: binds,\n PortBindings: portBindings,\n CapAdd: configs[0].throttleConfig && os.platform() === 'linux' ? ['NET_ADMIN'] : [],\n NetworkMode: configs[0].prometheusPushgateway.startsWith('http://localhost')\n ? 'prometheus-stack_default'\n : 'bridge',\n ExtraHosts: process.env.EXTRA_HOSTS ? process.env.EXTRA_HOSTS.split(',').map(h => h.trim()) : [],\n },\n Env: env,\n AttachStdin: true,\n AttachStdout: true,\n AttachStderr: true,\n Tty: true,\n OpenStdin: true,\n StdinOnce: true,\n ExposedPorts: exposedPorts,\n }\n\n try {\n if (!process.env.DEBUG_SRC) {\n log.info('Pulling latest webrtcperf image...')\n await docker.pull('ghcr.io/vpalmisano/webrtcperf:devel')\n }\n\n try {\n const existingContainer = await docker.getContainer('webrtcperf')\n await existingContainer.remove({ force: true })\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (err: unknown) {\n // Container doesn't exist, continue\n }\n\n const container = await docker.createContainer(containerConfig)\n await container.start()\n\n const stream = await container.attach({\n stream: true,\n stdin: true,\n stdout: true,\n stderr: true,\n })\n\n process.stdin.pipe(stream)\n stream.pipe(process.stdout)\n\n await new Promise(resolve => {\n container.wait((err: Error, data: { StatusCode: number }) => {\n if (err) log.error('Error waiting for container:', data, err.stack)\n resolve(data)\n })\n })\n\n await container.remove()\n } catch (error) {\n log.error('Docker operation failed:', error)\n throw error\n }\n\n await fs.promises.unlink(jsonConfigPath)\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './app';
|
|
2
2
|
export * from './config';
|
|
3
|
+
export * from './docker';
|
|
3
4
|
export * from './media';
|
|
4
5
|
export * from './rtcstats';
|
|
5
6
|
export * from './server';
|
|
@@ -7,3 +8,4 @@ export * from './session';
|
|
|
7
8
|
export * from './stats';
|
|
8
9
|
export * from './utils';
|
|
9
10
|
export * from './vmaf';
|
|
11
|
+
export * from './scenarios';
|
package/build/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./app"), exports);
|
|
18
18
|
__exportStar(require("./config"), exports);
|
|
19
|
+
__exportStar(require("./docker"), exports);
|
|
19
20
|
__exportStar(require("./media"), exports);
|
|
20
21
|
__exportStar(require("./rtcstats"), exports);
|
|
21
22
|
__exportStar(require("./server"), exports);
|
|
@@ -23,4 +24,5 @@ __exportStar(require("./session"), exports);
|
|
|
23
24
|
__exportStar(require("./stats"), exports);
|
|
24
25
|
__exportStar(require("./utils"), exports);
|
|
25
26
|
__exportStar(require("./vmaf"), exports);
|
|
27
|
+
__exportStar(require("./scenarios"), exports);
|
|
26
28
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,2CAAwB;AACxB,0CAAuB;AACvB,6CAA0B;AAC1B,2CAAwB;AACxB,4CAAyB;AACzB,0CAAuB;AACvB,0CAAuB;AACvB,yCAAsB","sourcesContent":["export * from './app'\nexport * from './config'\nexport * from './media'\nexport * from './rtcstats'\nexport * from './server'\nexport * from './session'\nexport * from './stats'\nexport * from './utils'\nexport * from './vmaf'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,2CAAwB;AACxB,2CAAwB;AACxB,0CAAuB;AACvB,6CAA0B;AAC1B,2CAAwB;AACxB,4CAAyB;AACzB,0CAAuB;AACvB,0CAAuB;AACvB,yCAAsB;AACtB,8CAA2B","sourcesContent":["export * from './app'\nexport * from './config'\nexport * from './docker'\nexport * from './media'\nexport * from './rtcstats'\nexport * from './server'\nexport * from './session'\nexport * from './stats'\nexport * from './utils'\nexport * from './vmaf'\nexport * from './scenarios'\n"]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { FastStats } from './stats';
|
|
2
|
+
import { ThrottleRule } from '@vpalmisano/throttler';
|
|
3
|
+
/**
|
|
4
|
+
* It parses a CSV stats file and returns an array of objects representing each row.
|
|
5
|
+
* @param filePath The path to the CSV stats file.
|
|
6
|
+
* @returns An array of objects where each object represents a row in the CSV file with keys as column headers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseStatsFile(filePath: string): Promise<Record<string, string | number>[]>;
|
|
9
|
+
export type StatsSummary = {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
id: string;
|
|
12
|
+
scenario: string;
|
|
13
|
+
videoRecvBitratePerPixel: FastStats;
|
|
14
|
+
videoRecvFps: FastStats;
|
|
15
|
+
videoSentFps: FastStats;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* It aggregates the stats summary from multiple test runs in a directory.
|
|
19
|
+
* @param options.dirPath Directory path containing test run subdirectories. Default is 'logs'.
|
|
20
|
+
* @param options.senderParticipantName Participant name of the sender. Default is 'Participant-000001'.
|
|
21
|
+
* @param options.receiverParticipantName Participant name of the receiver. Default is 'Participant-000000'.
|
|
22
|
+
* @param options.nameParser Function to parse test directory names. Default splits by '_' and extracts id and scenario.
|
|
23
|
+
* @returns Array of aggregated stats including timestamp, id, scenario, videoRecvBitratePerPixel, videoRecvFps, and videoSentFps.
|
|
24
|
+
*/
|
|
25
|
+
export declare function aggregateStatsSummary({ dirPath, senderParticipantName, receiverParticipantName, nameParser, }: {
|
|
26
|
+
dirPath?: string | undefined;
|
|
27
|
+
senderParticipantName?: string | undefined;
|
|
28
|
+
receiverParticipantName?: string | undefined;
|
|
29
|
+
nameParser?: ((name: string) => {
|
|
30
|
+
id: string;
|
|
31
|
+
scenario: string;
|
|
32
|
+
}) | undefined;
|
|
33
|
+
}): Promise<StatsSummary[]>;
|
|
34
|
+
/**
|
|
35
|
+
* It uploads the aggregated stats to a Google Sheet.
|
|
36
|
+
* A valid Google service account credentials file must be specified
|
|
37
|
+
* in the `GOOGLE_CREDENTIALS_PATH` environment variable.
|
|
38
|
+
* @param stats The aggregated stats to upload.
|
|
39
|
+
* @param spreadsheetId The ID of the Google Spreadsheet.
|
|
40
|
+
* @param table The name of the table (sheet) within the spreadsheet. Default is 'data'.
|
|
41
|
+
*/
|
|
42
|
+
export declare function uploadStatsToGoogleSheet(stats: StatsSummary[], spreadsheetId: string, table?: string): Promise<void>;
|
|
43
|
+
export type ThrottleDirection = 'up' | 'down' | 'bidi';
|
|
44
|
+
export declare function formatThrottleRule(throttleRule: ThrottleRule & {
|
|
45
|
+
direction: ThrottleDirection;
|
|
46
|
+
}, human?: boolean): string;
|
|
47
|
+
export declare function parseThrottleRule(throttleDesc: string): {
|
|
48
|
+
direction: ThrottleDirection;
|
|
49
|
+
rate: number;
|
|
50
|
+
loss: number;
|
|
51
|
+
delay: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* It generates a test configuration with a scenario including 2 participants.
|
|
55
|
+
* The first participant sends video and the second receives it.
|
|
56
|
+
* Both participants send and receive audio.
|
|
57
|
+
* The network conditions are applied according to the specified direction to the sender (`up`),
|
|
58
|
+
* the receiver (`down`) or both (`bidi`).
|
|
59
|
+
* The test is repeated the specified number of times.
|
|
60
|
+
* The output is an array of partial configuration objects that can be used to run the tests
|
|
61
|
+
* with the main application, after merging it with a configuration that includes
|
|
62
|
+
* the destination url (mandatory) and other optional parameters.
|
|
63
|
+
* @param id The unique identifier for the test scenario.
|
|
64
|
+
* @param options.rate The target bandwidth in kbps.
|
|
65
|
+
* @param options.loss The packet loss percentage.
|
|
66
|
+
* @param options.delay The network delay in milliseconds.
|
|
67
|
+
* @param options.direction The direction of the network throttling: 'up', 'down', or 'bidi'.
|
|
68
|
+
* @param repeat The number of times to repeat the test scenario. Default is 1.
|
|
69
|
+
* @returns An array of partial configuration objects for each test scenario.
|
|
70
|
+
*/
|
|
71
|
+
export declare function twoParticipantsWithRateLossDelay(id: string, { rate, loss, delay, direction }: {
|
|
72
|
+
rate: number;
|
|
73
|
+
loss: number;
|
|
74
|
+
delay: number;
|
|
75
|
+
direction: ThrottleDirection;
|
|
76
|
+
}, repeat: 1): Promise<Partial<{
|
|
77
|
+
url: string;
|
|
78
|
+
urlQuery: string;
|
|
79
|
+
customUrlHandler: string;
|
|
80
|
+
videoPath: string;
|
|
81
|
+
videoWidth: number;
|
|
82
|
+
videoHeight: number;
|
|
83
|
+
videoFramerate: number;
|
|
84
|
+
videoSeek: number;
|
|
85
|
+
videoDuration: number;
|
|
86
|
+
videoCacheRaw: boolean;
|
|
87
|
+
videoCachePath: string;
|
|
88
|
+
videoFormat: string;
|
|
89
|
+
useFakeMedia: boolean;
|
|
90
|
+
runDuration: number;
|
|
91
|
+
throttleConfig: string;
|
|
92
|
+
useBrowserThrottling: boolean;
|
|
93
|
+
randomAudioPeriod: number;
|
|
94
|
+
randomAudioProbability: number;
|
|
95
|
+
randomAudioRange: string;
|
|
96
|
+
chromiumPath: string;
|
|
97
|
+
chromiumVersion: any;
|
|
98
|
+
chromiumUrl: string;
|
|
99
|
+
chromiumFieldTrials: string;
|
|
100
|
+
windowWidth: number;
|
|
101
|
+
windowHeight: number;
|
|
102
|
+
deviceScaleFactor: number;
|
|
103
|
+
maxVideoDecoders: number;
|
|
104
|
+
maxVideoDecodersRange: string;
|
|
105
|
+
incognito: boolean;
|
|
106
|
+
display: string;
|
|
107
|
+
sessions: number;
|
|
108
|
+
tabsPerSession: number;
|
|
109
|
+
startSessionId: number;
|
|
110
|
+
startTimestamp: number;
|
|
111
|
+
enableDetailedStats: string;
|
|
112
|
+
spawnRate: number;
|
|
113
|
+
showPageLog: boolean;
|
|
114
|
+
pageLogFilter: string;
|
|
115
|
+
pageLogPath: string;
|
|
116
|
+
enableBrowserLogging: string;
|
|
117
|
+
userAgent: string;
|
|
118
|
+
scriptPath: string;
|
|
119
|
+
scriptParams: string;
|
|
120
|
+
disabledVideoCodecs: string;
|
|
121
|
+
localStorage: string;
|
|
122
|
+
sessionStorage: string;
|
|
123
|
+
clearCookies: boolean;
|
|
124
|
+
enableGpu: string;
|
|
125
|
+
blockedUrls: string;
|
|
126
|
+
extraHeaders: string;
|
|
127
|
+
responseModifiers: string;
|
|
128
|
+
downloadResponses: string;
|
|
129
|
+
extraCSS: string;
|
|
130
|
+
cookies: string;
|
|
131
|
+
overridePermissions: string;
|
|
132
|
+
hardwareConcurrency: number;
|
|
133
|
+
debuggingPort: number;
|
|
134
|
+
debuggingAddress: string;
|
|
135
|
+
emulateCpuThrottling: number;
|
|
136
|
+
showStats: boolean;
|
|
137
|
+
statsPath: string;
|
|
138
|
+
detailedStatsPath: string;
|
|
139
|
+
statsInterval: number;
|
|
140
|
+
rtcStatsTimeout: number;
|
|
141
|
+
customMetrics: string;
|
|
142
|
+
prometheusPushgateway: string;
|
|
143
|
+
prometheusPushgatewayJobName: string;
|
|
144
|
+
prometheusPushgatewayAuth: string;
|
|
145
|
+
prometheusPushgatewayGzip: boolean;
|
|
146
|
+
alertRules: string;
|
|
147
|
+
alertRulesOutput: string;
|
|
148
|
+
alertRulesFailPercentile: number;
|
|
149
|
+
pushStatsUrl: string;
|
|
150
|
+
pushStatsId: string;
|
|
151
|
+
serverPort: number;
|
|
152
|
+
serverSecret: string;
|
|
153
|
+
serverUseHttps: boolean;
|
|
154
|
+
serverData: string;
|
|
155
|
+
vmafPath: string;
|
|
156
|
+
vmafPreview: boolean;
|
|
157
|
+
vmafKeepIntermediateFiles: boolean;
|
|
158
|
+
vmafKeepSourceFiles: boolean;
|
|
159
|
+
vmafSkipDuplicated: boolean;
|
|
160
|
+
vmafCrop: string;
|
|
161
|
+
vmafPrepareVideo: string;
|
|
162
|
+
vmafProcessVideo: string;
|
|
163
|
+
vmafVideoCrop: string;
|
|
164
|
+
visqolPath: string;
|
|
165
|
+
visqolKeepSourceFiles: boolean;
|
|
166
|
+
}>[]>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseStatsFile = parseStatsFile;
|
|
7
|
+
exports.aggregateStatsSummary = aggregateStatsSummary;
|
|
8
|
+
exports.uploadStatsToGoogleSheet = uploadStatsToGoogleSheet;
|
|
9
|
+
exports.formatThrottleRule = formatThrottleRule;
|
|
10
|
+
exports.parseThrottleRule = parseThrottleRule;
|
|
11
|
+
exports.twoParticipantsWithRateLossDelay = twoParticipantsWithRateLossDelay;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const stats_1 = require("./stats");
|
|
15
|
+
const googleapis_1 = require("googleapis");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const log = (0, utils_1.logger)('webrtcperf:scenarios');
|
|
18
|
+
/**
|
|
19
|
+
* It parses a CSV stats file and returns an array of objects representing each row.
|
|
20
|
+
* @param filePath The path to the CSV stats file.
|
|
21
|
+
* @returns An array of objects where each object represents a row in the CSV file with keys as column headers.
|
|
22
|
+
*/
|
|
23
|
+
async function parseStatsFile(filePath) {
|
|
24
|
+
log.debug(`parseStatsFile: ${filePath}`);
|
|
25
|
+
const fileData = await fs_1.default.promises.readFile(filePath, 'utf-8');
|
|
26
|
+
const lines = fileData.split('\n');
|
|
27
|
+
const headers = lines[0].split(',');
|
|
28
|
+
const data = lines.slice(1).map(line => line.split(',').reduce((acc, value, index) => {
|
|
29
|
+
if (value !== '') {
|
|
30
|
+
acc[headers[index]] = isNaN(Number(value)) ? value : Number(value);
|
|
31
|
+
}
|
|
32
|
+
return acc;
|
|
33
|
+
}, {}));
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* It aggregates the stats summary from multiple test runs in a directory.
|
|
38
|
+
* @param options.dirPath Directory path containing test run subdirectories. Default is 'logs'.
|
|
39
|
+
* @param options.senderParticipantName Participant name of the sender. Default is 'Participant-000001'.
|
|
40
|
+
* @param options.receiverParticipantName Participant name of the receiver. Default is 'Participant-000000'.
|
|
41
|
+
* @param options.nameParser Function to parse test directory names. Default splits by '_' and extracts id and scenario.
|
|
42
|
+
* @returns Array of aggregated stats including timestamp, id, scenario, videoRecvBitratePerPixel, videoRecvFps, and videoSentFps.
|
|
43
|
+
*/
|
|
44
|
+
async function aggregateStatsSummary({ dirPath = 'logs', senderParticipantName = 'Participant-000001', receiverParticipantName = 'Participant-000000', nameParser = (name) => {
|
|
45
|
+
const [_, id, scenario] = name.split('_');
|
|
46
|
+
return { id, scenario };
|
|
47
|
+
}, }) {
|
|
48
|
+
log.debug(`aggregateStatsSummary: ${dirPath}`);
|
|
49
|
+
const stats = [];
|
|
50
|
+
const results = await fs_1.default.promises.readdir(dirPath);
|
|
51
|
+
for (const test of results) {
|
|
52
|
+
const filePath = path_1.default.join(dirPath, test, 'detailed-stats-summary.csv');
|
|
53
|
+
if (!fs_1.default.existsSync(filePath))
|
|
54
|
+
continue;
|
|
55
|
+
const timestamp = fs_1.default.statSync(path_1.default.join(dirPath, test)).ctime.getTime();
|
|
56
|
+
const data = await parseStatsFile(filePath);
|
|
57
|
+
const { id, scenario } = nameParser(test);
|
|
58
|
+
const aggregated = {
|
|
59
|
+
timestamp,
|
|
60
|
+
id,
|
|
61
|
+
scenario,
|
|
62
|
+
videoRecvBitratePerPixel: new stats_1.FastStats(),
|
|
63
|
+
videoRecvFps: new stats_1.FastStats(),
|
|
64
|
+
videoSentFps: new stats_1.FastStats(),
|
|
65
|
+
};
|
|
66
|
+
data.forEach(v => {
|
|
67
|
+
const { participantName, trackId } = v;
|
|
68
|
+
const metrics = v;
|
|
69
|
+
if (participantName === receiverParticipantName) {
|
|
70
|
+
if (trackId?.endsWith('-v') && metrics.videoRecvFrames > 0) {
|
|
71
|
+
const videoRecvBitratePerPixel = metrics.videoRecvBitrates / (metrics.videoRecvWidth * metrics.videoRecvHeight);
|
|
72
|
+
if (!isNaN(videoRecvBitratePerPixel))
|
|
73
|
+
aggregated.videoRecvBitratePerPixel.push(videoRecvBitratePerPixel);
|
|
74
|
+
if (!isNaN(metrics.videoRecvFps))
|
|
75
|
+
aggregated.videoRecvFps.push(metrics.videoRecvFps);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (participantName === senderParticipantName) {
|
|
79
|
+
if (trackId?.endsWith('-v') && metrics.videoSentFrames > 0) {
|
|
80
|
+
if (!isNaN(metrics.videoSentFps))
|
|
81
|
+
aggregated.videoSentFps.push(metrics.videoSentFps);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
stats.push(aggregated);
|
|
86
|
+
}
|
|
87
|
+
return stats.sort((a, b) => a.timestamp - b.timestamp);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* It uploads the aggregated stats to a Google Sheet.
|
|
91
|
+
* A valid Google service account credentials file must be specified
|
|
92
|
+
* in the `GOOGLE_CREDENTIALS_PATH` environment variable.
|
|
93
|
+
* @param stats The aggregated stats to upload.
|
|
94
|
+
* @param spreadsheetId The ID of the Google Spreadsheet.
|
|
95
|
+
* @param table The name of the table (sheet) within the spreadsheet. Default is 'data'.
|
|
96
|
+
*/
|
|
97
|
+
async function uploadStatsToGoogleSheet(stats, spreadsheetId, table = 'data') {
|
|
98
|
+
log.debug(`uploadResultsToGoogleSheet spreadsheetId: ${spreadsheetId} table: ${table}`);
|
|
99
|
+
if (!process.env.GOOGLE_CREDENTIALS_PATH)
|
|
100
|
+
throw new Error('GOOGLE_CREDENTIALS_PATH environment variable is not set');
|
|
101
|
+
if (!fs_1.default.existsSync(process.env.GOOGLE_CREDENTIALS_PATH))
|
|
102
|
+
throw new Error(`Google credentials file not found: ${process.env.GOOGLE_CREDENTIALS_PATH}`);
|
|
103
|
+
if (!stats.length)
|
|
104
|
+
return;
|
|
105
|
+
const auth = new googleapis_1.Auth.GoogleAuth({
|
|
106
|
+
keyFile: process.env.GOOGLE_CREDENTIALS_PATH,
|
|
107
|
+
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
|
|
108
|
+
});
|
|
109
|
+
const sheets = googleapis_1.google.sheets({ version: 'v4', auth });
|
|
110
|
+
// Update headers.
|
|
111
|
+
const headers = ['datetime', 'id', 'scenario', 'videoRecvBitratePerPixel', 'videoRecvFps'];
|
|
112
|
+
await sheets.spreadsheets.values.update({
|
|
113
|
+
spreadsheetId,
|
|
114
|
+
range: `${table}!A1:E1`,
|
|
115
|
+
valueInputOption: 'USER_ENTERED',
|
|
116
|
+
requestBody: { majorDimension: 'ROWS', values: [headers] },
|
|
117
|
+
});
|
|
118
|
+
// Append values.
|
|
119
|
+
const values = [];
|
|
120
|
+
stats.forEach(s => {
|
|
121
|
+
const { timestamp, id, scenario, videoRecvBitratePerPixel, videoRecvFps } = s;
|
|
122
|
+
if (!videoRecvBitratePerPixel.length)
|
|
123
|
+
return;
|
|
124
|
+
const datetime = new Date(timestamp).toLocaleString('en-US', {
|
|
125
|
+
timeZone: 'UTC',
|
|
126
|
+
hourCycle: 'h23',
|
|
127
|
+
});
|
|
128
|
+
values.push([
|
|
129
|
+
datetime,
|
|
130
|
+
id,
|
|
131
|
+
formatThrottleRule(parseThrottleRule(scenario), true),
|
|
132
|
+
videoRecvBitratePerPixel.percentile(95).toFixed(3),
|
|
133
|
+
videoRecvFps.percentile(95).toFixed(3),
|
|
134
|
+
]);
|
|
135
|
+
});
|
|
136
|
+
if (values.length) {
|
|
137
|
+
await sheets.spreadsheets.values.append({
|
|
138
|
+
spreadsheetId,
|
|
139
|
+
range: `${table}!A:E`,
|
|
140
|
+
valueInputOption: 'USER_ENTERED',
|
|
141
|
+
insertDataOption: 'INSERT_ROWS',
|
|
142
|
+
requestBody: { majorDimension: 'ROWS', values },
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function formatBitrate(bitrate, prefix = ' ') {
|
|
147
|
+
if (bitrate === undefined)
|
|
148
|
+
return '';
|
|
149
|
+
let suffix = 'Kbps';
|
|
150
|
+
if (bitrate >= 10000) {
|
|
151
|
+
bitrate /= 1000;
|
|
152
|
+
suffix = 'Mbps';
|
|
153
|
+
}
|
|
154
|
+
return `${prefix}${bitrate.toFixed(0)}${suffix}`.padStart(8, ' ');
|
|
155
|
+
}
|
|
156
|
+
function formatLoss(loss, prefix = ' ') {
|
|
157
|
+
return loss !== undefined ? `${prefix}${loss.toFixed(0).padStart(2, ' ')}%` : '';
|
|
158
|
+
}
|
|
159
|
+
function formatDelay(delay, prefix = ' ') {
|
|
160
|
+
return delay !== undefined ? `${prefix}${delay.toFixed(0).padStart(3, ' ')}ms` : '';
|
|
161
|
+
}
|
|
162
|
+
function formatThrottleRule(throttleRule, human = false) {
|
|
163
|
+
const { rate, loss, delay, direction } = throttleRule;
|
|
164
|
+
return human
|
|
165
|
+
? `${direction.padEnd(4, ' ')}${formatBitrate(rate)}${formatLoss(loss)}${formatDelay(delay)}`
|
|
166
|
+
: `${direction}-r${rate}-l${loss}-d${delay}`;
|
|
167
|
+
}
|
|
168
|
+
function parseThrottleRule(throttleDesc) {
|
|
169
|
+
const match = throttleDesc.match(/(up|down|bidi)-r(\d+)-l([\d.]+)-d(\d+)/);
|
|
170
|
+
if (!match)
|
|
171
|
+
throw new Error(`Invalid throttle description: ${throttleDesc}`);
|
|
172
|
+
const direction = match[1];
|
|
173
|
+
const rate = parseInt(match[2]);
|
|
174
|
+
const loss = parseInt(match[3]);
|
|
175
|
+
const delay = parseInt(match[4]);
|
|
176
|
+
return { direction, rate, loss, delay };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* It generates a test configuration with a scenario including 2 participants.
|
|
180
|
+
* The first participant sends video and the second receives it.
|
|
181
|
+
* Both participants send and receive audio.
|
|
182
|
+
* The network conditions are applied according to the specified direction to the sender (`up`),
|
|
183
|
+
* the receiver (`down`) or both (`bidi`).
|
|
184
|
+
* The test is repeated the specified number of times.
|
|
185
|
+
* The output is an array of partial configuration objects that can be used to run the tests
|
|
186
|
+
* with the main application, after merging it with a configuration that includes
|
|
187
|
+
* the destination url (mandatory) and other optional parameters.
|
|
188
|
+
* @param id The unique identifier for the test scenario.
|
|
189
|
+
* @param options.rate The target bandwidth in kbps.
|
|
190
|
+
* @param options.loss The packet loss percentage.
|
|
191
|
+
* @param options.delay The network delay in milliseconds.
|
|
192
|
+
* @param options.direction The direction of the network throttling: 'up', 'down', or 'bidi'.
|
|
193
|
+
* @param repeat The number of times to repeat the test scenario. Default is 1.
|
|
194
|
+
* @returns An array of partial configuration objects for each test scenario.
|
|
195
|
+
*/
|
|
196
|
+
async function twoParticipantsWithRateLossDelay(id, { rate, loss, delay, direction }, repeat) {
|
|
197
|
+
const throttle = {};
|
|
198
|
+
const queue = 25;
|
|
199
|
+
if (direction === 'down' || direction === 'bidi') {
|
|
200
|
+
throttle.down = [
|
|
201
|
+
{ rate: 20000, loss: 0, delay: 0, queue },
|
|
202
|
+
{ rate, loss, delay, queue, at: 30 },
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
if (direction === 'up' || direction === 'bidi') {
|
|
206
|
+
throttle.up = [
|
|
207
|
+
{ rate: 20000, loss: 0, delay, queue },
|
|
208
|
+
{ rate, loss, delay, queue, at: 30 },
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
const throttleDesc = formatThrottleRule({ rate, loss, delay, direction });
|
|
212
|
+
const now = Date.now();
|
|
213
|
+
const ret = [];
|
|
214
|
+
for (let i = 0; i < repeat; i++) {
|
|
215
|
+
const basePath = `logs/${now}-${i + 1}_${id}_${throttleDesc}`;
|
|
216
|
+
const sessions = direction === 'bidi' ? '0-1' : direction === 'down' ? '0' : '1';
|
|
217
|
+
ret.push({
|
|
218
|
+
sessions: 2,
|
|
219
|
+
runDuration: 60 * 3,
|
|
220
|
+
debuggingPort: 9000,
|
|
221
|
+
prometheusPushgateway: 'http://localhost:9091',
|
|
222
|
+
prometheusPushgatewayJobName: id,
|
|
223
|
+
statsPath: `${basePath}/stats.csv`,
|
|
224
|
+
detailedStatsPath: `${basePath}/detailed-stats.csv`,
|
|
225
|
+
showPageLog: false,
|
|
226
|
+
showStats: false,
|
|
227
|
+
statsInterval: 5,
|
|
228
|
+
scriptParams: JSON.stringify({
|
|
229
|
+
enableMic: '0-1',
|
|
230
|
+
enableCam: '1',
|
|
231
|
+
}),
|
|
232
|
+
throttleConfig: JSON.stringify([
|
|
233
|
+
{
|
|
234
|
+
sessions,
|
|
235
|
+
protocol: 'udp',
|
|
236
|
+
skipSourcePorts: '53,80,443',
|
|
237
|
+
skipDestinationPorts: '53,80,443',
|
|
238
|
+
...throttle,
|
|
239
|
+
},
|
|
240
|
+
]),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return ret;
|
|
244
|
+
}
|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A;IACtB,MAAM,GAAG,GAAsB,EAAE,CAAA;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,YAAY,EAAE,CAAA;QAC7D,MAAM,QAAQ,GAAG,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;QAChF,GAAG,CAAC,IAAI,CAAC;YACP,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,EAAE,GAAG,CAAC;YACnB,aAAa,EAAE,IAAI;YACnB,qBAAqB,EAAE,uBAAuB;YAC9C,4BAA4B,EAAE,EAAE;YAChC,SAAS,EAAE,GAAG,QAAQ,YAAY;YAClC,iBAAiB,EAAE,GAAG,QAAQ,qBAAqB;YACnD,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC3B,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,GAAG;aACf,CAAC;YACF,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC7B;oBACE,QAAQ;oBACR,QAAQ,EAAE,KAAK;oBACf,eAAe,EAAE,WAAW;oBAC5B,oBAAoB,EAAE,WAAW;oBACjC,GAAG,QAAQ;iBACZ;aACF,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport { FastStats } from './stats'\nimport { ThrottleConfig, ThrottleRule } from '@vpalmisano/throttler'\nimport { Config } from './config'\nimport { Auth, google } from 'googleapis'\nimport { logger } from './utils'\n\nconst log = logger('webrtcperf:scenarios')\n\n/**\n * It parses a CSV stats file and returns an array of objects representing each row.\n * @param filePath The path to the CSV stats file.\n * @returns An array of objects where each object represents a row in the CSV file with keys as column headers.\n */\nexport async function parseStatsFile(filePath: string) {\n log.debug(`parseStatsFile: ${filePath}`)\n const fileData = await fs.promises.readFile(filePath, 'utf-8')\n const lines = fileData.split('\\n')\n const headers = lines[0].split(',')\n const data = lines.slice(1).map(line =>\n line.split(',').reduce(\n (acc, value, index) => {\n if (value !== '') {\n acc[headers[index]] = isNaN(Number(value)) ? value : Number(value)\n }\n return acc\n },\n {} as Record<string, string | number>,\n ),\n )\n return data\n}\n\nexport type StatsSummary = {\n timestamp: number\n id: string\n scenario: string\n videoRecvBitratePerPixel: FastStats\n videoRecvFps: FastStats\n videoSentFps: FastStats\n}\n\n/**\n * It aggregates the stats summary from multiple test runs in a directory.\n * @param options.dirPath Directory path containing test run subdirectories. Default is 'logs'.\n * @param options.senderParticipantName Participant name of the sender. Default is 'Participant-000001'.\n * @param options.receiverParticipantName Participant name of the receiver. Default is 'Participant-000000'.\n * @param options.nameParser Function to parse test directory names. Default splits by '_' and extracts id and scenario.\n * @returns Array of aggregated stats including timestamp, id, scenario, videoRecvBitratePerPixel, videoRecvFps, and videoSentFps.\n */\nexport async function aggregateStatsSummary({\n dirPath = 'logs',\n senderParticipantName = 'Participant-000001',\n receiverParticipantName = 'Participant-000000',\n nameParser = (name: string) => {\n const [_, id, scenario] = name.split('_')\n return { id, scenario }\n },\n}) {\n log.debug(`aggregateStatsSummary: ${dirPath}`)\n const stats: StatsSummary[] = []\n const results = await fs.promises.readdir(dirPath)\n for (const test of results) {\n const filePath = path.join(dirPath, test, 'detailed-stats-summary.csv')\n if (!fs.existsSync(filePath)) continue\n const timestamp = fs.statSync(path.join(dirPath, test)).ctime.getTime()\n const data = await parseStatsFile(filePath)\n const { id, scenario } = nameParser(test)\n\n const aggregated = {\n timestamp,\n id,\n scenario,\n videoRecvBitratePerPixel: new FastStats(),\n videoRecvFps: new FastStats(),\n videoSentFps: new FastStats(),\n }\n data.forEach(v => {\n const { participantName, trackId } = v as { participantName: string; trackId: string }\n const metrics = v as Record<string, number>\n if (participantName === receiverParticipantName) {\n if (trackId?.endsWith('-v') && metrics.videoRecvFrames > 0) {\n const videoRecvBitratePerPixel =\n metrics.videoRecvBitrates / (metrics.videoRecvWidth * metrics.videoRecvHeight)\n if (!isNaN(videoRecvBitratePerPixel)) aggregated.videoRecvBitratePerPixel.push(videoRecvBitratePerPixel)\n if (!isNaN(metrics.videoRecvFps)) aggregated.videoRecvFps.push(metrics.videoRecvFps)\n }\n } else if (participantName === senderParticipantName) {\n if (trackId?.endsWith('-v') && metrics.videoSentFrames > 0) {\n if (!isNaN(metrics.videoSentFps)) aggregated.videoSentFps.push(metrics.videoSentFps)\n }\n }\n })\n stats.push(aggregated)\n }\n return stats.sort((a, b) => a.timestamp - b.timestamp)\n}\n\n/**\n * It uploads the aggregated stats to a Google Sheet.\n * A valid Google service account credentials file must be specified\n * in the `GOOGLE_CREDENTIALS_PATH` environment variable.\n * @param stats The aggregated stats to upload.\n * @param spreadsheetId The ID of the Google Spreadsheet.\n * @param table The name of the table (sheet) within the spreadsheet. Default is 'data'.\n */\nexport async function uploadStatsToGoogleSheet(stats: StatsSummary[], spreadsheetId: string, table = 'data') {\n log.debug(`uploadResultsToGoogleSheet spreadsheetId: ${spreadsheetId} table: ${table}`)\n if (!process.env.GOOGLE_CREDENTIALS_PATH) throw new Error('GOOGLE_CREDENTIALS_PATH environment variable is not set')\n if (!fs.existsSync(process.env.GOOGLE_CREDENTIALS_PATH))\n throw new Error(`Google credentials file not found: ${process.env.GOOGLE_CREDENTIALS_PATH}`)\n if (!stats.length) return\n const auth = new Auth.GoogleAuth({\n keyFile: process.env.GOOGLE_CREDENTIALS_PATH,\n scopes: ['https://www.googleapis.com/auth/spreadsheets'],\n })\n const sheets = google.sheets({ version: 'v4', auth })\n // Update headers.\n const headers = ['datetime', 'id', 'scenario', 'videoRecvBitratePerPixel', 'videoRecvFps']\n await sheets.spreadsheets.values.update({\n spreadsheetId,\n range: `${table}!A1:E1`,\n valueInputOption: 'USER_ENTERED',\n requestBody: { majorDimension: 'ROWS', values: [headers] },\n })\n // Append values.\n const values = [] as string[][]\n stats.forEach(s => {\n const { timestamp, id, scenario, videoRecvBitratePerPixel, videoRecvFps } = s\n if (!videoRecvBitratePerPixel.length) return\n const datetime = new Date(timestamp).toLocaleString('en-US', {\n timeZone: 'UTC',\n hourCycle: 'h23',\n })\n values.push([\n datetime,\n id,\n formatThrottleRule(parseThrottleRule(scenario), true),\n videoRecvBitratePerPixel.percentile(95).toFixed(3),\n videoRecvFps.percentile(95).toFixed(3),\n ])\n })\n if (values.length) {\n await sheets.spreadsheets.values.append({\n spreadsheetId,\n range: `${table}!A:E`,\n valueInputOption: 'USER_ENTERED',\n insertDataOption: 'INSERT_ROWS',\n requestBody: { majorDimension: 'ROWS', values },\n })\n }\n}\n\nexport type ThrottleDirection = 'up' | 'down' | 'bidi'\n\nfunction formatBitrate(bitrate: number | undefined, prefix = ' ') {\n if (bitrate === undefined) return ''\n let suffix = 'Kbps'\n if (bitrate >= 10000) {\n bitrate /= 1000\n suffix = 'Mbps'\n }\n return `${prefix}${bitrate.toFixed(0)}${suffix}`.padStart(8, ' ')\n}\n\nfunction formatLoss(loss: number | undefined, prefix = ' ') {\n return loss !== undefined ? `${prefix}${loss.toFixed(0).padStart(2, ' ')}%` : ''\n}\n\nfunction formatDelay(delay: number | undefined, prefix = ' ') {\n return delay !== undefined ? `${prefix}${delay.toFixed(0).padStart(3, ' ')}ms` : ''\n}\n\nexport function formatThrottleRule(throttleRule: ThrottleRule & { direction: ThrottleDirection }, human = false) {\n const { rate, loss, delay, direction } = throttleRule\n return human\n ? `${direction.padEnd(4, ' ')}${formatBitrate(rate)}${formatLoss(loss)}${formatDelay(delay)}`\n : `${direction}-r${rate}-l${loss}-d${delay}`\n}\n\nexport function parseThrottleRule(throttleDesc: string) {\n const match = throttleDesc.match(/(up|down|bidi)-r(\\d+)-l([\\d.]+)-d(\\d+)/)\n if (!match) throw new Error(`Invalid throttle description: ${throttleDesc}`)\n const direction = match[1] as ThrottleDirection\n const rate = parseInt(match[2])\n const loss = parseInt(match[3])\n const delay = parseInt(match[4])\n return { direction, rate, loss, delay }\n}\n\n/**\n * It generates a test configuration with a scenario including 2 participants.\n * The first participant sends video and the second receives it.\n * Both participants send and receive audio.\n * The network conditions are applied according to the specified direction to the sender (`up`),\n * the receiver (`down`) or both (`bidi`).\n * The test is repeated the specified number of times.\n * The output is an array of partial configuration objects that can be used to run the tests\n * with the main application, after merging it with a configuration that includes\n * the destination url (mandatory) and other optional parameters.\n * @param id The unique identifier for the test scenario.\n * @param options.rate The target bandwidth in kbps.\n * @param options.loss The packet loss percentage.\n * @param options.delay The network delay in milliseconds.\n * @param options.direction The direction of the network throttling: 'up', 'down', or 'bidi'.\n * @param repeat The number of times to repeat the test scenario. Default is 1.\n * @returns An array of partial configuration objects for each test scenario.\n */\nexport async function twoParticipantsWithRateLossDelay(\n id: string,\n { rate, loss, delay, direction }: { rate: number; loss: number; delay: number; direction: ThrottleDirection },\n repeat: 1,\n) {\n const throttle: ThrottleConfig = {}\n const queue = 25\n if (direction === 'down' || direction === 'bidi') {\n throttle.down = [\n { rate: 20000, loss: 0, delay: 0, queue },\n { rate, loss, delay, queue, at: 30 },\n ]\n }\n if (direction === 'up' || direction === 'bidi') {\n throttle.up = [\n { rate: 20000, loss: 0, delay, queue },\n { rate, loss, delay, queue, at: 30 },\n ]\n }\n const throttleDesc = formatThrottleRule({ rate, loss, delay, direction })\n const now = Date.now()\n const ret: Partial<Config>[] = []\n for (let i = 0; i < repeat; i++) {\n const basePath = `logs/${now}-${i + 1}_${id}_${throttleDesc}`\n const sessions = direction === 'bidi' ? '0-1' : direction === 'down' ? '0' : '1'\n ret.push({\n sessions: 2,\n runDuration: 60 * 3,\n debuggingPort: 9000,\n prometheusPushgateway: 'http://localhost:9091',\n prometheusPushgatewayJobName: id,\n statsPath: `${basePath}/stats.csv`,\n detailedStatsPath: `${basePath}/detailed-stats.csv`,\n showPageLog: false,\n showStats: false,\n statsInterval: 5,\n scriptParams: JSON.stringify({\n enableMic: '0-1',\n enableCam: '1',\n }),\n throttleConfig: JSON.stringify([\n {\n sessions,\n protocol: 'udp',\n skipSourcePorts: '53,80,443',\n skipDestinationPorts: '53,80,443',\n ...throttle,\n },\n ]),\n })\n }\n return ret\n}\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Session } from './session';
|
|
2
|
-
import { FastStats } from './stats';
|
|
3
2
|
export declare function logger(name: string, options?: {}): any;
|
|
4
3
|
/**
|
|
5
4
|
* Resolves the absolute path from the package installation directory.
|
|
@@ -235,21 +234,4 @@ export declare function analyzeColors(fpath: string): Promise<{
|
|
|
235
234
|
*/
|
|
236
235
|
export declare function waitStopProcess(pid: number, timeout?: number): Promise<boolean>;
|
|
237
236
|
export declare function getDockerLogsPath(): Promise<string>;
|
|
238
|
-
export declare function parseStatsFile(filePath: string): Promise<Record<string, string | number>[]>;
|
|
239
|
-
export declare function aggregateStatsSummary({ dirPath, senderParticipantName, receiverParticipantName, nameParser, }: {
|
|
240
|
-
dirPath?: string | undefined;
|
|
241
|
-
senderParticipantName?: string | undefined;
|
|
242
|
-
receiverParticipantName?: string | undefined;
|
|
243
|
-
nameParser?: ((name: string) => {
|
|
244
|
-
destination: string;
|
|
245
|
-
scenario: string;
|
|
246
|
-
}) | undefined;
|
|
247
|
-
}): Promise<{
|
|
248
|
-
timestamp: number;
|
|
249
|
-
destination: string;
|
|
250
|
-
scenario: string;
|
|
251
|
-
videoRecvBitratePerPixel: FastStats;
|
|
252
|
-
videoRecvFps: FastStats;
|
|
253
|
-
videoSentFps: FastStats;
|
|
254
|
-
}[]>;
|
|
255
237
|
export {};
|