use of io.fabric8.maven.core.config.Profile 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);
}
use of io.fabric8.maven.core.config.Profile 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);
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testGetPatchProfile.
@Test
public void testGetPatchProfile() throws IOException {
PatchServiceImpl.PatchDescriptor test1 = getPatchDescriptor("test1.patch");
PatchServiceImpl.PatchDescriptor test3 = getPatchDescriptor("test3.patch");
Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-test3").done();
Profile profile = PatchServiceImpl.getPatchProfile(version, test3);
assertNotNull("test3 patch profile should be found", profile);
assertEquals("patch-test3", profile.getId());
assertNull("test1 patch profile should not be found", PatchServiceImpl.getPatchProfile(version, test1));
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class VersionImpl method getRequiredProfile.
@Override
public Profile getRequiredProfile(String profileId) {
Profile profile = profiles.get(profileId);
IllegalStateAssertion.assertNotNull(profile, "Profile '" + profileId + "' does not exist in version: " + versionId);
return profile;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class AutoScalers method requirementsSatisfied.
/**
* Returns true if the requirements are satisfied for the given profile requirements; updating the auto scale status
* accordingly
*/
public static boolean requirementsSatisfied(FabricService service, String version, FabricRequirements requirements, ProfileRequirements profileRequirement, AutoScaleStatus status) {
String profile = profileRequirement.getProfile();
List<String> dependentProfiles = profileRequirement.getDependentProfiles();
if (dependentProfiles != null) {
for (String dependentProfile : dependentProfiles) {
ProfileRequirements dependentProfileRequirements = requirements.getOrCreateProfileRequirement(dependentProfile);
Integer minimumInstances = dependentProfileRequirements.getMinimumInstances();
if (minimumInstances != null) {
List<Container> containers = Containers.aliveAndSuccessfulContainersForProfile(version, dependentProfile, service);
int dependentSize = containers.size();
if (minimumInstances > dependentSize) {
status.profileStatus(profile).missingDependency(dependentProfile, dependentSize, minimumInstances);
return false;
}
}
}
}
return true;
}
Aggregations