Skip to content

Commit

Permalink
Test to demonstrate that the vector container is not being created co…
Browse files Browse the repository at this point in the history
…rrectly.
  • Loading branch information
Miles-Garnsey committed May 23, 2024
1 parent 66db83a commit d102719
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions controllers/k8ssandra/k8ssandracluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,11 @@ func injectContainersAndVolumes(t *testing.T, ctx context.Context, f *framework.
Cassandra: &api.CassandraClusterTemplate{
DatacenterOptions: api.DatacenterOptions{
ServerVersion: serverVersion,
Telemetry: &telemetryapi.TelemetrySpec{
Vector: &telemetryapi.VectorSpec{
Enabled: ptr.To(true),
},
},
StorageConfig: &cassdcapi.StorageConfig{
CassandraDataVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{
StorageClassName: &defaultStorageClass,
Expand All @@ -2431,6 +2436,13 @@ func injectContainersAndVolumes(t *testing.T, ctx context.Context, f *framework.
},
},
},
{
Name: "server-system-logger",
SecurityContext: &corev1.SecurityContext{
RunAsUser: ptr.To[int64](9999),
ReadOnlyRootFilesystem: ptr.To(true),
},
},
},
ExtraVolumes: &api.K8ssandraVolumes{
PVCs: []cassdcapi.AdditionalVolumes{
Expand Down Expand Up @@ -2505,6 +2517,18 @@ func injectContainersAndVolumes(t *testing.T, ctx context.Context, f *framework.
_, foundMain := cassandra.FindContainer(dc.Spec.PodTemplateSpec, "injected-container")
require.True(foundMain, "failed to find injected-container")

vectorContainerIdx, foundVector := cassandra.FindContainer(dc.Spec.PodTemplateSpec, "server-system-logger")
require.True(foundVector, "failed to find injected-container")
require.Equal(ptr.To[int64](9999),
dc.Spec.PodTemplateSpec.Spec.Containers[vectorContainerIdx].SecurityContext.RunAsUser,
"server-system-logger RunAsUser is not set")
require.Equal(ptr.To(true),
dc.Spec.PodTemplateSpec.Spec.Containers[vectorContainerIdx].SecurityContext.ReadOnlyRootFilesystem,
"server-system-logger RunAsUser is not set")
require.Equal(ptr.To(true),
dc.Spec.PodTemplateSpec.Spec.Containers[vectorContainerIdx].SecurityContext.ReadOnlyRootFilesystem,
"server-system-logger RunAsUser is not set")

require.Equal(2, len(dc.Spec.StorageConfig.AdditionalVolumes), "expected 2 additionals volumes")
require.Equal("/etc/injected", dc.Spec.StorageConfig.AdditionalVolumes[0].MountPath, "expected injected-volume mount path")

Expand Down

0 comments on commit d102719

Please sign in to comment.