org.apache.brooklyn.entity.software.base.EmptySoftwareProcess Java Examples

The following examples show how to use org.apache.brooklyn.entity.software.base.EmptySoftwareProcess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigInheritanceYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtendsSuperTypeConfigMixingShortOverridingLongName() throws Exception {
    ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");

    // super-type has shell.env; sub-type env
    String yaml = Joiner.on("\n").join(
            "location: localhost-stub",
            "services:",
            "- type: EmptySoftwareProcess-with-shell.env",
            "  brooklyn.config:",
            "    env:",
            "      ENV2: myEnv2");
    
    Entity app = createStartWaitAndLogApplication(yaml);
    Entity entity = Iterables.getOnlyElement(app.getChildren());
    EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.SHELL_ENVIRONMENT, expectedEnv);
}
 
Example #2
Source File: LocationExternalConfigYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups="Integration")
public void testLocalhostInheritance() throws Exception {
    String yaml = Joiner.on("\n").join(
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "location:",
            "  localhost:",
            "    my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");

    origApp = (StartableApplication) createAndStartApplication(new StringReader(yaml));

    Entity entity = Iterables.getOnlyElement( origApp.getChildren() );
    Location l = Iterables.getOnlyElement( entity.getLocations() );
    assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
            
    Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    Assert.assertTrue(rawConfig.isPresentAndNonNull());
    Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
}
 
Example #3
Source File: EmptySoftwareProcessYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoSshing() throws Exception {
    Entity app = createAndStartApplication(
            "location:",
            "  localhost:",
            "    sshToolClass: "+RecordingSshTool.class.getName(),
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "  brooklyn.config:",
            "    sshMonitoring.enabled: false",
            "    "+BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION.getName()+": true");
    waitForApplicationTasks(app);

    EmptySoftwareProcess entity = (EmptySoftwareProcess) Iterables.getOnlyElement(app.getChildren());
    EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true);
    EntityAsserts.assertAttributeEqualsContinually(entity, Attributes.SERVICE_UP, true);
    
    assertEquals(RecordingSshTool.getExecCmds(), ImmutableList.of());
}
 
Example #4
Source File: EmptySoftwareProcessYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithAppAndEntityLocations() throws Exception {
    Entity app = createAndStartApplication(
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "  location:",
            "    localhost:(name=localhost on entity):",
            "      sshToolClass: "+RecordingSshTool.class.getName(),
            "location: byon:(hosts=\"127.0.0.1\", name=loopback on app)");
    waitForApplicationTasks(app);
    Dumper.dumpInfo(app);
    
    Location appLocation = Iterables.getOnlyElement(app.getLocations());
    Assert.assertEquals(appLocation.getDisplayName(), "loopback on app");
    
    Entity entity = Iterables.getOnlyElement(app.getChildren());
    Assert.assertEquals(entity.getLocations().size(), 2);
    Location provisioningLoc = Iterables.get(entity.getLocations(), 0);
    Location machineLoc = Iterables.get(entity.getLocations(), 1);
    
    Assert.assertEquals(provisioningLoc.getDisplayName(), "localhost on entity");
    Assert.assertTrue(machineLoc instanceof SshMachineLocation, "wrong location: "+machineLoc);
    // TODO this, below, probably should be 'localhost on entity', see #1377
    Assert.assertEquals(machineLoc.getParent().getDisplayName(), "localhost on entity");
}
 
Example #5
Source File: EmptySoftwareProcessYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testProvisioningProperties() throws Exception {
    Entity app = createAndStartApplication(
        "location:",
        "  localhost:",
        "    sshToolClass: "+RecordingSshTool.class.getName(),
        "    myLocConfig: myval",
        "services:",
        "- type: "+EmptySoftwareProcess.class.getName(),
        "  brooklyn.config:",
        "    provisioning.properties:",
        "      minRam: 16384");
    waitForApplicationTasks(app);

    log.info("App started:");
    Dumper.dumpInfo(app);
    
    EmptySoftwareProcess entity = (EmptySoftwareProcess) app.getChildren().iterator().next();
    Map<String, Object> pp = entity.getConfig(EmptySoftwareProcess.PROVISIONING_PROPERTIES);
    assertEquals(pp.get("minRam"), 16384);
    
    MachineLocation machine = Locations.findUniqueMachineLocation(entity.getLocations()).get();
    assertEquals(machine.config().get(ConfigKeys.newConfigKey(Object.class, "myLocConfig")), "myval");
    assertEquals(machine.config().get(ConfigKeys.newConfigKey(Object.class, "minRam")), 16384);
}
 
