From b5be1ca519133b4edb4412b49256b5f25c497866 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 30 Nov 2023 12:21:53 +0100 Subject: [PATCH 1/3] Migration DeploymentConfigs to Deployment See more info here: https://docs.openshift.com/container-platform/4.12/applications/deployments/what-deployments-are.html Since OPenShift 4.14 DeploymentConfigs are deprecated: https://access.redhat.com/articles/7041372 Signed-off-by: Petr "Stone" Hracek --- examples/mariadb-ephemeral-template.json | 32 ++++++----------------- examples/mariadb-persistent-template.json | 32 ++++++----------------- test/run-openshift-remote-cluster | 2 +- test/test-lib-mysql.sh | 9 +++++-- 4 files changed, 24 insertions(+), 51 deletions(-) diff --git a/examples/mariadb-ephemeral-template.json b/examples/mariadb-ephemeral-template.json index 7c77b6e..f419390 100644 --- a/examples/mariadb-ephemeral-template.json +++ b/examples/mariadb-ephemeral-template.json @@ -61,40 +61,24 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${DATABASE_SERVICE_NAME}", "annotations": { - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mariadb:${MARIADB_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { "strategy": { - "type": "Recreate" + "type": "RollingUpdate" }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mariadb" - ], - "from": { - "kind": "ImageStreamTag", - "name": "mariadb:${MARIADB_VERSION}", - "namespace": "${NAMESPACE}" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${DATABASE_SERVICE_NAME}" + "matchLabels": { + "name": "${DATABASE_SERVICE_NAME}" + } }, "template": { "metadata": { diff --git a/examples/mariadb-persistent-template.json b/examples/mariadb-persistent-template.json index 1a90791..412c0a5 100644 --- a/examples/mariadb-persistent-template.json +++ b/examples/mariadb-persistent-template.json @@ -78,40 +78,24 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${DATABASE_SERVICE_NAME}", "annotations": { - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mariadb:${MARIADB_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { "strategy": { - "type": "Recreate" + "type": "RollingUpdate" }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mariadb" - ], - "from": { - "kind": "ImageStreamTag", - "name": "mariadb:${MARIADB_VERSION}", - "namespace": "${NAMESPACE}" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${DATABASE_SERVICE_NAME}" + "matchLabels": { + "name": "${DATABASE_SERVICE_NAME}" + } }, "template": { "metadata": { diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index 56cfb2d..a309b32 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -16,7 +16,7 @@ source "${THISDIR}/test-lib-remote-openshift.sh" TEST_LIST="\ test_mariadb_integration test_mariadb_imagestream -test_mariadb_template +test_mariadb_templates run_latest_imagestreams " diff --git a/test/test-lib-mysql.sh b/test/test-lib-mysql.sh index 326a049..3440110 100755 --- a/test/test-lib-mysql.sh +++ b/test/test-lib-mysql.sh @@ -140,10 +140,15 @@ function test_mariadb_imagestream() { ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/examples/mariadb-ephemeral-template.json" mariadb "-p MARIADB_VERSION=${VERSION}${tag}" } -function test_mariadb_template() { - ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/mariadb-ephemeral-template.json" mariadb +function test_mariadb_templates() { + TEMPLATES="mariadb-ephemeral-template.json + mariadb-persistent-template.json" + for template in $TEMPLATES; do + ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/${template}" mariadb + done } + # Check the latest imagestreams function run_latest_imagestreams() { local result=1 From e367dce2516f2cd12b44997d62b2d1705b8efc34 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 30 Nov 2023 12:23:05 +0100 Subject: [PATCH 2/3] Improve tests. Use official released mariadb image Signed-off-by: Petr "Stone" Hracek --- test/test-lib-mysql.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-lib-mysql.sh b/test/test-lib-mysql.sh index 3440110..dbcd553 100755 --- a/test/test-lib-mysql.sh +++ b/test/test-lib-mysql.sh @@ -116,11 +116,12 @@ function test_mariadb_integration() { local service_name=mariadb TEMPLATES="mariadb-ephemeral-template.json mariadb-persistent-template.json" + SHORT_VERSION="${VERSION//.}" for template in $TEMPLATES; do ct_os_test_template_app_func "${IMAGE_NAME}" \ "${THISDIR}/${template}" \ "${service_name}" \ - "ct_os_check_cmd_internal '' '${service_name}-testing' \"echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h testdb -utestu -ptestp\" '^42' 120" \ + "ct_os_check_cmd_internal 'registry.redhat.io/${OS}/mariadb-${SHORT_VERSION}:latest' '${service_name}-testing' \"echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h testdb -utestu -ptestp\" '^42' 120" \ "-p MARIADB_VERSION=${VERSION} \ -p DATABASE_SERVICE_NAME="${service_name}-testing" \ -p MYSQL_USER=testu \ From 48897c40944be9fdb688fed2d16ce7bb7bb429fe Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 4 Dec 2023 13:12:48 +0100 Subject: [PATCH 3/3] Use proper RHEL7 image and test both templates Signed-off-by: Petr "Stone" Hracek --- examples/mariadb-ephemeral-template.json | 2 +- examples/mariadb-persistent-template.json | 2 +- test/run-openshift-remote-cluster | 2 +- test/test-lib-mysql.sh | 17 +++++++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/mariadb-ephemeral-template.json b/examples/mariadb-ephemeral-template.json index f419390..fffb6fa 100644 --- a/examples/mariadb-ephemeral-template.json +++ b/examples/mariadb-ephemeral-template.json @@ -72,7 +72,7 @@ }, "spec": { "strategy": { - "type": "RollingUpdate" + "type": "Recreate" }, "replicas": 1, "selector": { diff --git a/examples/mariadb-persistent-template.json b/examples/mariadb-persistent-template.json index 412c0a5..0294880 100644 --- a/examples/mariadb-persistent-template.json +++ b/examples/mariadb-persistent-template.json @@ -89,7 +89,7 @@ }, "spec": { "strategy": { - "type": "RollingUpdate" + "type": "Recreate" }, "replicas": 1, "selector": { diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index a309b32..56cfb2d 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -16,7 +16,7 @@ source "${THISDIR}/test-lib-remote-openshift.sh" TEST_LIST="\ test_mariadb_integration test_mariadb_imagestream -test_mariadb_templates +test_mariadb_template run_latest_imagestreams " diff --git a/test/test-lib-mysql.sh b/test/test-lib-mysql.sh index dbcd553..63a6760 100755 --- a/test/test-lib-mysql.sh +++ b/test/test-lib-mysql.sh @@ -117,11 +117,16 @@ function test_mariadb_integration() { TEMPLATES="mariadb-ephemeral-template.json mariadb-persistent-template.json" SHORT_VERSION="${VERSION//.}" + if [ "${OS}" == "rhel7" ]; then + namespace_image="rhscl/mariadb-${SHORT_VERSION}-rhel7" + else + namespace_image="${OS}/mariadb-${SHORT_VERSION}" + fi for template in $TEMPLATES; do ct_os_test_template_app_func "${IMAGE_NAME}" \ "${THISDIR}/${template}" \ "${service_name}" \ - "ct_os_check_cmd_internal 'registry.redhat.io/${OS}/mariadb-${SHORT_VERSION}:latest' '${service_name}-testing' \"echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h testdb -utestu -ptestp\" '^42' 120" \ + "ct_os_check_cmd_internal 'registry.redhat.io/${namespace_image}' '${service_name}-testing' \"echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h testdb -utestu -ptestp\" '^42' 120" \ "-p MARIADB_VERSION=${VERSION} \ -p DATABASE_SERVICE_NAME="${service_name}-testing" \ -p MYSQL_USER=testu \ @@ -138,14 +143,18 @@ function test_mariadb_imagestream() { elif [ "${OS}" == "rhel9" ]; then tag="-el9" fi - ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/examples/mariadb-ephemeral-template.json" mariadb "-p MARIADB_VERSION=${VERSION}${tag}" + TEMPLATES="mariadb-ephemeral-template.json + mariadb-persistent-template.json" + for template in $TEMPLATES; do + ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/examples/${template}" mariadb "-p MARIADB_VERSION=${VERSION}${tag}" + done } -function test_mariadb_templates() { +function test_mariadb_template() { TEMPLATES="mariadb-ephemeral-template.json mariadb-persistent-template.json" for template in $TEMPLATES; do - ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/${template}" mariadb + ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS%[0-9]*}.json" "${THISDIR}/examples/${template}" mariadb done }