Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(repository): Remove duplicate storeStage call #4795

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,12 +793,20 @@ 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("updates the stage with a non-default start time") {
verify(repository).storeStage(
check {
assertThat(it.startTime).isPositive()
}
)
}
}

and("only the branch should fail") {
Expand All @@ -825,20 +833,28 @@ 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)
}
)
}

it("updates the stage with a non-default start time") {
verify(repository).storeStage(
check {
assertThat(it.startTime).isPositive()
}
)
}
}

and("the branch should be allowed to continue") {
Expand All @@ -865,20 +881,28 @@ 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)
}
)
}

it("updates the stage with a non-default start time") {
verify(repository).storeStage(
check {
assertThat(it.startTime).isPositive()
}
)
}
}
}

Expand Down Expand Up @@ -929,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 @@ -938,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