Example #6
Source File: MachineDetailsEc2LiveTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
protected void doTest(Location loc) throws Exception {
    Entity testEntity = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class));
    app.start(ImmutableList.of(loc));
    EntityAsserts.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS),
            testEntity, Startable.SERVICE_UP, true);

    SshMachineLocation sshLoc = Locations.findUniqueSshMachineLocation(testEntity.getLocations()).get();
    MachineDetails machine = app.getExecutionContext()
            .submit(BasicMachineDetails.taskForSshMachineLocation(sshLoc))
            .getUnchecked();
    LOG.info("Found the following at {}: {}", loc, machine);
    assertNotNull(machine);
    OsDetails details = machine.getOsDetails();
    assertNotNull(details);
    assertNotNull(details.getArch());
    assertNotNull(details.getName());
    assertNotNull(details.getVersion());
    assertFalse(details.getArch().startsWith("architecture:"));
    assertFalse(details.getName().startsWith("name:"));
    assertFalse(details.getVersion().startsWith("version:"));
}
 
Example #7
Source File: SetLimitsCustomizerIntegrationTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups="Integration")
public void testAppendsToGivenFile() throws Exception {
    file = File.createTempFile("testAppendsToGivenFile", ".conf");
    
    Entity app = createAndStartApplication(
        "location: localhost",
        "services:",
        "- type: " + EmptySoftwareProcess.class.getName(),
        "  brooklyn.config:",
        "    provisioning.properties:",
        "      machineCustomizers:",
        "        - $brooklyn:object:",
        "            type: "+SetLimitsCustomizer.class.getName(),
        "            brooklyn.config:",
        "              file: " + file.getAbsolutePath(),
        "              contents:",
        "                - my line 1",
        "                - my line 2");
    waitForApplicationTasks(app);
    
    List<String> actual = Files.readAllLines(file.toPath());
    assertEquals(actual, ImmutableList.of("my line 1", "my line 2"), "actual="+actual);
}
 
Example #8
Source File: MachineDetailsGoogleComputeLiveTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
protected void doTest(Location loc) throws Exception {
    Entity testEntity = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class));
    app.start(ImmutableList.of(loc));
    EntityAsserts.assertAttributeEqualsEventually(testEntity, Startable.SERVICE_UP, true);

    SshMachineLocation sshLoc = Locations.findUniqueSshMachineLocation(testEntity.getLocations()).get();
    MachineDetails machine = app.getExecutionContext()
            .submit(BasicMachineDetails.taskForSshMachineLocation(sshLoc))
            .getUnchecked();
    LOG.info("Found the following at {}: {}", loc, machine);
    assertNotNull(machine);
    OsDetails details = machine.getOsDetails();
    assertNotNull(details);
    assertNotNull(details.getArch());
    assertNotNull(details.getName());
    assertNotNull(details.getVersion());
    assertFalse(details.getArch().startsWith("architecture:"));
    assertFalse(details.getName().startsWith("name:"));
    assertFalse(details.getVersion().startsWith("version:"));
}
 
Example #9
Source File: ExternalConfigYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups="Integration")
public void testExternalisedLocationConfigInheritanceReferencedFromYaml() throws Exception {
    ConfigKey<String> MY_CONFIG_KEY = ConfigKeys.newStringConfigKey("my.config.key");

    String yaml = Joiner.on("\n").join(
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "location:",
            "  localhost:",
            "    my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");

    Entity app = createAndStartApplication(yaml);
    waitForApplicationTasks(app);
    Entity entity = Iterables.getOnlyElement( app.getChildren() );
    Location l = Iterables.getOnlyElement( entity.getLocations() );
    assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
    Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    Assert.assertTrue(rawConfig.isPresentAndNonNull());
    Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
}
 
