Skip to content

Commit 035ac68

Browse files
authored
Add Openshift tests (sclorg#128)
* Add s2i openshift test * Add example template * Add test_sample_template in run-openshift * Test also dancer-ex example
1 parent c55e6e4 commit 035ac68

17 files changed

+384
-18
lines changed

5.20/test/run-openshift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
#
3+
# Test the Perl image in OpenShift.
4+
#
5+
# IMAGE_NAME specifies a name of the candidate image used for testing.
6+
# The image has to be available before this script is executed.
7+
#
8+
9+
THISDIR=$(dirname ${BASH_SOURCE[0]})
10+
11+
source ${THISDIR}/test-lib.sh
12+
source ${THISDIR}/test-lib-openshift.sh
13+
14+
set -exo nounset
15+
16+
test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
17+
test -n "${VERSION-}" || false 'make sure $VERSION is defined'
18+
19+
ct_os_cluster_up
20+
21+
# TODO: We should ideally use a local directory instead of ${VERSION}/test/sample-test-app,
22+
# so we can test changes in that example app that are done as part of the PR
23+
ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/sclorg/s2i-perl-container.git" ${VERSION}/test/sample-test-app "Everything is OK"
24+
25+
ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/openshift/dancer-ex.git" . 'Welcome to your Dancer application on OpenShift'
26+
27+
# TODO: this was not working because the referenced example dir was added as part of this commit
28+
ct_os_test_template_app ${IMAGE_NAME} \
29+
${THISDIR}/sample-test-app.json \
30+
perl \
31+
"Everything is OK" \
32+
8080 http 200 "-p SOURCE_REPOSITORY_REF=staging -p VERSION=${VERSION}"
33+

5.20/test/sample-test-app

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../examples/sample-test-app/

5.20/test/sample-test-app.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../examples/templates/sample-test-app.json

5.20/test/test-lib-openshift.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/test-lib-openshift.sh

5.20/test/test-lib.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/test-lib.sh

5.24/test/run-openshift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
#
3+
# Test the Perl image in OpenShift.
4+
#
5+
# IMAGE_NAME specifies a name of the candidate image used for testing.
6+
# The image has to be available before this script is executed.
7+
#
8+
9+
THISDIR=$(dirname ${BASH_SOURCE[0]})
10+
11+
source ${THISDIR}/test-lib.sh
12+
source ${THISDIR}/test-lib-openshift.sh
13+
14+
set -exo nounset
15+
16+
test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
17+
test -n "${VERSION-}" || false 'make sure $VERSION is defined'
18+
19+
ct_os_cluster_up
20+
21+
# TODO: We should ideally use a local directory instead of ${VERSION}/test/sample-test-app,
22+
# so we can test changes in that example app that are done as part of the PR
23+
ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/sclorg/s2i-perl-container.git" ${VERSION}/test/sample-test-app "Everything is OK"
24+
25+
ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/openshift/dancer-ex.git" . 'Welcome to your Dancer application on OpenShift'
26+
27+
# TODO: this was not working because the referenced example dir was added as part of this commit
28+
ct_os_test_template_app ${IMAGE_NAME} \
29+
${THISDIR}/sample-test-app.json \
30+
perl \
31+
"Everything is OK" \
32+
8080 http 200 "-p SOURCE_REPOSITORY_REF=staging -p VERSION=${VERSION}"
33+

5.24/test/sample-test-app

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../examples/sample-test-app/

5.24/test/sample-test-app.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../examples/templates/sample-test-app.json

5.24/test/sample-test-app/cpanfile

-1
This file was deleted.

5.24/test/sample-test-app/index.pl

-16
This file was deleted.

5.24/test/test-lib-openshift.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/test-lib-openshift.sh

5.24/test/test-lib.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/test-lib.sh

common

examples/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# S2I Sample Applications for Perl Builder Image
2+
3+
This is a very basic sample application repository that can be built and deployed
4+
on [OpenShift](https://www.openshift.com) using the [Perl builder image](https://github.com/sclorg/s2i-perl-container).
5+
6+
The application serves a single static html page via perl, while also installing Math::Round package from cpan.
7+
8+
To build and run the application:
9+
10+
```
11+
$ s2i build --context-dir=examples/sample-test-app https://github.com/sclorg/s2i-perl-container centos/perl-524-centos7 myperlimage
12+
$ docker run -p 8080:8080 myperlimage
13+
$ # browse to http://localhost:8080
14+
```
15+
16+
You can also build and deploy the application on OpenShift, assuming you have a
17+
working `oc` command line environment connected to your cluster already:
18+
19+
`$ oc new-app --context-dir=examples/sample-test-app centos/perl-524-centos7~https://github.com/sclorg/s2i-perl-container`
20+
21+
You can also deploy the sample template for the application:
22+
23+
`$ oc new-app -f https://raw.githubusercontent.com/sclorg/s2i-perl-container/master/examples/templates/sample-test-app.json`
24+

0 commit comments

Comments
 (0)