Skip to content

Commit 489b3ef

Browse files
author
zkofiro
committed
update test
1 parent e9a0e00 commit 489b3ef

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

rest-mvc/impl/src/test/java/com/intuit/tank/rest/mvc/rest/cloud/JobEventSenderTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ void getInstancesForJob_returnsEmptyForNonExistent() throws Exception {
193193
}
194194

195195
@Test
196-
@DisplayName("getInstancesForJob excludes replaced instances (AgentWatchdog replacements)")
197-
void getInstancesForJob_excludesReplacedInstances() throws Exception {
196+
@DisplayName("getInstancesForJob includes replaced instances (needed for EC2 termination)")
197+
void getInstancesForJob_includesReplacedInstances() throws Exception {
198198
// Given: VMStatus.replaced is set by AgentWatchdog when an agent fails and is replaced
199199
container.getStatuses().add(createStatus("i-running", JobStatus.Running, VMStatus.running));
200200
container.getStatuses().add(createStatus("i-replaced", JobStatus.Starting, VMStatus.replaced));
@@ -204,14 +204,14 @@ void getInstancesForJob_excludesReplacedInstances() throws Exception {
204204
// When
205205
List<String> instances = invokeGetInstancesForJob("123");
206206

207-
// Then: Replaced instances should be filtered out (can't receive commands)
208-
assertEquals(1, instances.size());
207+
// Then: ALL instances returned including replaced (EC2 still needs termination)
208+
assertEquals(2, instances.size());
209209
assertTrue(instances.contains("i-running"));
210-
assertFalse(instances.contains("i-replaced"));
210+
assertTrue(instances.contains("i-replaced"));
211211
}
212212

213213
@Test
214-
@DisplayName("getInstancesForJob filters correctly with mixed statuses from AgentWatchdog scenario")
214+
@DisplayName("getInstancesForJob returns all instances including replaced for AgentWatchdog scenario")
215215
void getInstancesForJob_agentWatchdogScenario() throws Exception {
216216
// Given: Real-world scenario where AgentWatchdog replaced some agents
217217
// - 3 running agents (healthy)
@@ -227,18 +227,18 @@ void getInstancesForJob_agentWatchdogScenario() throws Exception {
227227
// When: User tries to kill the job
228228
List<String> instances = invokeGetInstancesForJob("123");
229229

230-
// Then: Only healthy instances should receive the kill command
231-
assertEquals(3, instances.size());
230+
// Then: ALL instances returned (replaced EC2 instances still need termination)
231+
assertEquals(5, instances.size());
232232
assertTrue(instances.contains("i-healthy1"));
233233
assertTrue(instances.contains("i-healthy2"));
234234
assertTrue(instances.contains("i-healthy3"));
235-
assertFalse(instances.contains("i-replaced1"));
236-
assertFalse(instances.contains("i-replaced2"));
235+
assertTrue(instances.contains("i-replaced1"));
236+
assertTrue(instances.contains("i-replaced2"));
237237
}
238238

239239
@Test
240-
@DisplayName("getInstancesForJob excludes only replaced instances")
241-
void getInstancesForJob_excludesOnlyReplaced() throws Exception {
240+
@DisplayName("getInstancesForJob returns all instances regardless of status")
241+
void getInstancesForJob_returnsAllInstances() throws Exception {
242242
// Given: One instance of each state
243243
container.getStatuses().add(createStatus("i-running", JobStatus.Running, VMStatus.running));
244244
container.getStatuses().add(createStatus("i-terminated", JobStatus.Completed, VMStatus.terminated));
@@ -252,15 +252,14 @@ void getInstancesForJob_excludesOnlyReplaced() throws Exception {
252252
// When
253253
List<String> instances = invokeGetInstancesForJob("123");
254254

255-
// Then: Only replaced is excluded (watchdog already killed it on AWS)
256-
// All others included (EC2 instances exist or AWS handles idempotently)
257-
assertEquals(5, instances.size());
255+
// Then: ALL instances returned (no filtering - AWS handles idempotently)
256+
assertEquals(6, instances.size());
258257
assertTrue(instances.contains("i-running"));
259258
assertTrue(instances.contains("i-terminated"));
260259
assertTrue(instances.contains("i-stopped"));
261260
assertTrue(instances.contains("i-stopping"));
262261
assertTrue(instances.contains("i-shutting-down"));
263-
assertFalse(instances.contains("i-replaced"));
262+
assertTrue(instances.contains("i-replaced"));
264263
}
265264

266265
@Test

0 commit comments

Comments
 (0)