Search in sources :

Example 1 with EmbeddedTitusCell

use of com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell in project titus-control-plane by Netflix.

the class EmbeddedTitusCellTest method testShutdownCleanup.

@Test
@Ignore
public void testShutdownCleanup() {
    Set<Thread> threadsBefore = Thread.getAllStackTraces().keySet();
    EmbeddedTitusCell titusStack = EmbeddedTitusCells.basicKubeCell(1);
    titusStack.boot();
    titusStack.shutdown();
    Set<Thread> threadsAfter = Thread.getAllStackTraces().keySet();
    // Filter-out non Titus threads
    Set<Thread> titusRemainingThreads = threadsAfter.stream().filter(t -> {
        ThreadGroup threadGroup = t.getThreadGroup();
        if (threadGroup == null) {
            // if thread died
            return false;
        }
        return !matches(OK_THREAD_GROUPS, threadGroup.getName());
    }).filter(t -> !matches(OK_THREADS, t.getName())).collect(Collectors.toSet());
    CollectionsExt.copyAndRemove(titusRemainingThreads, threadsBefore).forEach(t -> {
        logger.info("Unexpected thread {}:\n{}", t.getName(), String.join("\n", Arrays.stream(t.getStackTrace()).map(e -> "  " + e).collect(Collectors.toList())));
    });
    assertThat(titusRemainingThreads).isSubsetOf(threadsBefore);
}
Also used : Arrays(java.util.Arrays) EmbeddedTitusCells(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells) Logger(org.slf4j.Logger) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) Ignore(org.junit.Ignore) EmbeddedTitusCell(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell) Pattern(java.util.regex.Pattern) EmbeddedTitusCell(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell) Ignore(org.junit.Ignore) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 2 with EmbeddedTitusCell

use of com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell in project titus-control-plane by Netflix.

the class EmbeddedTitusStackRunner method main.

public static void main(String[] args) throws InterruptedException {
    CommandLineFacade cliFacade = buildCliFacade(args);
    EmbeddedTitusMaster titusMaster = EmbeddedTitusMaster.aTitusMaster().withEmbeddedKubeCluster(EmbeddedKubeClusters.basicCluster(2)).withApiPort(8080).withGrpcPort(7104).withEnableDisruptionBudget(true).build();
    boolean federationEnabled = cliFacade.isEnabled("f");
    EmbeddedTitusCell cell = EmbeddedTitusCell.aTitusCell().withMaster(titusMaster).withGateway(EmbeddedTitusGateway.aDefaultTitusGateway().withMasterEndpoint("localhost", 8090, 8080).withHttpPort(8081).withGrpcPort(8091).withProperty("titus.relocation.grpcClient.grpcPort", "7105").withProperty("titus.feature.mergingTaskMigrationPlanInGatewayEnabled", "true").build(), !federationEnabled).build();
    cell.boot();
    if (federationEnabled) {
        EmbeddedTitusFederation stack = EmbeddedTitusFederation.aDefaultTitusFederation().withCell(".*", cell).withHttpPort(8082).withGrpcPort(8092).build();
        stack.boot();
    }
    System.out.println("TitusStack started");
    Thread.sleep(24 * 60 * 60 * 1000L);
}
Also used : EmbeddedTitusFederation(com.netflix.titus.testkit.embedded.federation.EmbeddedTitusFederation) EmbeddedTitusMaster(com.netflix.titus.testkit.embedded.cell.master.EmbeddedTitusMaster) CommandLineFacade(com.netflix.titus.testkit.util.cli.CommandLineFacade) EmbeddedTitusCell(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell)

Aggregations

EmbeddedTitusCell (com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCell)2 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)1 EmbeddedTitusCells (com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells)1 EmbeddedTitusMaster (com.netflix.titus.testkit.embedded.cell.master.EmbeddedTitusMaster)1 EmbeddedTitusFederation (com.netflix.titus.testkit.embedded.federation.EmbeddedTitusFederation)1 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)1 CommandLineFacade (com.netflix.titus.testkit.util.cli.CommandLineFacade)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1