Skip to content

Commit

Permalink
feat: add volume
Browse files Browse the repository at this point in the history
  • Loading branch information
kqzh committed Nov 7, 2023
1 parent 17b8fce commit 039d274
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 10 deletions.
3 changes: 3 additions & 0 deletions tests/e2e/e2ematcher/e2ematcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func structImpl(preFields []string, actual any, matchers map[string]any) (retErr

if m, ok := matcher.(Matcher); ok {
for actualVal.Kind() == reflect.Ptr {
if actualVal.IsNil() {
break
}
actualVal = actualVal.Elem()
}
val := actualVal.Interface()
Expand Down
11 changes: 9 additions & 2 deletions tests/e2e/envfuncsext/nebulacluster-ready-func.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ func isComponentStatefulSetExpected(ctx context.Context, cfg *envconf.Config, co
},
},
"NodeSelector": e2ematcher.DeepEqual(nodeSelector),
//"Affinity": e2ematcher.DeepEqual(&[]corev1.Affinity{}),
"Tolerations": e2ematcher.DeepEqual(component.ComponentSpec().Tolerations()),
"Affinity": e2ematcher.DeepEqual(affinityPtrOrNil(component.ComponentSpec().Affinity())),
"Tolerations": e2ematcher.DeepEqual(component.ComponentSpec().Tolerations()),
},
},
},
Expand Down Expand Up @@ -797,3 +797,10 @@ func extractComponentConfig(r io.Reader, paramValuePattern *regexp.Regexp) (map[
}
return componentConfig, nil
}

func affinityPtrOrNil(affinity *corev1.Affinity) any {
if affinity == nil {
return affinity
}
return *affinity
}
103 changes: 103 additions & 0 deletions tests/e2e/nebulacluster_k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
LabelGroupK8sTolerations = "tolerations"
LabelGroupK8sInitContainers = "initContainers"
LabelGroupK8sSidecarContainers = "sidecarContainers"
LabelGroupK8sVolumes = "volumes"
LabelGroupK8sReadinessProbe = "readinessProbe"
LabelGroupK8sLivenessProbe = "livenessProbe"
)
Expand All @@ -36,6 +37,7 @@ func init() {
testCasesK8s = append(testCasesK8s, testCaseK8sTolerations...)
testCasesK8s = append(testCasesK8s, testCaseK8sInitContainers...)
testCasesK8s = append(testCasesK8s, testCaseK8sSidecarContainers...)
testCasesK8s = append(testCasesK8s, testCaseK8sVolumes...)
testCasesK8s = append(testCasesK8s, testCaseK8sReadinessProbe...)
testCasesK8s = append(testCasesK8s, testCaseK8sLivenessProbe...)
}
Expand Down Expand Up @@ -801,3 +803,104 @@ var testCaseK8sLivenessProbe = []ncTestCase{
},
},
}

var testCaseK8sVolumes = []ncTestCase{
{
Name: "k8s volumes with default values",
Labels: map[string]string{
LabelKeyCategory: LabelCategoryK8s,
LabelKeyGroup: LabelGroupK8sVolumes,
},
InstallWaitNCOptions: []envfuncsext.NebulaClusterOption{
envfuncsext.WithNebulaClusterReadyFuncs(
envfuncsext.DefaultNebulaClusterReadyFunc,
),
},
UpgradeCases: []ncTestUpgradeCase{
{
Name: "update components volumes",
UpgradeNCOptions: []envfuncsext.NebulaClusterOption{
envfuncsext.WithNebulaClusterHelmRawOptions(
helm.WithArgs(
"--set", "nebula.graphd.volumes[0].name=test-volume",
"--set", "nebula.graphd.volumes[0].emptyDir.medium=Memory",
"--set", "nebula.graphd.volumeMounts[0].name=test-volume",
"--set", "nebula.graphd.volumeMounts[0].mountPath=/test",
"--set", "nebula.storaged.volumes[0].name=test-volume",
"--set", "nebula.storaged.volumes[0].emptyDir.medium=Memory",
"--set", "nebula.storaged.volumeMounts[0].name=test-volume",
"--set", "nebula.storaged.volumeMounts[0].mountPath=/test",
"--set", "nebula.metad.volumes[0].name=test-volume",
"--set", "nebula.metad.volumes[0].emptyDir.medium=Memory",
"--set", "nebula.metad.volumeMounts[0].name=test-volume",
"--set", "nebula.metad.volumeMounts[0].mountPath=/test",
),
),
},
UpgradeWaitNCOptions: []envfuncsext.NebulaClusterOption{
envfuncsext.WithNebulaClusterReadyFuncs(
envfuncsext.NebulaClusterReadyFuncForFields(true, map[string]any{
"Spec": map[string]any{
"Graphd": map[string]any{
"Volumes": e2ematcher.DeepEqual([]corev1.Volume{
{
Name: "test-volume",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
},
},
},
}),
"VolumeMounts": e2ematcher.DeepEqual([]corev1.VolumeMount{
{
Name: "test-volume",
MountPath: "/test",
},
}),
},
"Storaged": map[string]any{
"Volumes": e2ematcher.DeepEqual([]corev1.Volume{
{
Name: "test-volume",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
},
},
},
}),
"VolumeMounts": e2ematcher.DeepEqual([]corev1.VolumeMount{
{
Name: "test-volume",
MountPath: "/test",
},
}),
},
"Metad": map[string]any{
"Volumes": e2ematcher.DeepEqual([]corev1.Volume{
{
Name: "test-volume",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
},
},
},
}),
"VolumeMounts": e2ematcher.DeepEqual([]corev1.VolumeMount{
{
Name: "test-volume",
MountPath: "/test",
},
}),
},
},
}),
envfuncsext.DefaultNebulaClusterReadyFunc,
),
},
},
},
},
}
9 changes: 1 addition & 8 deletions tests/e2e/nebulacluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ import (
"github.com/vesoft-inc/nebula-operator/tests/e2e/envfuncsext"
)

var ncGlobalTestCases []ncTestCase

func init() {
ncGlobalTestCases = append(ncGlobalTestCases, testCasesBasic...)
ncGlobalTestCases = append(ncGlobalTestCases, testCasesCustomConfig...)
ncGlobalTestCases = append(ncGlobalTestCases, testCasesK8s...)
}

type (
ncTestCase struct {
Name string
Expand All @@ -69,6 +61,7 @@ func TestNebulaCluster(t *testing.T) {
ncTestCases = append(ncTestCases, testCasesTools...)
ncTestCases = append(ncTestCases, testCasesZone...)
ncTestCases = append(ncTestCases, testCasesPV...)
ncTestCases = append(ncTestCases, testCasesK8s...)

defaultNebulaClusterHelmArgs := getDefaultNebulaClusterHelmArgs()

Expand Down

0 comments on commit 039d274

Please sign in to comment.