Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit 0ecdc24

Browse files
sonjaerckiosidis
authored andcommitted
Fixed tests related to created event
1 parent 0fa12f2 commit 0ecdc24

File tree

7 files changed

+127
-92
lines changed

7 files changed

+127
-92
lines changed

styx-api-service/src/test/java/com/spotify/styx/api/StatusResourceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static org.mockito.Mockito.spy;
3535
import static org.mockito.Mockito.when;
3636

37+
import com.google.common.collect.ImmutableSet;
3738
import com.spotify.apollo.Environment;
3839
import com.spotify.apollo.Response;
3940
import com.spotify.apollo.Status;
@@ -132,6 +133,7 @@ public void testEventsRoundtrip() throws Exception {
132133
sinceVersion(Api.Version.V3);
133134

134135
storage.writeEvent(SequenceEvent.create(Event.triggerExecution(WFI_1, TRIGGER, TriggerParameters.zero()), 0L, 0L));
136+
storage.writeEvent(SequenceEvent.create(Event.dequeue(WFI_1, ImmutableSet.of()), 1L, 1L));
135137
storage.writeEvent(SequenceEvent.create(Event.started(WFI_1), 2L, 2L));
136138

137139
Response<ByteString> response =

styx-api-service/src/test/java/com/spotify/styx/api/WorkflowResourceTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ public void shouldReturnWorkflowInstancesData() throws Exception {
345345
WorkflowInstance wfi = WorkflowInstance.create(WORKFLOW.id(), "2016-08-10");
346346
storage.writeEvent(create(Event.triggerExecution(wfi, NATURAL_TRIGGER, TRIGGER_PARAMETERS), 0L, ms("07:00:00")));
347347
storage.writeEvent(create(Event.dequeue(wfi, ImmutableSet.of()), 1L, ms("07:00:01")));
348-
storage.writeEvent(create(Event.started(wfi), 2L, ms("07:00:02")));
348+
storage.writeEvent(create(Event.submit(wfi, EXECUTION_DESCRIPTION, "exec"), 2L, ms("07:00:02")));
349+
storage.writeEvent(create(Event.submitted(wfi, "exec", "test"), 3L, ms("07:00:03")));
350+
storage.writeEvent(create(Event.started(wfi), 4L, ms("07:00:04")));
349351

350352
Response<ByteString> response =
351353
awaitResponse(serviceHelper.request("GET", path("/foo/bar/instances")));
@@ -361,7 +363,7 @@ public void shouldReturnWorkflowInstancesData() throws Exception {
361363
assertJson(response, "[0].triggers.[0].complete", is(false));
362364
assertJson(response, "[0].triggers.[0].executions", hasSize(1));
363365
assertJson(response, "[0].triggers.[0].executions.[0].execution_id", is("exec"));
364-
assertJson(response, "[0].triggers.[0].executions.[0].docker_image", is("img"));
366+
assertJson(response, "[0].triggers.[0].executions.[0].docker_image", is("busybox:1.1"));
365367
assertJson(response, "[0].triggers.[0].executions.[0].statuses", hasSize(2));
366368
assertJson(response, "[0].triggers.[0].executions.[0].statuses.[0].status", is("SUBMITTED"));
367369
assertJson(response, "[0].triggers.[0].executions.[0].statuses.[1].status", is("STARTED"));
@@ -386,7 +388,9 @@ public void shouldReturnWorkflowRangeOfInstancesData() throws Exception {
386388
WorkflowInstance wfi = WorkflowInstance.create(WORKFLOW.id(), "2016-08-10");
387389
storage.writeEvent(create(Event.triggerExecution(wfi, NATURAL_TRIGGER, TRIGGER_PARAMETERS), 0L, ms("07:00:00")));
388390
storage.writeEvent(create(Event.dequeue(wfi, ImmutableSet.of()), 1L, ms("07:00:01")));
389-
storage.writeEvent(create(Event.started(wfi), 2L, ms("07:00:02")));
391+
storage.writeEvent(create(Event.submit(wfi, EXECUTION_DESCRIPTION, "exec"), 2L, ms("07:00:02")));
392+
storage.writeEvent(create(Event.submitted(wfi, "exec", "test"), 3L, ms("07:00:03")));
393+
storage.writeEvent(create(Event.started(wfi), 4L, ms("07:00:04")));
390394

391395
Response<ByteString> response =
392396
awaitResponse(serviceHelper.request("GET", path("/foo/bar/instances?start=2016-08-10")));
@@ -402,7 +406,7 @@ public void shouldReturnWorkflowRangeOfInstancesData() throws Exception {
402406
assertJson(response, "[0].triggers.[0].complete", is(false));
403407
assertJson(response, "[0].triggers.[0].executions", hasSize(1));
404408
assertJson(response, "[0].triggers.[0].executions.[0].execution_id", is("exec"));
405-
assertJson(response, "[0].triggers.[0].executions.[0].docker_image", is("img"));
409+
assertJson(response, "[0].triggers.[0].executions.[0].docker_image", is("busybox:1.1"));
406410
assertJson(response, "[0].triggers.[0].executions.[0].statuses", hasSize(2));
407411
assertJson(response, "[0].triggers.[0].executions.[0].statuses.[0].status", is("SUBMITTED"));
408412
assertJson(response, "[0].triggers.[0].executions.[0].statuses.[1].status", is("STARTED"));
@@ -438,9 +442,9 @@ public void shouldReturnWorkflowInstanceData() throws Exception {
438442
assertJson(response, "triggers.[0].executions.[0].statuses.[0].status", is("SUBMITTED"));
439443
assertJson(response, "triggers.[0].executions.[0].statuses.[1].status", is("STARTED"));
440444
assertJson(response, "triggers.[0].executions.[0].statuses.[0].timestamp",
441-
is("2016-08-10T07:00:01Z"));
445+
is("2016-08-10T07:00:03Z"));
442446
assertJson(response, "triggers.[0].executions.[0].statuses.[1].timestamp",
443-
is("2016-08-10T07:00:02Z"));
447+
is("2016-08-10T07:00:04Z"));
444448
}
445449

446450
@Test

styx-common/src/main/java/com/spotify/styx/testdata/TestData.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ public final class TestData {
158158
.commitSha(VALID_SHA)
159159
.build();
160160

161+
public static final ExecutionDescription EXECUTION_DESCRIPTION2 =
162+
ExecutionDescription.builder()
163+
.dockerImage("busybox:1.2")
164+
.dockerArgs("foo", "bar")
165+
.secret(WorkflowConfiguration.Secret.create("secret", "/dev/null"))
166+
.commitSha(VALID_SHA)
167+
.build();
168+
161169
public static final Workflow WORKFLOW_WITH_RESOURCES = Workflow.create(WORKFLOW_ID.componentId(),
162170
HOURLY_WORKFLOW_CONFIGURATION_WITH_RESOURCES);
163171

styx-scheduler-service/src/test/java/com/spotify/styx/state/handlers/TimeoutHandlerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import org.mockito.MockitoAnnotations;
5454

5555
@RunWith(JUnitParamsRunner.class)
56-
public class TimeoutHandlerTest {
56+
public class TimeoutHandlerTest {
5757

5858
private Instant now = Instant.parse("2016-12-02T22:00:00Z");
5959
private Time time = () -> now;

styx-service-common/src/main/java/com/spotify/styx/state/RunState.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,11 @@ public RunState submitted(WorkflowInstance workflowInstance, String executionId,
212212
public RunState started(WorkflowInstance workflowInstance) {
213213
switch (state()) {
214214
case SUBMITTED:
215-
case PREPARE:
216215
return state(RUNNING);
216+
case PREPARE:
217+
return state(RUNNING, data().builder()
218+
.tries(data().tries() + 1)
219+
.build());
217220

218221
default:
219222
throw illegalTransition("started");

0 commit comments

Comments
 (0)