Use /readyz for 1.7.3 onwards (#124)

This commit is contained in:
Henrik Schmidt
2024-01-02 18:59:17 +01:00
committed by GitHub
parent 9a66c3c1c1
commit f5cd22e0da
6 changed files with 65 additions and 20 deletions

View File

@@ -2,11 +2,11 @@ lint:
helm lint charts/qdrant
test-unit:
go test -v ./test
go test ./test
test-integration:
bats test/integration --verbose-run --show-output-of-passing-tests
bats test/integration
test-unit-lint:
gofmt -w -s ./test
golangci-lint run ./test
golangci-lint run ./test

View File

@@ -9,6 +9,7 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
podManagementPolicy: Parallel
selector:
matchLabels:
{{- include "qdrant.selectorLabels" . | nindent 6 }}
@@ -118,7 +119,7 @@ spec:
{{- end }}
{{- if eq .name "http"}}
httpGet:
path: /
path: "{{- if semverCompare ">=1.7.3" ($.Values.image.tag | default $.Chart.AppVersion) -}}/readyz{{else}}/{{end}}"
port: {{ .targetPort }}
{{- if and $values.config.service $values.config.service.enable_tls }}
scheme: HTTPS

View File

@@ -0,0 +1,16 @@
@test "Rolling update" {
run kubectl rollout restart sts/qdrant -n distributed-update-test
[ $status -eq 0 ]
}
setup() {
# Using a custom namespace to avoid side effects with other tests
kubectl create ns distributed-update-test
helm upgrade --install qdrant charts/qdrant -n distributed-update-test --wait --timeout 3m --set replicaCount=3 --set image.tag=v1.7.3
kubectl rollout status statefulset qdrant -n distributed-update-test
}
teardown() {
helm uninstall qdrant -n distributed-update-test
kubectl delete ns distributed-update-test
}

View File

@@ -1,7 +1,7 @@
setup_suite() {
kind create cluster -n qdrant-helm-integration
kubectl create serviceaccount default -n default
kubectl -n default run curl --image=curlimages/curl --command -- sh -c "sleep 3600"
kubectl -n default run curl --image=docker.io/curlimages/curl --command -- sh -c "sleep 3600"
kubectl wait --for=condition=Ready pod/curl -n default --timeout=300s
kubectl create namespace qdrant-helm-integration
kubectl create serviceaccount default -n qdrant-helm-integration || true

View File

@@ -68,7 +68,7 @@ func TestOverwriteImage(t *testing.T) {
options := &helm.Options{
SetValues: map[string]string{
"image.tag": "test-tag",
"image.tag": "v1.6.0",
"image.repository": "test/repo",
"image.useUnprivilegedImage": "true",
},
@@ -84,5 +84,5 @@ func TestOverwriteImage(t *testing.T) {
return container.Name == "qdrant"
})
require.Equal(t, "test/repo:test-tag-unprivileged", container.Image)
require.Equal(t, "test/repo:v1.6.0-unprivileged", container.Image)
}

View File

@@ -1,12 +1,13 @@
package test
import (
"github.com/samber/lo"
corev1 "k8s.io/api/core/v1"
"path/filepath"
"strings"
"testing"
"github.com/samber/lo"
corev1 "k8s.io/api/core/v1"
"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/logger"
@@ -25,20 +26,47 @@ func TestDefaultProbesOnStatefulset(t *testing.T) {
namespaceName := "qdrant-" + strings.ToLower(random.UniqueId())
logger.Log(t, "Namespace: %s\n", namespaceName)
options := &helm.Options{
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
tests := []struct {
version string
readynessEndpoint string
}{
{
version: "v1.6.0",
readynessEndpoint: "/",
},
{
version: "v1.7.3",
readynessEndpoint: "/readyz",
},
{
version: "v1.7.4",
readynessEndpoint: "/readyz",
},
}
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
for _, test := range tests {
t.Run("/readyz with "+test.version, func(t *testing.T) {
options := &helm.Options{
SetValues: map[string]string{
"image.tag": test.version,
"image.repository": "test/repo",
"image.useUnprivilegedImage": "true",
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}
var statefulSet appsv1.StatefulSet
helm.UnmarshalK8SYaml(t, output, &statefulSet)
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
container, _ := lo.Find(statefulSet.Spec.Template.Spec.Containers, func(container corev1.Container) bool {
return container.Name == "qdrant"
})
var statefulSet appsv1.StatefulSet
helm.UnmarshalK8SYaml(t, output, &statefulSet)
require.Empty(t, container.StartupProbe)
require.Equal(t, "/", container.ReadinessProbe.HTTPGet.Path)
require.Empty(t, container.LivenessProbe)
container, _ := lo.Find(statefulSet.Spec.Template.Spec.Containers, func(container corev1.Container) bool {
return container.Name == "qdrant"
})
require.Empty(t, container.StartupProbe)
require.Equal(t, test.readynessEndpoint, container.ReadinessProbe.HTTPGet.Path)
require.Empty(t, container.LivenessProbe)
})
}
}