-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathqdrant_image_test.go
88 lines (68 loc) · 2.44 KB
/
qdrant_image_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package test
import (
"log"
"os"
"path/filepath"
"strings"
"testing"
"github.com/ghodss/yaml"
"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"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"
helmv3 "helm.sh/helm/v3/pkg/chart"
appsv1 "k8s.io/api/apps/v1"
)
func TestDefaultImage(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{
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"
})
chartYaml, err := os.ReadFile("../charts/qdrant/Chart.yaml")
if err != nil {
log.Fatalf("unable to chart yaml file: %v", err)
}
var chart helmv3.Metadata
err = yaml.Unmarshal(chartYaml, &chart)
if err != nil {
log.Fatalf("unable to decode chart yaml: %v", err)
}
require.Equal(t, "docker.io/qdrant/qdrant:"+chart.AppVersion, container.Image)
}
func TestOverwriteImage(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{
SetValues: map[string]string{
"image.tag": "v1.6.0",
"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)
container, _ := lo.Find(statefulSet.Spec.Template.Spec.Containers, func(container corev1.Container) bool {
return container.Name == "qdrant"
})
require.Equal(t, "test/repo:v1.6.0-unprivileged", container.Image)
}