Example #10
Source File: LocationExternalConfigYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups="Integration")
public void testProvisioningPropertyInheritance() throws Exception {
    String yaml = Joiner.on("\n").join(
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "  provisioning.properties:",
            "      simple: 42",
            "      my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")",
            "location: localhost");

    origApp = (StartableApplication) createAndStartApplication(new StringReader(yaml));

    Entity entity = Iterables.getOnlyElement( origApp.getChildren() );
    Location l = Iterables.getOnlyElement( entity.getLocations() );
    assertEquals(l.config().get(ConfigKeys.builder(Integer.class, "simple").build()), (Integer)42);
    assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
            
    Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    Assert.assertTrue(rawConfig.isPresentAndNonNull());
    Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
}
 
Example #11
Source File: LoopOverGroupMembersTestCaseTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testOneChildWhichPasses() {
    EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
    EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();

    LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.addChild(EntitySpec.create(LoopOverGroupMembersTestCase.class)
            .configure(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec)
            .configure(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup));

    app.start(ImmutableList.of(app.newSimulatedLocation()));

    assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
    assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();

    Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
    assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
    assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
    assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
}
 
Example #12
Source File: ConfigInheritanceYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtendsSuperTypeConfigMixingShortOverridingShortName() throws Exception {
    // fixed Sept 2016
    ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");

    // super-type has env; sub-type env
    String yaml = Joiner.on("\n").join(
            "location: localhost-stub",
            "services:",
            "- type: EmptySoftwareProcess-with-env",
            "  brooklyn.config:",
            "    env:",
            "      ENV2: myEnv2");

    Entity app = createStartWaitAndLogApplication(yaml);
    Entity entity = Iterables.getOnlyElement(app.getChildren());
    EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.SHELL_ENVIRONMENT, expectedEnv);
}
 
Example #13
Source File: ConfigInheritanceYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtendsSuperTypeConfigMixingLongOverridingShortNames() throws Exception {
    ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");

    // super-type has env; sub-type shell.env
    String yaml = Joiner.on("\n").join(
            "location: localhost-stub",
            "services:",
            "- type: EmptySoftwareProcess-with-env",
            "  brooklyn.config:",
            "    shell.env:",
            "      ENV2: myEnv2");
    
    Entity app = createStartWaitAndLogApplication(yaml);
    Entity entity = Iterables.getOnlyElement(app.getChildren());
    EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.SHELL_ENVIRONMENT, expectedEnv);
}
 
Example #14
Source File: ConfigInheritanceYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtendsSuperTypeConfigSimple() throws Exception {
    ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");

    // super-type has shell.env; sub-type shell.env
    String yaml = Joiner.on("\n").join(
            "location: localhost-stub",
            "services:",
            "- type: EmptySoftwareProcess-with-shell.env",
            "  brooklyn.config:",
            "    shell.env:",
            "      ENV2: myEnv2");
    
    Entity app = createStartWaitAndLogApplication(yaml);
    Entity entity = Iterables.getOnlyElement(app.getChildren());
    EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.SHELL_ENVIRONMENT, expectedEnv);
}
 
Example #15
Source File: KubernetesLocationYamlLiveTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"Live"})
public void testLoginPasswordOverride() throws Exception {
    String customPassword = "myDifferentPassword";

    String yaml = Joiner.on("\n").join(
            locationYaml,
            "services:",
            "  - type: " + EmptySoftwareProcess.class.getName(),
            "    brooklyn.config:",
            "      provisioning.properties:",
            "        " + KubernetesLocationConfig.LOGIN_USER_PASSWORD.getName() + ": " + customPassword);

    Entity app = createStartWaitAndLogApplication(yaml);
    EmptySoftwareProcess entity = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, EmptySoftwareProcess.class));

    SshMachineLocation machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
    assertEquals(machine.config().get(SshMachineLocation.PASSWORD), customPassword);
    assertTrue(machine.isSshable());
}
 
Example #16
Source File: LoopOverGroupMembersTestCaseTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleChildrenWhichPass() {
    Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
    EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();

    LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.addChild(EntitySpec.create(LoopOverGroupMembersTestCase.class)
            .configure(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec)
            .configure(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup));

    app.start(ImmutableList.of(app.newSimulatedLocation()));

    assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
    assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();

    for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
        assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
        assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
        assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
        emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
    }
}
 
