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/22 14:40:15 UTC
[1/2] brooklyn-server git commit: Test case for resources used by
vanilla software processes
Repository: brooklyn-server
Updated Branches:
refs/heads/master 8f2ccde00 -> 917e10185
Test case for resources used by vanilla software processes
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/cb90e30c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/cb90e30c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/cb90e30c
Branch: refs/heads/master
Commit: cb90e30ce0c677e1cb57ce33c9512683924d0345
Parents: 8cf7bbc
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Fri Apr 22 13:36:29 2016 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri Apr 22 13:36:29 2016 +0100
----------------------------------------------------------------------
.../test/entity/VanillaSoftwareProcessTest.java | 114 +++++++++++++++++++
.../vanilla-software-process-with-resource.yaml | 39 +++++++
.../brooklyn/test/osgi/resources/message.txt | 16 +++
.../osgi/brooklyn-test-osgi-entities.jar | Bin 15301 -> 16091 bytes
4 files changed, 169 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cb90e30c/rest/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/VanillaSoftwareProcessTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/VanillaSoftwareProcessTest.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/VanillaSoftwareProcessTest.java
new file mode 100644
index 0000000..05d63b9
--- /dev/null
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/VanillaSoftwareProcessTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.rest.test.entity;
+
+import static org.apache.brooklyn.test.Asserts.assertNotNull;
+import static org.apache.brooklyn.test.Asserts.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.net.URI;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.location.Machines;
+import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
+import org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncherTestFixture;
+import org.apache.brooklyn.test.support.TestResourceUnavailableException;
+import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.core.task.ssh.SshTasks;
+import org.apache.brooklyn.util.http.HttpAsserts;
+import org.apache.brooklyn.util.http.HttpToolResponse;
+import org.apache.brooklyn.util.os.Os;
+import org.eclipse.jetty.server.Server;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class VanillaSoftwareProcessTest extends BrooklynRestApiLauncherTestFixture {
+
+ Server server;
+
+ @BeforeMethod(alwaysRun=true)
+ public void setUp() throws Exception {
+ server = newServer();
+ useServerForTest(server);
+ }
+
+ @Test(groups = "Integration")
+ public void testVanillaSoftwareProcessCanUseResourcesInBundles() throws Exception {
+ try {
+ new ResourceUtils(this).getResourceAsString("classpath://org/apache/brooklyn/test/osgi/resources/message.txt");
+ fail("classpath://org/apache/brooklyn/test/osgi/resources/message.txt should not be on classpath");
+ } catch (Exception e) {/* expected */}
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/brooklyn/osgi/brooklyn-test-osgi-entities.jar");
+
+ final String catalogItemUrl = "classpath://vanilla-software-process-with-resource.yaml";
+ final String catalogYaml = ResourceUtils.create(this)
+ .getResourceAsString(catalogItemUrl);
+
+ final URI webConsoleUri = URI.create(getBaseUriRest(server));
+
+ // Test setup
+ final EntitySpec<BrooklynNode> spec = EntitySpec.create(BrooklynNode.class);
+ final ManagementContext mgmt = getManagementContextFromJettyServerAttributes(server);
+ final BrooklynNode node = mgmt.getEntityManager().createEntity(spec);
+ node.sensors().set(BrooklynNode.WEB_CONSOLE_URI, webConsoleUri);
+
+ // Add catalogue item.
+ HttpToolResponse response = node.http().post(
+ "/catalog",
+ ImmutableMap.<String, String>of(),
+ catalogYaml.getBytes());
+ HttpAsserts.assertHealthyStatusCode(response.getResponseCode());
+
+ // Deploy it.
+ final String blueprint = "location: localhost\n" +
+ "services:\n" +
+ "- type: vanilla-software-resource-test:1.0";
+ response = node.http().post(
+ "/applications",
+ ImmutableMap.of("Content-Type", "text/yaml"),
+ blueprint.getBytes());
+ HttpAsserts.assertHealthyStatusCode(response.getResponseCode());
+
+ // Assert application is eventually running and not on fire.
+ final Entity vanilla = mgmt.getApplications().iterator().next().getChildren().iterator().next();
+ assertTrue(vanilla instanceof VanillaSoftwareProcess,
+ "expected " + VanillaSoftwareProcess.class.getName() + ", found: " + vanilla);
+ EntityAsserts.assertAttributeEqualsEventually(vanilla, SoftwareProcess.SERVICE_UP, true);
+
+ // And check that the message was copied to rundir.
+ SshMachineLocation machine = Machines.findUniqueMachineLocation(vanilla.getLocations(), SshMachineLocation.class).get();
+ String file = Os.mergePaths(vanilla.sensors().get(SoftwareProcess.RUN_DIR), "message.txt");
+ String message = Entities.submit(vanilla, SshTasks.newSshFetchTaskFactory(machine, file).newTask()).get();
+ assertNotNull(message);
+ assertTrue(message.startsWith("Licensed to the Apache Software Foundation"),
+ "expected ASF license header, found: " + message);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cb90e30c/rest/rest-server/src/test/resources/vanilla-software-process-with-resource.yaml
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/resources/vanilla-software-process-with-resource.yaml b/rest/rest-server/src/test/resources/vanilla-software-process-with-resource.yaml
new file mode 100644
index 0000000..c0ce54f
--- /dev/null
+++ b/rest/rest-server/src/test/resources/vanilla-software-process-with-resource.yaml
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+# A test case that demonstrates vanilla software processes can
+# reference items in their libraries.
+
+brooklyn.catalog:
+ id: vanilla-software-resource-test
+ version: 1.0
+ item:
+ services:
+ - type: org.apache.brooklyn.entity.stock.BasicApplication
+ brooklyn.children:
+ - type: java:org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+ brooklyn.config:
+ launch.command: true
+ checkRunning.command: true
+ # Contained in library jar.
+ runtimeFiles:
+ classpath://org/apache/brooklyn/test/osgi/resources/message.txt: message.txt
+
+ libraries:
+ - classpath://brooklyn/osgi/brooklyn-test-osgi-entities.jar
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cb90e30c/utils/common/dependencies/osgi/entities/src/main/resources/org/apache/brooklyn/test/osgi/resources/message.txt
----------------------------------------------------------------------
diff --git a/utils/common/dependencies/osgi/entities/src/main/resources/org/apache/brooklyn/test/osgi/resources/message.txt b/utils/common/dependencies/osgi/entities/src/main/resources/org/apache/brooklyn/test/osgi/resources/message.txt
new file mode 100644
index 0000000..c99a620
--- /dev/null
+++ b/utils/common/dependencies/osgi/entities/src/main/resources/org/apache/brooklyn/test/osgi/resources/message.txt
@@ -0,0 +1,16 @@
+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.
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cb90e30c/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.jar
----------------------------------------------------------------------
diff --git a/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.jar b/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.jar
index 5470401..807e855 100644
Binary files a/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.jar and b/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.jar differ
[2/2] brooklyn-server git commit: Closes #122
Posted by sv...@apache.org.
Closes #122
Test case for resources used by vanilla software processes
@neykov Here's the test case for resources used by `VanillaSoftwareProcesses`.
@rdowner The blueprint in this pull request would be a good entry in an FAQ. Would be useful to talk to you about how to get it there.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/917e1018
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/917e1018
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/917e1018
Branch: refs/heads/master
Commit: 917e101858b00477a7a1832c3fa01cc1604a9259
Parents: 8f2ccde cb90e30
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Apr 22 13:40:10 2016 +0100
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Apr 22 13:40:10 2016 +0100
----------------------------------------------------------------------
.../test/entity/VanillaSoftwareProcessTest.java | 114 +++++++++++++++++++
.../vanilla-software-process-with-resource.yaml | 39 +++++++
.../brooklyn/test/osgi/resources/message.txt | 16 +++
.../osgi/brooklyn-test-osgi-entities.jar | Bin 15301 -> 16091 bytes
4 files changed, 169 insertions(+)
----------------------------------------------------------------------