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
1 change: 1 addition & 0 deletions operator/api/apps/v1/postgresservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ type IntegrationTests struct {
DockerImage string `json:"image,omitempty"`
RunTestScenarios string `json:"runTestScenarios,omitempty"`
TestList []string `json:"testList,omitempty"`
Tags string `json:"tags,omitempty"`
Replicas int `json:"replicas,omitempty"`
PgNodeQty int `json:"pgNodeQty,omitempty"`
PodLabels map[string]string `json:"podLabels,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions operator/api/common/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions operator/api/patroni/v1/patronicore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ type IntegrationTests struct {
DockerImage string `json:"image,omitempty"`
RunTestScenarios string `json:"runTestScenarios,omitempty"`
TestList []string `json:"testList,omitempty"`
Tags string `json:"tags,omitempty"`
Replicas int `json:"replicas,omitempty"`
PgNodeQty int `json:"pgNodeQty,omitempty"`
PodLabels map[string]string `json:"podLabels,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,8 @@ spec:
type: object
runTestScenarios:
type: string
tags:
type: string
testList:
items:
type: string
Expand Down Expand Up @@ -2636,9 +2638,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
3 changes: 3 additions & 0 deletions operator/charts/patroni-core/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ spec:
- {{ . }}
{{- end }}
{{ end }}
{{- if .Values.tests.tags }}
tags: {{ .Values.tests.tags | quote }}
{{- end }}
pgNodeQty: {{ ( include "postgres.replicasCount" . ) }}
{{ 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 "patroni-tests.monitoredImages" . }}
dd_images: {{ include "patroni-tests.monitoredImages" . }}
{{ else }}
dd_images: ""
{{ end }}
dd_images: {{ (.Values.tests.ddImages | default (include "patroni-tests.monitoredImages" .) | default "") | quote }}
{{- end }}
1 change: 1 addition & 0 deletions operator/charts/patroni-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ tests:
podLabels: {}
# One of "full", "basic"or one from testScenarios
runTestScenarios: "basic"
tags: ""
testScenarios:
patroniSimple:
- check_patroni_rest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,8 @@ spec:
type: object
runTestScenarios:
type: string
tags:
type: string
testList:
items:
type: string
Expand Down Expand Up @@ -6139,9 +6141,10 @@ spec:
operator:
description: |-
Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal.
Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod can
tolerate all taints of a particular category.
Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators).
type: string
tolerationSeconds:
description: |-
Expand Down
3 changes: 3 additions & 0 deletions operator/charts/patroni-services/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ spec:
- {{ . }}
{{- end }}
{{ end }}
{{- if .Values.tests.tags }}
tags: {{ .Values.tests.tags | quote }}
{{- 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 }}
1 change: 1 addition & 0 deletions operator/charts/patroni-services/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ tests:
podLabels: {}
# One of "full", "basic"or one from testScenarios
runTestScenarios: "basic"
tags: ""
testScenarios:
patroniSimple:
- check_patroni_rest
Expand Down
69 changes: 43 additions & 26 deletions operator/pkg/deployment/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package deployment

import (
"fmt"
"regexp"
"strconv"
"strings"

Expand All @@ -35,23 +34,21 @@ var (
func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniClusterSettings) *corev1.Pod {
testsSpec := cr.Spec.IntegrationTests
tastsTags := ""
opt := true
pgHost := cluster.PostgresServiceName
if strings.ToLower(testsSpec.RunTestScenarios) == "full" {

if testsSpec.Tags != "" {
tastsTags = strings.Join(strings.Fields(testsSpec.Tags), "")
} else if strings.ToLower(testsSpec.RunTestScenarios) == "full" {
if cr.Spec.BackupDaemon != nil && cr.Spec.BackupDaemon.Resources != nil {
tastsTags = "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 strings.ToLower(testsSpec.RunTestScenarios) == "basic" {
if cr.Spec.BackupDaemon != nil && cr.Spec.BackupDaemon.Resources != nil {
tastsTags = "backup_basic"
}
} else if len(testsSpec.TestList) > 0 {
tastsTags = strings.Join(testsSpec.TestList, "OR")
}
dockerImage := testsSpec.DockerImage
name := "integration-robot-tests"
Expand Down Expand Up @@ -127,6 +124,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 @@ -150,25 +157,25 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl
func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.PatroniClusterSettings) *corev1.Pod {
testsSpec := cr.Spec.IntegrationTests
tastsTags := ""
opt := true
pgHost := cluster.PostgresServiceName
if cr.Spec.Patroni.StandbyCluster != nil {
pgHost = fmt.Sprintf("pg-%s-external", cluster.ClusterName)
}
if strings.ToLower(cr.Spec.Patroni.Dcs.Type) != "kubernetes" {
if testsSpec.Tags != "" {
tastsTags = strings.ReplaceAll(testsSpec.Tags, " ", "")
} else if strings.ToLower(cr.Spec.Patroni.Dcs.Type) != "kubernetes" {
tastsTags = "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, "_")
}
}
} else if strings.ToLower(testsSpec.RunTestScenarios) == "full" {
tastsTags = "patroni*"
} else if strings.ToLower(testsSpec.RunTestScenarios) == "basic" {
tastsTags = "patroni_basic"
} else if len(testsSpec.TestList) > 0 {
cleaned := make([]string, 0, len(testsSpec.TestList))
for _, t := range testsSpec.TestList {
cleaned = append(cleaned, strings.ReplaceAll(t, " ", "_"))
}
tastsTags = strings.Join(cleaned, "OR")
}
dockerImage := testsSpec.DockerImage
name := "patroni-robot-tests"
Expand Down Expand Up @@ -248,6 +255,16 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro
},
},
},
{
Name: "DD_IMAGES",
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}