Example #17
Source File: LoopOverGroupMembersTestCaseTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleChildrenWhichAllFail() {
    Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
    EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();

    LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.addChild(EntitySpec.create(LoopOverGroupMembersTestCase.class)
            .configure(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec)
            .configure(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup));

    startAppAssertingFailure(app, app.newSimulatedLocation());

    assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
    assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();

    for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
        assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
        assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
        assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
        emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
    }
}
 
Example #18
Source File: BindDnsServerIntegrationTest.java    From brooklyn-library with Apache License 2.0 6 votes vote down vote up
@Test(groups = "Integration")
public void testOneARecordAndNoCnameRecordsWhenEntitiesHaveSameName() {
    TestApplication app = origManagementContext.getEntityManager().createEntity(EntitySpec.create(TestApplication.class));
    EnricherSpec<?> dnsEnricher = Enrichers.builder().transforming(Attributes.HOSTNAME)
            .computing(Functions.constant("my-name"))
            .publishing(PrefixAndIdEnricher.SENSOR)
            .build();
    EntitySpec<EmptySoftwareProcess> emptySoftwareProcessSpec = EntitySpec.create(EmptySoftwareProcess.class)
            .enricher(dnsEnricher);
    dns = app.createAndManageChild(EntitySpec.create(BindDnsServer.class, TestBindDnsServerImpl.class)
            .configure(BindDnsServer.HOSTNAME_SENSOR, PrefixAndIdEnricher.SENSOR));

    // App DNS will listen to
    cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
            .configure(DynamicCluster.MEMBER_SPEC, emptySoftwareProcessSpec)
            .configure(DynamicCluster.INITIAL_SIZE, 3));

    app.start(ImmutableList.of(app.newLocalhostProvisioningLocation()));

    assertDnsEntityEventuallyHasActiveMembers(1);
    // All of the entities publish the same domain name so there should be a single DNS entry and no CNAMEs.
    assertMapSizes(1, 1, 0, 1);
}
 
Example #19
Source File: LoopOverGroupMembersTestCaseTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testOneChildWhichFails() {
    EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
    EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();

    LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.addChild(EntitySpec.create(LoopOverGroupMembersTestCase.class)
            .configure(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec)
            .configure(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup));

    startAppAssertingFailure(app, app.newSimulatedLocation());

    assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
    assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();

    Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
    assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
    assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
    assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
}
 
Example #20
Source File: CassandraDatacenterTest.java    From brooklyn-library with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoesNotPopulateInitialTokens() throws Exception {
    cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
            .configure(CassandraDatacenter.INITIAL_SIZE, 2)
            .configure(CassandraDatacenter.USE_VNODES, true)
            .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
            .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));

    app.start(ImmutableList.of(loc));

    Set<BigInteger> tokens = Sets.newLinkedHashSet();
    for (Entity member : cluster.getMembers()) {
        Set<BigInteger > memberTokens = member.getConfig(CassandraNode.TOKENS);
        if (memberTokens != null) tokens.addAll(memberTokens);
    }
    assertEquals(tokens, ImmutableSet.of());
}
 
Example #21
Source File: CassandraDatacenterTest.java    From brooklyn-library with Apache License 2.0 6 votes vote down vote up
@Test
public void testPopulatesInitialTokens() throws Exception {
    cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
            .configure(CassandraDatacenter.INITIAL_SIZE, 2)
            .configure(CassandraDatacenter.TOKEN_SHIFT, BigInteger.ZERO)
            .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
            .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));

    app.start(ImmutableList.of(loc));

    Set<BigInteger> tokens = Sets.newLinkedHashSet();
    for (Entity member : cluster.getMembers()) {
        Set<BigInteger > memberTokens = member.getConfig(CassandraNode.TOKENS);
        if (memberTokens != null) tokens.addAll(memberTokens);
    }
    assertEquals(tokens, ImmutableSet.of(new BigInteger("-9223372036854775808"), BigInteger.ZERO));
}
 
Example #22
Source File: SeaCloudsManagementPolicyLiveTest.java    From SeaCloudsPlatform with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"Live"}, enabled = false)
public void testAttachPolicyToApplication() {
    app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class));
    app.policies().add(getPolicySpec());

    app.start(ImmutableList.of(loc));

    assertTrue(Iterables.getOnlyElement(app.policies()) instanceof SeaCloudsManagementPolicy);

    Asserts.succeedsEventually(new Runnable() {
        public void run() {
            assertTrue(app.getAttribute(Startable.SERVICE_UP));
            assertNotNull(app.getAttribute(SeaCloudsManagementPolicy.SLA_ID));

            assertNotNull(app.getAttribute(SeaCloudsManagementPolicy.T4C_IDS));
            assertFalse(app.getAttribute(SeaCloudsManagementPolicy.T4C_IDS).isEmpty());
        }
    });
}
 
