Search in sources :

Example 76 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.

the class DefaultControllerEnricherTest method enrichAndAssert.

protected void enrichAndAssert(int sizeOfObjects, int replicaCount) throws com.fasterxml.jackson.core.JsonProcessingException {
    // Setup a sample docker build configuration
    final BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().ports(Arrays.asList("8080")).build();
    final TreeMap controllerConfig = new TreeMap();
    controllerConfig.put("replicaCount", String.valueOf(replicaCount));
    setupExpectations(buildConfig, controllerConfig);
    // Enrich
    DefaultControllerEnricher controllerEnricher = new DefaultControllerEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder();
    controllerEnricher.addMissingResources(builder);
    // Validate that the generated resource contains
    KubernetesList list = builder.build();
    assertEquals(sizeOfObjects, list.getItems().size());
    String json = KubernetesResourceUtil.toJson(list.getItems().get(0));
    assertThat(json, JsonPathMatchers.isJson());
    assertThat(json, JsonPathMatchers.hasJsonPath("$.spec.replicas", Matchers.equalTo(replicaCount)));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) TreeMap(java.util.TreeMap) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Example 77 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.

the class DependencyEnricherTest method createResourcesForTest.

private KubernetesListBuilder createResourcesForTest() throws IOException, URISyntaxException {
    setupExpectations();
    List<File> resourceList = new ArrayList<>();
    resourceList.add(new File(Paths.get(getClass().getResource(overrideFragementFile).toURI()).toAbsolutePath().toString()));
    /*
         * Our override file also contains a ConfigMap item with name jenkins, load it while
         * loading Kubernetes resources.
         */
    KubernetesListBuilder builder = KubernetesResourceUtil.readResourceFragmentsFrom(KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING, project.getName(), resourceList.toArray(new File[resourceList.size()]));
    return builder;
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) File(java.io.File)

Example 78 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.

the class MavenProjectEnricherTest method testOldStyleGeneratedResources.

@Test
public void testOldStyleGeneratedResources() {
    final Properties properties = new Properties();
    properties.setProperty("fabric8.enricher.fmp-project.useProjectLabel", "true");
    new Expectations() {

        {
            mavenProject.getProperties();
            result = properties;
        }
    };
    ProjectEnricher projectEnricher = new ProjectEnricher(context);
    KubernetesListBuilder builder = createListWithDeploymentConfig();
    projectEnricher.adapt(builder);
    KubernetesList list = builder.build();
    Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
    assertNotNull(labels);
    assertEquals("groupId", labels.get("group"));
    assertEquals("artifactId", labels.get("project"));
    assertEquals("version", labels.get("version"));
    assertNull(labels.get("app"));
    Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
    assertEquals("groupId", selectors.get("group"));
    assertEquals("artifactId", selectors.get("project"));
    assertNull(selectors.get("version"));
    assertNull(selectors.get("app"));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Properties(java.util.Properties) Test(org.junit.Test)

Example 79 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.

the class MavenProjectEnricherTest method testGeneratedResources.

@Test
public void testGeneratedResources() {
    ProjectEnricher projectEnricher = new ProjectEnricher(context);
    KubernetesListBuilder builder = createListWithDeploymentConfig();
    projectEnricher.adapt(builder);
    KubernetesList list = builder.build();
    Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
    assertNotNull(labels);
    assertEquals("groupId", labels.get("group"));
    assertEquals("artifactId", labels.get("app"));
    assertEquals("version", labels.get("version"));
    assertNull(labels.get("project"));
    Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
    assertEquals("groupId", selectors.get("group"));
    assertEquals("artifactId", selectors.get("app"));
    assertNull(selectors.get("version"));
    assertNull(selectors.get("project"));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Example 80 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.

the class RevisionHistoryEnricherTest method testDefaultRevisionHistoryLimit.

@Test
public void testDefaultRevisionHistoryLimit() throws JsonProcessingException {
    // Given
    KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
    RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
    // When
    enricher.addMissingResources(builder);
    // Then
    assertRevisionHistory(builder.build(), Configs.asInt(RevisionHistoryEnricher.Config.limit.def()));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Profile (io.fabric8.api.Profile)33 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)27 FabricService (io.fabric8.api.FabricService)24 InputStream (java.io.InputStream)21 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 Logger (org.slf4j.Logger)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)17 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 IOException (java.io.IOException)16 Action (org.apache.felix.gogo.commands.Action)16 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)16