Skip to content

Commit

Permalink
make image to test flexible in test.sh (#160)
Browse files Browse the repository at this point in the history
This will allow to easily test no just the current
centos image but also a fedora variant and Java 11 version.
(It could also be used to self test that RHEL variant.)
  • Loading branch information
vorburger committed Nov 13, 2018
1 parent b545768 commit d11aee4
Showing 1 changed file with 41 additions and 31 deletions.
72 changes: 41 additions & 31 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/sh
set -ex

cd java ; fish-pepper ; cd ..

docker build java/images/centos/ -t fabric8/s2i-java

# ----------------------------------------------------------------------------------
# ==================================================================================

function test_container() {
local name=$1

CONTAINER_ID=$(docker run --name ${name}-test -d -p 8080 fabric8/${name})
CONTAINER_ID=$(docker run --name ${name}-test -d -p 8080 ${name})

# sleep is required because after docker run returns, the container is up but our server may not quite be yet
sleep 5
Expand All @@ -29,45 +25,59 @@ function test_container() {
fi
}

# ==================================================================================

function test_image() {
local dir=$1
local name=$2

docker build ${dir} -t ${name}

# ----------------------------------------------------------------------------------
# Maven
# ----------------------------------------------------------------------------------
# Maven
# ----------------------------------------------------------------------------------

s2i build --copy java/examples/maven fabric8/s2i-java fabric8/s2i-java-maven-example
s2i build --copy java/examples/maven ${name} ${name}-maven-example

# Now rebuild incrementally, it should not re-download .m2
s2i build --copy java/examples/maven fabric8/s2i-java fabric8/s2i-java-maven-example --incremental
# Now rebuild incrementally, it should not re-download .m2
s2i build --copy java/examples/maven ${name} ${name}-maven-example --incremental

test_container "s2i-java-maven-example"
test_container "${name}-maven-example"


# --------------------------------------------------------------------------------
# Gradle
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
# Gradle
# --------------------------------------------------------------------------------

s2i build --copy java/examples/gradle ${name} ${name}-gradle-example

s2i build --copy java/examples/gradle fabric8/s2i-java fabric8/s2i-java-gradle-example
s2i build --copy java/examples/gradle ${name} ${name}-gradle-example --incremental

s2i build --copy java/examples/gradle fabric8/s2i-java fabric8/s2i-java-gradle-example --incremental
test_container "s2i-java-gradle-example"

test_container "s2i-java-gradle-example"

# ----------------------------------------------------------------------------------
# Binary
# ----------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------
# Binary
# ----------------------------------------------------------------------------------
mvn -f java/examples/maven/ clean package
cp java/examples/maven/target/*.jar java/examples/binary/deployments/

mvn -f java/examples/maven/ clean package
cp java/examples/maven/target/*.jar java/examples/binary/deployments/
s2i build --copy java/examples/binary/ ${name} ${name}-binary-example
rm java/examples/binary/deployments/*

s2i build --copy java/examples/binary/ fabric8/s2i-java fabric8/s2i-java-binary-example
rm java/examples/binary/deployments/*
test_container "s2i-java-binary-example"

test_container "s2i-java-binary-example"

# ----------------------------------------------------------------------------------
# Maven Wrapper
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# Maven Wrapper
# ----------------------------------------------------------------------------------

s2i build --copy java/examples/maven-wrapper fabric8/s2i-java fabric8/s2i-java-maven-wrapper-example
s2i build --copy java/examples/maven-wrapper fabric8/s2i-java fabric8/s2i-java-maven-wrapper-example --incremental
s2i build --copy java/examples/maven-wrapper ${name} ${name}-maven-wrapper-example
s2i build --copy java/examples/maven-wrapper ${name} ${name}-maven-wrapper-example --incremental
}

# ==================================================================================

cd java ; fish-pepper ; cd ..
test_image "java/images/centos/" "s2i-java"

0 comments on commit d11aee4

Please sign in to comment.