Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
41890b9
Fix for SUREFIRE-1588
kemitix Nov 1, 2018
da7550d
This closes #1012
tbouron Nov 2, 2018
9f89562
[rt-felix] embedded framework test survives teardown
kemitix Nov 5, 2018
fbb6a6f
[core] embedded framework test survives teardown
kemitix Nov 5, 2018
c2af743
[utils] Extract FileUtil.deleteDirectory() from duplicated code
kemitix Nov 5, 2018
18f65e1
[core] Fix syntax for maven-compiler plugin
kemitix Nov 5, 2018
c5a851d
[test-support] Add @DisableOnWindows annotation for TestNG tests
kemitix Nov 6, 2018
2ba7ce6
[core] Disable BashCommandsIntegrationTest test on Windows
kemitix Nov 6, 2018
6dddc5d
[core] Remove unused Logger in OsgiTestBase
kemitix Nov 6, 2018
61ac3cc
This closes #1013
grkvlt Nov 8, 2018
ed08ff1
when getting details, get the raw value then resolve it immediately
ahgittin Nov 15, 2018
5dbf70d
introduce new distinct "application" itemType on catalog BOM files, w…
ahgittin Nov 15, 2018
d0897b2
Closes #1015
grkvlt Nov 15, 2018
44b6e54
when editting it is useful to know the source URL
ahgittin Nov 16, 2018
57e7b1a
This closes #1016
aledsage Nov 20, 2018
cd5e532
Merge branch 'master' into subtype-config-used-as-key-defaultval
ahgittin Nov 23, 2018
2174aa4
add test to show deep coercion problem
ahgittin Nov 24, 2018
fc62d39
defer to parent key to extract value when overriding, and coerce better
ahgittin Nov 24, 2018
4d79eaf
update other tests where semantics are changed in acceptable ways
ahgittin Nov 24, 2018
4f12917
don't include common defaults in serialized repn of config keys
ahgittin Nov 25, 2018
731b9ad
fix set config and isSet check for BasicConfigKeyOverwritten
ahgittin Nov 26, 2018
9374ecd
add failing test (marked broken) for edge case where flags not includ…
ahgittin Nov 26, 2018
69f33c0
expand + correct test of runtime inheritance for key visibility
ahgittin Nov 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public interface CatalogItem<T,SpecT> extends BrooklynObject, Rebindable {

public static enum CatalogItemType {
TEMPLATE,
APPLICATION,
ENTITY,
POLICY,
ENRICHER,
Expand All @@ -63,7 +64,7 @@ public static CatalogItemType ofTargetClass(Class<? extends BrooklynObject> type
if (Policy.class.isAssignableFrom(type)) return POLICY;
if (Enricher.class.isAssignableFrom(type)) return ENRICHER;
if (Location.class.isAssignableFrom(type)) return LOCATION;
if (Application.class.isAssignableFrom(type)) return TEMPLATE;
if (Application.class.isAssignableFrom(type)) return APPLICATION;
if (Entity.class.isAssignableFrom(type)) return ENTITY;
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ public static BrooklynObjectType of(CatalogItemType t) {
switch (t) {
case ENRICHER: return BrooklynObjectType.ENRICHER;
case ENTITY: return BrooklynObjectType.ENTITY;
case APPLICATION: return BrooklynObjectType.ENTITY;
case TEMPLATE: return BrooklynObjectType.ENTITY;
case LOCATION: return BrooklynObjectType.LOCATION;
case POLICY: return BrooklynObjectType.POLICY;
case TEMPLATE: return BrooklynObjectType.ENTITY;
default: return BrooklynObjectType.UNKNOWN;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.io.File;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
Expand All @@ -35,6 +36,7 @@
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.config.ConfigPredicates;
import org.apache.brooklyn.core.config.MapConfigKey;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityAsserts;
Expand All @@ -43,6 +45,7 @@
import org.apache.brooklyn.core.test.entity.TestEntityImpl;
import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
import org.apache.brooklyn.entity.stock.BasicApplication;
import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
import org.apache.brooklyn.util.os.Os;
Expand Down Expand Up @@ -556,6 +559,9 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {
" type: java.util.Map",
" inheritance.runtime: not_reinherited");

ImmutableMap<String, String> defaultKV = ImmutableMap.of("myDefaultKey", "myDefaultVal");
ImmutableMap<String, String> myKV = ImmutableMap.of("mykey", "myval");

// Test retrieval of defaults
{
String yaml = Joiner.on("\n").join(
Expand All @@ -567,10 +573,10 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {
Entity app = createStartWaitAndLogApplication(yaml);
TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());

assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-merged", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-overwrite", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-never", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-not-reinherited", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-merged", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-overwrite", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-never", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-not-reinherited", defaultKV);
}

// Test override defaults in parent entity
Expand All @@ -593,10 +599,10 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {
Entity app = createStartWaitAndLogApplication(yaml);
TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());

assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-merged", ImmutableMap.of("mykey", "myval"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-overwrite", ImmutableMap.of("mykey", "myval"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-never", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-not-reinherited", ImmutableMap.of("mykey", "myval"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-merged", myKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-overwrite", myKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-never", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(entity, "map.type-not-reinherited", myKV);
}

// Test merging/overriding of explicit config
Expand Down Expand Up @@ -649,28 +655,60 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {
" map.type-not-reinherited:",
" mykey: myval",
" brooklyn.children:",
" - type: " + TestEntity.class.getName(),
"- type: entity-with-keys",
" brooklyn.children:",
" - type: " + TestEntity.class.getName());

Entity app = createStartWaitAndLogApplication(yaml);
TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
TestEntity child = (TestEntity) Iterables.getOnlyElement(entity.getChildren());
Iterator<Entity> children = app.getChildren().iterator();
TestEntity entityMyValues = (TestEntity) children.next();
TestEntity childMyValues = (TestEntity) Iterables.getOnlyElement(entityMyValues.getChildren());
TestEntity entityNoValues = (TestEntity) children.next();
TestEntity childNoValues = (TestEntity) Iterables.getOnlyElement(entityNoValues.getChildren());

// Not using `assertConfigEquals(child, ...)`, bacause child.getEntityType().getConfigKey()
// will not find these keys.
//
// TODO Note the different behaviour for "never" and "not-reinherited" keys for if an
// untyped key is used, versus the strongly typed key. We can live with that - I wouldn't
// expect an implementation of TestEntity to try to use such keys that it doesn't know
// about!
assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-merged")), ImmutableMap.of("mykey", "myval"));
assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-overwrite")), ImmutableMap.of("mykey", "myval"));
assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-never")), ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-not-reinherited")), ImmutableMap.of("myDefaultKey", "myDefaultVal"));
// looking first at child with MY values (from runtime mgmt parent)

// using keys from cNV we see the inherited values or if not inherited we don't see the keys
assertEquals(childMyValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-merged")), myKV);
assertEquals(childMyValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-overwrite")), myKV);
assertEquals(childMyValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-never")), null);
assertEquals(childMyValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-not-reinherited")), null);

assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-merged")), ImmutableMap.of("mykey", "myval"));
assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-overwrite")), ImmutableMap.of("mykey", "myval"));
assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-never")), null);
assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-not-reinherited")), null);
// using keys from eNV as originally defined, we get the runtime inherited values or original default values
// the use of non-inherited keys is weird but allows us to assert the right things happen depending which
// keys we use (this of course is also why we don't use `assertConfigEquals(child, ...)`
assertEquals(childMyValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-merged")), myKV);
assertEquals(childMyValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-overwrite")), myKV);
assertEquals(childMyValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-never")), defaultKV);
assertEquals(childMyValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-not-reinherited")), defaultKV);

// if we use eMV keys, the "defaults" we see are the values it has set, since we change defaults (2018-11)
assertEquals(childMyValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-merged")), myKV);
assertEquals(childMyValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-overwrite")), myKV);
assertEquals(childMyValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-never")), myKV);
assertEquals(childMyValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-not-reinherited")), myKV);

// looking at child with NO values

// using keys from cNV we see the default values or if not inherited we don't see the keys
assertEquals(childNoValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-merged")), defaultKV);
assertEquals(childNoValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-overwrite")), defaultKV);
assertEquals(childNoValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-never")), null);
assertEquals(childNoValues.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-not-reinherited")), null);

// using keys from eNV as originally defined, we get the runtime inherited values or original default values
assertEquals(childNoValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-merged")), defaultKV);
assertEquals(childNoValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-overwrite")), defaultKV);
assertEquals(childNoValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-never")), defaultKV);
assertEquals(childNoValues.config().get(entityNoValues.getEntityType().getConfigKey("map.type-not-reinherited")), defaultKV);

// if we use eMV keys, the "defaults" we see are the values it has set, since we change defaults (2018-11)
// (this is a weird one, we wouldn't do this in real life!)
assertEquals(childNoValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-merged")), myKV);
assertEquals(childNoValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-overwrite")), myKV);
assertEquals(childNoValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-never")), myKV);
assertEquals(childNoValues.config().get(entityMyValues.getEntityType().getConfigKey("map.type-not-reinherited")), myKV);
}

// Test inheritance by child with duplicated keys that have no defaults - does it get runtime-management parent's defaults?
Expand All @@ -687,8 +725,8 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {

// Note this merges the default values from the parent and child (i.e. the child's default
// value does not override the parent's.
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-merged", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-overwrite", ImmutableMap.of("myDefaultKey", "myDefaultVal"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-merged", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-overwrite", defaultKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-never", null);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-not-reinherited", null);
}
Expand All @@ -715,8 +753,8 @@ public void testEntityRuntimeInheritanceOptions() throws Exception {
TestEntity child = (TestEntity) Iterables.getOnlyElement(entity.getChildren());


assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-merged", ImmutableMap.of("mykey", "myval"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-overwrite", ImmutableMap.of("mykey", "myval"));
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-merged", myKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-overwrite", myKV);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-never", null);
assertDeclaredKeyAndAnonymousKeyValuesEqual(child, "map.type-not-reinherited", null);
}
Expand All @@ -741,7 +779,7 @@ public void testExtendsSuperTypeConfigSimple() throws Exception {
}

@Test
public void testExtendsSuperTypeConfigMixingLongOverridingShortNames() throws Exception {
public Entity testExtendsSuperTypeConfigMixingLongOverridingShortNames() throws Exception {
ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");

// super-type has env; sub-type shell.env
Expand All @@ -756,8 +794,21 @@ public void testExtendsSuperTypeConfigMixingLongOverridingShortNames() throws Ex
Entity app = createStartWaitAndLogApplication(yaml);
Entity entity = Iterables.getOnlyElement(app.getChildren());
EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.SHELL_ENVIRONMENT, expectedEnv);
return entity;
}


/** EntitySpecs track flags and config separately, with the merge occurring on Entity creation,
* so from the spec alone it is not straightforward to include flags in the determination of the default value.
* Thus default values do _not_ include flags and this test has only the shell.env KV pair in the default
* (so size 1, not size 2 which we want)
*/
@Test(groups="Broken")
public void testDefaultValueWhenExtendingSuperTypeConfigMixingLongOverridingShortNames() throws Exception {
Entity entity = testExtendsSuperTypeConfigMixingLongOverridingShortNames();
ConfigKey<?> key = Iterables.getOnlyElement(entity.config().findKeysDeclared(ConfigPredicates.nameEqualTo(EmptySoftwareProcess.SHELL_ENVIRONMENT.getName())));
Asserts.assertSize((Map<?,?>)key.getDefaultValue(), 2);
}

@Test
public void testExtendsSuperTypeConfigMixingShortOverridingLongName() throws Exception {
ImmutableMap<String, Object> expectedEnv = ImmutableMap.<String, Object>of("ENV1", "myEnv1", "ENV2", "myEnv2");
Expand Down
Loading