Skip to content

Commit

Permalink
specify connection props directly (#417)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pega-roska authored Apr 26, 2022
1 parent 7152d36 commit 2dbb9eb
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 6 deletions.
6 changes: 6 additions & 0 deletions charts/pega/charts/installer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@
value: {{ $apiserver.httpsServicePort | quote }}
{{- end }}
{{- end }}

{{- define "customJdbcProps" -}}
{{ range (splitList ";" .Values.global.jdbc.connectionProperties) }}
{{ . }}
{{ end }}
{{- end -}}
17 changes: 11 additions & 6 deletions charts/pega/charts/installer/templates/_pega-installer-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,42 @@ 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 }}
{{- end }}

{{ if and (eq $dbType "udb") ( $udbConf := .root.Files.Glob $udbConfPath ) }}
udb.conf: |-
{{ include "customJdbcProps" .root | indent 6 }}
{{ .root.Files.Get $udbConfPath | indent 6 }}
{{- end }}

Expand Down
25 changes: 25 additions & 0 deletions terratest/src/test/pega/data/expectedDB2SiteDependent.properties
Original file line number Diff line number Diff line change
@@ -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=
13 changes: 13 additions & 0 deletions terratest/src/test/pega/data/expecteddb2zos.conf
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions terratest/src/test/pega/data/expectedmssql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

prop1=value1

prop2=value2

# Add any special properties for your Database configuration
7 changes: 7 additions & 0 deletions terratest/src/test/pega/data/expectedoracledate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

prop1=value1

prop2=value2

# Add any special properties for your Database configuration
oracle.jdbc.V8Compatible=true
6 changes: 6 additions & 0 deletions terratest/src/test/pega/data/expectedpostgres.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

prop1=value1

prop2=value2

# Add any special properties for your Database configuration
8 changes: 8 additions & 0 deletions terratest/src/test/pega/data/expectedudb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

prop1=value1

prop2=value2

# Add any special properties for your Database configuration
currentSchema=
currentFunctionPath=SYSIBM,SYSFUN
59 changes: 59 additions & 0 deletions terratest/src/test/pega/pega-installer-config-connprops_test.go
Original file line number Diff line number Diff line change
@@ -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"], "")
}
}

0 comments on commit 2dbb9eb

Please sign in to comment.