use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ContainerImplTest method testGetSingleProfile.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testGetSingleProfile() throws Exception {
String v = "1.0";
String profileId = "feature-camel";
// new VersionImpl(v, fabricService);
Version version = null;
List<String> profiles = Arrays.asList(profileId);
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, profileId)).andReturn(true).anyTimes();
replay(fabricService);
replay(dataStore);
Profile[] p = container.getProfiles();
assertNotNull(p);
assertEquals(1, p.length);
assertEquals(profileId, p[0].getId());
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ContainerImplTest method testGetContainerProfileOverlay.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testGetContainerProfileOverlay() throws Exception {
String v = "1.0";
String defaultProfile = "default";
String camelProfile = "feature-camel";
String cxfProfile = "feature-cxf";
// new VersionImpl(v, fabricService);
Version version = null;
List<String> profiles = Arrays.asList(camelProfile, cxfProfile);
Map<String, String> defaultAttributes = new HashMap<String, String>();
Map<String, String> camelAttributes = new HashMap<String, String>();
Map<String, String> cxfAttributes = new HashMap<String, String>();
Map<String, byte[]> defaultFiles = new HashMap<String, byte[]>();
Map<String, byte[]> camelFiles = new HashMap<String, byte[]>();
Map<String, byte[]> cxfFiles = new HashMap<String, byte[]>();
Map<String, Map<String, String>> defaultPids = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> camelPids = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> cxfPids = new HashMap<String, Map<String, String>>();
camelAttributes.put("attribute." + Profile.PARENTS, "default");
cxfAttributes.put("attribute." + Profile.PARENTS, "feature-camel");
defaultFiles.put("test1.properties", "key=fromDefault".getBytes());
camelFiles.put("test1.properties", "key=fromCamel".getBytes());
cxfFiles.put("test2.properties", "key=fromCxf".getBytes());
expect(fabricService.getEnvironment()).andReturn("").anyTimes();
expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
// Define Attributes
// expect(profileRegistry.getProfileAttributes(eq(v), eq(defaultProfile))).andReturn(defaultAttributes).anyTimes();
// expect(profileRegistry.getProfileAttributes(eq(v), eq(camelProfile))).andReturn(camelAttributes).anyTimes();
// expect(profileRegistry.getProfileAttributes(eq(v), eq(cxfProfile))).andReturn(cxfAttributes).anyTimes();
// Define Files
// expect(profileRegistry.getFileConfigurations(eq(v), eq(defaultProfile))).andReturn(defaultFiles).anyTimes();
// expect(profileRegistry.getFileConfigurations(eq(v), eq(camelProfile))).andReturn(camelFiles).anyTimes();
// expect(profileRegistry.getFileConfigurations(eq(v), eq(cxfProfile))).andReturn(cxfFiles).anyTimes();
// Define PIDS
// expect(profileRegistry.getConfigurations(eq(v), eq(defaultProfile))).andReturn(defaultPids).anyTimes();
// expect(profileRegistry.getConfigurations(eq(v), eq(camelProfile))).andReturn(camelPids).anyTimes();
// expect(profileRegistry.getConfigurations(eq(v), eq(cxfProfile))).andReturn(cxfPids).anyTimes();
fabricService.substituteConfigurations((Map<String, Map<String, String>>) anyObject());
expectLastCall().anyTimes();
expect(dataStore.getContainerVersion(eq(CONTAINER_ID))).andReturn(v).anyTimes();
expect(dataStore.getContainerProfiles(eq(CONTAINER_ID))).andReturn(profiles).anyTimes();
expect(profileRegistry.hasProfile(v, camelProfile)).andReturn(true).anyTimes();
expect(profileRegistry.hasProfile(v, cxfProfile)).andReturn(true).anyTimes();
replay(fabricService);
replay(dataStore);
Map<String, Map<String, String>> configs = container.getOverlayProfile().getConfigurations();
assertNotNull(configs);
assertEquals(2, configs.size());
assertNotNull(configs.get("test1"));
assertEquals(1, configs.get("test1").size());
assertEquals("fromCamel", configs.get("test1").get("key"));
assertNotNull(configs.get("test2"));
assertEquals(1, configs.get("test2").size());
assertEquals("fromCxf", configs.get("test2").get("key"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ContainerImplTest method testContainerProfileWithMissingParents.
@Test
@Ignore("[FABRIC-1110] Mocked test makes invalid assumption on the implementation")
public void testContainerProfileWithMissingParents() 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);
expect(profileService.getRequiredVersion(eq(v))).andReturn(version).anyTimes();
expect(fabricService.getEnvironment()).andReturn("").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();
replay(fabricService);
replay(dataStore);
Profile overlay = container.getOverlayProfile();
List<String> parents = overlay.getParentIds();
assertEquals(2, parents.size());
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ExtendedJoinTest method testContainerHostnameSupport.
/**
* Verify that containers can use dot symbol in their name
*
* @throws Exception
*/
@Test
public void testContainerHostnameSupport() throws Exception {
System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
AdminService adminService = ServiceLocator.awaitService(AdminService.class);
Container root = fabricService.getContainer("root");
Set<Container> set = new HashSet<>();
set.add(root);
String version = System.getProperty("fabric.version");
try {
System.out.println(CommandSupport.executeCommand("fabric:profile-edit --features admin default"));
ProvisionSupport.provisioningSuccess(set, 60_000L);
System.out.println(CommandSupport.executeCommand("admin:create --java-opts ' -Dpatching.disabled=true ' --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric joiner "));
System.out.println(CommandSupport.executeCommand("admin:start joiner"));
ProvisionSupport.instanceStarted(Arrays.asList("joiner"), ProvisionSupport.PROVISION_TIMEOUT);
System.out.println(CommandSupport.executeCommand("admin:list"));
String joinCommand = "fabric:join -f --zookeeper-password " + fabricService.getZookeeperPassword() + " " + fabricService.getZookeeperUrl() + " joiner.complex.name";
String response = "";
for (int i = 0; i < 10 && !response.contains("true"); i++) {
response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("joiner").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
Thread.sleep(1000);
}
response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("joiner").getSshPort() + " localhost " + joinCommand);
ProvisionSupport.containersExist(Arrays.asList("joiner.complex.name"), ProvisionSupport.PROVISION_TIMEOUT);
Container joiner = fabricService.getContainer("joiner.complex.name");
ProvisionSupport.containerStatus(Arrays.asList(joiner), "success", ProvisionSupport.PROVISION_TIMEOUT);
// System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("basic_cnt_f").getSshPort() + " localhost " + joinCommand));
} finally {
System.out.println(CommandSupport.executeCommand("fabric:container-info joiner"));
System.out.println(CommandSupport.executeCommand("admin:stop joiner"));
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ExtendedUpgradeAndRollbackTest method testContainerAfterVersionDowngrade.
/**
* This is a test for http://fusesource.com/issues/browse/FABRIC-367.
*/
@Test
@SuppressWarnings("unchecked")
public void testContainerAfterVersionDowngrade() throws Exception {
System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
System.out.println(CommandSupport.executeCommand("fabric:version-create --parent 1.0 1.1"));
System.out.println(CommandSupport.executeCommand("fabric:container-upgrade --all 1.1"));
Set<Container> containers = ContainerBuilder.create().withName("basic_camel_b").withProfiles("feature-camel").assertProvisioningResult().build(fabricService);
try {
System.out.println(CommandSupport.executeCommand("fabric:container-rollback --all 1.0"));
ProvisionSupport.provisioningSuccess(containers, ProvisionSupport.PROVISION_TIMEOUT);
for (Container container : containers) {
Assert.assertEquals("Container should have version 1.0", "1.0", container.getVersion().getId());
Assert.assertNotNull(ZooKeeperUtils.exists(ServiceLocator.awaitService(CuratorFramework.class), "/fabric/configs/versions/1.0/containers/" + container.getId()));
}
} finally {
ContainerBuilder.stop(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
Aggregations