Skip to content

Commit

Permalink
Fix tests to not use image_config.yaml, since release-process modifie…
Browse files Browse the repository at this point in the history
…s it
  • Loading branch information
burmanm committed Oct 25, 2023
1 parent 371ce2d commit 3842048
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/controllers/cassandra/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var _ = BeforeSuite(func() {
ErrorIfCRDPathMissing: true,
}

Expect(images.ParseImageConfig(filepath.Join("..", "..", "..", "config", "manager", "image_config.yaml"))).To(Succeed())
Expect(images.ParseImageConfig(filepath.Join("..", "..", "..", "tests", "testdata", "image_config_parsing.yaml"))).To(Succeed())

cfg, err := testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expand Down
10 changes: 6 additions & 4 deletions pkg/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestCassandraOverride(t *testing.T) {
}

func TestDefaultImageConfigParsing(t *testing.T) {
t.Skip()
assert := require.New(t)
imageConfigFile := filepath.Join("..", "..", "config", "manager", "image_config.yaml")
err := ParseImageConfig(imageConfigFile)
Expand All @@ -77,8 +78,9 @@ func TestDefaultImageConfigParsing(t *testing.T) {
// Verify some default values are set
assert.NotNil(GetImageConfig())
assert.NotNil(GetImageConfig().Images)
assert.True(strings.HasPrefix(GetImageConfig().Images.SystemLogger, "k8ssandra/system-logger:"))
assert.True(strings.HasPrefix(GetImageConfig().Images.ConfigBuilder, "datastax/cass-config-builder:"))
assert.True(strings.Contains(GetImageConfig().Images.SystemLogger, "k8ssandra/system-logger:"))
assert.True(strings.Contains(GetImageConfig().Images.ConfigBuilder, "datastax/cass-config-builder:"))
assert.True(strings.Contains(GetImageConfig().Images.Client, "datastax/k8ssandra-client:"))

assert.Equal("k8ssandra/cass-management-api", GetImageConfig().DefaultImages.CassandraImageComponent.Repository)
assert.Equal("datastax/dse-mgmtapi-6_8", GetImageConfig().DefaultImages.DSEImageComponent.Repository)
Expand All @@ -101,15 +103,15 @@ func TestImageConfigParsing(t *testing.T) {
assert.True(strings.HasPrefix(GetImageConfig().Images.ConfigBuilder, "datastax/cass-config-builder:"))

assert.Equal("k8ssandra/cass-management-api", GetImageConfig().DefaultImages.CassandraImageComponent.Repository)
assert.Equal("datastax/dse-server", GetImageConfig().DefaultImages.DSEImageComponent.Repository)
assert.Equal("datastax/dse-mgmtapi-6_8", GetImageConfig().DefaultImages.DSEImageComponent.Repository)

assert.Equal("localhost:5000", GetImageConfig().ImageRegistry)
assert.Equal(corev1.PullAlways, GetImageConfig().ImagePullPolicy)
assert.Equal("my-secret-pull-registry", GetImageConfig().ImagePullSecret.Name)

path, err := GetCassandraImage("dse", "6.8.17")
assert.NoError(err)
assert.Equal("localhost:5000/datastax/dse-server:6.8.17-ubi7", path)
assert.Equal("localhost:5000/datastax/dse-mgmtapi-6_8:6.8.17-ubi8", path)

path, err = GetCassandraImage("dse", "6.8.999")
assert.NoError(err)
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciliation/construct_podtemplatespec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

func init() {
imageConfigFile := filepath.Join("..", "..", "config", "manager", "image_config.yaml")
imageConfigFile := filepath.Join("..", "..", "tests", "testdata", "image_config_parsing.yaml")
err := images.ParseImageConfig(imageConfigFile)
if err != nil {
panic(err)
Expand Down Expand Up @@ -1441,7 +1441,7 @@ func Test_makeImage(t *testing.T) {
serverType: "dse",
serverVersion: "6.8.0",
},
want: "datastax/dse-mgmtapi-6_8:6.8.0-ubi8",
want: "localhost:5000/datastax/dse-mgmtapi-6_8:6.8.0-ubi8",
errString: "",
},
{
Expand All @@ -1451,7 +1451,7 @@ func Test_makeImage(t *testing.T) {
serverType: "cassandra",
serverVersion: "3.11.10",
},
want: "k8ssandra/cass-management-api:3.11.10-ubi8",
want: "localhost:5000/k8ssandra/cass-management-api:3.11.10-ubi8",
errString: "",
},
{
Expand Down Expand Up @@ -1491,7 +1491,7 @@ func Test_makeImage(t *testing.T) {
serverType: "dse",
serverVersion: "6.8.1234",
},
want: "datastax/dse-mgmtapi-6_8:6.8.1234-ubi8",
want: "localhost:5000/datastax/dse-mgmtapi-6_8:6.8.1234-ubi8",
errString: "",
},
{
Expand All @@ -1501,7 +1501,7 @@ func Test_makeImage(t *testing.T) {
serverType: "dse",
serverVersion: "6.8.26",
},
want: "datastax/dse-mgmtapi-6_8:6.8.26-ubi8",
want: "localhost:5000/datastax/dse-mgmtapi-6_8:6.8.26-ubi8",
errString: "",
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciliation/construct_statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func Test_newStatefulSetForCassandraDatacenterWithAdditionalVolumes(t *testing.T
assert.Equal(t, "/var/log/cassandra", got.Spec.Template.Spec.InitContainers[0].VolumeMounts[0].MountPath)

assert.Equal(t, "server-config-init", got.Spec.Template.Spec.InitContainers[1].Name)
assert.Equal(t, "datastax/cass-config-builder:1.0-ubi7", got.Spec.Template.Spec.InitContainers[1].Image)
assert.Equal(t, "localhost:5000/datastax/cass-config-builder:1.0-ubi7", got.Spec.Template.Spec.InitContainers[1].Image)
assert.Equal(t, 1, len(got.Spec.Template.Spec.InitContainers[1].VolumeMounts))
assert.Equal(t, "server-config", got.Spec.Template.Spec.InitContainers[1].VolumeMounts[0].Name)
assert.Equal(t, "/config", got.Spec.Template.Spec.InitContainers[1].VolumeMounts[0].MountPath)
Expand Down
6 changes: 4 additions & 2 deletions tests/testdata/image_config_parsing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
images:
system-logger: "k8ssandra/system-logger:latest"
config-builder: "datastax/cass-config-builder:1.0-ubi7"
k8ssandra-client: "k8ssandra/k8ssandra-client:v0.2.1"
cassandra:
"4.0.0": "k8ssandra/cassandra-ubi:latest"
dse:
Expand All @@ -17,6 +18,7 @@ defaults:
# Note, postfix is ignored if repository is not set
cassandra:
repository: "k8ssandra/cass-management-api"
suffix: "-ubi8"
dse:
repository: "datastax/dse-server"
suffix: "-ubi7"
repository: "datastax/dse-mgmtapi-6_8"
suffix: "-ubi8"
13 changes: 13 additions & 0 deletions tests/testdata/tasks/flush_task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: control.k8ssandra.io/v1alpha1
kind: CassandraTask
metadata:
name: flush-node
spec:
datacenter:
name: dc2
namespace: cass-operator
jobs:
- name: flush-run
command: flush
args:
pod_name: cluster2-dc2-r1-sts-0

0 comments on commit 3842048

Please sign in to comment.