-
-
Notifications
You must be signed in to change notification settings - Fork 932
/
load-test-config.ts
77 lines (72 loc) · 2.11 KB
/
load-test-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* tslint:disable:no-console */
import { AssetServerPlugin } from '@vendure/asset-server-plugin';
import {
DefaultLogger,
DefaultSearchPlugin,
examplePaymentHandler,
LogLevel,
mergeConfig,
VendureConfig,
} from '@vendure/core';
import { defaultConfig } from '@vendure/core/dist/config/default-config';
import path from 'path';
export function getMysqlConnectionOptions(count: number) {
return {
type: 'mysql' as const,
host: '192.168.99.100',
port: 3306,
username: 'root',
password: '',
database: `vendure-load-testing-${count}`,
};
}
export function getLoadTestConfig(tokenMethod: 'cookie' | 'bearer'): Required<VendureConfig> {
const count = getProductCount();
return mergeConfig(defaultConfig, {
paymentOptions: {
paymentMethodHandlers: [examplePaymentHandler],
},
orderOptions: {
orderItemsLimit: 99999,
},
logger: new DefaultLogger({ level: LogLevel.Info }),
dbConnectionOptions: getMysqlConnectionOptions(count),
authOptions: {
tokenMethod,
requireVerification: false,
},
importExportOptions: {
importAssetsDir: path.join(__dirname, './data-sources'),
},
workerOptions: {
runInMainProcess: true,
},
customFields: {},
plugins: [
AssetServerPlugin.init({
assetUploadDir: path.join(__dirname, 'static/assets'),
route: 'assets',
port: 5002,
}),
DefaultSearchPlugin,
],
});
}
export function getProductCsvFilePath() {
const count = getProductCount();
return path.join(__dirname, `./data-sources/products-${count}.csv`);
}
export function getProductCount() {
const count = +process.argv[2];
if (!count) {
console.error(`Please specify the number of products to generate`);
process.exit(1);
}
return count;
}
export function getScriptToRun(): string[] | undefined {
const script = process.argv[3];
if (script) {
return [script];
}
}