Search in sources :

Example 71 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class StatementBuilderTest method testExplicitExports.

@Test
public void testExplicitExports() throws Exception {
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys();
    clusterSpec.setClusterName("test-cluster");
    clusterSpec.setProvider("test-provider");
    StatementBuilder builder = new StatementBuilder();
    builder.addExport("FOO_BAR", "my_value");
    builder.addStatement(Statements.exec("echo $FOO_BAR"));
    String script = builder.name("foo").build(clusterSpec).render(OsFamily.UNIX);
    assertThat(script, containsString("export FOO_BAR="));
    assertThat(script, containsString("my_value"));
    assertThat(script, containsString("echo $FOO_BAR"));
}
Also used : ClusterSpec(org.apache.whirr.ClusterSpec) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 72 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class StatementBuilderTest method testClusterSpecExports.

@Test
public void testClusterSpecExports() throws Exception {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.addProperty("ignored", "ignored_value");
    conf.addProperty("whirr.env.FOO_BAR", "my_value");
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);
    clusterSpec.setClusterName("test-cluster");
    clusterSpec.setProvider("test-provider");
    StatementBuilder builder = new StatementBuilder();
    builder.addStatement(Statements.exec("echo $FOO_BAR"));
    String script = builder.name("foo").build(clusterSpec).render(OsFamily.UNIX);
    assertThat(script, containsString("export FOO_BAR="));
    assertThat(script, containsString("my_value"));
    assertThat(script, containsString("echo $FOO_BAR"));
    assertThat(script, not(containsString("ignored")));
}
Also used : ClusterSpec(org.apache.whirr.ClusterSpec) Matchers.containsString(org.hamcrest.Matchers.containsString) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 73 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class BlobClusterStateStoreTest method testStoreAndLoadState.

@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void testStoreAndLoadState() throws Exception {
    ClusterSpec spec = getTestClusterSpec();
    BlobStoreContext context = BlobStoreContextBuilder.build(spec);
    String container = generateRandomContainerName(context);
    try {
        spec.setStateStore("blob");
        spec.setStateStoreContainer(container);
        Cluster expected = createTestCluster(new String[] { "region/id1", "region/id2" }, new String[] { "role1", "role2" });
        BlobClusterStateStore store = new BlobClusterStateStore(spec);
        store.save(expected);
        /* load and check the stored state */
        Cluster stored = store.load();
        Cluster.Instance first = Iterables.getFirst(stored.getInstances(), null);
        assertNotNull(first);
        assertThat(first.getId(), is("region/id1"));
        assertThat(first.getRoles().contains("role1"), is(true));
        assertThat(stored.getInstances().size(), is(2));
        /* destroy stored state and check it no longer exists */
        store.destroy();
        expected = store.load();
        assertNull(expected);
    } finally {
        LOG.info("Removing temporary container '{}'", container);
        context.getBlobStore().deleteContainer(container);
    }
}
Also used : BlobClusterStateStore(org.apache.whirr.state.BlobClusterStateStore) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) BlobStoreContext(org.jclouds.blobstore.BlobStoreContext) Test(org.junit.Test)

Example 74 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class BlobClusterStateStoreTest method testInvalidContainerName.

@Test(expected = IllegalArgumentException.class, timeout = TestConstants.ITEST_TIMEOUT)
public void testInvalidContainerName() throws Exception {
    ClusterSpec spec = getTestClusterSpec();
    /* underscores are not allowed and it should throw exception */
    spec.setStateStoreContainer("whirr_test");
}
Also used : ClusterSpec(org.apache.whirr.ClusterSpec) Test(org.junit.Test)

Example 75 with ClusterSpec

use of org.apache.whirr.ClusterSpec in project whirr by apache.

the class BlobCacheTest method testUploadInEUS3Region.

@Test
public void testUploadInEUS3Region() throws Exception {
    ClusterSpec spec = getTestClusterSpec();
    if ("aws-ec2".equals(spec.getProvider())) {
        // Configuration workaround need until the following issue is fixed
        // http://code.google.com/p/jclouds/issues/detail?id=656
        spec.setBlobStoreLocationId("EU");
        spec.getConfiguration().setProperty("jclouds.aws-s3.endpoint", "https://s3-eu-west-1.amazonaws.com");
        testBlobCacheUpload(RandomStringUtils.randomAlphanumeric(1024 * 1024), spec);
    }
}
Also used : ClusterSpec(org.apache.whirr.ClusterSpec) Test(org.junit.Test)

Aggregations

ClusterSpec (org.apache.whirr.ClusterSpec)98 Configuration (org.apache.commons.configuration.Configuration)39 Cluster (org.apache.whirr.Cluster)35 Test (org.junit.Test)34 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)16 Instance (org.apache.whirr.Cluster.Instance)14 ClusterController (org.apache.whirr.ClusterController)10 InetAddress (java.net.InetAddress)9 DryRun (org.apache.whirr.service.DryRunModule.DryRun)9 OptionSet (joptsimple.OptionSet)8 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)8 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)8 IOException (java.io.IOException)7 ComputeService (org.jclouds.compute.ComputeService)7 File (java.io.File)6 ClusterControllerFactory (org.apache.whirr.ClusterControllerFactory)6 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)6 Set (java.util.Set)5 Stack (java.util.Stack)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5