Skip to content

Commit 2e7ab38

Browse files
jagednabhi18av
authored andcommitted
reproduce nomad server answers in test with a first running state followed by a completed
Signed-off-by: Jorge Aguilera <[email protected]>
1 parent b740505 commit 2e7ab38

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed

plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ class NomadDSLSpec extends Dsl2Spec{
102102
given:
103103
boolean submitted = false
104104
boolean summary = false
105+
int requestCounter = 0
105106
mockWebServer.dispatcher = new Dispatcher() {
106107
@Override
107108
MockResponse dispatch(@NotNull RecordedRequest recordedRequest) throws InterruptedException {
108109
switch (recordedRequest.method.toLowerCase()){
109110
case "get":
110111
if( recordedRequest.path.endsWith("/allocations")) {
111112
summary = true
113+
def resource = !requestCounter++ ? "/allocations.json" : "/completed.json"
112114
return new MockResponse().setResponseCode(200)
113-
.setBody(this.getClass().getResourceAsStream("/allocations.json").text).addHeader("Content-Type", "application/json")
115+
.setBody(this.getClass().getResourceAsStream(resource).text).addHeader("Content-Type", "application/json")
114116
}else {
115117
return new MockResponse().setResponseCode(200)
116118
.setBody('{"Status": "dead"}').addHeader("Content-Type", "application/json")
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
[
2+
{
3+
"ID": "ed344e0a-7290-d117-41d3-a64f853ca3c2",
4+
"EvalID": "a9c5effc-2242-51b2-f1fe-054ee11ab189",
5+
"Name": "example.cache[0]",
6+
"NodeID": "cb1f6030-a220-4f92-57dc-7baaabdc3823",
7+
"PreviousAllocation": "516d2753-0513-cfc7-57ac-2d6fac18b9dc",
8+
"NextAllocation": "cd13d9b9-4f97-7184-c88b-7b451981616b",
9+
"RescheduleTracker": {
10+
"Events": [
11+
{
12+
"PrevAllocID": "516d2753-0513-cfc7-57ac-2d6fac18b9dc",
13+
"PrevNodeID": "9230cd3b-3bda-9a3f-82f9-b2ea8dedb20e",
14+
"RescheduleTime": 1517434161192946200,
15+
"Delay": 5000000000
16+
}
17+
]
18+
},
19+
"JobID": "example",
20+
"TaskGroup": "cache",
21+
"DesiredStatus": "run",
22+
"DesiredDescription": "",
23+
"ClientStatus": "complete",
24+
"ClientDescription": "",
25+
"TaskStates": {
26+
"redis": {
27+
"State": "complete",
28+
"Failed": false,
29+
"StartedAt": "2017-05-25T23:41:23.240184101Z",
30+
"FinishedAt": "0001-01-01T00:00:00Z",
31+
"Events": [
32+
{
33+
"Type": "Received",
34+
"Time": 1495755675956923000,
35+
"FailsTask": false,
36+
"RestartReason": "",
37+
"SetupError": "",
38+
"DriverError": "",
39+
"ExitCode": 0,
40+
"Signal": 0,
41+
"Message": "",
42+
"KillTimeout": 0,
43+
"KillError": "",
44+
"KillReason": "",
45+
"StartDelay": 0,
46+
"DownloadError": "",
47+
"ValidationError": "",
48+
"DiskLimit": 0,
49+
"FailedSibling": "",
50+
"VaultError": "",
51+
"TaskSignalReason": "",
52+
"TaskSignal": "",
53+
"DriverMessage": ""
54+
},
55+
{
56+
"Type": "Task Setup",
57+
"Time": 1495755675957466400,
58+
"FailsTask": false,
59+
"RestartReason": "",
60+
"SetupError": "",
61+
"DriverError": "",
62+
"ExitCode": 0,
63+
"Signal": 0,
64+
"Message": "Building Task Directory",
65+
"KillTimeout": 0,
66+
"KillError": "",
67+
"KillReason": "",
68+
"StartDelay": 0,
69+
"DownloadError": "",
70+
"ValidationError": "",
71+
"DiskLimit": 0,
72+
"FailedSibling": "",
73+
"VaultError": "",
74+
"TaskSignalReason": "",
75+
"TaskSignal": "",
76+
"DriverMessage": ""
77+
},
78+
{
79+
"Type": "Driver",
80+
"Time": 1495755675970286800,
81+
"FailsTask": false,
82+
"RestartReason": "",
83+
"SetupError": "",
84+
"DriverError": "",
85+
"ExitCode": 0,
86+
"Signal": 0,
87+
"Message": "",
88+
"KillTimeout": 0,
89+
"KillError": "",
90+
"KillReason": "",
91+
"StartDelay": 0,
92+
"DownloadError": "",
93+
"ValidationError": "",
94+
"DiskLimit": 0,
95+
"FailedSibling": "",
96+
"VaultError": "",
97+
"TaskSignalReason": "",
98+
"TaskSignal": "",
99+
"DriverMessage": "Downloading image redis:7"
100+
},
101+
{
102+
"Type": "Started",
103+
"Time": 1495755683227522000,
104+
"FailsTask": false,
105+
"RestartReason": "",
106+
"SetupError": "",
107+
"DriverError": "",
108+
"ExitCode": 0,
109+
"Signal": 0,
110+
"Message": "",
111+
"KillTimeout": 0,
112+
"KillError": "",
113+
"KillReason": "",
114+
"StartDelay": 0,
115+
"DownloadError": "",
116+
"ValidationError": "",
117+
"DiskLimit": 0,
118+
"FailedSibling": "",
119+
"VaultError": "",
120+
"TaskSignalReason": "",
121+
"TaskSignal": "",
122+
"DriverMessage": ""
123+
}
124+
]
125+
}
126+
},
127+
"CreateIndex": 9,
128+
"ModifyIndex": 13,
129+
"CreateTime": 1495755675944527600,
130+
"ModifyTime": 1495755675944527600
131+
}
132+
]

0 commit comments

Comments
 (0)