-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_cluster.js
60 lines (47 loc) · 1.89 KB
/
test_cluster.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
var api = include("app_api");
function test() {
const nameTest = "TEST-CLUSTER";
function clusterGet(cluster) {
var clusters = api.clustersMap();
var tmp = clusters[cluster];
console.debug("Load cluster", cluster, ": ", tmp);
return tmp;
}
function clusterCreate(cluster, data) {
console.debug("Check that", cluster, "not exists.");
var clusters = api.clustersMap();
var ourCluster = clusters[cluster];
console.assert(!clusters[cluster], "Cluster with ", cluster, " already exists!");
console.debug("Create cluster:", cluster);
api.clusterCreate(cluster, data);
}
function clear() {
console.debug("Clean...");
api.clusterDelete(nameTest);
}
function testCreate() {
var ourClusterName = nameTest;
var ourClusterTitle = "TEST TITLE";
clusterCreate(ourClusterName, {title: ourClusterTitle});
console.debug("Check that", ourClusterName, "is exists");
var ourCluster = clusterGet(ourClusterName);
console.assert(!!ourCluster, "Cluster with ", ourClusterName, " is not exists!");
console.assert(ourCluster.title === ourClusterTitle, "Cluster with ", ourClusterName,
" has unexpected title: ", ourCluster.title);
console.debug("Delete", ourClusterName);
api.clusterDelete(ourClusterName);
}
function testCreateWithBadName() {
var ourClusterName = "TEST_CLUSTER"
clusterCreate(ourClusterName);
console.debug("Check that", ourClusterName, "is not exists");
var cluster = clusterGet(ourClusterName);
console.assert(!cluster, "Cluster with bad name: ", ourClusterName, " is created!");
}
api.host = process.env.API_HOST;
console.debug("api.host:", api.host);
api.login("admin", "password");
clear();
testCreateWithBadName();
testCreate();
}