Skip to content

Commit

Permalink
Use /readyz for 1.7.3 onwards (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrIncompetent authored Jan 2, 2024
1 parent 9a66c3c commit f5cd22e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion charts/qdrant/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
podManagementPolicy: Parallel
selector:
matchLabels:
{{- include "qdrant.selectorLabels" . | nindent 6 }}
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/integration/multi_node_installation.bats
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion test/integration/setup_suite.bash
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/qdrant_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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)
}
54 changes: 41 additions & 13 deletions test/qdrant_probes_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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),
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})

var statefulSet appsv1.StatefulSet
helm.UnmarshalK8SYaml(t, output, &statefulSet)
var statefulSet appsv1.StatefulSet
helm.UnmarshalK8SYaml(t, output, &statefulSet)

container, _ := lo.Find(statefulSet.Spec.Template.Spec.Containers, func(container corev1.Container) bool {
return container.Name == "qdrant"
})
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, "/", container.ReadinessProbe.HTTPGet.Path)
require.Empty(t, container.LivenessProbe)
require.Empty(t, container.StartupProbe)
require.Equal(t, test.readynessEndpoint, container.ReadinessProbe.HTTPGet.Path)
require.Empty(t, container.LivenessProbe)
})
}
}

0 comments on commit f5cd22e

Please sign in to comment.