Search in sources :

Example 36 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricServiceImpl method setConfigurationValue.

@Override
public void setConfigurationValue(String versionId, String profileId, String pid, String key, String value) {
    assertValid();
    Version version = profileService.get().getRequiredVersion(versionId);
    Profile profile = version.getRequiredProfile(profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    Map<String, String> config = builder.getConfiguration(pid);
    config.put(key, value);
    builder.addConfiguration(pid, config);
    profileService.get().updateProfile(builder.getProfile());
}
Also used : Version(io.fabric8.api.Version) ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 37 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricServiceImpl method getZookeeperInfo.

// FIXME public access on the impl
public String getZookeeperInfo(String name) {
    assertValid();
    String zooKeeperUrl = null;
    // Also this is required for the integration with the IDE.
    try {
        if (curator.get().getZookeeperClient().isConnected()) {
            Version defaultVersion = getDefaultVersion();
            if (defaultVersion != null) {
                Profile profile = defaultVersion.getRequiredProfile("default");
                if (profile != null) {
                    Map<String, String> zookeeperConfig = profile.getConfiguration(Constants.ZOOKEEPER_CLIENT_PID);
                    if (zookeeperConfig != null) {
                        zooKeeperUrl = getSubstitutedData(curator.get(), zookeeperConfig.get(name));
                    }
                }
            }
        }
    } catch (Exception e) {
    // Ignore it.
    }
    if (zooKeeperUrl == null) {
        try {
            Configuration config = configAdmin.get().getConfiguration(Constants.ZOOKEEPER_CLIENT_PID, null);
            zooKeeperUrl = (String) config.getProperties().get(name);
        } catch (Exception e) {
        // Ignore it.
        }
    }
    return zooKeeperUrl;
}
Also used : BootstrapConfiguration(io.fabric8.zookeeper.bootstrap.BootstrapConfiguration) Configuration(org.osgi.service.cm.Configuration) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile) ProfileDependencyException(io.fabric8.api.ProfileDependencyException) EncryptionOperationNotPossibleException(org.jasypt.exceptions.EncryptionOperationNotPossibleException) FabricException(io.fabric8.api.FabricException) IOException(java.io.IOException)

Example 38 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class ContainerImplTest method testRemoveMissingProfile.

// We should be able to remove a profile that doesn't exist from a container.
// A missing profile may be added to a container during startup (not possible to validate) or after an upgrade / rollback operation.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testRemoveMissingProfile() throws Exception {
    String v = "1.0";
    String profile1Id = "feature-camel";
    String profile2Id = "feature-cxf";
    String missing = "missing";
    // new VersionImpl(v, fabricService);
    Version version = null;
    List<String> profiles = Arrays.asList(profile1Id, profile2Id, missing);
    List<String> profilesToSet = Arrays.asList(profile1Id, profile2Id);
    expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
    expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
    expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
    expect(profileRegistry.hasProfile(v, profile1Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, profile2Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, missing)).andReturn(false).anyTimes();
    // expect(profileRegistry.getProfileAttributes(eq(v), EasyMock.<String>anyObject())).andReturn(Maps.<String, String>newHashMap()).anyTimes();
    dataStore.setContainerProfiles(eq(CONTAINER_ID), eq(profilesToSet));
    expectLastCall().once();
    replay(fabricService);
    replay(dataStore);
    container.removeProfiles(missing);
    verify(fabricService);
    verify(dataStore);
}
Also used : Version(io.fabric8.api.Version) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 39 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class ContainerImplTest method testGetMultipleProfiles.

@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testGetMultipleProfiles() throws Exception {
    String v = "1.0";
    String profile1Id = "feature-camel";
    String profile2Id = "feature-cxf";
    // new VersionImpl(v, fabricService);
    Version version = null;
    List<String> profiles = Arrays.asList(profile1Id, profile2Id);
    expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
    expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
    expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
    expect(profileRegistry.hasProfile(v, profile1Id)).andReturn(true).anyTimes();
    expect(profileRegistry.hasProfile(v, profile2Id)).andReturn(true).anyTimes();
    replay(fabricService);
    replay(dataStore);
    Profile[] p = container.getProfiles();
    assertNotNull(p);
    assertEquals(2, p.length);
    assertEquals(profile1Id, p[0].getId());
    assertEquals(profile2Id, p[1].getId());
    verify(fabricService);
    verify(dataStore);
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 40 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class PatchServiceImplTest method testCheckRequirementsSatisfied.

@Test
public void testCheckRequirementsSatisfied() throws IOException {
    PatchServiceImpl.PatchDescriptor descriptor = getPatchDescriptor("test3.patch");
    Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq3", "patch-somethingelse").done();
    // this should not throw a RuntimeException
    PatchServiceImpl.checkRequirements(version, descriptor);
}
Also used : Version(io.fabric8.api.Version) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)154 Map (java.util.Map)110 IOException (java.io.IOException)87 Version (io.fabric8.api.Version)74 ArrayList (java.util.ArrayList)73 File (java.io.File)72 HashMap (java.util.HashMap)71 Profile (io.fabric8.api.Profile)70 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)65 List (java.util.List)65 Test (org.junit.Test)65 Vertx (io.vertx.core.Vertx)58 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)57 Pod (io.fabric8.kubernetes.api.model.Pod)56 Collections (java.util.Collections)56 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)56 Checkpoint (io.vertx.junit5.Checkpoint)54 VertxExtension (io.vertx.junit5.VertxExtension)54 VertxTestContext (io.vertx.junit5.VertxTestContext)54 BeforeAll (org.junit.jupiter.api.BeforeAll)53