Skip to content

Commit

Permalink
Fix 2 tests in ReplaceActorTest suite
Browse files Browse the repository at this point in the history
One of the test is slightly different; we don't have to wait for one
instance to be dead when in overcapacity.
  • Loading branch information
Lqp1 authored and komuta committed Aug 14, 2020
1 parent e50108e commit be44390
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {
expectTerminated(ref)
}

"replace and scale down from more than new minCapacity" ignore {
"replace and scale down from more than new minCapacity" in {
val f = new Fixture
val app = AppDefinition(
id = AbsolutePathId("/myApp"),
Expand Down Expand Up @@ -162,10 +162,7 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {
f.sendState(app, newApp, ref, oldInstances, newInstances, 0, 2)
promise.future.futureValue

eventually {
verify(f.tracker, times(3)).setGoal(any, any, any)
}
verify(f.queue).resetDelay(newApp)
verify(f.tracker, times(3)).setGoal(any, any, any)

expectTerminated(ref)
}
Expand Down Expand Up @@ -442,7 +439,7 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {
expectTerminated(ref)
}

"downscale tasks during rolling upgrade with 1 over-capacity" ignore {
"downscale tasks during rolling upgrade with 1 over-capacity" in {
val f = new Fixture
val app = AppDefinition(
id = AbsolutePathId("/myApp"),
Expand Down Expand Up @@ -472,13 +469,9 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {

f.sendState(app, newApp, ref, oldInstances, newInstances, 4, 0)
// one task is killed directly because we are over capacity
// we also can schedule one because overcapacity
eventually {
verify(f.tracker).setGoal(any, eq(Goal.Decommissioned), eq(GoalChangeReason.Upgrading))
}

// the kill is confirmed (see answer above) and the first new task is queued
f.sendState(app, newApp, ref, oldInstances, newInstances, 3, 0)
eventually {
verify(f.queue, times(1)).add(newApp, 1)
verify(f.queue, times(1)).resetDelay(newApp)
}
Expand All @@ -487,17 +480,13 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {
f.sendState(app, newApp, ref, oldInstances, newInstances, 3, 1)
eventually {
verify(f.tracker, times(2)).setGoal(any, any, any)
}
eventually {
verify(f.queue, times(2)).add(newApp, 1)
}

// second new task becomes healthy and another old task is killed
f.sendState(app, newApp, ref, oldInstances, newInstances, 2, 2)
eventually {
verify(f.tracker, times(3)).setGoal(any, any, any)
}
eventually {
verify(f.queue, times(3)).add(newApp, 1)
}

Expand Down Expand Up @@ -731,12 +720,6 @@ class TaskReplaceActorTest extends AkkaUnitTest with Eventually {
.getInstance()
}

def healthyInstance(app: AppDefinition, healthy: Boolean = true): Instance = {
TestInstanceBuilder.newBuilderForRunSpec(app, now = app.version)
.addTaskWithBuilder().taskRunning().asHealthyTask(healthy).withNetworkInfo(hostName = Some(hostName), hostPorts = hostPorts).build()
.getInstance()
}

def readinessResults(instance: Instance, checkName: String, ready: Boolean): (Cancellable, Source[ReadinessCheckResult, Cancellable]) = {
val cancellable = new CancellableOnce(() => ())
val source = Source(instance.tasksMap.values.map(task => ReadinessCheckResult(checkName, task.taskId, ready, None)).toList).
Expand Down

0 comments on commit be44390

Please sign in to comment.