Skip to content

Commit

Permalink
perf(stage): Remove duplicate storeStage call
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Daniel Zheng authored and kirangodishala committed Nov 11, 2024
1 parent a1cc8bf commit e566e21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class StartStageHandler(
try {
// Set the startTime in case we throw an exception.
stage.startTime = clock.millis()
repository.storeStage(stage)
stage.plan()
stage.status = RUNNING
repository.storeStage(stage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

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

it("attaches tasks to the stage") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.tasks.size).isEqualTo(1)
it.tasks.first().apply {
Expand Down Expand Up @@ -222,7 +222,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("updates the stage status") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.status).isEqualTo(RUNNING)
assertThat(it.startTime).isEqualTo(clock.millis())
Expand Down Expand Up @@ -267,7 +267,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("updates the stage status") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.status).isEqualTo(RUNNING)
assertThat(it.startTime).isEqualTo(clock.millis())
Expand Down Expand Up @@ -312,7 +312,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
afterGroup(::resetMocks)

it("attaches tasks to the stage") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.tasks.size).isEqualTo(3)
it.tasks[0].apply {
Expand Down Expand Up @@ -702,7 +702,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("starts the stage") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.type).isEqualTo("bar")
assertThat(it.status).isEqualTo(RUNNING)
Expand All @@ -712,7 +712,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("attaches a task to the stage") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.tasks.size).isEqualTo(1)
it.tasks.first().apply {
Expand Down Expand Up @@ -793,7 +793,7 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("attaches the exception to the stage context") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
}
Expand Down Expand Up @@ -833,15 +833,15 @@ object StartStageHandlerTest : SubjectSpek<StartStageHandler>({
}

it("attaches the exception to the stage context") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
}
)
}

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

it("attaches the exception to the stage context") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.context["exception"]).isEqualTo(exceptionDetails)
}
)
}

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

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

it("attaches tasks to the stage") {
verify(repository, times(2)).storeStage(
verify(repository).storeStage(
check {
assertThat(it.tasks.size).isEqualTo(1)
it.tasks.first().apply {
Expand Down

0 comments on commit e566e21

Please sign in to comment.