From bf406d276c56075c2cfcec5a5c1683bfbab31195 Mon Sep 17 00:00:00 2001 From: Heshma Date: Mon, 6 Mar 2023 11:19:29 -0500 Subject: [PATCH] Avoid jmx usage in zero downtime upgrade orchestration process (#532) * avoid jmx usage and leverage prpcServiceUtils for pre/post upgrade actions * support only upgrade-deploy for zero-downtime * Use valid UpgradeType for the UpgradeAction being performed in tests * add testing for ZDT rest settings --------- Co-authored-by: degah Co-authored-by: walsd1 --- .../charts/installer/templates/_helpers.tpl | 1 + .../pega-installer-action-validate.yaml | 4 +- .../templates/pega-installer-job.yaml | 5 +- .../pega-upgrade-environment-config.yaml | 9 ++ charts/pega/charts/installer/values.yaml | 4 + charts/pega/values-large.yaml | 4 + charts/pega/values.yaml | 4 + ...upgrading-pega-deployment-zero-downtime.md | 7 +- .../test/pega/pega-action-validate_test.go | 2 +- ...dentials-secret-with-cassandra-enc_test.go | 2 +- ...ntials-secret-with-external-stream_test.go | 2 +- .../test/pega/pega-credentials-secret_test.go | 10 +- .../pega-installer-action-validate_test.go | 4 +- .../pega-installer-config-connprops_test.go | 2 +- .../test/pega/pega-installer-config_test.go | 6 +- ...ega-installer-job-artifactory-cert_test.go | 106 +++++++++--------- .../src/test/pega/pega-installer-job_test.go | 2 +- .../test/pega/pega-registry-secret_test.go | 42 ++++--- .../pega-upgrade-environment-config_test.go | 21 ++-- terratest/src/test/pega/utilities.go | 8 ++ 20 files changed, 140 insertions(+), 105 deletions(-) diff --git a/charts/pega/charts/installer/templates/_helpers.tpl b/charts/pega/charts/installer/templates/_helpers.tpl index 60f687e88..bab0d70e5 100644 --- a/charts/pega/charts/installer/templates/_helpers.tpl +++ b/charts/pega/charts/installer/templates/_helpers.tpl @@ -14,6 +14,7 @@ {{- define "pegaDBOOPRulesUpgrade" -}}pega-db-ooprules-upgrade{{- end -}} {{- define "pegaDBOOPDataUpgrade" -}}pega-db-oopdata-upgrade{{- end -}} {{- define "pegaDBZDTUpgrade" -}}pega-zdt-upgrade{{- end -}} +{{- define "pegaDBOOPUpgrade" -}}pega-db-oop-upgrade{{- end -}} {{- define "pegaDBInPlaceUpgrade" -}}pega-in-place-upgrade{{- end -}} {{- define "installerConfig" -}}installer-config{{- end -}} {{- define "installerJobReaderRole" -}}jobs-reader{{- end -}} diff --git a/charts/pega/charts/installer/templates/pega-installer-action-validate.yaml b/charts/pega/charts/installer/templates/pega-installer-action-validate.yaml index c11233e46..0728178c4 100644 --- a/charts/pega/charts/installer/templates/pega-installer-action-validate.yaml +++ b/charts/pega/charts/installer/templates/pega-installer-action-validate.yaml @@ -1,7 +1,7 @@ {{- if (eq (include "performOnlyUpgrade" .) "true") }} -{{- $validUpgradeType := list "in-place" "out-of-place" "zero-downtime" "custom" "out-of-place-rules" "out-of-place-data"}} +{{- $validUpgradeType := list "in-place" "out-of-place" "custom" "out-of-place-rules" "out-of-place-data"}} {{- if not (has .Values.upgrade.upgradeType $validUpgradeType) }} -{{- fail "Upgrade Type value is not correct for upgrade action. The valid values are 'in-place' 'out-of-place' 'zero-downtime' 'custom' 'out-of-place-rules' 'out-of-place-data' " }} +{{- fail "Upgrade Type value is not correct for upgrade action. The valid values are 'in-place' 'out-of-place' 'custom' 'out-of-place-rules' 'out-of-place-data' " }} {{- end }} {{- end }} {{- if (eq (include "performUpgradeAndDeployment" .) "true") }} diff --git a/charts/pega/charts/installer/templates/pega-installer-job.yaml b/charts/pega/charts/installer/templates/pega-installer-job.yaml index 566a0abf1..92498a26c 100644 --- a/charts/pega/charts/installer/templates/pega-installer-job.yaml +++ b/charts/pega/charts/installer/templates/pega-installer-job.yaml @@ -9,9 +9,8 @@ {{ template "pega.installer" dict "root" $ "name" (include "pegaDBZDTUpgrade" .) "action" "upgrade" "initContainers" (list "waitForPreDBUpgrade") }} {{ template "pega.installer" dict "root" $ "name" (include "pegaPostDBUpgrade" .) "action" "post-upgrade" "initContainers" (list "waitForPegaDBZDTUpgrade" "waitForRollingUpdates") }} {{ end }} -{{ if ( and (eq (include "performOnlyUpgrade" .) "true") (or (eq .Values.upgrade.upgradeType "zero-downtime") (eq .Values.upgrade.upgradeType "out-of-place"))) }} -{{ template "pega.installer" dict "root" $ "name" (include "pegaPreDBUpgrade" .) "action" "pre-upgrade" }} -{{ template "pega.installer" dict "root" $ "name" (include "pegaDBZDTUpgrade" .) "action" "upgrade" "initContainers" (list "waitForPreDBUpgrade") }} +{{ if ( and (eq (include "performOnlyUpgrade" .) "true") (eq .Values.upgrade.upgradeType "out-of-place")) }} +{{ template "pega.installer" dict "root" $ "name" (include "pegaDBOOPUpgrade" .) "action" "upgrade" }} {{ end }} {{ if ( and (eq (include "performOnlyUpgrade" .) "true") (eq .Values.upgrade.upgradeType "custom")) }} {{ template "pega.installer" dict "root" $ "name" (include "pegaDBCustomUpgrade" .) "action" "upgrade" }} diff --git a/charts/pega/charts/installer/templates/pega-upgrade-environment-config.yaml b/charts/pega/charts/installer/templates/pega-upgrade-environment-config.yaml index 6fc68cc9d..f475ec354 100644 --- a/charts/pega/charts/installer/templates/pega-upgrade-environment-config.yaml +++ b/charts/pega/charts/installer/templates/pega-upgrade-environment-config.yaml @@ -35,6 +35,15 @@ data: # custom upgrade steps {{- if .Values.upgrade.upgradeSteps }} UPGRADE_STEP: {{ .Values.upgrade.upgradeSteps }} +{{- end }} +{{- if .Values.upgrade.pegaRESTServerURL }} + PEGA_REST_SERVER_URL: {{ .Values.upgrade.pegaRESTServerURL }} +{{- end }} +{{- if .Values.upgrade.pegaRESTUsername }} + PEGA_REST_USERNAME: {{ .Values.upgrade.pegaRESTUsername }} +{{- end }} +{{- if .Values.upgrade.pegaRESTPassword }} + PEGA_REST_PASSWORD: {{ .Values.upgrade.pegaRESTPassword }} {{- end }} # Whether this is a Multitenant System ('true' if yes, 'false' if no) {{- if .Values.multitenant_system }} diff --git a/charts/pega/charts/installer/values.yaml b/charts/pega/charts/installer/values.yaml index 7ba839682..130e425b3 100644 --- a/charts/pega/charts/installer/values.yaml +++ b/charts/pega/charts/installer/values.yaml @@ -69,6 +69,10 @@ upgrade: runRulesetCleanup: "false" # Rebuild Database Rules Indexes after Rules Load to improve Database Access Performance rebuildIndexes: "false" + # Specify the server URL and the required server username and password to access a Pega REST server used to perform pre- and post-update actions during zero-downtime updates. + pegaRESTServerURL: "" + pegaRESTUsername: "" + pegaRESTPassword: "" # Memory and CPU settings for installer resources: diff --git a/charts/pega/values-large.yaml b/charts/pega/values-large.yaml index 5205cc79a..b50fc184d 100644 --- a/charts/pega/values-large.yaml +++ b/charts/pega/values-large.yaml @@ -406,6 +406,10 @@ installer: # For postgres databases that you are upgrading from Pega Infinity version 8.4.0 and later # And for Oracle databases that you are upgrading from Pega Infinity version 8.4.3 and later. targetDataSchema: "" + # Specify the server URL and the required server username and password to access a Pega REST server used to perform pre- and post-update actions during zero-downtime updates. + pegaRESTServerURL: "" + pegaRESTUsername: "" + pegaRESTPassword: "" # Hazelcast settings (applicable from Pega 8.6) hazelcast: diff --git a/charts/pega/values.yaml b/charts/pega/values.yaml index 9919e77fa..642981598 100644 --- a/charts/pega/values.yaml +++ b/charts/pega/values.yaml @@ -416,6 +416,10 @@ installer: # For postgres databases that you are upgrading from Pega Infinity version 8.4.0 and later # And for Oracle databases that you are upgrading from Pega Infinity version 8.4.3 and later. targetDataSchema: "" + # Specify the server URL and the required server username and password to access a Pega REST server used to perform pre- and post-update actions during zero-downtime updates. + pegaRESTServerURL: "" + pegaRESTUsername: "" + pegaRESTPassword: "" # Hazelcast settings (applicable from Pega 8.6) hazelcast: diff --git a/docs/upgrading-pega-deployment-zero-downtime.md b/docs/upgrading-pega-deployment-zero-downtime.md index f48b60cfa..f5de53a0a 100644 --- a/docs/upgrading-pega-deployment-zero-downtime.md +++ b/docs/upgrading-pega-deployment-zero-downtime.md @@ -95,7 +95,7 @@ To configure the parameters in the pega.yaml Helm, download the file in the char To complete an upgrade with zero downtime, configure the following settings in your pega.yaml: -- Specify `action.execute: upgrade` to upgrade your application using the software version contained in your Pega-provided "installer" image. +- Specify `action.execute: upgrade-deploy` to upgrade your application using the software version contained in your Pega-provided "installer" image. - Specify the source schema names in your database: - `jdbc.rulesSchema: "YOUR_RULES_SCHEMA"` - `jdbc.dataSchema: "YOUR_DATA_SCHEMA"` @@ -138,6 +138,9 @@ You can leave the existing customized parameters as is; the upgrade process will | installer.upgrade.upgradeType | Specify an zero-downtime upgrade to upgrade using the zero-downtime upgrade process. | upgradeType: "zero-downtime" | | installer.upgrade.targetRulesSchema | For upgrades from 8.4.2 and later, specify a new rules schema name within the quotes that the process uses to create the schema in your existing database to support the upgrade process.| targetRulesSchema: "" | | installer.upgrade.targetDataSchema | For upgrades from 8.4.2 and later, specify the new target data schema name within the quotes that the process uses to create the schema in your existing database to support the upgrade process. You must delete this schema from your database after you complete your upgrade. For upgrades starting at earlier versions, you can leave this value empty, as is (do not leave it blank). | targetDataSchema: "" | + | installer.upgrade.pegaRESTServerURL | For zero-downtime upgrades, specify Pega REST server URL within the quotes that the process uses to perform pre-upgrade/post-upgrade actions required for the upgrade orchestration. | pegaRESTServerURL: "" | + | installer.upgrade.pegaRESTUsername | For zero-downtime upgrades, specify username to access Pega REST server within the quotes that the process uses to perform pre-upgrade/post-upgrade actions required for the upgrade orchestration. | pegaRESTUsername: "" | + | installer.upgrade.pegaRESTPassword | For zero-downtime upgrades, specify user's password to access Pega REST server within the quotes that the process uses to perform pre-upgrade/post-upgrade actions required for the upgrade orchestration. | pegaRESTPassword: "" | 2. Save the file. @@ -177,4 +180,4 @@ In this document, you specify that the Helm chart always “deploys” by using A successful deployment does not show errors across the various workloads. The `mypega--demo` Namespace **Overview** view shows charts of the percentage of complete tiers and resources configurations. A successful deployment has 100% complete **Workloads**. - It takes a little over an hour for the upgrade process to upgrade the applicable rules and then perform a rolling reboot of your nodes. \ No newline at end of file + It takes a little over an hour for the upgrade process to upgrade the applicable rules and then perform a rolling reboot of your nodes. diff --git a/terratest/src/test/pega/pega-action-validate_test.go b/terratest/src/test/pega/pega-action-validate_test.go index 359310cf8..22384c26f 100644 --- a/terratest/src/test/pega/pega-action-validate_test.go +++ b/terratest/src/test/pega/pega-action-validate_test.go @@ -21,7 +21,7 @@ func TestPegaActonValidate_WithValidAction(t *testing.T){ SetValues: map[string]string{ "global.provider": "k8s", "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), }, } diff --git a/terratest/src/test/pega/pega-credentials-secret-with-cassandra-enc_test.go b/terratest/src/test/pega/pega-credentials-secret-with-cassandra-enc_test.go index 672eb4cb0..2fbf1d76d 100644 --- a/terratest/src/test/pega/pega-credentials-secret-with-cassandra-enc_test.go +++ b/terratest/src/test/pega/pega-credentials-secret-with-cassandra-enc_test.go @@ -31,7 +31,7 @@ func TestPegaCredentialsSecretWithCassandraEncryptionPresent(t *testing.T) { SetValues: map[string]string{ "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "dds.trustStorePassword": trustStorePassword, "dds.keyStorePassword": keyStorePassword, }, diff --git a/terratest/src/test/pega/pega-credentials-secret-with-external-stream_test.go b/terratest/src/test/pega/pega-credentials-secret-with-external-stream_test.go index 088f52ed5..e879c3e10 100644 --- a/terratest/src/test/pega/pega-credentials-secret-with-external-stream_test.go +++ b/terratest/src/test/pega/pega-credentials-secret-with-external-stream_test.go @@ -32,7 +32,7 @@ func TestPegaCredentialsSecretWithExternalStreamArePresent(t *testing.T) { SetValues: map[string]string{ "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "stream.trustStorePassword": streamTrustStorePassword, "stream.keyStorePassword": streamKeyStorePassword, "stream.jaasConfig": jaasConfig, diff --git a/terratest/src/test/pega/pega-credentials-secret_test.go b/terratest/src/test/pega/pega-credentials-secret_test.go index 00e32adf6..becbc0c1c 100644 --- a/terratest/src/test/pega/pega-credentials-secret_test.go +++ b/terratest/src/test/pega/pega-credentials-secret_test.go @@ -31,7 +31,7 @@ func TestPegaCredentialsSecret(t *testing.T){ "global.deployment.name": depName, "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), }, } @@ -63,7 +63,7 @@ func TestPegaCredentialsSecretWithArtifactoryBasicAuth(t *testing.T){ "global.deployment.name": depName, "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "global.customArtifactory.authentication.basic.username": "username", "global.customArtifactory.authentication.basic.password": "pwd", "global.customArtifactory.authentication.apiKey.headerName": "", @@ -99,7 +99,7 @@ func TestPegaCredentialsSecretWithNoArtifactoryBasicAuth(t *testing.T){ "global.deployment.name": depName, "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "global.customArtifactory.authentication.basic.username": "", "global.customArtifactory.authentication.basic.password": "pwd", "global.customArtifactory.authentication.apiKey.headerName": "", @@ -135,7 +135,7 @@ func TestPegaCredentialsSecretWithArtifactoryApiKeyAuth(t *testing.T){ "global.deployment.name": depName, "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "global.customArtifactory.authentication.apiKey.headerName": "headerName", "global.customArtifactory.authentication.apiKey.value": "apiKey-value", "global.customArtifactory.authentication.basic.username": "", @@ -171,7 +171,7 @@ func TestPegaCredentialsSecretWithNoArtifactoryApiKeyAuth(t *testing.T){ "global.deployment.name": depName, "global.provider": vendor, "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.upgradeType": getUpgradeTypeForUpgradeAction(operation), "global.customArtifactory.authentication.apiKey.headerName": "headerName", "global.customArtifactory.authentication.apiKey.value": "", "global.customArtifactory.authentication.basic.username": "", diff --git a/terratest/src/test/pega/pega-installer-action-validate_test.go b/terratest/src/test/pega/pega-installer-action-validate_test.go index 7d5ec4235..b89fcd440 100644 --- a/terratest/src/test/pega/pega-installer-action-validate_test.go +++ b/terratest/src/test/pega/pega-installer-action-validate_test.go @@ -11,7 +11,7 @@ import ( func TestPegaInstallerAction_WithValidUpgradeType(t *testing.T) { var supportedActions = []string{"upgrade"} - var supportedUpgradeTypes = []string{"in-place" ,"out-of-place", "zero-downtime", "custom", "out-of-place-rules" ,"out-of-place-data"} + var supportedUpgradeTypes = []string{"in-place" ,"out-of-place", "custom", "out-of-place-rules" ,"out-of-place-data"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -36,7 +36,7 @@ func TestPegaInstallerAction_WithValidUpgradeType(t *testing.T) { func TestPegaInstallerAction_WithValidUpgradedeployType(t *testing.T) { var supportedActions = []string{"upgrade-deploy"} - var supportedUpgradeTypes = []string{"zero-downtime" } + var supportedUpgradeTypes = []string{"zero-downtime"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) diff --git a/terratest/src/test/pega/pega-installer-config-connprops_test.go b/terratest/src/test/pega/pega-installer-config-connprops_test.go index b5e5b2a4d..2398d43c6 100644 --- a/terratest/src/test/pega/pega-installer-config-connprops_test.go +++ b/terratest/src/test/pega/pega-installer-config-connprops_test.go @@ -13,7 +13,7 @@ import ( func TestPegaInstallerConnectionPropsConfig(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} var supportedDbs = []string{"postgres", "mssql", "oracledate", "udb", "db2zos"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) diff --git a/terratest/src/test/pega/pega-installer-config_test.go b/terratest/src/test/pega/pega-installer-config_test.go index 212d5828d..33ae93ad9 100644 --- a/terratest/src/test/pega/pega-installer-config_test.go +++ b/terratest/src/test/pega/pega-installer-config_test.go @@ -11,7 +11,7 @@ import ( func TestPegaInstallerConfig(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -20,8 +20,8 @@ func TestPegaInstallerConfig(t *testing.T) { for _, operation := range supportedOperations { var options = &helm.Options{ SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, + "global.provider": vendor, + "global.actions.execute": operation, "installer.upgrade.upgradeType": "zero-downtime", }, } diff --git a/terratest/src/test/pega/pega-installer-job-artifactory-cert_test.go b/terratest/src/test/pega/pega-installer-job-artifactory-cert_test.go index fc944d920..8700f6746 100644 --- a/terratest/src/test/pega/pega-installer-job-artifactory-cert_test.go +++ b/terratest/src/test/pega/pega-installer-job-artifactory-cert_test.go @@ -13,81 +13,81 @@ import ( func TestPegaInstallerJobWithArtifactoryCert(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) for _, vendor := range supportedVendors { for _, operation := range supportedOperations { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", - "global.customArtifactory.enableSSLVerification": "true", - "global.customArtifactory.certificate": "self-signed-certificate.cer: |\n-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgIENdb1mTANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJJ\nTjESMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNV\nBAoTBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMw\nHhcNMjIwMzIyMTYwNzQxWhcNMjMwMzE3MTYwNzQxWjBrMQswCQYDVQQGEwJJTjES\nMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNVBAoT\nBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMwggEi\nMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCNYvEPbKRZ1y3u5fmPcvdBaQVK\nXsy3ioY7ToMP6vpNXGmRhI06t6jVzDVU85jtdSb4On2B4uyZwUSxO9cWfOFtI6wW\nnrdhRxmygFvXwinon6LXcoRfK9TjI72C/694UWu/UysaUp8yWyrHf2XfQK2qFqMC\nej57bpRSCME2maAXKC88IGNpeX2XjhICUKPPBrWDpK4Jq7NhcgV6z0hmtCWg8+lj\nmMZRXDoJKMNNhWOKMYhL/djDJZH+PMON7sOGVtE52U0UBLhff6Ee4ERBRummNgCv\nxt4MTmzgewsN1uKQ5MiBjtJduVEmKhhiIV38QetrCPpejAHOJLFe2l5VfKHDAgMB\nAAGjITAfMB0GA1UdDgQWBBTK0eVfaa41Vr4qXTww3RBTgFO78DANBgkqhkiG9w0B\nAQsFAAOCAQEAOAjezNJmMx9j0hnutOspnHC8iOqaFQjW8t6D9cWEQALd2PNPB5S9\nQxlEuaN3x/zbtNI55fxZW6ryP/AJ0DclTs8vwzEk7DJ1Yt7vMfFG6DxbIUlPY677\nDGB23K68BXl8MtSYvOLbDwXYjyMDUzcmojaIjS6RwW8C5yvXW34h2jjwVWQm1yti\n46xANKLHEVTp44LiG+gf/9TxfQjSQXpSdgdMbJB744tMmozyfbtulWE0T5dBvd8w\ncdbPKbgldsv4bc8EojOYRRasYu6nZqP+8Tw/4jHr4IB2kiuJ63gs6IlqnzDyzzQ7\nYc0a+hYe1cTSXQn23aL/c9v/901LUpdAYw==\n-----END CERTIFICATE-----\n", - }, - } + var options = &helm.Options{ + SetValues: map[string]string{ + "global.provider": vendor, + "global.actions.execute": operation, + "installer.upgrade.upgradeType": "zero-downtime", + "global.customArtifactory.enableSSLVerification": "true", + "global.customArtifactory.certificate": "self-signed-certificate.cer: |\n-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgIENdb1mTANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJJ\nTjESMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNV\nBAoTBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMw\nHhcNMjIwMzIyMTYwNzQxWhcNMjMwMzE3MTYwNzQxWjBrMQswCQYDVQQGEwJJTjES\nMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNVBAoT\nBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMwggEi\nMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCNYvEPbKRZ1y3u5fmPcvdBaQVK\nXsy3ioY7ToMP6vpNXGmRhI06t6jVzDVU85jtdSb4On2B4uyZwUSxO9cWfOFtI6wW\nnrdhRxmygFvXwinon6LXcoRfK9TjI72C/694UWu/UysaUp8yWyrHf2XfQK2qFqMC\nej57bpRSCME2maAXKC88IGNpeX2XjhICUKPPBrWDpK4Jq7NhcgV6z0hmtCWg8+lj\nmMZRXDoJKMNNhWOKMYhL/djDJZH+PMON7sOGVtE52U0UBLhff6Ee4ERBRummNgCv\nxt4MTmzgewsN1uKQ5MiBjtJduVEmKhhiIV38QetrCPpejAHOJLFe2l5VfKHDAgMB\nAAGjITAfMB0GA1UdDgQWBBTK0eVfaa41Vr4qXTww3RBTgFO78DANBgkqhkiG9w0B\nAQsFAAOCAQEAOAjezNJmMx9j0hnutOspnHC8iOqaFQjW8t6D9cWEQALd2PNPB5S9\nQxlEuaN3x/zbtNI55fxZW6ryP/AJ0DclTs8vwzEk7DJ1Yt7vMfFG6DxbIUlPY677\nDGB23K68BXl8MtSYvOLbDwXYjyMDUzcmojaIjS6RwW8C5yvXW34h2jjwVWQm1yti\n46xANKLHEVTp44LiG+gf/9TxfQjSQXpSdgdMbJB744tMmozyfbtulWE0T5dBvd8w\ncdbPKbgldsv4bc8EojOYRRasYu6nZqP+8Tw/4jHr4IB2kiuJ63gs6IlqnzDyzzQ7\nYc0a+hYe1cTSXQn23aL/c9v/901LUpdAYw==\n-----END CERTIFICATE-----\n", + }, + } - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) - yamlSplit := strings.Split(yamlContent, "---") + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) + yamlSplit := strings.Split(yamlContent, "---") - // If there are three slices, it means that it is a pega-upgrade-deploy job - if len(yamlSplit) == 4 { - for index, jobInfo := range yamlSplit { - if index >= 1 && index <= 3 { - assertJobArtifactoryCertVolumeAndMount(t, jobInfo, true) - } + // If there are three slices, it means that it is a pega-upgrade-deploy job + if len(yamlSplit) == 4 { + for index, jobInfo := range yamlSplit { + if index >= 1 && index <= 3 { + assertJobArtifactoryCertVolumeAndMount(t, jobInfo, true) } + } + } else { + if operation == "install" || operation == "install-deploy" { + assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], true) } else { - if operation == "install" || operation == "install-deploy" { - assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], true) - } else { - assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], true) - } + assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], true) } } + } } } func TestPegaInstallerJobWithoutArtifactoryCert(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) for _, vendor := range supportedVendors { for _, operation := range supportedOperations { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", - "global.customArtifactory.enableSSLVerification": "false", - "global.customArtifactory.certificate": "self-signed-certificate.cer: |\n-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgIENdb1mTANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJJ\nTjESMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNV\nBAoTBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMw\nHhcNMjIwMzIyMTYwNzQxWhcNMjMwMzE3MTYwNzQxWjBrMQswCQYDVQQGEwJJTjES\nMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNVBAoT\nBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMwggEi\nMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCNYvEPbKRZ1y3u5fmPcvdBaQVK\nXsy3ioY7ToMP6vpNXGmRhI06t6jVzDVU85jtdSb4On2B4uyZwUSxO9cWfOFtI6wW\nnrdhRxmygFvXwinon6LXcoRfK9TjI72C/694UWu/UysaUp8yWyrHf2XfQK2qFqMC\nej57bpRSCME2maAXKC88IGNpeX2XjhICUKPPBrWDpK4Jq7NhcgV6z0hmtCWg8+lj\nmMZRXDoJKMNNhWOKMYhL/djDJZH+PMON7sOGVtE52U0UBLhff6Ee4ERBRummNgCv\nxt4MTmzgewsN1uKQ5MiBjtJduVEmKhhiIV38QetrCPpejAHOJLFe2l5VfKHDAgMB\nAAGjITAfMB0GA1UdDgQWBBTK0eVfaa41Vr4qXTww3RBTgFO78DANBgkqhkiG9w0B\nAQsFAAOCAQEAOAjezNJmMx9j0hnutOspnHC8iOqaFQjW8t6D9cWEQALd2PNPB5S9\nQxlEuaN3x/zbtNI55fxZW6ryP/AJ0DclTs8vwzEk7DJ1Yt7vMfFG6DxbIUlPY677\nDGB23K68BXl8MtSYvOLbDwXYjyMDUzcmojaIjS6RwW8C5yvXW34h2jjwVWQm1yti\n46xANKLHEVTp44LiG+gf/9TxfQjSQXpSdgdMbJB744tMmozyfbtulWE0T5dBvd8w\ncdbPKbgldsv4bc8EojOYRRasYu6nZqP+8Tw/4jHr4IB2kiuJ63gs6IlqnzDyzzQ7\nYc0a+hYe1cTSXQn23aL/c9v/901LUpdAYw==\n-----END CERTIFICATE-----\n", - }, - } + var options = &helm.Options{ + SetValues: map[string]string{ + "global.provider": vendor, + "global.actions.execute": operation, + "installer.upgrade.upgradeType": "zero-downtime", + "global.customArtifactory.enableSSLVerification": "false", + "global.customArtifactory.certificate": "self-signed-certificate.cer: |\n-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgIENdb1mTANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJJ\nTjESMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNV\nBAoTBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMw\nHhcNMjIwMzIyMTYwNzQxWhcNMjMwMzE3MTYwNzQxWjBrMQswCQYDVQQGEwJJTjES\nMBAGA1UECBMJVGVsYW5nYW5hMRIwEAYDVQQHEwlIeWRlcmFiYWQxDTALBgNVBAoT\nBFBlZ2ExDTALBgNVBAsTBFBERFMxFjAUBgNVBAMTDTEwLjIyNS43MS4xNDMwggEi\nMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCNYvEPbKRZ1y3u5fmPcvdBaQVK\nXsy3ioY7ToMP6vpNXGmRhI06t6jVzDVU85jtdSb4On2B4uyZwUSxO9cWfOFtI6wW\nnrdhRxmygFvXwinon6LXcoRfK9TjI72C/694UWu/UysaUp8yWyrHf2XfQK2qFqMC\nej57bpRSCME2maAXKC88IGNpeX2XjhICUKPPBrWDpK4Jq7NhcgV6z0hmtCWg8+lj\nmMZRXDoJKMNNhWOKMYhL/djDJZH+PMON7sOGVtE52U0UBLhff6Ee4ERBRummNgCv\nxt4MTmzgewsN1uKQ5MiBjtJduVEmKhhiIV38QetrCPpejAHOJLFe2l5VfKHDAgMB\nAAGjITAfMB0GA1UdDgQWBBTK0eVfaa41Vr4qXTww3RBTgFO78DANBgkqhkiG9w0B\nAQsFAAOCAQEAOAjezNJmMx9j0hnutOspnHC8iOqaFQjW8t6D9cWEQALd2PNPB5S9\nQxlEuaN3x/zbtNI55fxZW6ryP/AJ0DclTs8vwzEk7DJ1Yt7vMfFG6DxbIUlPY677\nDGB23K68BXl8MtSYvOLbDwXYjyMDUzcmojaIjS6RwW8C5yvXW34h2jjwVWQm1yti\n46xANKLHEVTp44LiG+gf/9TxfQjSQXpSdgdMbJB744tMmozyfbtulWE0T5dBvd8w\ncdbPKbgldsv4bc8EojOYRRasYu6nZqP+8Tw/4jHr4IB2kiuJ63gs6IlqnzDyzzQ7\nYc0a+hYe1cTSXQn23aL/c9v/901LUpdAYw==\n-----END CERTIFICATE-----\n", + }, + } - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) - yamlSplit := strings.Split(yamlContent, "---") + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) + yamlSplit := strings.Split(yamlContent, "---") - // If there are three slices, it means that it is a pega-upgrade-deploy job - if len(yamlSplit) == 4 { - for index, jobInfo := range yamlSplit { - if index >= 1 && index <= 3 { - assertJobArtifactoryCertVolumeAndMount(t, jobInfo, false) - } + // If there are three slices, it means that it is a pega-upgrade-deploy job + if len(yamlSplit) == 4 { + for index, jobInfo := range yamlSplit { + if index >= 1 && index <= 3 { + assertJobArtifactoryCertVolumeAndMount(t, jobInfo, false) } + } + } else { + if operation == "install" || operation == "install-deploy" { + assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], false) } else { - if operation == "install" || operation == "install-deploy" { - assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], false) - } else { - assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], false) - } + assertJobArtifactoryCertVolumeAndMount(t, yamlSplit[1], false) } + } } } } @@ -109,14 +109,14 @@ func assertJobArtifactoryCertVolumeAndMount(t *testing.T, jobYaml string, should var foundVolMount = false for _, container := range jobSpec.Containers { - for _, volMount := range container.VolumeMounts { - if volMount.Name == "pega-volume-custom-artifactory-certificate" { - require.Equal(t, "/opt/pega/artifactory/cert", volMount.MountPath) - foundVolMount = true - break - } + for _, volMount := range container.VolumeMounts { + if volMount.Name == "pega-volume-custom-artifactory-certificate" { + require.Equal(t, "/opt/pega/artifactory/cert", volMount.MountPath) + foundVolMount = true + break } - break + } + break } require.Equal(t, shouldHaveVol, foundVolMount) diff --git a/terratest/src/test/pega/pega-installer-job_test.go b/terratest/src/test/pega/pega-installer-job_test.go index c3f85f99e..a4d485f8a 100644 --- a/terratest/src/test/pega/pega-installer-job_test.go +++ b/terratest/src/test/pega/pega-installer-job_test.go @@ -24,7 +24,7 @@ var volDefaultModePointer = &volDefaultMode func TestPegaInstallerJob(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} var deploymentNames = []string{"pega", "myapp-dev"} var imagePullPolicy = []string{"", "IfNotPresent", "Always"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) diff --git a/terratest/src/test/pega/pega-registry-secret_test.go b/terratest/src/test/pega/pega-registry-secret_test.go index dfccbc134..fb7ef6fda 100644 --- a/terratest/src/test/pega/pega-registry-secret_test.go +++ b/terratest/src/test/pega/pega-registry-secret_test.go @@ -1,49 +1,45 @@ package pega import ( + "fmt" "github.com/gruntwork-io/terratest/modules/helm" "github.com/stretchr/testify/require" k8score "k8s.io/api/core/v1" "path/filepath" "testing" - "fmt" ) - - -func TestPegaRegistrySecret(t *testing.T){ - var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} - var supportedOperations = []string{"install","install-deploy", "upgrade", "upgrade-deploy"} - var deploymentNames = []string{"pega","myapp-dev"} +func TestPegaRegistrySecret(t *testing.T) { + var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} + var supportedOperations = []string{"install", "install-deploy", "upgrade-deploy"} + var deploymentNames = []string{"pega", "myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) + for _, vendor := range supportedVendors { - for _,vendor := range supportedVendors{ + for _, operation := range supportedOperations { - for _,operation := range supportedOperations{ + for _, depName := range deploymentNames { - for _, depName := range deploymentNames { + fmt.Println(vendor + "-" + operation) - fmt.Println(vendor + "-" + operation) - - var options = &helm.Options{ - SetValues: map[string]string{ - "global.deployment.name": depName, - "global.provider": vendor, - "global.actions.execute": operation, + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, "installer.upgrade.upgradeType": "zero-downtime", - }, - } + }, + } - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-registry-secret.yaml"}) - VerfiyRegistrySecret(t, yamlContent, options) + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-registry-secret.yaml"}) + VerfiyRegistrySecret(t, yamlContent, options) } } } - } // VerfiyRegistrySecret - Verifies the registry secret deployed with the values as provided in default values.yaml @@ -54,4 +50,4 @@ func VerfiyRegistrySecret(t *testing.T, yamlContent string, options *helm.Option reqgistrySecretData := registrySecretObj.Data require.Contains(t, string(reqgistrySecretData[".dockerconfigjson"]), "YOUR_DOCKER_REGISTRY") require.Contains(t, string(reqgistrySecretData[".dockerconfigjson"]), "WU9VUl9ET0NLRVJfUkVHSVNUUllfVVNFUk5BTUU6WU9VUl9ET0NLRVJfUkVHSVNUUllfUEFTU1dPUkQ=") -} \ No newline at end of file +} diff --git a/terratest/src/test/pega/pega-upgrade-environment-config_test.go b/terratest/src/test/pega/pega-upgrade-environment-config_test.go index b9a0686f3..0c4e15ddf 100644 --- a/terratest/src/test/pega/pega-upgrade-environment-config_test.go +++ b/terratest/src/test/pega/pega-upgrade-environment-config_test.go @@ -11,7 +11,8 @@ import ( func TestPegaUpgradeEnvironmentConfig(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} - var supportedOperations = []string{"upgrade", "upgrade-deploy"} + var supportedOperations = []string{"upgrade-deploy"} + var expectedValues = map[string]string{"PEGA_REST_SERVER_URL": "restURL", "PEGA_REST_USERNAME": "username", "PEGA_REST_PASSWORD": "password"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -20,19 +21,22 @@ func TestPegaUpgradeEnvironmentConfig(t *testing.T) { for _, operation := range supportedOperations { var options = &helm.Options{ SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - "installer.upgrade.upgradeType": "zero-downtime", + "global.provider": vendor, + "global.actions.execute": operation, + "installer.upgrade.upgradeType": "zero-downtime", + "installer.upgrade.pegaRESTServerURL": expectedValues["PEGA_REST_SERVER_URL"], + "installer.upgrade.pegaRESTUsername": expectedValues["PEGA_REST_USERNAME"], + "installer.upgrade.pegaRESTPassword": expectedValues["PEGA_REST_PASSWORD"], }, } yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-upgrade-environment-config.yaml"}) - assertUpgradeEnvironmentConfig(t, yamlContent, options) + assertUpgradeEnvironmentConfig(t, yamlContent, options, expectedValues) } } } -func assertUpgradeEnvironmentConfig(t *testing.T, configYaml string, options *helm.Options) { +func assertUpgradeEnvironmentConfig(t *testing.T, configYaml string, options *helm.Options, expectedValues map[string]string) { var upgradeEnvConfigMap k8score.ConfigMap UnmarshalK8SYaml(t, configYaml, &upgradeEnvConfigMap) @@ -59,6 +63,9 @@ func assertUpgradeEnvironmentConfig(t *testing.T, configYaml string, options *he require.Equal(t, upgradeEnvConfigData["UPDATE_APPLICATIONS_SCHEMA"], "false") require.Equal(t, upgradeEnvConfigData["RUN_RULESET_CLEANUP"], "false") require.Equal(t, upgradeEnvConfigData["REBUILD_INDEXES"], "false") + require.Equal(t, upgradeEnvConfigData["PEGA_REST_SERVER_URL"], expectedValues["PEGA_REST_SERVER_URL"]) + require.Equal(t, upgradeEnvConfigData["PEGA_REST_USERNAME"], expectedValues["PEGA_REST_USERNAME"]) + require.Equal(t, upgradeEnvConfigData["PEGA_REST_PASSWORD"], expectedValues["PEGA_REST_PASSWORD"]) require.Equal(t, upgradeEnvConfigData["DISTRIBUTION_KIT_URL"], "") - require.Equal(t, upgradeEnvConfigData["ENABLE_CUSTOM_ARTIFACTORY_SSL_VERIFICATION"], "true") + require.Equal(t, upgradeEnvConfigData["ENABLE_CUSTOM_ARTIFACTORY_SSL_VERIFICATION"], "true") } diff --git a/terratest/src/test/pega/utilities.go b/terratest/src/test/pega/utilities.go index f75cfb856..393355d72 100644 --- a/terratest/src/test/pega/utilities.go +++ b/terratest/src/test/pega/utilities.go @@ -92,3 +92,11 @@ func getDeploymentName(options *helm.Options) string { func getObjName(options *helm.Options, suffix string) string { return getDeploymentName(options) + suffix } + +func getUpgradeTypeForUpgradeAction(action string) string { + if action == "upgrade-deploy" { + return "zero-downtime" + } else { + return "out-of-place" + } +}