Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions operator/charts/patroni-core/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,24 @@ spec:
cpu: 150m
memory: 256Mi
{{ end }}
{{- $runTestScenarios := .Values.tests.runTestScenarios }}
{{- if or (eq (lower $runTestScenarios) "full") (eq (lower $runTestScenarios) "basic") }}
runTestScenarios: {{.Values.tests.runTestScenarios}}
{{- else if index .Values.tests.testScenarios (printf "%s" $runTestScenarios) }}
{{- $runTestScenarios := lower .Values.tests.runTestScenarios }}
{{- if or (eq $runTestScenarios "full") (eq $runTestScenarios "basic") }}
runTestScenarios: {{ $runTestScenarios }}
{{- else if eq $runTestScenarios "custom" }}
runTestScenarios: custom
{{- if .Values.tests.testList }}
testList:
{{- range (index .Values.tests.testScenarios (printf "%s" $runTestScenarios)) }}
{{- range .Values.tests.testList }}
- {{ . }}
{{- end }}
{{ end }}
{{- end }}
{{- end }}
{{- else if hasKey .Values.tests.testScenarios .Values.tests.runTestScenarios }}
runTestScenarios: custom
testList:
{{- range (index .Values.tests.testScenarios .Values.tests.runTestScenarios) }}
- {{ . }}
{{- end }}
{{- end }}
pgNodeQty: {{ ( include "postgres.replicasCount" . ) }}
{{ end }}
{{ if .Values.runTestsOnly }}
Expand Down
23 changes: 16 additions & 7 deletions operator/charts/patroni-services/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,24 @@ spec:
cpu: 150m
memory: 256Mi
{{ end }}
{{- $runTestScenarios := .Values.tests.runTestScenarios }}
{{- if or (eq (lower $runTestScenarios) "full") (eq (lower $runTestScenarios) "basic") }}
runTestScenarios: {{.Values.tests.runTestScenarios}}
{{- else if index .Values.tests.testScenarios (printf "%s" $runTestScenarios) }}
{{- $runTestScenarios := lower .Values.tests.runTestScenarios }}
{{- if or (eq $runTestScenarios "full") (eq $runTestScenarios "basic") }}
runTestScenarios: {{ $runTestScenarios }}
{{- else if eq $runTestScenarios "custom" }}
runTestScenarios: custom
{{- if .Values.tests.testList }}
testList:
{{- range (index .Values.tests.testScenarios (printf "%s" $runTestScenarios)) }}
{{- range .Values.tests.testList }}
- {{ . }}
{{- end }}
{{ end }}
{{- end }}
{{- end }}
{{- else if hasKey .Values.tests.testScenarios .Values.tests.runTestScenarios }}
runTestScenarios: custom
testList:
{{- range (index .Values.tests.testScenarios .Values.tests.runTestScenarios) }}
- {{ . }}
{{- end }}
{{- end }}
pgNodeQty: {{ default "1" .Values.patroni.replicas }}
{{ end }}
{{ if .Values.runTestsOnly }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ metadata:
labels:
app: patroni-tests
data:
{{- if include "supplementary-tests.monitoredImages" . }}
dd_images: {{ include "supplementary-tests.monitoredImages" . }}
{{ else }}
dd_images: ""
{{ end }}
dd_images: {{ (.Values.tests.ddImages | default (include "supplementary-tests.monitoredImages" .) | default "") | quote }}
{{- end }}
79 changes: 48 additions & 31 deletions operator/pkg/deployment/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,22 @@ var (

func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniClusterSettings) *corev1.Pod {
testsSpec := cr.Spec.IntegrationTests
tastsTags := ""
var testsTags string
opt := true
pgHost := cluster.PostgresServiceName
if strings.ToLower(testsSpec.RunTestScenarios) == "full" {
scenario := strings.ToLower(testsSpec.RunTestScenarios)
if scenario == "full" {
if cr.Spec.BackupDaemon != nil && cr.Spec.BackupDaemon.Resources != nil {
tastsTags = "backup*ORdbaas*"
testsTags = "backup*ORdbaas*"
}
} else {
if strings.ToLower(testsSpec.RunTestScenarios) == "basic" {
if cr.Spec.BackupDaemon != nil && cr.Spec.BackupDaemon.Resources != nil {
tastsTags = "backup_basic"
}
} else {
if testsSpec.TestList != nil {
tastsTags = strings.Join(testsSpec.TestList, "OR")
r := regexp.MustCompile(`\s+`)
tastsTags = r.ReplaceAllString(tastsTags, "_")
}
} else if scenario == "basic" {
if cr.Spec.BackupDaemon != nil && cr.Spec.BackupDaemon.Resources != nil {
testsTags = "backup_basic"
}
} else if scenario == "custom" && testsSpec.TestList != nil {
testsTags = strings.Join(testsSpec.TestList, "OR")
r := regexp.MustCompile(`\s+`)
testsTags = r.ReplaceAllString(testsTags, "_")
}
dockerImage := testsSpec.DockerImage
name := "integration-robot-tests"
Expand All @@ -75,7 +73,7 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl
Image: dockerImage,
ImagePullPolicy: cr.Spec.ImagePullPolicy,
SecurityContext: util.GetDefaultSecurityContext(),
Args: []string{"robot", "-i", tastsTags, "/test_runs/"},
Args: []string{"robot", "-i", testsTags, "/test_runs/"},
Env: []corev1.EnvVar{
{
Name: "POSTGRES_USER",
Expand Down Expand Up @@ -105,7 +103,7 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl
},
{
Name: "TESTS_TAGS",
Value: tastsTags,
Value: testsTags,
},
{
Name: "PG_HOST",
Expand All @@ -127,6 +125,16 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl
},
},
},
{
Name: "DD_IMAGES",
ValueFrom: &corev1.EnvVarSource{
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: "supplementary-tests-config"},
Key: "dd_images",
Optional: &opt,
},
},
},
},
VolumeMounts: []corev1.VolumeMount{},
},
Expand All @@ -149,25 +157,24 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl

