1 | "use strict";
|
2 |
|
3 | var _child_process = require("child_process");
|
4 |
|
5 | var _fsExtra = require("fs-extra");
|
6 |
|
7 | var _path = _interopRequireDefault(require("path"));
|
8 |
|
9 | var _shelljs = require("shelljs");
|
10 |
|
11 | var _terminate = _interopRequireDefault(require("terminate"));
|
12 |
|
13 | var _util = require("util");
|
14 |
|
15 | var _CommonUtils = require("../Tests/BrowserTestsCore/PageObjects/Bases/CommonUtils");
|
16 |
|
17 | var _candyToolExecutable = require("./candyToolExecutable");
|
18 |
|
19 | var _clusterConfigSettingsUtils = require("./clusterConfigSettingsUtils");
|
20 |
|
21 | var _consoleApplication = require("./Commons/consoleApplication");
|
22 |
|
23 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24 |
|
25 | const terminateAsync = (0, _util.promisify)(_terminate.default);
|
26 | (0, _consoleApplication.runConsoleApplication)(async () => {
|
27 | const pathToCandyApiExecutableDir = _path.default.resolve(process.argv[process.argv.length - 1]);
|
28 |
|
29 | console.log(pathToCandyApiExecutableDir);
|
30 | await (0, _clusterConfigSettingsUtils.updateClusterConfigConfigurationFile)(_path.default.join(pathToCandyApiExecutableDir, "settings", "candy.api", "config"), {
|
31 | ResourcesPath: _path.default.join(__dirname, "..", "Tests", "TestForms", "TestResources"),
|
32 | ResourcesDefaultPath: _path.default.join(__dirname, "..", "Tests", "TestForms", "TestResources"),
|
33 | UseTestClassification: "true",
|
34 | ResourcesBuildServerUri: "http://localhost:9000",
|
35 | KonturDomains: "*|*:*",
|
36 | ServiceDiscoveryZone: "teamcity-agents"
|
37 | });
|
38 | const devBuildServerProcess = (0, _child_process.spawn)(`${(0, _candyToolExecutable.getPathCandyToolExecutable)()}`, ["dev-build-server", "--debug-only"], {
|
39 | cwd: _path.default.resolve(__dirname, "..", "Tests", "TestForms", "TestFarm"),
|
40 | shell: true,
|
41 | stdio: "inherit"
|
42 | });
|
43 | await (0, _CommonUtils.delay)(5000);
|
44 | const candyApiProcess = (0, _child_process.spawn)(_path.default.join(pathToCandyApiExecutableDir, "Candy.Api.exe"), [], {
|
45 | cwd: pathToCandyApiExecutableDir,
|
46 | shell: true
|
47 | });
|
48 |
|
49 | if (await (0, _fsExtra.pathExists)(_path.default.join(pathToCandyApiExecutableDir, "settings", "ClusterConfig"))) {
|
50 | (0, _shelljs.rm)(_path.default.join(pathToCandyApiExecutableDir, "settings", "ClusterConfig"));
|
51 | }
|
52 |
|
53 | console.log(`Started candy api process: PID: ${candyApiProcess.pid}`);
|
54 |
|
55 | try {
|
56 | (0, _shelljs.exec)("npm run e2e:test -- --reporter mocha-teamcity-reporter");
|
57 | } finally {
|
58 | console.log(`Killing candy api process: PID: ${candyApiProcess.pid}`);
|
59 | await terminateAsync(candyApiProcess.pid);
|
60 | console.log(`Killing dev-build-server process: PID: ${devBuildServerProcess.pid}`);
|
61 | await terminateAsync(devBuildServerProcess.pid);
|
62 | }
|
63 | });
|
64 |
|
\ | No newline at end of file |