Skip to content

Commit 0df5c32

Browse files
Pierre Tascitekton-robot
Pierre Tasci
authored andcommitted
Update bundle tests to use IP of service to avoid cluster domain rules
1 parent 68dfa5d commit 0df5c32

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

test/registry_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,13 @@ func getRegistryService(namespace string) *corev1.Service {
9292
},
9393
}
9494
}
95+
96+
// getRegistryServiceIP fetches the registry service's current IP.
97+
func getRegistryServiceIP(ctx context.Context, t *testing.T, c *clients, namespace string) string {
98+
t.Helper()
99+
svc, err := c.KubeClient.Kube.CoreV1().Services(namespace).Get(ctx, "registry", metav1.GetOptions{})
100+
if err != nil {
101+
t.Fatalf("failed to lookup registry service: %q", err)
102+
}
103+
return svc.Spec.ClusterIP
104+
}

test/tektonbundles_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestTektonBundlesSimpleWorkingExample(t *testing.T) {
193193
taskName := "hello-world"
194194
pipelineName := "hello-world-pipeline"
195195
pipelineRunName := "hello-world-piplinerun"
196-
repo := fmt.Sprintf("registry.%s.svc.cluster.local:5000/tektonbundlessimple", namespace)
196+
repo := fmt.Sprintf("%s:5000/tektonbundlessimple", getRegistryServiceIP(ctx, t, c, namespace))
197197

198198
ref, err := name.ParseReference(repo)
199199
if err != nil {
@@ -333,7 +333,7 @@ func TestTektonBundlesUsingRegularImage(t *testing.T) {
333333
taskName := "hello-world-dne"
334334
pipelineName := "hello-world-pipeline-dne"
335335
pipelineRunName := "hello-world-piplinerun"
336-
repo := fmt.Sprintf("registry.%s.svc.cluster.local:5000/tektonbundlesregularimage", namespace)
336+
repo := fmt.Sprintf("%s:5000/tektonbundlesregularimage", getRegistryServiceIP(ctx, t, c, namespace))
337337

338338
ref, err := name.ParseReference(repo)
339339
if err != nil {
@@ -418,7 +418,7 @@ func TestTektonBundlesUsingImproperFormat(t *testing.T) {
418418
taskName := "hello-world"
419419
pipelineName := "hello-world-pipeline"
420420
pipelineRunName := "hello-world-piplinerun"
421-
repo := fmt.Sprintf("registry.%s.svc.cluster.local:5000/tektonbundlesimproperformat", namespace)
421+
repo := fmt.Sprintf("%s:5000/tektonbundlesimproperformat", getRegistryServiceIP(ctx, t, c, namespace))
422422

423423
ref, err := name.ParseReference(repo)
424424
if err != nil {

0 commit comments

Comments
 (0)