Skip to content

Commit

Permalink
Merge pull request #136 from OpenLiberty/qa
Browse files Browse the repository at this point in the history
Merge qa to master: add daily build GH action
  • Loading branch information
gkwan-ibm authored Jan 8, 2021
2 parents 1c42e21 + 748af58 commit 1963d54
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 84 deletions.
45 changes: 21 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This workflow will test the guide application.
# For more information about building and testing Java,
# see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Test application

on:
Expand All @@ -27,6 +23,7 @@ jobs:
echo "Need to run test"
echo "::set-output name=canSkip::false"
fi
java8build:
runs-on: ubuntu-latest
needs: [needTest]
Expand All @@ -36,25 +33,25 @@ jobs:
working-directory: finish

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- run: unset _JAVA_OPTIONS
- name: Run tests
run: chmod +x ../scripts/travisTest.sh && sudo ../scripts/travisTest.sh
- name: Post tests
if: always()
run: |
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- run: unset _JAVA_OPTIONS

- name: Run tests
run: sudo ../scripts/testApp.sh

- name: Post tests
if: always()
run: |
logsPath=$(sudo find . -name "console.log");
sudo cat $logsPath | sudo grep Launching
- name: Archive server logs if failed
if: failure()
uses: actions/upload-artifact@v2
with:
name: server-logs
path: finish/target/liberty/wlp/usr/servers/guideServer/logs/
- name: Archive server logs if failed
if: failure()
uses: actions/upload-artifact@v2
with:
name: server-logs
path: finish/target/liberty/wlp/usr/servers/defaultServer/logs/
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ the `localhost` host to the inventory. Next, the test case makes a connection to
Then, it asserts whether the time that is needed to retrieve
the system properties for localhost is less than 4 seconds.

* The [hotspot=testInventoryAccessCountMetric file=0]`testInventoryAccessCountMetric()` test case validates the [hotspot=countedForList file=1]`@Counted` metric. The test case sends a request to the
`\http://localhost:9080/inventory/systems` URL to retrieve the whole inventory, and then it asserts
that this endpoint is accessed at least once.
* The [hotspot=testInventoryAccessCountMetric file=0]`testInventoryAccessCountMetric()` test case validates the [hotspot=countedForList file=1]`@Counted` metric.
The test case obtains metric data before and after a request to the `\http://localhost:9080/inventory/systems` URL.
It then asserts that the metric was increased after the URL was accessed.

* The [hotspot=testInventorySizeGaugeMetric file=0]`testInventorySizeGaugeMetric()` test case validates the [hotspot=gaugeForGetTotal file=1]`@Gauge` metric. The test case first ensures
that the localhost is in the inventory, then looks for the [hotspot=gaugeForGetTotal file=1]`@Gauge` metric and asserts
Expand Down
2 changes: 1 addition & 1 deletion finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.2</version>
<version>3.2.3</version>
</plugin>
<!-- Plugin to run functional tests -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ public void testPropertiesRequestTimeMetric() {
// end::Order2[]
// tag::testInventoryAccessCountMetric[]
public void testInventoryAccessCountMetric() {
metrics = getMetrics();
Map<String, Integer> accessCountsBefore = getIntMetrics(metrics,
"application_inventoryAccessCount_total");
connectToEndpoint(baseHttpUrl + INVENTORY_HOSTS);
metrics = getMetrics();
for (String metric : metrics) {
if (metric.startsWith("application_inventoryAccessCount_total")) {
assertTrue(
1 <= Integer.parseInt(metric.split(" ")[metric.split(" ").length - 1]));
}
Map<String, Integer> accessCountsAfter = getIntMetrics(metrics,
"application_inventoryAccessCount_total");
for (String key : accessCountsBefore.keySet()) {
Integer accessCountBefore = accessCountsBefore.get(key);
Integer accessCountAfter = accessCountsAfter.get(key);
assertTrue(accessCountAfter > accessCountBefore);
}
}
// end::testInventoryAccessCountMetric[]
Expand All @@ -126,11 +130,10 @@ public void testInventoryAccessCountMetric() {
// tag::testInventorySizeGaugeMetric[]
public void testInventorySizeGaugeMetric() {
metrics = getMetrics();
for (String metric : metrics) {
if (metric.startsWith("application_inventorySizeGauge")) {
assertTrue(
1 <= Character.getNumericValue(metric.charAt(metric.length() - 1)));
}
Map<String, Integer> inventorySizeGauges = getIntMetrics(metrics,
"application_inventorySizeGauge");
for (Integer value : inventorySizeGauges.values()) {
assertTrue(1 <= value);
}
}
// end::testInventorySizeGaugeMetric[]
Expand Down Expand Up @@ -198,5 +201,18 @@ private Response getResponse(String url) {
private void assertResponse(String url, Response response) {
assertEquals(200, response.getStatus(), "Incorrect response code from " + url);
}

private Map<String, Integer> getIntMetrics(List<String> metrics, String metricName) {
Map<String, Integer> output = new HashMap<String, Integer>();
for (String metric : metrics) {
if (metric.startsWith(metricName)) {
String[] mSplit = metric.split("\\s+");
String key = mSplit[0];
Integer value = Integer.parseInt(mSplit[mSplit.length - 1]);
output.put(key, value);
}
}
return output;
}
}
// end::MetricsTest[]
17 changes: 17 additions & 0 deletions scripts/dailyBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
while getopts t:d:b:u: flag; do
case "${flag}" in
t) DATE="${OPTARG}" ;;
d) DRIVER="${OPTARG}" ;;
b) BUILD="${OPTARG}" ;;
u) DOCKER_USERNAME="${OPTARG}" ;;
esac
done

sed -i "\#<artifactId>liberty-maven-plugin</artifactId>#a<configuration><install><runtimeUrl>https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/"$DATE"/"$DRIVER"</runtimeUrl></install></configuration>" pom.xml
cat pom.xml

sed -i "s;FROM openliberty/open-liberty:kernel-java8-openj9-ubi;FROM "$DOCKER_USERNAME"/olguides:"$BUILD";g" Dockerfile
cat Dockerfile

../scripts/testApp.sh
9 changes: 4 additions & 5 deletions scripts/travisTest.sh → scripts/testApp.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euxo pipefail

##############################################################################
##
## Travis CI test script
## GH action CI test script
##
##############################################################################

Expand All @@ -13,13 +13,12 @@ set -euxo pipefail
# package - Take the compiled code and package it in its distributable format.
# liberty:create - Create a Liberty server.
# liberty:install-feature - Install a feature packaged as a Subsystem Archive (esa) to the Liberty runtime.
# liberty:deploy - Copy applications to the Liberty server's dropins or apps directory.
# liberty:deploy - Copy applications to the Liberty server's dropins or apps directory.
mvn -q clean package liberty:create liberty:install-feature liberty:deploy


## Run the tests
# These commands are separated because if one of the commands fail, the test script will fail and exit.
# e.g if liberty:start fails, then there is no need to run the failsafe commands.
# These commands are separated because if one of the commands fail, the test script will fail and exit.
# e.g if liberty:start fails, then there is no need to run the failsafe commands.
# liberty:start - Start a Liberty server in the background.
# failsafe:integration-test - Runs the integration tests of an application.
# liberty:stop - Stop a Liberty server.
Expand Down
2 changes: 1 addition & 1 deletion start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.2</version>
<version>3.2.3</version>
</plugin>
<!-- Plugin to run functional tests -->
<plugin>
Expand Down

0 comments on commit 1963d54

Please sign in to comment.