Skip to content

Commit

Permalink
Open liberty tests (#249)
Browse files Browse the repository at this point in the history
* adding open liberty testing

* updating test

* checking for property

* updating tests, ymls, and docs

* changing property file names

* fixing test file

* removed online/offlne logic and added review changes

* removing java7 from the travis tests
  • Loading branch information
mattbsox authored Apr 23, 2018
1 parent 87ff881 commit 570dc7b
Show file tree
Hide file tree
Showing 92 changed files with 349 additions and 579 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
sudo: required
language: java
matrix:
include:
- jdk: openjdk8
env: WLP_VERSION=17.0.0.3
- jdk: openjdk8
env: WLP_VERSION=17.0.0.4
jdk:
- openjdk8
env:
- propertiesFile=wlp1.properties
- propertiesFile=wlp2.properties
- propertiesFile=ol1.properties
- propertiesFile=ol2.properties
script:
- export GRADLE_OPTS="-Dorg.gradle.daemon=true -Dorg.gradle.jvmargs='-XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m'"
- travis_wait ./gradlew install check -Prunit=online -DwlpVersion=$WLP_VERSION --stacktrace --info --no-daemon
- travis_wait ./gradlew install integrationTest -DpropertiesFile=${propertiesFile} --stacktrace --info --no-daemon
dist: trusty
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ Clone this repository and then, with a JRE on the path, execute the following co
$ ./gradlew build
```

This will download Gradle and then build the plugin `liberty-gradle-plugin-2.0.jar` in to the `build\libs` directory. It is also possible to install the plugin in to your local Maven repository using `gradlew install`.
This will download Gradle and then build the plugin `liberty-gradle-plugin-2.3-SNAPSHOT.jar` in to the `build\libs` directory. It is also possible to install the plugin in to your local Maven repository using `./gradlew install`.

To build the plugin and run the integration tests execute the following commands in the root directory.
To build the plugin and run the integration tests execute the following commands in the root directory. The `propertiesFile` parameter is used to select the Liberty runtime that will be used to run the tests. The `wlpLicense` parameter is only needed for Liberty packaged as a JAR file.

1. To run the integration tests using an existing Liberty server installation.
```bash
$ ./gradlew build -Prunit=offline -DwlpInstallDir=<liberty_install_directory>
```

2. To run the integration tests against an automatically downloaded and installed Liberty server. The `wlpLicense` parameter is only needed for Liberty packaged as a JAR file.
```bash
$ ./gradlew build -Prunit=online -DwlpLicense=<liberty_licesnse_code> -DwlpVersion=<liberty_version>
$ ./gradlew install integrationTest -DpropertiesFile=<property_file_name> -DwlpLicense=<liberty_license_code>
```

## Usage
Expand Down Expand Up @@ -104,4 +98,4 @@ Extensions are tasks that improve the compatibility or user experience of third

| Extension | Description |
| --------- | ------------ |
| [configureArquillian](docs/configureArquillian.md) | Integrates `arquillian.xml` configuration for the Liberty Managed and Remote Arquillian containers in the `liberty-gradle-plugin`. Automatically configures required `arquillian.xml` parameters for the Liberty Managed container. |
| [configureArquillian](docs/configureArquillian.md) | Integrates `arquillian.xml` configuration for the Liberty Managed and Remote Arquillian containers in the `liberty-gradle-plugin`. Automatically configures required `arquillian.xml` parameters for the Liberty Managed container. |
11 changes: 9 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
environment:
matrix:
matrix:
- jdk: "C:\\Program Files\\Java\\jdk1.8.0\\bin:"
PROPERTIES_FILE: wlp1.properties
- jdk: "C:\\Program Files\\Java\\jdk1.8.0\\bin:"
PROPERTIES_FILE: wlp2.properties
- jdk: "C:\\Program Files\\Java\\jdk1.8.0\\bin:"
PROPERTIES_FILE: ol1.properties
- jdk: "C:\\Program Files\\Java\\jdk1.8.0\\bin:"
PROPERTIES_FILE: ol2.properties

build_script:
# Build the compiled extension
- "gradlew.bat install check -Prunit=online -DwlpVersion=17.0.0.3 --stacktrace --info --no-daemon"
- "gradlew.bat install integrationTest -DpropertiesFile=%PROPERTIES_FILE% --stacktrace --info --no-daemon"

test: off
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ compileTestGroovy {
dependencies {
compile gradleApi()
compile localGroovy()
compile ('net.wasdev.wlp.ant:wlp-anttasks:1.3')
compile ('net.wasdev.wlp.ant:wlp-anttasks:1.4.1')
compile ('net.wasdev.wlp.common:ci.common:1.0')
compile group: 'commons-io', name: 'commons-io', version: '2.5'
provided group: 'com.ibm.websphere.appserver.api', name: 'com.ibm.websphere.appserver.spi.kernel.embeddable', version: '1.0.0'
Expand Down Expand Up @@ -79,12 +79,16 @@ task integrationTest(type: Test) {
classpath = sourceSets.integrationTest.runtimeClasspath

systemProperties System.getProperties()
systemProperty 'runit', project.getProperty('runit')
systemProperty 'runit', 'online'

mustRunAfter test
String libertyPropertiesFile = System.getProperty('propertiesFile')
doFirst {
if (libertyPropertiesFile == null || libertyPropertiesFile.isEmpty()) {
throw new GradleException('Tests could not be run. Please specify a properties file.')
}
}
}

check.dependsOn integrationTest
sourceSets.main.compileClasspath += configurations.provided

task wrapper(type: Wrapper) {
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corporation 2015, 2017.
* (C) Copyright IBM Corporation 2015, 2018.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,21 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.wasdev.wlp.gradle.plugins

import java.io.File

import static org.junit.Assert.*

import org.apache.commons.io.FileUtils
import org.gradle.tooling.BuildLauncher
import org.gradle.tooling.GradleConnector
import org.gradle.tooling.ProjectConnection
import java.io.File

import org.gradle.api.GradleException

abstract class AbstractIntegrationTest {

public static final String LIBERTY_PROPERTIES_FILENAME_1 = 'wlp1.properties'
public static final String LIBERTY_PROPERTIES_FILENAME_2 = 'wlp2.properties'
public static final String OPEN_LIBERTY_PROPERTIES_FILENAME_1 = 'ol1.properties'
public static final String OPEN_LIBERTY_PROPERTIES_FILENAME_2 = 'ol2.properties'

public static final String PROPERTY_FILE_DIRECTORY = "src/integTest/properties"

static File integTestDir = new File('build/testBuilds')
static final String test_mode = System.getProperty("runit")
static String WLP_DIR = System.getProperty("wlpInstallDir")
static String libertyProperties = System.getProperty("propertiesFile")

protected static void deleteDir(File dir) {
if (dir.exists()) {
Expand All @@ -46,8 +55,31 @@ abstract class AbstractIntegrationTest {
}

protected static File copyBuildFiles(File buildFilename, File buildDir) {
copyFile(buildFilename, new File(buildDir, 'build.gradle'))
copyFile(new File("gradle.properties"), new File(buildDir, 'gradle.properties'))
copyFile(buildFilename, new File(buildDir, 'build.gradle'))
copyPropertyFile(buildDir)
}

protected static void copyPropertyFile(File buildDir) {
File propertyFile
if (libertyProperties != null) {
switch (libertyProperties) {
case LIBERTY_PROPERTIES_FILENAME_2:
propertyFile = new File(PROPERTY_FILE_DIRECTORY, LIBERTY_PROPERTIES_FILENAME_2)
break;
case OPEN_LIBERTY_PROPERTIES_FILENAME_1:
propertyFile = new File(PROPERTY_FILE_DIRECTORY, OPEN_LIBERTY_PROPERTIES_FILENAME_1)
break;
case OPEN_LIBERTY_PROPERTIES_FILENAME_2:
propertyFile = new File(PROPERTY_FILE_DIRECTORY, OPEN_LIBERTY_PROPERTIES_FILENAME_2)
break;
default:
propertyFile = new File(PROPERTY_FILE_DIRECTORY, LIBERTY_PROPERTIES_FILENAME_1)
break;
}
} else {
throw new GradleException('Tests could not be run. Please specify a properties file.')
}
copyFile(propertyFile, new File(buildDir, 'gradle.properties'))
}

protected static File createTestProject(File parent, File sourceDir, String buildFilename) {
Expand Down Expand Up @@ -81,7 +113,6 @@ abstract class AbstractIntegrationTest {

try {
BuildLauncher build = connection.newBuild()
build.setJvmArguments("-DWLP_DIR=$WLP_DIR")
build.withArguments("-i");
build.forTasks(tasks)
build.run()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* (C) Copyright IBM Corporation 2017, 2018.
*
* Licensed 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 net.wasdev.wlp.gradle.plugins;

import java.io.File
Expand All @@ -24,7 +40,7 @@ class ConfigureArquillianTest extends AbstractIntegrationTest {
public static void setup() {
createDir(buildDir)
FileUtils.copyDirectory(resourceDir, buildDir);
copyFile(new File("gradle.properties"), new File(buildDir, 'gradle.properties'))
copyPropertyFile(buildDir)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class InstallFeature_acceptLicense extends AbstractIntegrationTest{
@BeforeClass
public static void setup() {
createDir(buildDir)
if (test_mode == "offline"){
WLP_DIR.replace("\\","/")
}
createTestProject(buildDir, resourceDir, buildFilename)
try {
runTasks(buildDir, 'libertyCreate')
Expand All @@ -49,12 +46,10 @@ class InstallFeature_acceptLicense extends AbstractIntegrationTest{
def file_2 = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.adminCenter-1.0.mf")
runTasks(buildDir, 'installFeature')

if (test_mode == "online") {
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
assert file_2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
assert file_2.canRead() : "com.ibm.websphere.appserver.adminCenter-1.0.mf cannot be read"
}
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
assert file_2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
assert file_2.canRead() : "com.ibm.websphere.appserver.adminCenter-1.0.mf cannot be read"
} catch (Exception e) {
throw new AssertionError ("Fail on task installFeature. "+e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class InstallFeature_multiple extends AbstractIntegrationTest{
@BeforeClass
public static void setup() {
createDir(buildDir)
if (test_mode == "offline"){
WLP_DIR.replace("\\","/")
}
copyBuildFiles(buildFilename, buildDir)
}

Expand All @@ -44,12 +41,10 @@ class InstallFeature_multiple extends AbstractIntegrationTest{
def file_2 = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.adminCenter-1.0.mf")
runTasks(buildDir, 'installFeature')

if (test_mode == "online") {
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
assert file_2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
assert file_2.canRead() : "com.ibm.websphere.appserver.adminCenter-1.0.mf cannot be read"
}
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
assert file_2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
assert file_2.canRead() : "com.ibm.websphere.appserver.adminCenter-1.0.mf cannot be read"
} catch (Exception e) {
throw new AssertionError ("Fail on task installFeature. "+e)
}
Expand All @@ -62,10 +57,8 @@ class InstallFeature_multiple extends AbstractIntegrationTest{
def file2 = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.adminCenter-1.0.mf")
runTasks(buildDir, 'uninstallFeature')

if (test_mode == "online") {
assert !file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not uninstalled"
assert !file2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
}
assert !file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not uninstalled"
assert !file2.exists() : "com.ibm.websphere.appserver.adminCenter-1.0.mf is not installed"
} catch (Exception e) {
throw new AssertionError ("Fail on task uninstallFeature. "+e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class InstallFeature_single extends AbstractIntegrationTest{
@BeforeClass
public static void setup() {
createDir(buildDir)
if (test_mode == "offline"){
WLP_DIR.replace("\\","/")
}
copyBuildFiles(buildFilename, buildDir)
}

Expand All @@ -43,10 +40,8 @@ class InstallFeature_single extends AbstractIntegrationTest{
def file = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.mongodb-2.0.mf")
runTasks(buildDir, 'installFeature')

if (test_mode == "online") {
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
}
assert file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not installed"
assert file.canRead() : "com.ibm.websphere.appserver.mongodb-2.0.mf cannot be read"
} catch (Exception e) {
throw new AssertionError ("Fail on task installFeature. "+e)
}
Expand All @@ -58,9 +53,7 @@ class InstallFeature_single extends AbstractIntegrationTest{
def file = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.mongodb-2.0.mf")
runTasks(buildDir, 'uninstallFeature')

if (test_mode == "online") {
assert !file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not uninstalled"
}
assert !file.exists() : "com.ibm.websphere.appserver.mongodb-2.0.mf is not uninstalled"
} catch (Exception e) {
throw new AssertionError ("Fail on task uninstallFeature. "+e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,22 @@ class InstallLiberty_javaee7 extends AbstractIntegrationTest{
@BeforeClass
public static void setup() {
createDir(buildDir)
if(test_mode == "offline"){
WLP_DIR.replace("\\","/")
createTestProject(buildDir, resourceDir, buildFilename)
}else if(test_mode == "online"){
createTestProject(buildDir, resourceDir, buildFilename)
try {
runTasks(buildDir, 'installLiberty')
} catch (Exception e) {
throw new AssertionError ("Fail on task installLiberty. "+ e)
}
createTestProject(buildDir, resourceDir, buildFilename)
try {
runTasks(buildDir, 'installLiberty')
} catch (Exception e) {
throw new AssertionError ("Fail on task installLiberty. "+ e)
}
}

@Test
public void test_installLiberty_javaee7() {
try {
def file = new File(buildDir, "build/wlp/lib/features/com.ibm.websphere.appserver.javaee-7.0.mf")

if (test_mode == "online") {
assert file.exists() : "file not found"
assert file.canRead() : "file cannot be read"
} else {
logger.debug "Skipping test_installLiberty_javaee7 in offline test mode"
}
assert file.exists() : "file not found"
assert file.canRead() : "file cannot be read"
} catch (Exception e) {
throw new AssertionError ("Fail on task installLiberty. "+e)
}
}
}

Loading

0 comments on commit 570dc7b

Please sign in to comment.