use of io.fabric8.testkit.FabricController in project fabric8 by jboss-fuse.
the class Fabric8Container method start.
@Override
public void start() throws LifecycleException {
// lets kill any containers that are running before we start
FabricAssertions.killJavaAndDockerProcesses();
fabricControllerManager = createFabricControllerManager();
Fabric8ContainerConfiguration config = configuration.get();
config.configure(fabricControllerManager);
try {
FabricController fabricController = FabricAssertions.assertFabricCreate(fabricControllerManager);
controller.set(fabricController);
} catch (Exception e) {
throw new LifecycleException("Failed to create fabric: " + e, e);
}
System.out.println("Created a controller " + controller.get());
}
use of io.fabric8.testkit.FabricController in project fabric8 by jboss-fuse.
the class CommandLineFabricControllerManager method createFabric.
@Override
public FabricController createFabric() throws Exception {
if (workDirectory == null) {
workDirectory = createTempDirectory();
}
String version = System.getProperty("fabric8-version", "1.2.0-SNAPSHOT");
String home = System.getProperty("user.home", "~");
String repo = home + "/.m2/repository";
File distro = new File(repo, "io/fabric8/fabric8-karaf/" + version + "/fabric8-karaf-" + version + ".tar.gz");
FabricAssertions.assertFileExists(distro);
installDir = new File(workDirectory, "fabric8-karaf-" + version);
killInstanceProcesses(getInstancesFile());
if (workDirectory.exists()) {
Files.recursiveDelete(workDirectory);
}
workDirectory.mkdirs();
executeCommand(workDirectory, "tar", "zxf", distro.getAbsolutePath());
FabricAssertions.assertDirectoryExists(installDir);
assertTrue("install dir does not exist: " + installDir.getAbsolutePath(), installDir.exists());
assertTrue("install dir is not a directory: " + installDir.getAbsolutePath(), installDir.isDirectory());
System.out.println("About to boot up the fabric8 at: " + installDir.getAbsolutePath());
File shellScript = new File(installDir, startFabricScriptName);
FabricAssertions.assertFileExists(shellScript);
executeCommand(installDir, "./" + startFabricScriptName);
final FabricController restApi = createFabricController();
return restApi;
}
use of io.fabric8.testkit.FabricController in project fabric8 by jboss-fuse.
the class AutoScaleSingleMessageBrokerTest method createProvisionedFabric.
@Test
public void createProvisionedFabric() throws Exception {
System.out.println("The fabric has now been created somewhere and we have a controller for it, so lets define our requirements");
FabricRequirements requirements = new FabricRequirements();
requirements.profile("mq-default").minimumInstances(1);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
// now lets ensure that the autoscaler can scale back down again, stopping the broker
requirements.profile("mq-default").minimumInstances(0).maximumInstances(0);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
}
use of io.fabric8.testkit.FabricController in project fabric8 by jboss-fuse.
the class ArchetypeTest method testCreateArchetype.
@Test
public void testCreateArchetype() throws Exception {
ArchetypeInfo archetype = archetypeIdToArchetypeInfoMap.get(archetypeId);
assertNotNull("No archetype found for id: " + archetypeId, archetype);
File mavenSettingsFile = getMavenSettingsFile();
assertFileExists(mavenSettingsFile);
// create a fabric
// generate and deploy archetypes
File workDir = new File(System.getProperty("basedir", "."), "target/generated-projects");
workDir.mkdirs();
String profileId = assertGenerateArchetype(archetype, workDir, mavenSettingsFile);
assertNotNull("Should have a profile ID for " + archetype, profileId);
FabricRequirements requirements = fabricController.getRequirements();
if (!addedBroker) {
addedBroker = true;
requirements.profile("mq-default").minimumInstances(1);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
}
// deploying each profile should have caused the requirements to be updated to add them all now
// so lets load the requirements and assert they are satisfied
requirements.profile(profileId).minimumInstances(1);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
System.out.println();
System.out.println("Managed to create a container for " + profileId + ". Now lets stop it");
System.out.println();
// now lets force the container to be stopped
requirements.profile(profileId).minimumInstances(0).maximumInstances(0);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
System.out.println();
System.out.println("Stopped a container for " + profileId + ". Now lets clear requirements");
System.out.println();
requirements.removeProfileRequirements(profileId);
FabricAssertions.assertRequirementsSatisfied(fabricController, requirements);
System.out.println();
System.out.println("Removed requirements for profile " + profileId);
System.out.println();
}
Aggregations