forked from nwalters512/docker-file-bug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (48 loc) · 1.34 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
const Pool = require('threads').Pool;
const pool = new Pool();
const fs = require('fs');
if (!fs.existsSync('/test-share/vendor')){
fs.mkdirSync('/test-share/vendor');
}
// Prepare the testcase
const testRootPath = '/volume/';
for (let i = 0; i < 10; i++) {
const folderPath = testRootPath + i;
// Create the folder
if (!fs.existsSync(folderPath)){
fs.mkdirSync(folderPath);
}
// Create symlink
if (!fs.existsSync('/test-share/vendor/' + i)) {
fs.symlinkSync(folderPath, '/test-share/vendor/' + i);
}
for (let j = 0; j < 100; j++) {
const filePath = folderPath + '/' + j;
if (!fs.existsSync(filePath)){
fs.writeFileSync(filePath, 'Hello World!');
}
}
}
pool.run((opts, done) => {
const fs = require('fs');
const testRootPath = '/test-share/vendor/';
for (let i = 0; i < 10; i++) {
const folderPath = testRootPath + i;
for (let j = 0; j < 100; j++) {
const filePath = folderPath + '/' + j;
if (!fs.existsSync(filePath)) {
console.log('File does not exist!');
} else {
console.log('.');
}
if (fs.readFileSync(filePath, 'utf-8') !== 'Hello World!') {
console.log('Invalid contents!');
}
}
}
done();
});
for (let i = 0; i < 10; i++) {
pool.send('test');
}
pool.on('finished', () => pool.killAll());