Skip to content

Commit 5537028

Browse files
authored
Merge pull request #45 from vizzuhq/veghdev
integration test: parallel run, simplify code
2 parents 3481fea + 43e0f30 commit 5537028

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4085
-2075
lines changed

ci/docker/vizzu-test-cloudbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
1515
ADD . /workspace/
1616
WORKDIR /workspace/test/integration
1717
RUN npm install
18-
RUN node vizzutest.js -r DISABLED -u /example/lib/vizzu.min.js
18+
RUN node test.js --vizzu /example/lib/vizzu.min.js --images DISABLED --hashes DISABLED --nologs

test/integration/man.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const yargs = require("yargs");
2+
3+
const Manual = require("./modules/manual/manual.js");
4+
5+
6+
try {
7+
var argv = yargs
8+
.usage("Usage: [options]")
9+
10+
.help("h")
11+
.alias("h", "help")
12+
.version(false)
13+
14+
.alias("p", "port")
15+
.describe("p", "Change workspace host's port")
16+
.nargs("p", 1)
17+
.default("p", "8080")
18+
19+
.array("c")
20+
.alias("c", "configs")
21+
.nargs("c", 1)
22+
.describe("c",
23+
"Change the list of config file's path of the test cases" +
24+
"\n(relative or absolute path where the repo folder is the root)" +
25+
"\n")
26+
.default("c",
27+
["/test/integration/test_cases/test_cases.json"])
28+
.argv;
29+
30+
let manual = new Manual(argv.configs, argv.port);
31+
manual.run();
32+
} catch (err) {
33+
process.exitCode = 1;
34+
console.error(err);
35+
}

test/integration/manual/manual.js

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
4+
const Chrome = require("../../modules/browser/chrome.js");
5+
6+
7+
class BrowsersChrome {
8+
9+
#browsers = [];
10+
11+
#browsersNum;
12+
#browsersGui;
13+
14+
#browsersLogPath;
15+
#browsersLogFilePrefix;
16+
#browsersLogTimeStamp;
17+
18+
#timeout = 120000;
19+
20+
21+
constructor(browsersNum, browsersGui, browsersLogPath = undefined, browsersLogTimeStamp = undefined) {
22+
this.setBrowsersNum(browsersNum);
23+
this.#browsersGui = browsersGui;
24+
if (browsersLogPath && browsersLogTimeStamp) {
25+
this.#browsersLogPath = browsersLogPath;
26+
this.#browsersLogFilePrefix = "chrome";
27+
this.#browsersLogTimeStamp = browsersLogTimeStamp;
28+
} else {
29+
if (browsersLogPath || browsersLogTimeStamp) {
30+
throw new Error("parameter is required");
31+
}
32+
}
33+
}
34+
35+
36+
startBrowsers() {
37+
let browsersReady = [];
38+
for (let i = 0; i < this.#browsersNum; i++) {
39+
let browser = new Chrome(!this.#browsersGui);
40+
this.#browsers.push(browser);
41+
browsersReady.push(browser.initializing);
42+
}
43+
return Promise.all(browsersReady);
44+
}
45+
46+
47+
closeBrowsers() {
48+
this.#browsers.forEach((browser, index) => {
49+
if (browser) {
50+
let browserLogReady = new Promise(resolve => { resolve() });
51+
if (this.#browsersLogPath) {
52+
browserLogReady = new Promise((resolve, reject) => {
53+
fs.mkdir(this.#browsersLogPath, { recursive: true, force: true }, err => {
54+
if (err) {
55+
return reject(err);
56+
}
57+
return resolve(path.join(this.#browsersLogPath, this.#browsersLogFilePrefix + "_" + index + '_' + this.#browsersLogTimeStamp + ".log"));
58+
});
59+
});
60+
}
61+
browserLogReady.then((browserLog) => {
62+
browser.closeBrowser(browserLog);
63+
});
64+
}
65+
});
66+
}
67+
68+
69+
shiftBrowser() {
70+
return this.#browsers.shift();
71+
}
72+
73+
74+
pushBrowser(browser) {
75+
this.#browsers.push(browser);
76+
}
77+
78+
79+
getBrowsersNum() {
80+
return this.#browsersNum;
81+
}
82+
83+
84+
setBrowsersNum(browsersNum) {
85+
browsersNum = parseInt(browsersNum);
86+
if (isNaN(browsersNum)) {
87+
throw new Error("browsersNum is integer");
88+
}
89+
this.#browsersNum = browsersNum;
90+
91+
let rate = 0.1;
92+
this.#timeout = parseInt(this.#timeout * Math.pow(1 + rate, this.#browsersNum));
93+
}
94+
95+
96+
getTimeout() {
97+
return this.#timeout;
98+
}
99+
}
100+
101+
102+
module.exports = BrowsersChrome;

0 commit comments

Comments
 (0)