Skip to content

Commit

Permalink
This pull request tests Nodejs-ex repo with postgresql database (#419)
Browse files Browse the repository at this point in the history
* This pull request tests Nodejs-ex repo with postgresql database
* Add tests for nodejs-ex with postgresql persistent storage
Check Migration to Deployement
Let's use for now postgresql-15-c9s image

---------

Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek authored Feb 19, 2024
1 parent 863366c commit 792e750
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
5 changes: 3 additions & 2 deletions test/run-openshift-remote-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ test_nodejs_imagestream
test_latest_imagestreams
"


# change the branch to a different value if a new change in the example
# app needs to be tested
BRANCH_TO_TEST=master
Expand All @@ -32,9 +31,11 @@ ct_os_set_ocp4 || exit $OC_ERR

ct_os_check_compulsory_vars || exit $OC_ERR

ct_os_check_login || exit $OC_ERR

ct_os_tag_image_for_cvp "nodejs"

ct_os_check_login || exit $OC_ERR
ct_pull_or_import_postgresql || exit $OC_ERR

set -u

Expand Down
42 changes: 35 additions & 7 deletions test/test-lib-nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -528,19 +528,43 @@ function test_safe_logging() {
fi
}


function ct_pull_or_import_postgresql() {
postgresql_image="quay.io/sclorg/postgresql-15-c9s"
image_short="postgresql"
image_tag="postgresql:15-c9s"
# Variable CVP is set by CVP pipeline
if [ "${CVP:-0}" -eq "0" ]; then
# In case of container or OpenShift 4 tests
# Pull image before going through tests
# Exit in case of failure, because postgresql container is mandatory
ct_pull_image "${postgresql_image}" "true"
else
# Import postgresql-10-centos7 image before running tests on CVP
oc import-image "${image_short}:latest" --from="${postgresql_image}:latest" --insecure=true --confirm
# Tag postgresql image to "postgresql:10" which is expected by test suite
oc tag "${image_short}:latest" "${image_tag}"
fi
}

# Check the imagestream
function test_nodejs_imagestream() {
local ret_val=0
if [[ "${VERSION}" == *"minimal"* ]]; then
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
fi
ct_os_test_image_stream_quickstart \
"${THISDIR}/imagestreams/nodejs-${OS%[0-9]*}.json" \
"https://raw.githubusercontent.com/sclorg/nodejs-ex/master/openshift/templates/nodejs.json" \
"https://raw.githubusercontent.com/sclorg/nodejs-ex/${BRANCH_TO_TEST}/openshift/templates/nodejs-postgresql-persistent.json" \
"${IMAGE_NAME}" \
'nodejs' \
"Welcome to your Node.js application on OpenShift" \
"Node.js Crud Application" \
8080 http 200 \
"-p SOURCE_REPOSITORY_REF=master -p SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git -p NODEJS_VERSION=${VERSION} -p NAME=nodejs-testing"
"-p SOURCE_REPOSITORY_REF=${BRANCH_TO_TEST} -p SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git -p NODEJS_VERSION=${VERSION} -p NAME=nodejs-testing
-p DATABASE_USER=testu \
-p DATABASE_PASSWORD=testpwd \
-p DATABASE_ADMIN_PASSWORD=testadminpwd" \
"quay.io/sclorg/postgresql-15-c9s|postgresql:15-c9s"|| ret_val=1
}

function test_nodejs_s2i_container() {
Expand All @@ -554,7 +578,7 @@ function test_nodejs_s2i_app_ex() {
ct_os_test_s2i_app "${IMAGE_NAME}" \
"https://github.com/sclorg/nodejs-ex.git" \
"." \
"Welcome to your Node.js application on OpenShift"
"Node.js Crud Application"
}

function test_nodejs_s2i_templates() {
Expand All @@ -566,11 +590,15 @@ function test_nodejs_s2i_templates() {
# MongoDB is not supported at all.
# Let's disable it or replace it with mariadb
ct_os_test_template_app "${IMAGE_NAME}" \
"https://raw.githubusercontent.com/sclorg/nodejs-ex/${BRANCH_TO_TEST}/openshift/templates/nodejs.json" \
"https://raw.githubusercontent.com/sclorg/nodejs-ex/${BRANCH_TO_TEST}/openshift/templates/nodejs-postgresql-persistent.json" \
nodejs \
"Welcome to your Node.js application on OpenShift" \
"Node.js Crud Application" \
8080 http 200 \
"-p SOURCE_REPOSITORY_REF=${BRANCH_TO_TEST} -p SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git -p NODEJS_VERSION=${VERSION} -p NAME=nodejs-testing" || ret_val=1
"-p SOURCE_REPOSITORY_REF=${BRANCH_TO_TEST} -p SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git -p NODEJS_VERSION=${VERSION} -p NAME=nodejs-testing
-p DATABASE_USER=testu \
-p DATABASE_PASSWORD=testpwd \
-p DATABASE_ADMIN_PASSWORD=testadminpwd" \
"quay.io/sclorg/postgresql-15-c9s|postgresql:15-c9s" || ret_val=1

return $ret_val
}
Expand Down

0 comments on commit 792e750

Please sign in to comment.