Skip to content

Commit

Permalink
Merge pull request #139 from mezarin/outerloopDockerUpdate
Browse files Browse the repository at this point in the history
Allow the execution of configure.sh to be optional
  • Loading branch information
mezarin authored Apr 2, 2021
2 parents 5a20190 + eb044d3 commit 581e6de
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 239 deletions.
50 changes: 31 additions & 19 deletions .github/workflows/stack-regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,64 @@ jobs:
stack-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout

- name: 'Setup: Checkout'
uses: actions/checkout@v2

- name: Setup Minikube
- name: 'Setup: Install Minikube'
uses: manusa/[email protected]
with:
minikube version: 'v1.11.0'
kubernetes version: 'v1.17.0'
github token: ${{ secrets.GITHUB_TOKEN }}
start args: '--addons=registry --addons=ingress --insecure-registry "10.0.0.0/24"'
- name: Wait for nodes to be ready

- name: 'Setup: Wait for nodes to be ready'
run: |
while [[ $(kubectl get nodes -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do
echo "waiting for nodes" && sleep 1;
done
- name: Install odo
- name: 'Setup: Install odo'
run: |
sudo curl -L https://mirror.openshift.com/pub/openshift-v4/clients/odo/latest/odo-linux-amd64 -o /usr/local/bin/odo
sudo chmod +x /usr/local/bin/odo
- name: Print version info
- name: 'Setup: Print version info'
run: |
set -x
docker version
kubectl version
odo version
minikube version
set +x
- name: Build stack
- name: 'Setup: Install the Open Liberty operator'
run: ./test/utils.sh installOpenLibertyOperator

- name: 'Setup: Build stack'
run: ./test/utils.sh buildStack

- name: Build stack image
- name: 'Setup: Build stack image'
run: ./test/utils.sh buildStackImage

- name: Devfile regression
run: ./test/devfile-regression.sh
- name: 'Test: InnerLoop: Basic'
run: ./test/inner-loop/basic-test.sh

- name: 'Test: InnerLoop: Parent plugin'
run: ./test/inner-loop/parent-plugin-test.sh

- name: 'Test: InnerLoop: Devfile regression'
run: ./test/inner-loop/devfile-regression-test.sh

- name: 'Test: OuterLoop: Basic'
run: ./test/outer-loop/basic-test.sh

- name: Inner loop test
run: ./test/inner-loop-test.sh
- name: 'Test: OuterLoop: Docker build MPH-off SCC-off args'
run: ./test/outer-loop/docker-build-mphOff-sccOff-test.sh

- name: Inner loop parent plugin test
run: ./test/inner-loop-parent-plugin-test.sh
- name: 'Test: OuterLoop: Docker build with MPH-on SCC-off args'
run: ./test/outer-loop/docker-build-mphOn-sccOff-test.sh

- name: Outer loop test
run: ./test/outer-loop-test.sh
- name: 'Test: OuterLoop: Docker build with MPH-off SCC-on args'
run: ./test/outer-loop/docker-build-mphOff-sccOn-test.sh
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ STACK_IMAGE="${STACK_IMAGE:-openliberty/application-stack:0.4}"
#
# URL at which your outer loop Dockerfile is hosted
#
DEVFILE_DOCKERFILE_LOC="${DEVFILE_DOCKERFILE_LOC:-https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.0/Dockerfile}"
DEVFILE_DOCKERFILE_LOC="${DEVFILE_DOCKERFILE_LOC:-https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.1/Dockerfile}"

#
# URL at which your outer loop deploy YAML template is hosted
#
DEVFILE_DEPLOY_YAML_LOC="${DEVFILE_DEPLOY_YAML_LOC:-https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.0/app-deploy.yaml}"
DEVFILE_DEPLOY_YAML_LOC="${DEVFILE_DEPLOY_YAML_LOC:-https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.1/app-deploy.yaml}"

# Generates application stack artifacts.
generate() {
Expand Down
2 changes: 1 addition & 1 deletion templates/devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schemaVersion: 2.0.0
metadata:
name: java-openliberty
version: 0.4.2
version: 0.4.3
description: Java application stack using Open Liberty runtime
alpha.build-dockerfile: "{{.DEVFILE_DOCKERFILE_LOC}}"
alpha.deployment-manifest: "{{.DEVFILE_DEPLOY_YAML_LOC}}"
Expand Down
35 changes: 26 additions & 9 deletions templates/outer-loop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ RUN cd /work/outer-loop-app && \
mvn -e liberty:create package

# Process any resources or shared libraries - if they are present in the dependencies block for this project (there may be none potentially)
# test to see if each is present and move to a well known location for later processing in the next stage
#
# test to see if each is present and move to a well known location for later processing in the next stage.
RUN cd /work/outer-loop-app/target/liberty/wlp/usr/servers && \
if [ -d ./*/lib ]; then mv ./*/lib /work/configlibdir; fi && \
if [ ! -d /work/configlibdir/lib ]; then mkdir /work/configlibdir/lib; fi && \
mv -f */* /work/config/ && \
rm -rf /work/config/workarea && \
chmod -R 770 /work/config/apps && \
if [ -d ../shared ]; then mv ../shared/* /work/shared/; fi

# Step 2: Package Open Liberty image
Expand All @@ -42,19 +43,24 @@ COPY --from=compile --chown=1001:0 /work/config/ /config/

# 2d) Add the microprofile health feature configuration if it is not already defined in the user's configuration.
# This allows k8s to use the deployment's health probes.
# To skip this step, use the ADD_MP_HEALTH argument when building the outer loop image.
# The allowed values are true/false. The default value is true.
# Example usage: docker build --build-arg ADD_MP_HEALTH=false ...
RUN mkdir -p /tmp/stack/config/configDropins/defaults
COPY --from=compile --chown=1001:0 /stack/ol/config/configDropins/defaults/ /tmp/stack/config/configDropins/defaults/

ARG ADD_MP_HEALTH=true
RUN if [ "$ADD_MP_HEALTH" = "true" ]; then \
/opt/ol/wlp/bin/server start; \
/opt/ol/wlp/bin/server stop; \
/opt/ol/wlp/bin/server start && \
/opt/ol/wlp/bin/server stop && \
if ! grep "CWWKF0012I" /logs/messages.log | grep -q 'mpHealth-[0-9]*.[0-9]*\|microProfile-[0-9]*.[0-9]*'; then \
echo "Missing mpHealth feature - adding config snippet"; \
echo "Missing mpHealth feature - adding config snippet" && \
cp /tmp/stack/config/configDropins/defaults/liberty-stack-mpHealth.xml /config/configDropins/overrides; \
else \
echo "Found mpHealth feature - not adding config snippet"; \
fi; \
fi && \
rm -rf /liberty/output/.classCache && \
rm -rf /output/* && \
rm -rf /logs/*; \
elif [ "$ADD_MP_HEALTH" != "false" ]; then \
echo "Invalid ADD_MP_HEALTH value: $ADD_MP_HEALTH. Valid values are \"true\" | \"false\" "; \
Expand All @@ -65,7 +71,18 @@ RUN rm -rf /tmp/stack
# 2e) Copy the application binary
COPY --from=compile --chown=1001:0 /work/outer-loop-app/target/*.[ew]ar /config/apps

# 2f) Run configure.sh
ENV OPENJ9_SCC=true
# 2f) Set the SCC environment variable.
# To set the SCC environment variable value, use the ENABLE_OPENJ9_SCC argument when building the outer loop image.
# The allowed values are true/false. The default value is true.
# Example usage: docker build --build-arg ENABLE_OPENJ9_SCC=false ...
ARG ENABLE_OPENJ9_SCC=true
RUN if [[ "$ENABLE_OPENJ9_SCC" != "true" && "$ENABLE_OPENJ9_SCC" != "false" ]]; then \
echo "Invalid ENABLE_OPENJ9_SCC value: $ENABLE_OPENJ9_SCC. Valid values are \"true\" | \"false\"." && \
exit 1; \
fi

ENV OPENJ9_SCC=$ENABLE_OPENJ9_SCC

# 2g) Run configure.sh
RUN configure.sh && \
chmod 664 /opt/ol/wlp/usr/servers/*/configDropins/defaults/keystore.xml
chmod 664 /opt/ol/wlp/usr/servers/*/configDropins/defaults/keystore.xml
12 changes: 6 additions & 6 deletions test/stack-inner-loop.sh → test/inner-loop/base-inner-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ while ! odo log | grep -q "CWWKF0011I: The defaultServer server"; do
count=`expr $count + 1`
if [ $count -eq 20 ]; then
echo "Timed out waiting for server to start"
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi
done
Expand All @@ -55,7 +55,7 @@ while ! echo $livenessResults | grep -qF '{"checks":[{"data":{},"name":"SampleLi
if [ $count -eq 20 ]; then
echo "Timed out waiting for liveness check to pass. Liveness results:"
echo $livenessResults
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi
done
Expand All @@ -69,7 +69,7 @@ while ! echo $readinessResults | grep -qF '{"checks":[{"data":{},"name":"SampleR
if [ $count -eq 20 ]; then
echo "Timed out waiting for Readiness check to pass. Readiness results:"
echo $readinessResults
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi
done
Expand All @@ -81,7 +81,7 @@ if ! echo $restResults | grep -qF 'Hello! Welcome to Open Liberty'; then
else
echo "REST endpoint check failed. REST endpoint returned:"
echo $restResults
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi

Expand All @@ -93,7 +93,7 @@ if [ $rc -ne 0 ]; then
odo test -v 4 --show-log
rc=$?
if [ $rc -ne 0 ]; then
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi
fi
Expand All @@ -106,7 +106,7 @@ while [ ! -z $(kubectl get pod -l component=$COMP_NAME -o jsonpath='{.items[*].m
count=`expr $count + 1`
if [ $count -eq 20 ]; then
echo "Timed out waiting for component pod to be terminated"
./../../test/utils.sh printDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
./../../test/utils.sh printLibertyDebugData "component=$COMP_NAME" $PROJ_NAME $LIBERTY_SERVER_LOGS_DIR_PATH
exit 12
fi
done
Expand Down
4 changes: 2 additions & 2 deletions test/inner-loop-test.sh → test/inner-loop/basic-test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Base inner loop test using the application-stack-intro application.
echo -e "\n> Base Inner loop test setup"
echo -e "\n> Basic inner loop test"
mkdir inner-loop-test-dir
cd inner-loop-test-dir

Expand All @@ -23,7 +23,7 @@ echo -e "\n Updated devfile contents:"
cat devfile.yaml

echo -e "\n> Base Inner loop test run"
COMP_NAME=my-ol-component PROJ_NAME=inner-loop-test ./../../test/stack-inner-loop.sh
COMP_NAME=my-ol-component PROJ_NAME=inner-loop-test ./../../test/inner-loop/base-inner-loop.sh
rc=$?
if [ $rc -ne 0 ]; then
exit 12
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!/bin/bash

echo -e "\n> make stacktest regression dir"
echo -e "\n> Make stacktest regression dir"
mkdir stacktest-reg
cd stacktest-reg

# get the currently released version of the devfile template and generate
# Get the currently released version of the devfile template and generate
# this will allow us to run the current devfile with the new stack image
# introduced via this current PR being tested
echo -e "\n> clone the main branch stack repo"
echo -e "\n> Clone the main branch stack repo"
git clone https://github.com/OpenLiberty/application-stack.git

echo -e "\n> run buildStack from the main branch in stack repo that was just cloned"
echo -e "\n> Run buildStack from the main branch in stack repo that was just cloned"
cd application-stack
./test/utils.sh buildStack

echo -e "\n>make a test app dir for test project"
echo -e "\n> Make a test app dir for test project"
mkdir devfile-regression-inner-loop-test-dir
cd devfile-regression-inner-loop-test-dir

echo -e "\n> Clone application-stack-intro project"
git clone https://github.com/OpenLiberty/application-stack-intro.git
cd application-stack-intro
# remove devfile from intro project
# Remove devfile from intro project
rm -rf devfile.yaml

# This is a copy of the 'main' version of the devfile - vs an updated devfile from this PR.
# vis-a-vie the fact that we git cloned the main branch of the stack repo above
echo -e "\n> Copy devfile and scripts"
cp ../../generated/devfile.yaml .

# this is a workaround to avoid surefire fork failures when running
# This is a workaround to avoid surefire fork failures when running
# the GHA test suite.
# Issue #138 has been opened to track and address this
# add the -DforkCount arg to the odo test cmd only for this run
Expand All @@ -39,11 +39,11 @@ sed -i 's/\B-Dmicroshed_hostname/-DforkCount=0 &/' devfile.yaml
echo -e "\n Updated devfile contents:"
cat devfile.yaml

# call common script here
# Call common script here
# the only accomodation we have to make is that
# we are one dir level deeper from the GHA test dir
echo -e "\n> Base Inner loop test run"
COMP_NAME=my-ol-component PROJ_NAME=devfile-regression-inner-loop-test ./../../../../test/stack-inner-loop.sh
COMP_NAME=my-ol-component PROJ_NAME=devfile-regression-inner-loop-test ./../../../../test/inner-loop/base-inner-loop.sh
rc=$?
if [ $rc -ne 0 ]; then
exit 12
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Inner loop test using the application-stack-intro application that defines a pom.xml containing the liberty-maven-app-parent artifact.
echo -e "\n> Inner loop parent plugin test setup."
echo -e "\n> Parent plugin inner loop test."
mkdir inner-loop-parent-plugin-test-dir
cd inner-loop-parent-plugin-test-dir

Expand All @@ -24,7 +24,7 @@ echo -e "\n Updated devfile contents:"
cat devfile.yaml

echo -e "\n> Inner loop parent plugin test run."
COMP_NAME=parent-plugin-comp PROJ_NAME=parent-plugin-proj ./../../test/stack-inner-loop.sh
COMP_NAME=parent-plugin-comp PROJ_NAME=parent-plugin-proj ./../../test/inner-loop/base-inner-loop.sh
rc=$?
if [ $rc -ne 0 ]; then
exit 12
Expand Down
Loading

0 comments on commit 581e6de

Please sign in to comment.