-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.js
65 lines (44 loc) · 1.83 KB
/
index.js
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
const { execSync } = require('node:child_process');
const createTestCafe = require('testcafe');
async function runTestCafe () {
const testcafe = await createTestCafe('localhost', 0, 0);
const runner = testcafe.createRunner();
const failedCount = await runner
.src('test.js')
.browsers('chrome:headless')
.run();
await testcafe.close();
return !!failedCount;
}
function startServer () {
execSync('docker run -d -it --name server -p 3000:5000 testcafe/testcafe-examples_kerberos-server');
execSync('docker exec server /etc/init.d/krb5-admin-server restart');
execSync('docker exec server /etc/init.d/krb5-kdc restart');
execSync('docker exec server mkdir home/server');
execSync('docker cp server/index.js server:home/server/index.js');
execSync('docker cp server/package.json server:home/server/package.json');
execSync('docker exec server sh -c "cd /home/server && npm i"');
execSync('docker exec -d server node /home/server');
}
function startClient () {
execSync('docker run -d -it --name client -p 3001:5000 testcafe/testcafe-examples_kerberos-client');
execSync('docker exec client sh -c "echo \'172.17.0.2\ttestcafe.io\' >> etc/hosts"');
execSync('docker exec client mkdir home/client');
execSync('docker cp client/index.js client:home/client/index.js');
execSync('docker cp client/package.json client:home/client/package.json');
execSync('docker exec client sh -c "cd /home/client && npm i"');
execSync('docker exec -d client node /home/client');
}
function removeContainers () {
execSync('docker rm -f server');
execSync('docker rm -f client');
}
async function start () {
startServer();
startClient();
const isFailed = await runTestCafe();
removeContainers();
if (isFailed)
throw 'Tests failed';
}
start();