@@ -9,6 +9,7 @@ source $(dirname ${BASH_SOURCE[0]})/test-lib.sh
9
9
# And the following trap must be set, in the beginning of the test script:
10
10
# trap ct_os_cleanup EXIT SIGINT
11
11
OS_TESTSUITE_RESULT=1
12
+ OS_CLUSTER_STARTED_BY_TEST=0
12
13
13
14
function ct_os_cleanup() {
14
15
if [ $OS_TESTSUITE_RESULT -eq 0 ] ; then
@@ -347,6 +348,15 @@ function ct_os_is_tag_exists() {
347
348
oc get is "${is_name} " - n openshift - o= jsonpath= '{.spec.tags[* ].name}' | grep - qw "${tag} "
348
349
}
349
350
351
+ # ct_os_template_exists T_NAME
352
+ # --------------------
353
+ # Checks whether the specified template exists for an image stream
354
+ # Arguments: t_name - template name of the image stream
355
+ function ct_os_template_exists() {
356
+ local t_name=$1 ; shift
357
+ oc get templates -n openshift | grep -q "^${t_name} \s"
358
+ }
359
+
350
360
# ct_os_install_in_centos
351
361
# --------------------
352
362
# Installs os cluster in CentOS
@@ -412,6 +422,7 @@ function ct_os_cluster_up() {
412
422
ct_os_wait_rc_ready docker-registry 180
413
423
ct_os_wait_rc_ready router 30
414
424
oc login -u developer -p developer
425
+ OS_CLUSTER_STARTED_BY_TEST=1
415
426
# let openshift cluster to sync to avoid some race condition errors
416
427
sleep 3
417
428
}
@@ -420,7 +431,12 @@ function ct_os_cluster_up() {
420
431
# --------------------
421
432
# Shuts down the local OpenShift cluster using 'oc cluster down'
422
433
function ct_os_cluster_down() {
423
- oc cluster down
434
+ if [ ${OS_CLUSTER_STARTED_BY_TEST:- 0} - eq 1 ] ; then
435
+ echo "Cluster started by the test, shutting down."
436
+ oc cluster down
437
+ else
438
+ echo "Cluster not started by the test, shutting down skipped."
439
+ fi
424
440
}
425
441
426
442
# ct_os_cluster_running
@@ -701,7 +717,7 @@ function ct_os_test_template_app_func() {
701
717
# get the template file from remote or local location; if not found, it is
702
718
# considered an internal template name, like 'mysql', so use the name
703
719
# explicitly
704
- local local_template=$(ct_obtain_input "${template} " || echo "${template} ")
720
+ local local_template=$(ct_obtain_input "${template} " 2 >/ dev / null || echo "-- template = ${template} ")
705
721
local namespace=${CT_NAMESPACE:- $(oc project -q)}
706
722
oc new-app ${local_template} \
707
723
--name "${name_in_template} " \
@@ -969,3 +985,4 @@ function ct_os_check_cmd_internal() {
969
985
return 1
970
986
}
971
987
988
+ # vim: set tabstop=2:shiftwidth=2:expandtab:
0 commit comments