Search in sources :

Example 36 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method start.

@Override
public final synchronized void start() throws LifecycleException {
    assertNotDestroyed();
    try {
        if (state == State.CREATED || state == State.STOPPED) {
            doStart(configuration);
            state = State.STARTED;
        }
    } catch (Exception ex) {
        throw new LifecycleException("Cannot start container", ex);
    }
}
Also used : LifecycleException(io.fabric8.runtime.container.LifecycleException) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Example 37 with Start

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

the class OpenshiftBuildService method build.

@Override
public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException {
    try {
        ImageName imageName = new ImageName(imageConfig.getName());
        File dockerTar = createBuildArchive(imageConfig);
        KubernetesListBuilder builder = new KubernetesListBuilder();
        // Check for buildconfig / imagestream and create them if necessary
        String buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig);
        checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName));
        applyResourceObjects(config, client, builder);
        // Start the actual build
        Build build = startBuild(client, dockerTar, buildName);
        // Wait until the build finishes
        waitForOpenShiftBuildToComplete(client, build);
        // Create a file with generated image streams
        addImageStreamToFile(getImageStreamFile(config), imageName, client);
    } catch (Fabric8ServiceException e) {
        throw e;
    } catch (Exception ex) {
        throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex);
    }
}
Also used : ImageName(io.fabric8.maven.docker.util.ImageName) Fabric8ServiceException(io.fabric8.maven.core.service.Fabric8ServiceException) Build(io.fabric8.openshift.api.model.Build) File(java.io.File) Fabric8ServiceException(io.fabric8.maven.core.service.Fabric8ServiceException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 38 with Start

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

the class SuiteListener method start.

public void start(@Observes(precedence = 100) BeforeSuite event, Configuration configuration, Logger logger) {
    session = new Session(configuration.getSessionId(), configuration.getNamespace(), logger);
    session.init();
    sessionProducer.set(session);
    controlEvent.fire(new Start(session));
}
Also used : Start(io.fabric8.arquillian.kubernetes.event.Start)

Example 39 with Start

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

the class TopicSerializationTest method testErrorInConfigInvalidKeyNull.

@Test
public void testErrorInConfigInvalidKeyNull() {
    Map<String, String> data = new HashMap<>();
    data.put(TopicSerialization.CM_KEY_REPLICAS, "1");
    data.put(TopicSerialization.CM_KEY_PARTITIONS, "1");
    data.put(TopicSerialization.CM_KEY_CONFIG, "{null:null}");
    ConfigMap cm = new ConfigMapBuilder().editOrNewMetadata().withName("my-topic").endMetadata().withData(data).build();
    try {
        TopicSerialization.fromConfigMap(cm);
        fail("Should throw");
    } catch (InvalidConfigMapException e) {
        assertEquals("ConfigMap's 'data' section has invalid key 'config': " + "Unexpected character ('n' (code 110)): was expecting double-quote to start field name\n" + " at [Source: 'config' key of 'data' section of ConfigMap 'my-topic' in namespace 'null'; line: 1, column: 3]", e.getMessage());
    }
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) HashMap(java.util.HashMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) Test(org.junit.Test)

Example 40 with Start

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

the class ClusterControllerTest method startStop.

/**
 * Does the CC start and then stop a verticle per namespace?
 * @param context
 * @param namespaces
 */
private void startStop(TestContext context, String namespaces) {
    AtomicInteger numWatchers = new AtomicInteger(0);
    KubernetesClient client = mock(KubernetesClient.class);
    MixedOperation mockCms = mock(MixedOperation.class);
    when(client.configMaps()).thenReturn(mockCms);
    List<String> namespaceList = asList(namespaces.split(" *,+ *"));
    for (String namespace : namespaceList) {
        MixedOperation mockNamespacedCms = mock(MixedOperation.class);
        when(mockNamespacedCms.watch(any())).thenAnswer(invo -> {
            numWatchers.incrementAndGet();
            Watch mockWatch = mock(Watch.class);
            doAnswer(invo2 -> {
                ((Watcher) invo.getArgument(0)).onClose(null);
                return null;
            }).when(mockWatch).close();
            return mockWatch;
        });
        when(mockNamespacedCms.withLabels(any())).thenReturn(mockNamespacedCms);
        when(mockCms.inNamespace(namespace)).thenReturn(mockNamespacedCms);
    }
    Async async = context.async();
    Map<String, String> env = new HashMap<>();
    env.put(ClusterControllerConfig.STRIMZI_NAMESPACE, namespaces);
    env.put(ClusterControllerConfig.STRIMZI_CONFIGMAP_LABELS, STRIMZI_IO_KIND_CLUSTER);
    env.put(ClusterControllerConfig.STRIMZI_FULL_RECONCILIATION_INTERVAL_MS, "120000");
    Main.run(vertx, client, true, env).setHandler(ar -> {
        context.assertNull(ar.cause(), "Expected all verticles to start OK");
        async.complete();
    });
    async.await();
    context.assertEquals(namespaceList.size(), vertx.deploymentIDs().size(), "A verticle per namespace");
    List<Async> asyncs = new ArrayList<>();
    for (String deploymentId : vertx.deploymentIDs()) {
        Async async2 = context.async();
        asyncs.add(async2);
        vertx.undeploy(deploymentId, ar -> {
            context.assertNull(ar.cause(), "Didn't expect error when undeploying verticle " + deploymentId);
            async2.complete();
        });
    }
    for (Async async2 : asyncs) {
        async2.await();
    }
    if (numWatchers.get() > namespaceList.size()) {
        context.fail("Looks like there were more watchers than namespaces");
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) Async(io.vertx.ext.unit.Async) Watch(io.fabric8.kubernetes.client.Watch) ArrayList(java.util.ArrayList) Watcher(io.fabric8.kubernetes.client.Watcher) MixedOperation(io.fabric8.kubernetes.client.dsl.MixedOperation)

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