Skip to content

Commit

Permalink
Add qa module
Browse files Browse the repository at this point in the history
Remove AlienSamplesLiveTest in its favour
  • Loading branch information
Sam Corbett committed Feb 9, 2016
1 parent 9913bff commit cc6c99a
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 112 deletions.

This file was deleted.

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<module>brooklyn-tosca-common</module>
<module>brooklyn-tosca-transformer</module>
<module>brooklyn-tosca-dist</module>
<module>qa</module>
</modules>

<properties>
Expand Down
156 changes: 156 additions & 0 deletions qa/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.cloudsoft.brooklyn.tosca</groupId>
<artifactId>brooklyn-tosca-parent</artifactId>
<version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_TOSCA_VERSION -->
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>brooklyn-tosca-qa</artifactId>
<packaging>jar</packaging>

<name>Brooklyn TOSCA QA tests</name>
<description>Whole-platform tests for Brooklyn TOSCA</description>

<properties>
<!-- A4C samples rely on Ubuntu/Debian machines -->
<locationSpec>jclouds:aws-ec2:us-east-1</locationSpec>
</properties>

<dependencies>
<!-- Implicitly reuses configuration for Alien4Cloud and elasticsearch -->
<dependency>
<groupId>io.cloudsoft.brooklyn.tosca</groupId>
<artifactId>brooklyn-tosca-transformer</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cloudsoft.brooklyn.tosca</groupId>
<artifactId>brooklyn-tosca-transformer</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-all</artifactId>
<version>${brooklyn.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-rest-api</artifactId>
<version>${brooklyn.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-rest-client</artifactId>
<version>${brooklyn.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-core</artifactId>
<version>${brooklyn.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*AcceptanceTest.java</exclude>
<exclude>**/*QATest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>run-local</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>io.brooklyn.maven</groupId>
<artifactId>brooklyn-maven-plugin</artifactId>
<version>0.3.0-SNAPSHOT</version>
<executions>
<execution>
<id>Run Brooklyn</id>
<goals>
<goal>start-server</goal>
<goal>stop-server</goal>
</goals>
<configuration>
<mainClass>io.cloudsoft.tosca.a4c.brooklyn.cli.BrooklynToscaMain</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>qa</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- Set by start-server goal -->
<server>${brooklyn.server}</server>
</systemPropertyVariables>
<includes>
<include>**/*AcceptanceTest.java</include>
<include>**/*QATest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

81 changes: 81 additions & 0 deletions qa/src/test/java/io/tosca/AlienSamplesAcceptanceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package io.tosca;

import java.util.concurrent.TimeUnit;

import org.apache.brooklyn.rest.client.BrooklynApi;
import org.apache.brooklyn.rest.client.BrooklynApiUtil;
import org.apache.brooklyn.rest.domain.TaskSummary;
import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.text.Strings;
import org.apache.brooklyn.util.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class AlienSamplesAcceptanceTest {

private static final Logger LOG = LoggerFactory.getLogger(AlienSamplesAcceptanceTest.class);
private static final Duration TEST_TIMEOUT = Duration.of(15, TimeUnit.MINUTES);

private BrooklynApi api;
private String singleTestBlueprint;

@BeforeClass(alwaysRun = true)
@Parameters({"server", "username", "password", "testBlueprint"})
public void setServer(String server, @Optional String username, @Optional String password,
@Optional String testBlueprint) {
if (Strings.isBlank(server)) {
throw new AssertionError("URL required for server");
}
if (!Strings.isBlank(username) && !Strings.isBlank(password)) {
this.api = BrooklynApi.newInstance(server, username, password);
} else {
this.api = BrooklynApi.newInstance(server);
}
this.singleTestBlueprint = testBlueprint;
}

@DataProvider
public Object[][] testGenerator() {
if (!Strings.isBlank(singleTestBlueprint)) {
return new Object[][]{{this.singleTestBlueprint}};
}
return new Object[][]{
new Object[]{"classpath://projects/apache-topology.tosca.yaml"},
// FIXME: Relies on artifact environment variables. Renable when RuntimeEnvironmentModifier is fixed.
// new Object[]{"classpath://projects/mysql-topology.tosca.yaml"},
new Object[]{"classpath://projects/php-topology.tosca.yaml"},
};
}

@Test(dataProvider = "testGenerator")
public void testBlueprint(String resource) throws Exception {
String testCaseYaml = loadBlueprint(resource);
String application = null;
try {
TaskSummary task = BrooklynApiUtil.deployBlueprint(api, testCaseYaml);
application = task.getEntityId();
BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, application, task.getId());
} catch (Exception e) {
throw new AssertionError("Error running application", e);
} finally {
if (application != null) {
LOG.info("Stopping application " + application);
BrooklynApiUtil.attemptStop(api, application, getTimeout());
}
}
}

private String loadBlueprint(String resource) {
return new ResourceUtils(null).getResourceAsString(resource);
}

private Duration getTimeout() {
return TEST_TIMEOUT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ topology_template:
protocol: tcp
initiator: source
network_name: PRIVATE
secure: true
secure: true

groups:
add_brooklyn_location:
members: [ Compute ]
policies:
- brooklyn.location: ${locationSpec}
Loading

0 comments on commit cc6c99a

Please sign in to comment.