Files
qdrant-helm/test/qdrant_additional_volume_test.go
Bastian Hofmann dfff7fac6a Make the qdrant api key easily configurable (#62)
* Make the qdrant api key easily configurable

This adds a new `apiKey` value.

If `true` it generates a random apiKey, stores it in a secret and ensures that it stays the same during upgrades.
If a string is passed, this string is used as the api key.

The secret is mounted as a `local.yaml` config into the container. See also https://qdrant.tech/documentation/guides/configuration/#order-and-priority.

Alternatively, there are two new values `additionalVolumes` and `additionalVolumeMounts` which allow to mount additional existing volumes, such as pre-existing secrets into the qdrant container.

This also adds bats-core based integration tests to test the correct api key handling

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>

* Fix bats integration tests

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>

* Fix bats integration tests

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>

* Fix bats integration tests

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>

* Fix bats integration tests

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>

* Fix statefulset

* doc: fix typo

---------

Signed-off-by: Bastian Hofmann <mail@bastianhofmann.de>
Co-authored-by: Tim Eggert <tim@elbart.com>
2023-08-31 15:22:54 +02:00

59 lines
1.8 KiB
Go

package test
import (
"path/filepath"
"strings"
"testing"
"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/samber/lo"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
)
func TestAdditionalVolumeAndVolumeMount(t *testing.T) {
t.Parallel()
helmChartPath, err := filepath.Abs("../charts/qdrant")
releaseName := "qdrant"
require.NoError(t, err)
namespaceName := "qdrant-" + strings.ToLower(random.UniqueId())
logger.Log(t, "Namespace: %s\n", namespaceName)
options := &helm.Options{
SetJsonValues: map[string]string{
"additionalVolumes": `[{"name":"volumeName","emptyDir":{"sizeLimit":"500Mi"}}]`,
"additionalVolumeMounts": `[{"name":"volumeName","mountPath":"/mount/path"}]`,
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
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"
})
volumeMount, hasAdditionalVolumeMount := lo.Find(container.VolumeMounts, func(volumeMount corev1.VolumeMount) bool {
return volumeMount.Name == "volumeName"
})
volume, hasAdditionalVolume := lo.Find(statefulSet.Spec.Template.Spec.Volumes, func(volume corev1.Volume) bool {
return volume.Name == "volumeName"
})
require.Equal(t, hasAdditionalVolumeMount, true)
require.Equal(t, hasAdditionalVolume, true)
require.Equal(t, "/mount/path", volumeMount.MountPath)
require.Equal(t, "500Mi", volume.EmptyDir.SizeLimit.String())
}