Search in sources :

Example 56 with Logger

use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.

the class Fabric8ServiceHubTest method testObtainOpenshiftBuildService.

@Test
public void testObtainOpenshiftBuildService() {
    Fabric8ServiceHub hub = new Fabric8ServiceHub.Builder().clusterAccess(clusterAccess).log(logger).platformMode(PlatformMode.openshift).dockerServiceHub(dockerServiceHub).buildServiceConfig(buildServiceConfig).build();
    BuildService buildService = hub.getBuildService();
    assertNotNull(buildService);
    assertTrue(buildService instanceof OpenshiftBuildService);
}
Also used : OpenshiftBuildService(io.fabric8.maven.core.service.openshift.OpenshiftBuildService) DockerBuildService(io.fabric8.maven.core.service.kubernetes.DockerBuildService) OpenshiftBuildService(io.fabric8.maven.core.service.openshift.OpenshiftBuildService) Test(org.junit.Test)

Example 57 with Logger

use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.

the class ClusterAccessTest method createClientTestKubernetes.

@Test
public void createClientTestKubernetes() throws Exception {
    RootPaths rootpaths = new RootPaths();
    rootpaths.setPaths(paths);
    mockServer.expect().get().withPath("/").andReturn(200, rootpaths).always();
    ClusterAccess clusterAccess = new ClusterAccess(null, client);
    Client outputClient = clusterAccess.createDefaultClient(logger);
    assertTrue(outputClient instanceof KubernetesClient);
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) RootPaths(io.fabric8.kubernetes.api.model.RootPaths) Client(io.fabric8.kubernetes.client.Client) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Test(org.junit.Test)

Example 58 with Logger

use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.

the class ClusterAccessTest method kubernetesPlatformModeTest.

@Test
public void kubernetesPlatformModeTest() throws Exception {
    RootPaths rootpaths = new RootPaths();
    rootpaths.setPaths(paths);
    mockServer.expect().get().withPath("/").andReturn(200, rootpaths).always();
    ClusterAccess clusterAccess = new ClusterAccess(null, client);
    mode = clusterAccess.resolvePlatformMode(PlatformMode.kubernetes, logger);
    assertEquals(PlatformMode.kubernetes, mode);
    mode = clusterAccess.resolvePlatformMode(PlatformMode.DEFAULT, logger);
    assertEquals(PlatformMode.kubernetes, mode);
    mode = clusterAccess.resolvePlatformMode(null, logger);
    assertEquals(PlatformMode.kubernetes, mode);
}
Also used : RootPaths(io.fabric8.kubernetes.api.model.RootPaths) Test(org.junit.Test)

Example 59 with Logger

use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.

the class ClusterAccessTest method createClientTestOpenshift.

@Test
public void createClientTestOpenshift() throws Exception {
    paths.add("/oapi");
    paths.add("/oapi/v1");
    RootPaths rootpaths = new RootPaths();
    rootpaths.setPaths(paths);
    mockServer.expect().get().withPath("/").andReturn(200, rootpaths).always();
    ClusterAccess clusterAccess = new ClusterAccess(null, client);
    Client outputClient = clusterAccess.createDefaultClient(logger);
    assertTrue(outputClient instanceof OpenShiftClient);
}
Also used : RootPaths(io.fabric8.kubernetes.api.model.RootPaths) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Client(io.fabric8.kubernetes.client.Client) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Test(org.junit.Test)

Example 60 with Logger

use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.

the class OpenshiftBuildServiceTest method checkTarPackage.

@Test
public void checkTarPackage() throws Exception {
    int nTries = 0;
    boolean bTestComplete = false;
    do {
        try {
            nTries++;
            BuildService.BuildServiceConfig config = defaultConfig.build();
            WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, true, true);
            OpenShiftMockServer mockServer = collector.getMockServer();
            OpenShiftClient client = mockServer.createOpenShiftClient();
            final OpenshiftBuildService service = new OpenshiftBuildService(client, logger, dockerServiceHub, config);
            ImageConfiguration imageWithEnv = new ImageConfiguration.Builder(image).buildConfig(new BuildImageConfiguration.Builder(image.getBuildConfiguration()).env(Collections.singletonMap("FOO", "BAR")).build()).build();
            service.createBuildArchive(imageWithEnv);
            final List<ArchiverCustomizer> customizer = new LinkedList<>();
            new Verifications() {

                {
                    archiveService.createDockerBuildArchive(withInstanceOf(ImageConfiguration.class), withInstanceOf(MojoParameters.class), withCapture(customizer));
                    assertTrue(customizer.size() == 1);
                }
            };
            customizer.get(0).customize(tarArchiver);
            final List<File> file = new LinkedList<>();
            new Verifications() {

                {
                    String path;
                    tarArchiver.addFile(withCapture(file), path = withCapture());
                    assertEquals(".s2i/environment", path);
                }
            };
            assertEquals(1, file.size());
            List<String> lines;
            try (FileReader reader = new FileReader(file.get(0))) {
                lines = IOUtils.readLines(reader);
            }
            assertTrue(lines.contains("FOO=BAR"));
            bTestComplete = true;
        } catch (Fabric8ServiceException exception) {
            Throwable rootCause = getRootCause(exception);
            logger.warn("A problem encountered while running test {}, retrying..", exception.getMessage());
            // Let's wait for a while, and then retry again
            if (rootCause != null && rootCause instanceof IOException) {
                continue;
            }
        }
    } while (nTries < MAX_TIMEOUT_RETRIES && !bTestComplete);
}
Also used : BuildService(io.fabric8.maven.core.service.BuildService) ArchiverCustomizer(io.fabric8.maven.docker.assembly.ArchiverCustomizer) ImageStreamStatusBuilder(io.fabric8.openshift.api.model.ImageStreamStatusBuilder) BuildBuilder(io.fabric8.openshift.api.model.BuildBuilder) NamedTagEventListBuilder(io.fabric8.openshift.api.model.NamedTagEventListBuilder) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) BuildConfigBuilder(io.fabric8.openshift.api.model.BuildConfigBuilder) IOException(java.io.IOException) Verifications(mockit.Verifications) LinkedList(java.util.LinkedList) OpenShiftMockServer(io.fabric8.openshift.client.server.mock.OpenShiftMockServer) Fabric8ServiceException(io.fabric8.maven.core.service.Fabric8ServiceException) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) MojoParameters(io.fabric8.maven.docker.util.MojoParameters) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) FileReader(java.io.FileReader) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)47 File (java.io.File)26 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)20 Verifications (mockit.Verifications)17 ArrayList (java.util.ArrayList)15 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)12 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 IOException (java.io.IOException)9 Expectations (mockit.Expectations)9 URL (java.net.URL)8 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)7 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)6 ResourceValidator (io.fabric8.maven.core.util.validator.ResourceValidator)6 AssemblyConfiguration (io.fabric8.maven.docker.config.AssemblyConfiguration)6 Logger (io.fabric8.maven.docker.util.Logger)6 MojoParameters (io.fabric8.maven.docker.util.MojoParameters)6 Properties (java.util.Properties)6 Util.readAsString (io.fabric8.arquillian.utils.Util.readAsString)5 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)5 Pod (io.fabric8.kubernetes.api.model.Pod)5