func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.PatroniClusterSettings) *corev1.Pod {
testsSpec := cr.Spec.IntegrationTests
tastsTags := ""
var testsTags string
opt := true
pgHost := cluster.PostgresServiceName
scenario := strings.ToLower(testsSpec.RunTestScenarios)
if cr.Spec.Patroni.StandbyCluster != nil {
pgHost = fmt.Sprintf("pg-%s-external", cluster.ClusterName)
}
if strings.ToLower(cr.Spec.Patroni.Dcs.Type) != "kubernetes" {
tastsTags = "patroni_simple"
testsTags = "patroni_simple"
} else {
if strings.ToLower(testsSpec.RunTestScenarios) == "full" {
tastsTags = "patroni*"
} else {
if strings.ToLower(testsSpec.RunTestScenarios) == "basic" {
tastsTags = "patroni_basic"
} else {
if testsSpec.TestList != nil {
r := regexp.MustCompile(`\s+`)
tastsTags = r.ReplaceAllString(tastsTags, "_")
}
}
if scenario == "full" {
testsTags = "patroni*"
} else if scenario == "basic" {
testsTags = "patroni_basic"
} else if scenario == "custom" && len(testsSpec.TestList) > 0 {
testsTags = strings.Join(testsSpec.TestList, "OR")
r := regexp.MustCompile(`\s+`)
testsTags = r.ReplaceAllString(testsTags, "_")
}
}
dockerImage := testsSpec.DockerImage
Expand All @@ -192,7 +199,7 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro
Image: dockerImage,
ImagePullPolicy: cr.Spec.ImagePullPolicy,
SecurityContext: util.GetDefaultSecurityContext(),
Args: []string{"robot", "-i", tastsTags, "/test_runs/"},
Args: []string{"robot", "-i", testsTags, "/test_runs/"},
Env: []corev1.EnvVar{
{
Name: "POSTGRES_USER",
Expand Down Expand Up @@ -226,7 +233,7 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro
},
{
Name: "TESTS_TAGS",
Value: tastsTags,
Value: testsTags,
},
{
Name: "PG_HOST",
Expand All @@ -248,6 +255,16 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro
},
},
},
{
Name: "DD_IMAGES",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of config map and put images here as is

ValueFrom: &corev1.EnvVarSource{
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: "patroni-tests-config"},
Key: "dd_images",
Optional: &opt,
},
},
},
},
VolumeMounts: []corev1.VolumeMount{},
},
Expand Down
8 changes: 4 additions & 4 deletions tests/robot/image_tests/image_tests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Compare Images From Resources With Dd
*** Test Cases ***
Test Hardcoded Images For Core Services
[Tags] patroni basic check_pg_images
${dd_images}= Get Dd Images From Config Map patroni-tests-config
Skip If '${dd_images}' == '${None}' There is no dd, not possible to check case!
${dd_images}= Get Environment Variable DD_IMAGES
Skip If '${dd_images}' == '${None}' or '${dd_images}' == '' There is no dd, not possible to check case!
Compare Images From Resources With Dd ${dd_images}

Test Hardcoded Images For Supplementary Services
[Tags] backup basic check_pg_images
${dd_images}= Get Dd Images From Config Map supplementary-tests-config
Skip If '${dd_images}' == '${None}' There is no dd, not possible to check case!
${dd_images}= Get Environment Variable DD_IMAGES
Skip If '${dd_images}' == '${None}' or '${dd_images}' == '' There is no dd, not possible to check case!
Compare Images From Resources With Dd ${dd_images}
Loading