From 2dbb9eb8dd0dbe46a0e3e49aded9fb18de948095 Mon Sep 17 00:00:00 2001 From: Andrew Roskuski Date: Tue, 26 Apr 2022 14:11:24 -0400 Subject: [PATCH] specify connection props directly (#417) * specify connection props directly Since we're not using the normal setupDatabase file path, they don't get picked up if we specify them the normal way * setupDatabase.xml will still need access to these * add unit test for custom props * fix compile error * import fmt * Fix paths to config files * also check site dependent props * fix assertion --- .../charts/installer/templates/_helpers.tpl | 6 ++ .../templates/_pega-installer-config.tpl | 17 ++++-- .../data/expectedDB2SiteDependent.properties | 25 ++++++++ .../src/test/pega/data/expecteddb2zos.conf | 13 ++++ .../src/test/pega/data/expectedmssql.conf | 6 ++ .../test/pega/data/expectedoracledate.conf | 7 +++ .../src/test/pega/data/expectedpostgres.conf | 6 ++ terratest/src/test/pega/data/expectedudb.conf | 8 +++ .../pega-installer-config-connprops_test.go | 59 +++++++++++++++++++ 9 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 terratest/src/test/pega/data/expectedDB2SiteDependent.properties create mode 100644 terratest/src/test/pega/data/expecteddb2zos.conf create mode 100644 terratest/src/test/pega/data/expectedmssql.conf create mode 100644 terratest/src/test/pega/data/expectedoracledate.conf create mode 100644 terratest/src/test/pega/data/expectedpostgres.conf create mode 100644 terratest/src/test/pega/data/expectedudb.conf create mode 100644 terratest/src/test/pega/pega-installer-config-connprops_test.go diff --git a/charts/pega/charts/installer/templates/_helpers.tpl b/charts/pega/charts/installer/templates/_helpers.tpl index 9d9ea813d..0707b2ce9 100644 --- a/charts/pega/charts/installer/templates/_helpers.tpl +++ b/charts/pega/charts/installer/templates/_helpers.tpl @@ -112,3 +112,9 @@ value: {{ $apiserver.httpsServicePort | quote }} {{- end }} {{- end }} + +{{- define "customJdbcProps" -}} +{{ range (splitList ";" .Values.global.jdbc.connectionProperties) }} +{{ . }} +{{ end }} +{{- end -}} \ No newline at end of file diff --git a/charts/pega/charts/installer/templates/_pega-installer-config.tpl b/charts/pega/charts/installer/templates/_pega-installer-config.tpl index 7f4c2811d..54ff8472c 100644 --- a/charts/pega/charts/installer/templates/_pega-installer-config.tpl +++ b/charts/pega/charts/installer/templates/_pega-installer-config.tpl @@ -66,30 +66,34 @@ data: {{- end }} {{- $dbType := .dbType }} -{{- $postgresConfPath := "config/postgres/postgres.conf" }} -{{- $oracledateConfPath := "config/oracledate/oracledate.conf" }} -{{- $db2zosConfPath := "config/db2zos/db2zos.conf" }} -{{- $mssqlConfPath := "config/mssql/mssql.conf" }} -{{- $udbConfPath := "config/udb/udb.conf" }} -{{- $zosPropertiesPath := "config/db2zos/DB2SiteDependent.properties" }} +{{- $postgresConfPath := "config/postgres.conf" }} +{{- $oracledateConfPath := "config/oracledate.conf" }} +{{- $db2zosConfPath := "config/db2zos.conf" }} +{{- $mssqlConfPath := "config/mssql.conf" }} +{{- $udbConfPath := "config/udb.conf" }} +{{- $zosPropertiesPath := "config/DB2SiteDependent.properties" }} {{ if and (eq $dbType "postgres") ( $postgresConf := .root.Files.Glob $postgresConfPath ) }} postgres.conf: |- +{{ include "customJdbcProps" .root | indent 6 }} {{ .root.Files.Get $postgresConfPath | indent 6 }} {{- end }} {{ if and (eq $dbType "oracledate") ( $oracledateConf := .root.Files.Glob $oracledateConfPath ) }} oracledate.conf: |- +{{ include "customJdbcProps" .root | indent 6 }} {{ .root.Files.Get $oracledateConfPath | indent 6 }} {{- end }} {{ if and (eq $dbType "mssql") ( $mssqlConf := .root.Files.Glob $mssqlConfPath ) }} mssql.conf: |- +{{ include "customJdbcProps" .root | indent 6 }} {{ .root.Files.Get $mssqlConfPath | indent 6 }} {{- end }} {{ if and (eq $dbType "db2zos") ( $db2zosConf := .root.Files.Glob $db2zosConfPath ) ( $db2zosProperties := .root.Files.Glob $zosPropertiesPath ) }} db2zos.conf: |- +{{ include "customJdbcProps" .root | indent 6 }} {{ .root.Files.Get $db2zosConfPath | indent 6 }} DB2SiteDependent.properties: |- {{ .root.Files.Get $zosPropertiesPath | indent 6 }} @@ -97,6 +101,7 @@ data: {{ if and (eq $dbType "udb") ( $udbConf := .root.Files.Glob $udbConfPath ) }} udb.conf: |- +{{ include "customJdbcProps" .root | indent 6 }} {{ .root.Files.Get $udbConfPath | indent 6 }} {{- end }} diff --git a/terratest/src/test/pega/data/expectedDB2SiteDependent.properties b/terratest/src/test/pega/data/expectedDB2SiteDependent.properties new file mode 100644 index 000000000..f802d8312 --- /dev/null +++ b/terratest/src/test/pega/data/expectedDB2SiteDependent.properties @@ -0,0 +1,25 @@ +#BLBBFP=BP32K1 +#BLBLCK=LOB +#BLBLCM=0 +#BLBLOG=YES +#BLBPRI=14400 +#BLBSEC=7200 +#BLBSTG=Blob.storage.group.name +## +#IDXBP=BP2 +#IDXPRI=7200 +#IDXSEC=7200 +#IDXSTG=Index.storage.group.name +## +#TSPLCK=PAGE +#TSPLCM=0 +#TSPPRI=14400 +#TSPSEC=7200 +#TSPSTG=Table.storage.group.name +#TS32BP=BP32K +# +#CCSID=EBCDIC +#DBNAME=PEGDB +#DBOWNR=PEGDBDBO +#DBUSER=PEGDB +#WLMUDF= \ No newline at end of file diff --git a/terratest/src/test/pega/data/expecteddb2zos.conf b/terratest/src/test/pega/data/expecteddb2zos.conf new file mode 100644 index 000000000..66be22240 --- /dev/null +++ b/terratest/src/test/pega/data/expecteddb2zos.conf @@ -0,0 +1,13 @@ + +prop1=value1 + +prop2=value2 + +# Add any special properties for your Database configuration +currentSchema= +currentSQLID= +currentFunctionPath=SYSIBM,SYSFUN +progressiveStreaming=2 +fullyMaterializeLobData=true +defaultIsolationLevel=1 +useJDBC4ColumnNameAndLabelSemantics=2 \ No newline at end of file diff --git a/terratest/src/test/pega/data/expectedmssql.conf b/terratest/src/test/pega/data/expectedmssql.conf new file mode 100644 index 000000000..58c10d414 --- /dev/null +++ b/terratest/src/test/pega/data/expectedmssql.conf @@ -0,0 +1,6 @@ + +prop1=value1 + +prop2=value2 + +# Add any special properties for your Database configuration \ No newline at end of file diff --git a/terratest/src/test/pega/data/expectedoracledate.conf b/terratest/src/test/pega/data/expectedoracledate.conf new file mode 100644 index 000000000..9e1d513ed --- /dev/null +++ b/terratest/src/test/pega/data/expectedoracledate.conf @@ -0,0 +1,7 @@ + +prop1=value1 + +prop2=value2 + +# Add any special properties for your Database configuration +oracle.jdbc.V8Compatible=true \ No newline at end of file diff --git a/terratest/src/test/pega/data/expectedpostgres.conf b/terratest/src/test/pega/data/expectedpostgres.conf new file mode 100644 index 000000000..58c10d414 --- /dev/null +++ b/terratest/src/test/pega/data/expectedpostgres.conf @@ -0,0 +1,6 @@ + +prop1=value1 + +prop2=value2 + +# Add any special properties for your Database configuration \ No newline at end of file diff --git a/terratest/src/test/pega/data/expectedudb.conf b/terratest/src/test/pega/data/expectedudb.conf new file mode 100644 index 000000000..3617a2ed7 --- /dev/null +++ b/terratest/src/test/pega/data/expectedudb.conf @@ -0,0 +1,8 @@ + +prop1=value1 + +prop2=value2 + +# Add any special properties for your Database configuration +currentSchema= +currentFunctionPath=SYSIBM,SYSFUN \ No newline at end of file diff --git a/terratest/src/test/pega/pega-installer-config-connprops_test.go b/terratest/src/test/pega/pega-installer-config-connprops_test.go new file mode 100644 index 000000000..b5e5b2a4d --- /dev/null +++ b/terratest/src/test/pega/pega-installer-config-connprops_test.go @@ -0,0 +1,59 @@ +package pega + +import ( + "fmt" + "path/filepath" + "testing" + + "github.com/gruntwork-io/terratest/modules/helm" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + k8score "k8s.io/api/core/v1" +) + +func TestPegaInstallerConnectionPropsConfig(t *testing.T) { + var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} + var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var supportedDbs = []string{"postgres", "mssql", "oracledate", "udb", "db2zos"} + + helmChartPath, err := filepath.Abs(PegaHelmChartPath) + require.NoError(t, err) + + for _, vendor := range supportedVendors { + for _, operation := range supportedOperations { + for _, dbPlatform := range supportedDbs { + var options = &helm.Options{ + SetValues: map[string]string{ + "global.provider": vendor, + "global.actions.execute": operation, + "global.jdbc.dbType": dbPlatform, + "global.jdbc.connectionProperties": "prop1=value1;prop2=value2", + "installer.upgrade.upgradeType": "zero-downtime", + }, + } + + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-config.yaml"}) + assertInstallerConnectionPropsConfig(t, yamlContent, dbPlatform) + } + } + } +} + +func assertInstallerConnectionPropsConfig(t *testing.T, configYaml string, dbPlatform string) { + var installConfigMap k8score.ConfigMap + UnmarshalK8SYaml(t, configYaml, &installConfigMap) + installConfigData := installConfigMap.Data + + compareConfigMapData(t, installConfigData["prconfig.xml.tmpl"], "data/expectedPrconfig.xml") + compareConfigMapData(t, installConfigData["setupDatabase.properties.tmpl"], "data/expectedSetupdatabase.properties") + compareConfigMapData(t, installConfigData["prbootstrap.properties.tmpl"], "data/expectedPRbootstrap.properties") + compareConfigMapData(t, installConfigData["migrateSystem.properties.tmpl"], "data/expectedMigrateSystem.properties.tmpl") + compareConfigMapData(t, installConfigData["prlog4j2.xml"], "data/expectedPRlog4j2.xml") + compareConfigMapData(t, installConfigData["prpcUtils.properties.tmpl"], "data/expectedPRPCUtils.properties.tmpl") + compareConfigMapData(t, installConfigData[fmt.Sprintf("%s.conf", dbPlatform)], fmt.Sprintf("data/expected%s.conf", dbPlatform)) + if dbPlatform == "db2zos" { + compareConfigMapData(t, installConfigData["DB2SiteDependent.properties"], "data/expectedDB2SiteDependent.properties") + } else { + assert.Equal(t, installConfigData["DB2SiteDependent.properties"], "") + } +}