Example #23
Source File: AbstractServerPoolTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected TestApplication createAppWithChildren(int numChildren) {
    if (numChildren < 0) fail("Invalid number of children for app: " + numChildren);

    TestApplication app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)
            .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, shouldSkipOnBoxBaseDirResolution()));

    while (numChildren-- > 0) {
        app.addChild(EntitySpec.create(EmptySoftwareProcess.class));
    }
    createdApps.add(app);
    return app;
}
 
Example #24
Source File: SoftwareProcessDriverCopyResourcesTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private void testPhase(MapConfigKey<String> filePhase, MapConfigKey<String> templatePhase,
                       AttributeSensor<String> directory) throws IOException {

    File file1 = new File(sourceFileDir, "file1");
    Files.write(TEST_CONTENT_FILE, file1, Charset.defaultCharset());
    File template1 = new File(sourceTemplateDir, "template1");
    Files.write(TEST_CONTENT_TEMPLATE, template1, Charset.defaultCharset());
    final EmptySoftwareProcess testEntity =
        app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class)
            .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, "true")
            .configure(filePhase.getName(),
                ImmutableMap.of(file1.getAbsolutePath(), "file1"))
            .configure(templatePhase.getName(),
                ImmutableMap.of(template1.getAbsolutePath(), "template1")));

    app.start(ImmutableList.of(location));
    final String installDirName = testEntity.sensors().get(directory);
    assertNotNull(installDirName);
    final File installDir = new File(installDirName);

    final File file1Installed = new File(installDir, "file1");
    final String firstLine = Files.readFirstLine(file1Installed, Charset.defaultCharset());
    assertEquals(TEST_CONTENT_FILE, firstLine);

    final File template1Installed = new File(installDir, "template1");
    Properties props = new Properties();
    final FileInputStream templateStream = new FileInputStream(template1Installed);
    props.load(templateStream);
    assertEquals(props.getProperty("id"), testEntity.getId());
}
 
Example #25
Source File: ServerPoolLocationResolverTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@BeforeMethod(alwaysRun=true)
@Override
public void setUp() throws Exception {
    super.setUp();
    serverPool = app.createAndManageChild(EntitySpec.create(ServerPool.class)
            .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, shouldSkipOnBoxBaseDirResolution())
            .configure(ServerPool.INITIAL_SIZE, 0)
            .configure(ServerPool.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
    Location localhostLoc = mgmt.getLocationManager()
            .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
    app.start(ImmutableList.of(localhostLoc));
}
 
Example #26
Source File: JcloudsExternalConfigYamlTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test
public void testProvisioningPropertyInheritance() throws Exception {
    String yaml = Joiner.on("\n").join(
            "location: " + LOCATION_CATALOG_ID,
            "services:",
            "- type: "+EmptySoftwareProcess.class.getName(),
            "  provisioning.properties:",
            "      password: $brooklyn:external(\"myprovider\", \"mykey\")",
            // note that these 2 do not get transferred -- see below
            "      simple: 42",
            "      my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");

    StartableApplication app = (StartableApplication) createAndStartApplication(new StringReader(yaml));

    Entity entity = Iterables.getOnlyElement( app.getChildren() );
    Location l = Iterables.getOnlyElement( entity.getLocations() );
    log.info("Location: "+l);
    assertEquals(l.config().get(JcloudsLocation.PASSWORD), "myval");

    Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(ConfigKeys.newStringConfigKey("password"));
    log.info("Raw config password: "+rawConfig);
    Assert.assertTrue(rawConfig.isPresentAndNonNull());
    Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());

    // these are null as only recognised provisioning properties are transmitted by jclouds
    log.info("my config key: "+l.getConfig(MY_CONFIG_KEY));
    log.info("my config key raw: "+((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY));
    log.info("simple: "+l.getConfig(ConfigKeys.builder(Integer.class, "simple").build()));
    log.info("simple raw: "+((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(ConfigKeys.builder(Integer.class, "simple").build()));
}
 
Example #27
Source File: MachineLifecycleEffectorTasksTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test(groups="Integration")
public void testProvisionLatchObeyed() throws Exception {

    AttributeSensor<Boolean> ready = Sensors.newBooleanSensor("readiness");

    BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));

    EmptySoftwareProcess entity = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class)
            .configure(BrooklynConfigKeys.PROVISION_LATCH, DependentConfiguration.attributeWhenReady(triggerEntity, ready)));

    final Task<Void> task = Entities.invokeEffector(app, app, Startable.START, ImmutableMap.of(
            "locations", ImmutableList.of(BailOutJcloudsLocation.newBailOutJcloudsLocation(app.getManagementContext()))));
    
    Time.sleep(ValueResolver.PRETTY_QUICK_WAIT);
    if (task.isDone()) throw new IllegalStateException("Task finished early with: "+task.get());
    assertEffectorBlockingDetailsEventually(entity, "Waiting for config " + BrooklynConfigKeys.PROVISION_LATCH.getName());

    Asserts.succeedsContinually(new Runnable() {
        @Override
        public void run() {
            if (task.isDone()) throw new IllegalStateException("Task finished early with: "+task.getUnchecked());
        }
    });
    try {
        triggerEntity.sensors().set(ready, true);
        task.get(Duration.THIRTY_SECONDS);
    } catch (Throwable t) {
        Exceptions.propagateIfFatal(t);
        if ((t.toString().contains(BailOutJcloudsLocation.ERROR_MESSAGE))) {
            // expected - BailOut location throws - just swallow
        } else {
            Exceptions.propagate(t);
        }
    }
}
 
