Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyz26 committed Oct 7, 2024
1 parent aa2a666 commit a527db3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
Expand Down Expand Up @@ -114,7 +115,14 @@
import io.mantisrx.server.core.Status;
import io.mantisrx.server.core.Status.TYPE;
import io.mantisrx.server.core.domain.WorkerId;
import io.mantisrx.server.master.domain.*;
import io.mantisrx.server.master.domain.DataFormatAdapter;
import io.mantisrx.server.master.domain.IJobClusterDefinition;
import io.mantisrx.server.master.domain.JobClusterConfig;
import io.mantisrx.server.master.domain.JobClusterDefinitionImpl;
import io.mantisrx.server.master.domain.JobClusterDefinitionImpl.CompletedJob;
import io.mantisrx.server.master.domain.JobDefinition;
import io.mantisrx.server.master.domain.JobId;
import io.mantisrx.server.master.domain.SLA;
import io.mantisrx.server.master.persistence.IMantisPersistenceProvider;
import io.mantisrx.server.master.persistence.KeyValueBasedPersistenceProvider;
import io.mantisrx.server.master.persistence.MantisJobStore;
Expand All @@ -123,6 +131,7 @@
import io.mantisrx.server.master.scheduler.WorkerEvent;
import io.mantisrx.server.master.store.FileBasedStore;
import io.mantisrx.server.master.store.NamedJob;
import io.mantisrx.shaded.com.google.common.collect.ImmutableList;
import io.mantisrx.shaded.com.google.common.collect.Lists;
import java.io.File;
import java.time.Duration;
Expand Down Expand Up @@ -643,6 +652,18 @@ public void testJobClusterDisable() throws InterruptedException {
.withJobDefinition(jobDefn)
.withJobState(JobState.Completed)
.build();
when(jobStoreMock.loadCompletedJobsForCluster(any(), anyInt(), any()))
// .thenReturn(ImmutableList.of());
.thenReturn(ImmutableList.of(
new CompletedJob(
completedJobMock.getClusterName(),
completedJobMock.getJobId().getId(),
"v1",
JobState.Completed,
-1L,
-1L,
completedJobMock.getUser(),
completedJobMock.getLabels())));
when(jobStoreMock.getArchivedJob(any())).thenReturn(of(completedJobMock));
doAnswer((Answer) invocation -> {
storeCompletedCalled.countDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -89,6 +90,7 @@
import io.mantisrx.server.master.domain.IJobClusterDefinition;
import io.mantisrx.server.master.domain.JobClusterConfig;
import io.mantisrx.server.master.domain.JobClusterDefinitionImpl;
import io.mantisrx.server.master.domain.JobClusterDefinitionImpl.CompletedJob;
import io.mantisrx.server.master.domain.JobDefinition;
import io.mantisrx.server.master.domain.JobId;
import io.mantisrx.server.master.domain.SLA;
Expand All @@ -99,6 +101,7 @@
import io.mantisrx.server.master.scheduler.WorkerEvent;
import io.mantisrx.server.master.scheduler.WorkerLaunched;
import io.mantisrx.server.master.store.FileBasedStore;
import io.mantisrx.shaded.com.google.common.collect.ImmutableList;
import io.mantisrx.shaded.com.google.common.collect.Lists;
import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -1596,7 +1599,7 @@ public void testTerminalEventFromZombieWorkerIgnored() {
}

@Test
public void testNonTerminalEventFromZombieWorkerLeadsToTermination() {
public void testNonTerminalEventFromZombieWorkerLeadsToTermination() throws IOException {
TestKit probe = new TestKit(system);
String clusterName = "testNonTerminalEventFromZombieWorkerLeadsToTermination";

Expand All @@ -1612,6 +1615,18 @@ public void testNonTerminalEventFromZombieWorkerLeadsToTermination() {
assertEquals(SUCCESS_CREATED, resp.responseCode);

WorkerId zWorker1 = new WorkerId("randomCluster", "randomCluster-1", 0, 1);
when(jobStoreMock.loadCompletedJobsForCluster(any(), anyInt(), any()))
// .thenReturn(ImmutableList.of());
.thenReturn(ImmutableList.of(
new CompletedJob(
clusterName,
clusterName + "-1",
"v1",
JobState.Completed,
-1L,
-1L,
"ut",
ImmutableList.of())));
when(jobStoreMock.getArchivedJob(zWorker1.getJobId()))
.thenReturn(Optional.of(
new MantisJobMetadataImpl.Builder().withJobDefinition(mock(JobDefinition.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Observable<ObservableConnection<HttpClientResponse<O>, HttpClientRequest<
}

protected void trackConnection(Channel channel) {
log.info("Tracking connection: {}", channel.toString());
log.debug("Tracking connection: {}", channel.toString());
synchronized (connectionTracker) {
if (isClosed.get()) {
log.info("Http client is already closed. Close the channel immediately. {}", channel);
Expand Down

0 comments on commit a527db3

Please sign in to comment.