[
https://issues.apache.org/jira/browse/BROOKLYN-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15366005#comment-15366005
]
ASF GitHub Bot commented on BROOKLYN-149:
-----------------------------------------
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/236#discussion_r69895917
--- Diff:
camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
---
@@ -85,63 +95,97 @@
REPLACE_CATALOG_WITH_NEWER_VERSION;
}
- @Test
- public void testRebindWithCatalogAndApp() throws Exception {
- runRebindWithCatalogAndApp(RebindWithCatalogTestMode.NO_OP);
- }
+ private Boolean defaultEnablementOfFeatureAutoFixatalogRefOnRebind;
- @Test
- public void testRebindWithCatalogDeprecatedAndAppExisting() throws
Exception {
-
runRebindWithCatalogAndApp(RebindWithCatalogTestMode.DEPRECATE_CATALOG);
+ @BeforeMethod(alwaysRun=true)
+ @Override
+ public void setUp() throws Exception {
+ defaultEnablementOfFeatureAutoFixatalogRefOnRebind =
BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND);
+ super.setUp();
}
- @Test
- public void testRebindWithCatalogDisabledAndAppExisting() throws
Exception {
-
runRebindWithCatalogAndApp(RebindWithCatalogTestMode.DISABLE_CATALOG);
- }
-
- // See https://issues.apache.org/jira/browse/BROOKLYN-149.
- // Deletes the catalog item before rebind, but the referenced types
are still on the
- // default classpath.
- // Will fallback to loading from classpath.
- @Test
- public void testRebindWithCatalogDeletedAndAppExisting() throws
Exception {
-
runRebindWithCatalogAndApp(RebindWithCatalogTestMode.DELETE_CATALOG);
+ @AfterMethod(alwaysRun=true)
+ @Override
+ public void tearDown() throws Exception {
+ if (defaultEnablementOfFeatureAutoFixatalogRefOnRebind != null) {
+
BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND,
defaultEnablementOfFeatureAutoFixatalogRefOnRebind);
+ }
+ super.tearDown();
}
- // Upgrades the catalog item before rebind, deleting the old version.
- // Will automatically upgrade.
- @Test
- public void
testRebindWithCatalogUpgradedWithOldDeletedAndAppExisting() throws Exception {
-
BrooklynFeatureEnablement.enable(BrooklynFeatureEnablement.FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND);
-
runRebindWithCatalogAndApp(RebindWithCatalogTestMode.REPLACE_CATALOG_WITH_NEWER_VERSION);
+ protected boolean useOsgi() {
+ return true;
}
-
- /**
- * Old persisted state for catalog items may not have a "deprecated"
or "disabled"
- * value. Need to check that their absence will default to false.
- */
- @Test
- public void
testRebindWithCatalogPropertiesForDeprecationAndEnablementAbsent() throws
Exception {
-
runRebindWithCatalogAndApp(RebindWithCatalogTestMode.STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM);
+
+ @DataProvider
+ public Object[][] dataProvider() {
+ return new Object[][] {
+ {RebindWithCatalogTestMode.NO_OP, false},
+ {RebindWithCatalogTestMode.NO_OP, true},
+
+
{RebindWithCatalogTestMode.STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM,
false},
+
{RebindWithCatalogTestMode.STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM,
true},
+
+ {RebindWithCatalogTestMode.DEPRECATE_CATALOG, false},
+ {RebindWithCatalogTestMode.DEPRECATE_CATALOG, true},
+
+ {RebindWithCatalogTestMode.DISABLE_CATALOG, false},
+ {RebindWithCatalogTestMode.DISABLE_CATALOG, true},
+
+ // For DELETE_CATALOG, see
https://issues.apache.org/jira/browse/BROOKLYN-149.
+ // Deletes the catalog item before rebind, but the referenced
types are still on the
+ // default classpath. Will fallback to loading from classpath.
+ //
+ // Does not work for OSGi, because our bundle will no longer
be available.
+ {RebindWithCatalogTestMode.DELETE_CATALOG, false},
+
+ // Upgrades the catalog item before rebind, deleting the old
version.
+ // Will automatically upgrade. Test will enable
"FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND"
+ {RebindWithCatalogTestMode.REPLACE_CATALOG_WITH_NEWER_VERSION,
false},
+ {RebindWithCatalogTestMode.REPLACE_CATALOG_WITH_NEWER_VERSION,
true},
+ };
}
- @SuppressWarnings({ "unused", "deprecation" })
- protected void runRebindWithCatalogAndApp(RebindWithCatalogTestMode
mode) throws Exception {
+ @Test(dataProvider = "dataProvider")
+ @SuppressWarnings("deprecation")
+ public void testRebindWithCatalogAndApp(RebindWithCatalogTestMode
mode, boolean useOsgi) throws Exception {
+ if (mode ==
RebindWithCatalogTestMode.REPLACE_CATALOG_WITH_NEWER_VERSION) {
+
BrooklynFeatureEnablement.enable(BrooklynFeatureEnablement.FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND);
+ }
+
String appSymbolicName = "my.catalog.app.id.load";
String appVersion = "0.1.0";
- String appCatalogFormat = Joiner.on("\n").join(
- "brooklyn.catalog:",
- " id: " + appSymbolicName,
- " version: %s",
- " itemType: entity",
- " item:",
- " type: "+ BasicEntity.class.getName(),
- " brooklyn.enrichers:",
- " - type: "+TestEnricher.class.getName(),
- " brooklyn.policies:",
- " - type: "+TestPolicy.class.getName());
+ String appCatalogFormat;
+ if (useOsgi) {
--- End diff --
Add a
`TestResourceUnavailableException.throwIfResourceUnavailable(getClass(),
OSGI_BUNDLE_URL);` for this case
> Rebind failed when entity's catalog item not found
> --------------------------------------------------
>
> Key: BROOKLYN-149
> URL: https://issues.apache.org/jira/browse/BROOKLYN-149
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.7.0
> Reporter: Aled Sage
>
> A customer's Brooklyn instance failed to rebind on restart. The error was:
> {noformat}
> vcompose1476-compose-amp.console-v1.5.3.log:2015-05-15 06:57:12,808 ERROR
> Management node zdJa2A7Y enountered problem during rebind when promoting self
> to master; demoting to FAILED and rethrowing:
> brooklyn.util.exceptions.PropagatedRuntimeException: Failure rebinding, 71
> errors including: problem creating ENTITY Ocs2eaWX of type
> brooklyn.entity.nosql.riak.RiakClusterImpl: Failed to load catalog item
> OJ081XYKT_0=:1.0 required for rebinding.
> oklyn-Allow-Non-Master-Access' to force)
> {noformat}
> The full exception was:
> {noformat}
> 2015-05-15 06:40:31,369 WARN b.e.r.RebindExceptionHandlerImpl
> [brooklyn-execmanager-boo0I83w-0]: No catalog item found with id
> OJ081XYKT_0=:1.0; returning null
> 2015-05-15 06:40:31,395 WARN b.e.r.RebindExceptionHandlerImpl
> [brooklyn-execmanager-boo0I83w-0]: Rebind: continuing after problem creating
> ENTITY Ocs2eaWX of type brooklyn.entity.nosql.riak.RiakClusterImpl
> java.lang.IllegalStateException: Failed to load catalog item OJ081XYKT_0=:1.0
> required for rebinding.
> at
> brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.getLoadingContextFromCatalogItemId(RebindIteration.java:903)
> ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.load(RebindIteration.java:869)
> ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.newEntity(RebindIteration.java:814)
> ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:407)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindIteration.doRun(RebindIteration.java:234)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindIteration.run(RebindIteration.java:260)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:545)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:496)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.entity.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:494)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at
> brooklyn.util.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:469)
> [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751]
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> [na:1.7.0_71]
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [na:1.7.0_71]
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [na:1.7.0_71]
> at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
> {noformat}
> In the persisted state, there is no mention of the catalog item OJ081XYKT_0.
> My assumption is that the customer manually added a catalog item (via the
> web-console), deployed an app (entitled "<snip> riak", of type RiakCluster),
> and then deleted the catalog item (or that "deletion" could have been an
> issue with persistence of catalog items - see
> https://github.com/apache/incubator-brooklyn/pull/555).
> The desired behaviour is that this does not cause the entire Brooklyn
> instance to fail to rebind/start.
> ---
> There are several potential things to investigate/improve:
> * Test (manually, and then perhaps automated tests?):
> * adding a catalog item (via web-console), deploying an app, and
> restarting AMP
> * adding a catalog item (via web-console), deploying an app, deleting the
> catalog item (but not the app), and restarting AMP
> * Investigate what catalog ids are used when adding through the web-console
> (or did they manually choose the name OJ081XYKT_0?)
> * Configurable for whether to continue startup onCreateFailed
> (e.g. web-console pops up with "there was an error..."), but can click
> continue.
> * Broolyn web-console to have a page showing all errors
> * Support "quick fixes" such as deleting the item(s).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)