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
fixed wrong gc calculation #4203
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d44ef77
fixed garbage calculation
unterstein ae6f02c
added test for recent fix
unterstein e74495a
Style change in MarathonTestHelper.scala
gkleiman 88265f3
Style changes ExpungeOverdueLostTasksActorTest
gkleiman 97fb279
since = since ... compilement error otherwise
unterstein File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/scala/mesosphere/marathon/core/task/jobs/ExpungeOverdueLostTasksActorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package mesosphere.marathon.core.task.jobs | ||
|
||
import akka.actor.{ ActorRef, ActorSystem, PoisonPill, Terminated } | ||
import akka.testkit.TestProbe | ||
import mesosphere.marathon | ||
import mesosphere.marathon.core.base.ConstantClock | ||
import mesosphere.marathon.core.task.jobs.impl.ExpungeOverdueLostTasksActor | ||
import mesosphere.marathon.core.task.tracker.TaskTracker.TasksByApp | ||
import mesosphere.marathon.core.task.tracker.{ TaskStateOpProcessor, TaskTracker } | ||
import mesosphere.marathon.{ MarathonSpec, MarathonTestHelper } | ||
import org.scalatest.GivenWhenThen | ||
import org.scalatest.concurrent.ScalaFutures | ||
import mesosphere.marathon.state.PathId._ | ||
import mesosphere.marathon.state.Timestamp | ||
|
||
import scala.concurrent.duration._ | ||
import scala.concurrent.{ Await, ExecutionContext, Future } | ||
import scala.concurrent.duration.Duration | ||
|
||
class ExpungeOverdueLostTasksActorTest extends MarathonSpec with GivenWhenThen with marathon.test.Mockito with ScalaFutures { | ||
implicit var actorSystem: ActorSystem = _ | ||
val taskTracker: TaskTracker = mock[TaskTracker] | ||
val clock = ConstantClock() | ||
val config = MarathonTestHelper.defaultConfig(maxTasksPerOffer = 10) | ||
val stateOpProcessor: TaskStateOpProcessor = mock[TaskStateOpProcessor] | ||
var checkActor: ActorRef = _ | ||
|
||
before { | ||
actorSystem = ActorSystem() | ||
checkActor = actorSystem.actorOf(ExpungeOverdueLostTasksActor.props(clock, config, taskTracker, stateOpProcessor)) | ||
} | ||
|
||
after { | ||
def waitForActorProcessingAllAndDying(): Unit = { | ||
checkActor ! PoisonPill | ||
val probe = TestProbe() | ||
probe.watch(checkActor) | ||
val terminated = probe.expectMsgAnyClassOf(classOf[Terminated]) | ||
assert(terminated.actor == checkActor) | ||
} | ||
|
||
waitForActorProcessingAllAndDying() | ||
|
||
Await.result(actorSystem.terminate(), Duration.Inf) | ||
} | ||
|
||
test("running tasks with more then 24 hours with no status update should not be killed") { | ||
Given("two running tasks") | ||
val running1 = MarathonTestHelper.minimalRunning("/running1".toPath, since = Timestamp.apply(0)) | ||
val running2 = MarathonTestHelper.minimalRunning("/running2".toPath, since = Timestamp.apply(0)) | ||
|
||
taskTracker.tasksByApp()(any[ExecutionContext]) returns Future.successful(TasksByApp.forTasks(running1, running2)) | ||
|
||
When("a check is performed") | ||
val testProbe = TestProbe() | ||
testProbe.send(checkActor, ExpungeOverdueLostTasksActor.Tick) | ||
testProbe.receiveOne(3.seconds) | ||
|
||
And("no kill calls are issued") | ||
noMoreInteractions(stateOpProcessor) | ||
} | ||
|
||
test("a unreachable task with more then 24 hours with no status update should be killed") { | ||
Given("one unreachable, one running tasks") | ||
val running = MarathonTestHelper.minimalRunning("/running1".toPath, since= Timestamp.apply(0)) | ||
val unreachable = MarathonTestHelper.minimalUnreachableTask("/running2".toPath, since = Timestamp.apply(0)) | ||
|
||
taskTracker.tasksByApp()(any[ExecutionContext]) returns Future.successful(TasksByApp.forTasks(running, unreachable)) | ||
|
||
When("a check is performed") | ||
val testProbe = TestProbe() | ||
testProbe.send(checkActor, ExpungeOverdueLostTasksActor.Tick) | ||
testProbe.receiveOne(3.seconds) | ||
|
||
And("one kill call is issued") | ||
verify(stateOpProcessor, once).process(any) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
times(1)
is the default, so this is redundant, but ok if you want to be very explicit =)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, did`t know that. Should I change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like it personally.
verify(mock).abc()
vsverify(mock, once).abc()
is much more obvious.