-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_jobs_update.js
61 lines (57 loc) · 1.82 KB
/
test_jobs_update.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
var api = include("app_api");
function test() {
api.host = process.env.API_HOST;
var clusterName = "job-test-cluster";
var jobId;
console.debug("api.host:", api.host);
api.login("admin", "password");
//clean
function clean() {
api.clusterDelete(clusterName);
if(jobId) {
var res = api.jobDelete(jobId);
console.assert(res.code == 200, "Can not delete job: ", res.message)
}
}
api.clusterCreate(clusterName, {title: "cluster for test updates"});
var params = {
type: "ui.updateContainers.stopThenStartEach",
title: "Update test Title",
parameters: {
cluster: clusterName,
"LoadContainersOfImage.percentage": 100,
images: {
images: [
{
name: "*",
from: "*",
to: "latest"
}
]
},
random: new Date().getTime()
}
}
// note that cluster now does not has any nodes because update do nothing,
// but we test job instantiation an parameters deserialization
var res = api.jobCreate(params);
console.assert(res.code == 200, "JOB: can not be scheduled");
var job = res.data;
console.debug("After run:", job);
if(job.status === 'COMPLETED') {
clean();
return;
}
var jobId = job.id;
//do something with below ugly thing
java.lang.Thread.sleep(3000);
var job = api.job(jobId).data
console.debug("Later:", job);
if(job.status === 'FAILED_JOB') {
var log = api.jobLog(jobId).data;
var latest = log[log.length - 1];
console.debug("Message of latest record of log:", latest.message);
console.assert(false, "Test failed");
}
clean();
}