You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/04/25 18:24:17 UTC
[1/2] brooklyn-server git commit: Add reading of default.catalog.bom.
Repository: brooklyn-server
Updated Branches:
refs/heads/master 917e10185 -> 5a4f313fe
Add reading of default.catalog.bom.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/a40fc785
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/a40fc785
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/a40fc785
Branch: refs/heads/master
Commit: a40fc785f1b82fb2448afe9bbcae87a60b91d8aa
Parents: bc0362b
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Thu Apr 21 14:06:54 2016 +0100
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Fri Apr 22 15:26:25 2016 +0100
----------------------------------------------------------------------
.../src/main/resources/etc/default.catalog.bom | 54 ++++++++++++++
.../brooklyn/launcher/osgi/OsgiLauncher.java | 3 +
.../catalog/internal/CatalogBomScannerTest.java | 54 +++++++-------
.../catalog/internal/DefaultBomLoadTest.java | 76 ++++++++++++++++++++
software/base/src/main/resources/catalog.bom | 34 ---------
5 files changed, 160 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a40fc785/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
----------------------------------------------------------------------
diff --git a/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom b/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
new file mode 100644
index 0000000..4cc4522
--- /dev/null
+++ b/karaf/apache-brooklyn/src/main/resources/etc/default.catalog.bom
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+brooklyn.catalog:
+ version: 0.10.0-SNAPSHOT # BROOKLYN_VERSION
+ items:
+ - id: server-template
+ itemType: template
+ name: "Template: Server"
+ description: |
+ Sample YAML to provision a server in a cloud with illustrative VM properties
+ item:
+ name: Server (Brooklyn Example)
+
+ # this basic example shows how Brooklyn can provision a single raw VM
+ # in the cloud or location of your choice
+
+ services:
+ - type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
+ name: My VM
+
+ # location can be e.g. `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`,
+ # or `localhost` or `byon:(hosts="10.9.1.1,10.9.1.2,produser2@10.9.2.{10,11,20-29}")`
+ location:
+ jclouds:aws-ec2:
+ # edit these to use your credential (or delete if credentials specified in brooklyn.properties)
+ identity: <REPLACE>
+ credential: <REPLACE>
+
+ region: eu-central-1
+
+ # we want Ubuntu, with a lot of RAM
+ osFamily: ubuntu
+ minRam: 8gb
+
+ # set up this user and password (default is to authorize a public key)
+ user: sample
+ password: s4mpl3
+
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a40fc785/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
----------------------------------------------------------------------
diff --git a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
index 03a1a2d..cf810ce 100644
--- a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
+++ b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
@@ -20,6 +20,7 @@ import javax.annotation.Nullable;
import org.apache.brooklyn.api.mgmt.ManagementContext;
import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
import org.apache.brooklyn.core.BrooklynVersionService;
+import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
import org.apache.brooklyn.core.internal.BrooklynProperties;
import org.apache.brooklyn.core.mgmt.persist.PersistMode;
import org.apache.brooklyn.launcher.common.BasicLauncher;
@@ -38,6 +39,7 @@ import org.slf4j.LoggerFactory;
public class OsgiLauncher extends BasicLauncher<OsgiLauncher> {
private static final Logger LOG = LoggerFactory.getLogger(OsgiLauncher.class);
+ private static final String DEFAULT_CATALOG_BOM = "file:etc/default.catalog.bom";
private BrooklynVersionService brooklynVersion;
@@ -52,6 +54,7 @@ public class OsgiLauncher extends BasicLauncher<OsgiLauncher> {
// Called by blueprint container
// init-method can't find the start method for some reason, provide an alternative
public void init() {
+ catalogInitialization(new CatalogInitialization(DEFAULT_CATALOG_BOM, false, null, false));
start();
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a40fc785/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScannerTest.java
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScannerTest.java b/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScannerTest.java
index 137ede4..baf92f4 100644
--- a/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScannerTest.java
+++ b/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScannerTest.java
@@ -33,10 +33,7 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -83,26 +80,11 @@ public class CatalogBomScannerTest {
@Configuration
public static Option[] configuration() throws Exception {
return defaultOptionsWith(
- logLevel(LogLevelOption.LogLevel.DEBUG),
- editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.logger.org.apache.brooklyn", "DEBUG"),
- keepRuntimeFolder()
// Uncomment this for remote debugging the tests on port 5005
// , KarafDistributionOption.debugConfiguration()
);
}
-
- @Test
- @Category(IntegrationTest.class)
- public void shouldFindBrooklynSoftwareBaseCatalogExampleServer() throws Exception {
- final CatalogItem<?, ?> catalogItem = managementContext.getCatalog()
- .getCatalogItem("server-template", BrooklynVersion.get()); // from brooklyn-software-base catalog.bom
- assertNotNull(catalogItem);
- assertEquals("Template: Server", catalogItem.getDisplayName());
- }
-
-
-
@Test
@Category(IntegrationTest.class)
public void shouldFindWebAppCatalogExampleOnlyAfterItsFeatureIsInstalled() throws Exception {
@@ -123,8 +105,6 @@ public class CatalogBomScannerTest {
});
}
-
-
@Test
@Category(IntegrationTest.class)
public void shouldNotFindNoSqlCatalogExampleIfItIsBlacklisted() throws Exception {
@@ -152,18 +132,38 @@ public class CatalogBomScannerTest {
featuresService.installFeature("brooklyn-software-nosql", BrooklynVersion.get());
// verify that the non-template entity org.apache.brooklyn.entity.nosql.redis.RedisStore gets added to catalog
+ verifyCatalogItemEventually(redisStore, true);
+
+ // verify that the template application hasn't made it into the catalog (because it's blacklisted)
+ catalogItem = getCatalogItem(riakTemplate);
+ assertNull(catalogItem);
+
+ // For completeness let's uninstall the bundle, un-blacklist nosql, and install again
+ featuresService.uninstallFeature("brooklyn-software-nosql", BrooklynVersion.get());
+
+ // verify it's gone away
+ verifyCatalogItemEventually(redisStore, false);
+
+ // un-blacklist nosql
+ bomProps.put("blackList", "");
+ bomScannerConfig.update(bomProps);
+
+ // install it again
+ featuresService.installFeature("brooklyn-software-nosql", BrooklynVersion.get());
+
+ // now the application should make it into the catalog
+ verifyCatalogItemEventually(redisStore, true);
+
+ }
+
+ private void verifyCatalogItemEventually(final String redisStore, final boolean isItThere) {
Asserts.succeedsEventually(MutableMap.of("timeout", Duration.TEN_SECONDS), new Runnable() {
@Override
public void run() {
- final CatalogItem<?, ?> redis = managementContext.getCatalog()
- .getCatalogItem(redisStore, BrooklynVersion.get());
- assertNotNull(redis);
+ final CatalogItem<?, ?> redis = getCatalogItem(redisStore);
+ assertEquals(null != redis, isItThere);
}
});
-
- // verify that the template application hasn't made it into the catalog (because it's blacklisted)
- catalogItem = getCatalogItem(riakTemplate);
- assertNull(catalogItem);
}
private CatalogItem<?, ?> getCatalogItem(String itemName) {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a40fc785/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/DefaultBomLoadTest.java
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/DefaultBomLoadTest.java b/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/DefaultBomLoadTest.java
new file mode 100644
index 0000000..13c008e
--- /dev/null
+++ b/karaf/itest/src/test/java/org/apache/brooklyn/core/catalog/internal/DefaultBomLoadTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.catalog.internal;
+
+
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.BrooklynVersion;
+import org.apache.brooklyn.test.IntegrationTest;
+import org.apache.karaf.features.BootFinished;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.exam.util.Filter;
+
+import javax.inject.Inject;
+
+import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+@Category(IntegrationTest.class)
+public class DefaultBomLoadTest {
+
+ /**
+ * To make sure the tests run only when the boot features are fully installed
+ */
+ @Inject
+ @Filter(timeout = 120000)
+ BootFinished bootFinished;
+
+ @Inject
+ protected ManagementContext managementContext;
+
+
+ @Configuration
+ public static Option[] configuration() throws Exception {
+ return defaultOptionsWith(
+ // Uncomment this for remote debugging the tests on port 5005
+// , KarafDistributionOption.debugConfiguration()
+ );
+ }
+
+
+ @Test
+ @Category(IntegrationTest.class)
+ public void shouldHaveLoadedDefaultCatalogBom() throws Exception {
+ final CatalogItem<?, ?> catalogItem = managementContext.getCatalog()
+ .getCatalogItem("server-template", BrooklynVersion.get()); // from brooklyn-software-base catalog.bom
+ assertNotNull(catalogItem);
+ assertEquals("Template: Server", catalogItem.getDisplayName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a40fc785/software/base/src/main/resources/catalog.bom
----------------------------------------------------------------------
diff --git a/software/base/src/main/resources/catalog.bom b/software/base/src/main/resources/catalog.bom
index 3dbbaa4..39367eb 100644
--- a/software/base/src/main/resources/catalog.bom
+++ b/software/base/src/main/resources/catalog.bom
@@ -70,40 +70,6 @@ brooklyn.catalog:
name: Server Pool
description: Creates a pre-allocated server pool, which other applications can deploy to
- - id: server-template
- itemType: template
- name: "Template: Server"
- description: |
- Sample YAML to provision a server in a cloud with illustrative VM properties
- item:
- name: Server (Brooklyn Example)
-
- # this basic example shows how Brooklyn can provision a single raw VM
- # in the cloud or location of your choice
-
- services:
- - type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
- name: My VM
-
- # location can be e.g. `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`,
- # or `localhost` or `byon:(hosts="10.9.1.1,10.9.1.2,produser2@10.9.2.{10,11,20-29}")`
- location:
- jclouds:aws-ec2:
- # edit these to use your credential (or delete if credentials specified in brooklyn.properties)
- identity: <REPLACE>
- credential: <REPLACE>
-
- region: eu-central-1
-
- # we want Ubuntu, with a lot of RAM
- osFamily: ubuntu
- minRam: 8gb
-
- # set up this user and password (default is to authorize a public key)
- user: sample
- password: s4mpl3
-
-
- id: bash-web-server-template
itemType: template
name: "Template: Bash Web Server"
[2/2] brooklyn-server git commit: Closes #120
Posted by sv...@apache.org.
Closes #120
Add reading of default.catalog.bom.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/5a4f313f
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/5a4f313f
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/5a4f313f
Branch: refs/heads/master
Commit: 5a4f313fe2715c36fa9e180ec7976b0a52efedad
Parents: 917e101 a40fc78
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Mon Apr 25 19:24:07 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Mon Apr 25 19:24:07 2016 +0300
----------------------------------------------------------------------
.../src/main/resources/etc/default.catalog.bom | 54 ++++++++++++++
.../brooklyn/launcher/osgi/OsgiLauncher.java | 3 +
.../catalog/internal/CatalogBomScannerTest.java | 54 +++++++-------
.../catalog/internal/DefaultBomLoadTest.java | 76 ++++++++++++++++++++
software/base/src/main/resources/catalog.bom | 34 ---------
5 files changed, 160 insertions(+), 61 deletions(-)
----------------------------------------------------------------------