-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathqdrant_additional_volume_test.go
58 lines (45 loc) · 1.83 KB
/
qdrant_additional_volume_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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())
}