Skip to content

Commit

Permalink
add one test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi committed Jun 19, 2021
1 parent d08243d commit bd2ab46
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void testOOMCount() {
new PodOOMHandler(
UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup());

String finishTime = "2020-03-19T13:14:48Z";
KubernetesPod kubernetesPod =
new KubernetesPod(
new PodBuilder()
Expand All @@ -60,7 +61,7 @@ public void testOOMCount() {
new ContainerStateBuilder()
.withNewTerminated()
.withFinishedAt(
"2020-10-19T13:14:48Z")
finishTime)
.withReason(
"OOMKilled")
.endTerminated()
Expand All @@ -71,14 +72,13 @@ public void testOOMCount() {
.build());
podOOMHandler.handle(kubernetesPod);
Assert.assertEquals(1, podOOMHandler.getTombstones().size());
Assert.assertTrue(
podOOMHandler
.getTombstones()
.getIfPresent("2020-10-19T13:14:48Z")
.contains("pod-1"));
Assert.assertTrue(podOOMHandler.getTombstones().getIfPresent(finishTime).contains("pod-1"));
// test ignore same events
podOOMHandler.handle(kubernetesPod);
Assert.assertEquals(
1, podOOMHandler.getTombstones().getIfPresent("2020-10-19T13:14:48Z").size());
Assert.assertEquals(1, podOOMHandler.getTombstones().getIfPresent(finishTime).size());

kubernetesPod.getInternalResource().getMetadata().setName("pod-2");
podOOMHandler.handle(kubernetesPod);
Assert.assertEquals(2, podOOMHandler.getTombstones().getIfPresent(finishTime).size());
}
}

0 comments on commit bd2ab46

Please sign in to comment.