Skip to content

Commit e566e21

Browse files
Daniel Zhengkirangodishala
Daniel Zheng
authored andcommitted
perf(stage): Remove duplicate storeStage call
The duplicate repository.storeStage call was originally added in e872ce8 to ensure that the start time for a stage is set even if the handler encounters an exception. However, even without the extra repository.storeStage, orca still sets the start time for a stage when it encounters an exception.
1 parent a1cc8bf commit e566e21

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

orca-queue/src/main/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandler.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class StartStageHandler(
9595
try {
9696
// Set the startTime in case we throw an exception.
9797
stage.startTime = clock.millis()
98-
repository.storeStage(stage)
9998
stage.plan()
10099
stage.status = RUNNING
101100
repository.storeStage(stage)

orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandlerTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
162162
}
163163

164164
it("updates the stage status") {
165-
verify(repository, times(2)).storeStage(
165+
verify(repository).storeStage(
166166
check {
167167
assertThat(it.status).isEqualTo(RUNNING)
168168
assertThat(it.startTime).isEqualTo(clock.millis())
@@ -171,7 +171,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
171171
}
172172

173173
it("attaches tasks to the stage") {
174-
verify(repository, times(2)).storeStage(
174+
verify(repository).storeStage(
175175
check {
176176
assertThat(it.tasks.size).isEqualTo(1)
177177
it.tasks.first().apply {
@@ -222,7 +222,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
222222
}
223223

224224
it("updates the stage status") {
225-
verify(repository, times(2)).storeStage(
225+
verify(repository).storeStage(
226226
check {
227227
assertThat(it.status).isEqualTo(RUNNING)
228228
assertThat(it.startTime).isEqualTo(clock.millis())
@@ -267,7 +267,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
267267
}
268268

269269
it("updates the stage status") {
270-
verify(repository, times(2)).storeStage(
270+
verify(repository).storeStage(
271271
check {
272272
assertThat(it.status).isEqualTo(RUNNING)
273273
assertThat(it.startTime).isEqualTo(clock.millis())
@@ -312,7 +312,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
312312
afterGroup(::resetMocks)
313313

314314
it("attaches tasks to the stage") {
315-
verify(repository, times(2)).storeStage(
315+
verify(repository).storeStage(
316316
check {
317317
assertThat(it.tasks.size).isEqualTo(3)
318318
it.tasks[0].apply {
@@ -702,7 +702,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
702702
}
703703

704704
it("starts the stage") {
705-
verify(repository, times(2)).storeStage(
705+
verify(repository).storeStage(
706706
check {
707707
assertThat(it.type).isEqualTo("bar")
708708
assertThat(it.status).isEqualTo(RUNNING)
@@ -712,7 +712,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
712712
}
713713

714714
it("attaches a task to the stage") {
715-
verify(repository, times(2)).storeStage(
715+
verify(repository).storeStage(
716716
check {
717717
assertThat(it.tasks.size).isEqualTo(1)
718718
it.tasks.first().apply {
@@ -793,7 +793,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
793793
}
794794

795795
it("attaches the exception to the stage context") {
796-
verify(repository, times(2)).storeStage(
796+
verify(repository).storeStage(
797797
check {
798798
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
799799
}
@@ -833,15 +833,15 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
833833
}
834834

835835
it("attaches the exception to the stage context") {
836-
verify(repository, times(2)).storeStage(
836+
verify(repository).storeStage(
837837
check {
838838
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
839839
}
840840
)
841841
}
842842

843843
it("attaches flag to the stage context to indicate that before stage planning failed") {
844-
verify(repository, times(2)).storeStage(
844+
verify(repository).storeStage(
845845
check {
846846
assertThat(it.context["beforeStagePlanningFailed"]).isEqualTo(true)
847847
}
@@ -881,15 +881,15 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
881881
}
882882

883883
it("attaches the exception to the stage context") {
884-
verify(repository, times(2)).storeStage(
884+
verify(repository).storeStage(
885885
check {
886886
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
887887
}
888888
)
889889
}
890890

891891
it("attaches flag to the stage context to indicate that before stage planning failed") {
892-
verify(repository, times(2)).storeStage(
892+
verify(repository).storeStage(
893893
check {
894894
assertThat(it.context["beforeStagePlanningFailed"]).isEqualTo(true)
895895
}
@@ -953,7 +953,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
953953
}
954954

955955
it("updates the stage status") {
956-
verify(repository, times(2)).storeStage(
956+
verify(repository).storeStage(
957957
check {
958958
assertThat(it.status).isEqualTo(RUNNING)
959959
assertThat(it.startTime).isEqualTo(clock.millis())
@@ -962,7 +962,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
962962
}
963963

964964
it("attaches tasks to the stage") {
965-
verify(repository, times(2)).storeStage(
965+
verify(repository).storeStage(
966966
check {
967967
assertThat(it.tasks.size).isEqualTo(1)
968968
it.tasks.first().apply {

0 commit comments

Comments
 (0)