forked from hugorodrigues/lxc.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
130 lines (102 loc) · 5.55 KB
/
test.js
File metadata and controls
130 lines (102 loc) · 5.55 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var async = require('async');
var colors = require('colors');
var lxc = require('./lxc.js')({
sshBind: ['/usr/bin/ssh', 'lxc']
});
function lxcTest (){
var fn = Array.prototype.slice.call(arguments, 0,1)
var args = Array.prototype.slice.call(arguments, 1,-1)
var cb = Array.prototype.slice.call(arguments, -1)[0]
args.push(function(data){ process.stdout.write(data.grey) })
args.push(function(error, messages){ cb(); console.log((error) ? 'Ended with error!'.underline.red : '-> OK!'.green, messages) })
lxc[fn].apply(this, args);
}
var testCreate = [
function(cb){ lxcTest('create', 'vm_test_1', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_2', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_3', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_4', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_5', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_6', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_7', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_8', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_9', 'ubuntu', {}, cb) },
function(cb){ lxcTest('create', 'vm_test_10', 'ubuntu', {}, cb) }
];
var testStart = [
function(cb){ lxcTest('start', 'vm_test_1', cb); },
function(cb){ lxcTest('start', 'vm_test_2', cb); },
function(cb){ lxcTest('start', 'vm_test_3', cb); },
function(cb){ lxcTest('start', 'vm_test_4', cb); },
function(cb){ lxcTest('start', 'vm_test_5', cb); },
function(cb){ lxcTest('start', 'vm_test_6', cb); },
function(cb){ lxcTest('start', 'vm_test_7', cb); },
function(cb){ lxcTest('start', 'vm_test_8', cb); },
function(cb){ lxcTest('start', 'vm_test_9', cb); },
function(cb){ lxcTest('start', 'vm_test_10', cb); },
];
var testFreeze = [
function(cb){ lxcTest('freeze', 'vm_test_1', cb); },
function(cb){ lxcTest('freeze', 'vm_test_2', cb); },
function(cb){ lxcTest('freeze', 'vm_test_3', cb); },
function(cb){ lxcTest('freeze', 'vm_test_4', cb); },
function(cb){ lxcTest('freeze', 'vm_test_5', cb); },
function(cb){ lxcTest('freeze', 'vm_test_6', cb); },
function(cb){ lxcTest('freeze', 'vm_test_7', cb); },
function(cb){ lxcTest('freeze', 'vm_test_8', cb); },
function(cb){ lxcTest('freeze', 'vm_test_9', cb); },
function(cb){ lxcTest('freeze', 'vm_test_10', cb); },
];
var testUnFreeze = [
function(cb){ lxcTest('unfreeze', 'vm_test_1', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_2', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_3', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_4', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_5', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_6', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_7', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_8', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_9', cb); },
function(cb){ lxcTest('unfreeze', 'vm_test_10', cb); },
];
var testStop = [
function(cb){ lxcTest('stop', 'vm_test_1', cb); },
function(cb){ lxcTest('stop', 'vm_test_2', cb); },
function(cb){ lxcTest('stop', 'vm_test_3', cb); },
function(cb){ lxcTest('stop', 'vm_test_4', cb); },
function(cb){ lxcTest('stop', 'vm_test_5', cb); },
function(cb){ lxcTest('stop', 'vm_test_6', cb); },
function(cb){ lxcTest('stop', 'vm_test_7', cb); },
function(cb){ lxcTest('stop', 'vm_test_8', cb); },
function(cb){ lxcTest('stop', 'vm_test_9', cb); },
function(cb){ lxcTest('stop', 'vm_test_10', cb); },
];
var testDestroy = [
function(cb){ lxcTest('destroy', 'vm_test_1', cb); },
function(cb){ lxcTest('destroy', 'vm_test_2', cb); },
function(cb){ lxcTest('destroy', 'vm_test_3', cb); },
function(cb){ lxcTest('destroy', 'vm_test_4', cb); },
function(cb){ lxcTest('destroy', 'vm_test_5', cb); },
function(cb){ lxcTest('destroy', 'vm_test_6', cb); },
function(cb){ lxcTest('destroy', 'vm_test_7', cb); },
function(cb){ lxcTest('destroy', 'vm_test_8', cb); },
function(cb){ lxcTest('destroy', 'vm_test_9', cb); },
function(cb){ lxcTest('destroy', 'vm_test_10', cb); },
];
var testAll = [
function(cb){ async.parallel(testCreate, function(err, results){ cb(null, "Created 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
function(cb){ async.parallel(testStart, function(err, results){ cb(null, "Started 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
function(cb){ async.parallel(testFreeze, function(err, results){ cb(null, "Freeze 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
function(cb){ async.parallel(testUnFreeze, function(err, results){ cb(null, "Unfreeze 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
function(cb){ async.parallel(testStop, function(err, results){ cb(null, "Stop 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
function(cb){ async.parallel(testDestroy, function(err, results){ cb(null, "Destroyed 10 vm's") }) },
function(cb){ setTimeout(function(){ console.log('Pausing...'.yellow); cb(null, "Paused 5seconds...")},5000) },
];
async.series(testAll, function(err, results){
console.log(err, results);
});