Skip to content

Commit

Permalink
test: dont compare image in e2e tests since registry will be different
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Mar 23, 2024
1 parent 8ffed24 commit 9ef5e37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ spec:
- name: LAUNCHER_CONTAINERLAB_TIMEOUT
- name: LAUNCHER_PRIVILEGED
value: "true"
image: 172.31.254.11/clabernetes-launcher:dev-latest
imagePullPolicy: IfNotPresent
name: srl1
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ spec:
- name: LAUNCHER_CONTAINERLAB_TIMEOUT
- name: LAUNCHER_PRIVILEGED
value: "true"
image: 172.31.254.11/clabernetes-launcher:dev-latest
imagePullPolicy: IfNotPresent
name: srl2
ports:
Expand Down
12 changes: 8 additions & 4 deletions e2e/topology/basic/topology_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ func TestContainerlabBasic(t *testing.T) {
},
"deployment": {
{
Name: fmt.Sprintf("%s-srl1", testName),
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{},
Name: fmt.Sprintf("%s-srl1", testName),
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
clabernetestesthelper.NormalizeDeployment,
},
},
{
Name: fmt.Sprintf("%s-srl2", testName),
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{},
Name: fmt.Sprintf("%s-srl2", testName),
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
clabernetestesthelper.NormalizeDeployment,
},
},
},
"connectivity": {
Expand Down
12 changes: 12 additions & 0 deletions testhelper/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ func NormalizeFabricService(t *testing.T, objectData []byte) []byte {
return objectData
}

// NormalizeDeployment normalizes a deployment by removing fields that may change between ci and
// local or other folks machines/clusters (like image/registry)-- so we can compare results more
// easily.
func NormalizeDeployment(t *testing.T, objectData []byte) []byte {
t.Helper()

// we dont care about testing that the image was set "right" really, so just remove it
objectData = YQCommand(t, objectData, "del(.spec.template.spec.containers[0].image)")

return objectData
}

// NormalizeConnectivity normalizes a connectivity cr between ci and local or other folks
// machines/clusters -- so we can compare results more easily. For now this is just replacing the
// namespace in the destinations since those will be random(ish) per test run.
Expand Down

0 comments on commit 9ef5e37

Please sign in to comment.