brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
Subject [GitHub] brooklyn-server pull request: Fix/required open ports
Date Sat, 28 May 2016 14:51:30 GMT
Github user aledsage commented on a diff in the pull request:
    --- Diff: software/base/src/test/java/org/apache/brooklyn/entity/software/base/
    @@ -50,4 +46,23 @@ public void testGetRequiredOpenPortsGetsDynamicallyAddedKeys() {
             Collection<Integer> dynamicRequiredOpenPorts = InboundPortsUtils.getRequiredOpenPorts(entity,
ImmutableSet.<ConfigKey<?>>of(), true, null);
             Assert.assertEquals(dynamicRequiredOpenPorts, ImmutableSet.of(9999), "Expected
new port to be added");
    +    @Test
    +    public void testGetRequiredOpenPortsGetsDynamicallyAddedPortBasedKeys() {
    +        TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
    +        PortAttributeSensorAndConfigKey newTestConfigKeyPort = ConfigKeys.newPortSensorAndConfigKey("new.test.config.port.string.first",
"port", "7777+");
    +        PortAttributeSensorAndConfigKey newTestConfigKeyPort2 = ConfigKeys.newPortSensorAndConfigKey("new.test.config.port.string.second",
    +        ConfigKey<String> newTestConfigKeyString = ConfigKeys.newStringConfigKey("new.test.config.key.string");
    +        entity.config().set(newTestConfigKeyPort, PortRanges.fromString("8888+"));
    +        entity.config().set(newTestConfigKeyPort2, PortRanges.fromInteger(9999));
    +        entity.config().set(newTestConfigKeyString, "");
    +        Collection<Integer> dynamicRequiredOpenPorts = InboundPortsUtils.getRequiredOpenPorts(entity,
ImmutableSet.<ConfigKey<?>>of(), true, null);
    +        Assert.assertTrue(dynamicRequiredOpenPorts.contains(8888));
    +        Assert.assertTrue(dynamicRequiredOpenPorts.contains(9999));
    --- End diff --
    It feels like your code handles an additional case, which is not tested: setting config
(e.g of type `ConfigKey<Object>`) where the value is a `PortRanges.fromInteger(2222)`.
Your new code will include that, even though the type and name of the config key didn't give
us a clue about it.
    If that is the case, then worth including it in the test case.
    (In contrast, your existing test cases use config keys of type PortAttributeSensorAndConfigKey,
so we can tell from the key that it is a port (without looking at the value)).

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message