Example #28
Source File: DynamicClusterWithAvailabilityZonesMultiLocationTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@BeforeMethod(alwaysRun=true)
@Override
public void setUp() throws Exception {
    super.setUp();
    cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
            .configure(DynamicCluster.ENABLE_AVAILABILITY_ZONES, true)
            .configure(DynamicCluster.INITIAL_SIZE, 0)
            .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
    
    subLoc1 = app.newLocalhostProvisioningLocation(ImmutableMap.of("displayName", "loc1"));
    subLoc2 = app.newLocalhostProvisioningLocation(ImmutableMap.of("displayName", "loc2"));
    multiLoc = mgmt.getLocationManager().createLocation(LocationSpec.create(MultiLocation.class)
            .configure(MultiLocation.SUB_LOCATIONS, ImmutableList.<MachineProvisioningLocation<?>>of(subLoc1, subLoc2)));
}
 
Example #29
Source File: SecurityGroupLiveTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@BeforeMethod(alwaysRun=true)
@Override
public void setUp() throws Exception {
    // Don't let any defaults from brooklyn.properties (except credentials) interfere with test
    brooklynProperties = BrooklynProperties.Factory.newDefault();
    brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-description-regex");
    brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-name-regex");
    brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-id");
    brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".inboundPorts");
    brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".hardware-id");

    // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can cause "stdin: is not a tty")
    brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");

    mgmt = new LocalManagementContextForTests(brooklynProperties);

    super.setUp();

    Map<String,?> allFlags = MutableMap.<String,Object>builder()
        .put("tags", ImmutableList.of(getClass().getName()))
        .putAll(ImmutableMap.of("imageId", UBUNTU_12, "loginUser", "ubuntu", "hardwareId", "m1.small"))
        .build();
    loc = mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC, allFlags);
    testEntity = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class));
    app.start(ImmutableList.of(loc));
    EntityAsserts.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS),
        testEntity, Startable.SERVICE_UP, true);
    SshMachineLocation sshLoc = Locations.findUniqueSshMachineLocation(testEntity.getLocations()).get();
    jcloudsMachineLocation = (JcloudsMachineLocation)sshLoc;
    computeService = jcloudsMachineLocation.getParent().getComputeService();

}
 
Example #30
Source File: SimpleAppOpenstackLiveTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void doTest(Location loc) throws Exception {

    LOG.info("Testing in {}", loc);
    final EmptySoftwareProcess server = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class));
    app.start(ImmutableList.of(loc));

    LOG.info("App started, waiting for RUNNING");
    Asserts.succeedsEventually(new Runnable() {
        @Override public void run() {
            EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
        }});
}