Search in sources :

Example 41 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project strimzi by strimzi.

the class ControllerIT method setup.

@Before
public void setup(TestContext context) throws Exception {
    LOGGER.info("Setting up test");
    Runtime.getRuntime().addShutdownHook(kafkaHook);
    kafkaCluster = new KafkaCluster();
    kafkaCluster.addBrokers(1);
    kafkaCluster.deleteDataPriorToStartup(true);
    kafkaCluster.deleteDataUponShutdown(true);
    kafkaCluster.usingDirectory(Files.createTempDirectory("controller-integration-test").toFile());
    kafkaCluster.startup();
    kubeClient = new DefaultKubernetesClient().inNamespace(NAMESPACE);
    LOGGER.info("Using namespace {}", NAMESPACE);
    Map<String, String> m = new HashMap();
    m.put(Config.KAFKA_BOOTSTRAP_SERVERS.key, kafkaCluster.brokerList());
    m.put(Config.ZOOKEEPER_CONNECT.key, "localhost:" + zkPort(kafkaCluster));
    m.put(Config.NAMESPACE.key, NAMESPACE);
    session = new Session(kubeClient, new Config(m));
    Async async = context.async();
    vertx.deployVerticle(session, ar -> {
        if (ar.succeeded()) {
            deploymentId = ar.result();
            adminClient = session.adminClient;
            topicsConfigWatcher = session.topicConfigsWatcher;
            topicWatcher = session.topicWatcher;
            topicsWatcher = session.topicsWatcher;
            async.complete();
        } else {
            context.fail("Failed to deploy session");
        }
    });
    async.await();
    waitFor(context, () -> this.topicsWatcher.started(), timeout, "Topics watcher not started");
    waitFor(context, () -> this.topicsConfigWatcher.started(), timeout, "Topic configs watcher not started");
    waitFor(context, () -> this.topicWatcher.started(), timeout, "Topic watcher not started");
    // We can't delete events, so record the events which exist at the start of the test
    // and then waitForEvents() can ignore those
    preExistingEvents = kubeClient.events().inNamespace(NAMESPACE).withLabels(cmPredicate.labels()).list().getItems().stream().map(evt -> evt.getMetadata().getUid()).collect(Collectors.toSet());
    LOGGER.info("Finished setting up test");
}
Also used : KafkaCluster(io.debezium.kafka.KafkaCluster) HashMap(java.util.HashMap) Async(io.vertx.ext.unit.Async) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Before(org.junit.Before)

Example 42 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project vertx-openshift-it by cescoffier.

the class HealthCheckIT method testReadinessIsPresent.

@Test
public void testReadinessIsPresent() throws Exception {
    final List<Container> containers = getContainers();
    ensureThat("the readiness probe is configured correctly", () -> {
        containers.forEach(c -> {
            Probe readinessProbe = c.getReadinessProbe();
            assertThat(readinessProbe).as("Readiness probe should not be null.").isNotNull();
            softly.assertThat(readinessProbe.getHttpGet().getPort().getIntVal()).as("port should be defined for readiness probe").isEqualTo(8088);
            softly.assertThat(readinessProbe.getHttpGet().getPath()).as("path should be defined for readiness probe").isEqualTo("/start");
        });
    });
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 43 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project flink by apache.

the class Fabric8FlinkKubeClient method createTaskManagerPod.

@Override
public CompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod) {
    return CompletableFuture.runAsync(() -> {
        final Deployment masterDeployment = this.internalClient.apps().deployments().withName(KubernetesUtils.getDeploymentName(clusterId)).get();
        if (masterDeployment == null) {
            throw new RuntimeException("Failed to find Deployment named " + clusterId + " in namespace " + this.namespace);
        }
        // Note that we should use the uid of the master Deployment for the
        // OwnerReference.
        setOwnerReference(masterDeployment, Collections.singletonList(kubernetesPod.getInternalResource()));
        LOG.debug("Start to create pod with spec {}{}", System.lineSeparator(), KubernetesUtils.tryToGetPrettyPrintYaml(kubernetesPod.getInternalResource()));
        this.internalClient.pods().create(kubernetesPod.getInternalResource());
    }, kubeClientExecutorService);
}
Also used : FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Example 44 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project zeppelin by apache.

the class K8sRemoteInterpreterProcess method start.

@Override
public void start(String userName) throws IOException {
    Properties templateProperties = getTemplateBindings(userName);
    // create new pod
    apply(specTemplates, false, templateProperties);
    // special handling if we doesn't want timeout the process during lifecycle phase pending
    if (!timeoutDuringPending) {
        // WATCH
        PodPhaseWatcher podWatcher = new PodPhaseWatcher(phase -> StringUtils.equalsAnyIgnoreCase(phase, "Succeeded", "Failed", "Running"));
        try (Watch watch = client.pods().inNamespace(interpreterNamespace).withName(podName).watch(podWatcher)) {
            podWatcher.getCountDownLatch().await();
        } catch (InterruptedException e) {
            LOGGER.error("Interrupt received during waiting for Running phase. Try to stop the interpreter and interrupt the current thread.", e);
            processStopped("Start process was interrupted during waiting for Running phase");
            stop();
            Thread.currentThread().interrupt();
        }
    }
    long startTime = System.currentTimeMillis();
    long timeoutTime = startTime + getConnectTimeout();
    // wait until interpreter send started message through thrift rpc
    synchronized (started) {
        while (!started.get() && !Thread.currentThread().isInterrupted()) {
            long timeToTimeout = timeoutTime - System.currentTimeMillis();
            if (timeToTimeout <= 0) {
                processStopped("The start process was aborted while waiting for the interpreter to start. PodPhase before stop: " + getPodPhase());
                stop();
                throw new IOException("Launching zeppelin interpreter on kubernetes is time out, kill it now");
            }
            try {
                started.wait(timeToTimeout);
            } catch (InterruptedException e) {
                LOGGER.error("Interrupt received during started wait. Try to stop the interpreter and interrupt the current thread.", e);
                processStopped("The start process was interrupted while waiting for the interpreter to start. PodPhase before stop: " + getPodPhase());
                stop();
                Thread.currentThread().interrupt();
            }
        }
    }
}
Also used : Watch(io.fabric8.kubernetes.client.Watch) IOException(java.io.IOException) Properties(java.util.Properties)

Example 45 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project docker-maven-plugin by fabric8io.

the class LogMatchCallbackTest method matchingSingleLineSucceeds.

@Test(expected = LogCallback.DoneException.class)
public void matchingSingleLineSucceeds() throws Exception {
    final String patternString = "The start has finished right now";
    final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patternString);
    new Expectations() {

        {
            callback.matched();
            times = 1;
        }
    };
    logMatchCallback.log(1, new Timestamp(), patternString);
}
Also used : Expectations(mockit.Expectations) Timestamp(io.fabric8.maven.docker.util.Timestamp) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 IOException (java.io.IOException)24 File (java.io.File)18 HashMap (java.util.HashMap)15 Map (java.util.Map)10 Git (org.eclipse.jgit.api.Git)10 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)8 ArrayList (java.util.ArrayList)8 Bundle (org.osgi.framework.Bundle)8 PatchException (io.fabric8.patch.management.PatchException)7 URISyntaxException (java.net.URISyntaxException)7 BundleException (org.osgi.framework.BundleException)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 CuratorFramework (org.apache.curator.framework.CuratorFramework)6 Container (io.fabric8.api.Container)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)5 FabricService (io.fabric8.api.FabricService)5 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)5 MalformedURLException (java.net.MalformedURLException)5 URI (java.net.URI)5