Skip to content

Commit a66847b

Browse files
committed
test: dont compare image in e2e tests since registry will be different
1 parent 8ffed24 commit a66847b

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

e2e/topology/basic/test-fixtures/golden/20-deployment.topology-basic-srl1.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ spec:
8080
- name: LAUNCHER_CONTAINERLAB_TIMEOUT
8181
- name: LAUNCHER_PRIVILEGED
8282
value: "true"
83-
image: 172.31.254.11/clabernetes-launcher:dev-latest
8483
imagePullPolicy: IfNotPresent
8584
name: srl1
8685
ports:

e2e/topology/basic/test-fixtures/golden/20-deployment.topology-basic-srl2.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ spec:
7979
- name: LAUNCHER_CONTAINERLAB_TIMEOUT
8080
- name: LAUNCHER_PRIVILEGED
8181
value: "true"
82-
image: 172.31.254.11/clabernetes-launcher:dev-latest
8382
imagePullPolicy: IfNotPresent
8483
name: srl2
8584
ports:

e2e/topology/basic/topology_basic_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ func TestContainerlabBasic(t *testing.T) {
5555
},
5656
"deployment": {
5757
{
58-
Name: fmt.Sprintf("%s-srl1", testName),
59-
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{},
58+
Name: fmt.Sprintf("%s-srl1", testName),
59+
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
60+
clabernetestesthelper.NormalizeDeployment,
61+
},
6062
},
6163
},
6264
"connectivity": {
@@ -96,12 +98,16 @@ func TestContainerlabBasic(t *testing.T) {
9698
},
9799
"deployment": {
98100
{
99-
Name: fmt.Sprintf("%s-srl1", testName),
100-
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{},
101+
Name: fmt.Sprintf("%s-srl1", testName),
102+
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
103+
clabernetestesthelper.NormalizeDeployment,
104+
},
101105
},
102106
{
103-
Name: fmt.Sprintf("%s-srl2", testName),
104-
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{},
107+
Name: fmt.Sprintf("%s-srl2", testName),
108+
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
109+
clabernetestesthelper.NormalizeDeployment,
110+
},
105111
},
106112
},
107113
"connectivity": {

testhelper/kubernetes.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ func NormalizeFabricService(t *testing.T, objectData []byte) []byte {
127127
return objectData
128128
}
129129

130+
// NormalizeDeployment normalizes a deployment by removing fields that may change between ci and
131+
// local or other folks machines/clusters (like image/registry)-- so we can compare results more
132+
// easily.
133+
func NormalizeDeployment(t *testing.T, objectData []byte) []byte {
134+
t.Helper()
135+
136+
// we dont care about testing that the image was set "right" really, so just remove it
137+
objectData = YQCommand(t, objectData, "del(.spec.template.spec.containers[0].image)")
138+
139+
return objectData
140+
}
141+
130142
// NormalizeConnectivity normalizes a connectivity cr between ci and local or other folks
131143
// machines/clusters -- so we can compare results more easily. For now this is just replacing the
132144
// namespace in the destinations since those will be random(ish) per test run.

0 commit comments

Comments
 (0)