load-test-config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* tslint:disable:no-console */
  2. import { VendureConfig } from '@vendure/core';
  3. import path from 'path';
  4. import { devConfig } from '../dev-config';
  5. export function getMysqlConnectionOptions(count: number) {
  6. return {
  7. type: 'mysql',
  8. host: '192.168.99.100',
  9. port: 3306,
  10. username: 'root',
  11. password: '',
  12. database: `vendure-load-testing-${count}`,
  13. };
  14. }
  15. export function getLoadTestConfig(tokenMethod: 'cookie' | 'bearer'): VendureConfig {
  16. const count = getProductCount();
  17. return {
  18. ...devConfig as any,
  19. dbConnectionOptions: getMysqlConnectionOptions(count),
  20. authOptions: {
  21. tokenMethod,
  22. requireVerification: false,
  23. },
  24. importExportOptions: {
  25. importAssetsDir: path.join(__dirname, './data-sources'),
  26. },
  27. customFields: {},
  28. };
  29. }
  30. export function getProductCsvFilePath() {
  31. const count = getProductCount();
  32. return path.join(__dirname, `./data-sources/products-${count}.csv`);
  33. }
  34. export function getProductCount() {
  35. const count = +process.argv[2];
  36. if (!count) {
  37. console.error(`Please specify the number of products to generate`);
  38. process.exit(1);
  39. }
  40. return count;
  41. }