Skip to content

Commit 1cd351f

Browse files
committed
fix kcp test
1 parent 90b6fa2 commit 1cd351f

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

contrib/kcp/deploy/examples/collection-wildwest.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apiVersion: kube-bind.io/v1alpha2
22
kind: Collection
33
metadata:
44
name: wildwest
5-
namespace: default
65
spec:
76
description: "A collection of Wild West service definitions including Cowboys and Sheriffs for frontier management"
87
templates:

contrib/kcp/test/e2e/browser.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ import (
3333
"github.com/kube-bind/kube-bind/test/e2e/framework"
3434
)
3535

36-
func performBindingWithBrowser(t *testing.T, backendAddr string, clusterID string, consumerCfg *rest.Config, consumerKubeconfig, resource string) {
36+
func performBindingWithBrowser(t *testing.T, backendAddr string, clusterID string, consumerCfg *rest.Config, consumerKubeconfig, resource, template string) {
3737
bindURL := fmt.Sprintf("http://%s/clusters/%s/exports", backendAddr, clusterID)
3838
t.Logf("Bind URL: %s", bindURL)
3939

4040
// Test binding dry run first (similar to happy-case test)
4141
t.Run("Service is bound dry run", func(t *testing.T) {
4242
authURLDryRunCh := make(chan string, 1)
43-
go simulateKCPBrowser(t, authURLDryRunCh, resource)
43+
go simulateKCPBrowser(t, authURLDryRunCh, template)
4444

4545
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
4646
framework.Bind(t, iostreams, authURLDryRunCh, nil, bindURL, "--kubeconfig", consumerKubeconfig, "--dry-run")
@@ -51,7 +51,7 @@ func performBindingWithBrowser(t *testing.T, backendAddr string, clusterID strin
5151
// Perform actual binding (similar to happy-case test)
5252
t.Run("Service is bound", func(t *testing.T) {
5353
authURLCh := make(chan string, 1)
54-
go simulateKCPBrowser(t, authURLCh, resource)
54+
go simulateKCPBrowser(t, authURLCh, template)
5555

5656
iostreams, _, _, _ := genericclioptions.NewTestIOStreams()
5757
invocations := make(chan framework.SubCommandInvocation, 1)
@@ -78,8 +78,8 @@ func performBindingWithBrowser(t *testing.T, backendAddr string, clusterID strin
7878
})
7979
}
8080

81-
// simulateKCPBrowser simulates browser interaction for KCP binding.
82-
func simulateKCPBrowser(t *testing.T, authURLCh chan string, resource string) {
81+
// simulateKCPBrowser simulates browser interaction for KCP binding using templates.
82+
func simulateKCPBrowser(t *testing.T, authURLCh chan string, template string) {
8383
browser := surf.NewBrowser()
8484
authURL := <-authURLCh
8585

@@ -90,9 +90,9 @@ func simulateKCPBrowser(t *testing.T, authURLCh chan string, resource string) {
9090
t.Logf("Waiting for browser to be at /resources")
9191
framework.BrowserEventuallyAtPath(t, browser, "/resources")
9292

93-
t.Logf("Clicking %s resource", resource)
94-
err = browser.Click("a." + resource)
95-
require.NoError(t, err, "Failed to click resource link")
93+
t.Logf("Clicking %s template", template)
94+
err = browser.Click("a." + template)
95+
require.NoError(t, err, "Failed to click template link")
9696

9797
t.Logf("Waiting for browser to be forwarded to client")
9898
framework.BrowserEventuallyAtPath(t, browser, "/callback")

contrib/kcp/test/e2e/kcp_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ func testKcpIntegration(t *testing.T, scope kubebindv1alpha2.InformerScope) {
101101
),
102102
)
103103

104-
t.Log("Applying example APIExport and APIResourceSchemas to provider workspace")
104+
t.Log("Applying example APIExport, APIResourceSchemas and templates to provider workspace")
105105
framework.ApplyFiles(t,
106106
providerCfg,
107107
"../../deploy/examples/apiexport.yaml",
108108
"../../deploy/examples/apiresourceschema-cowboys.yaml", // namespaced
109109
"../../deploy/examples/apiresourceschema-sheriffs.yaml", // cluster scoped
110+
"../../deploy/examples/template-cowboys.yaml", // template for cowboys
111+
"../../deploy/examples/template-sheriffs.yaml", // template for sheriffs
112+
"../../deploy/examples/collection-wildwest.yaml",
110113
)
111114

112115
t.Log("Bind the APIExport locally")
@@ -138,18 +141,20 @@ func testKcpIntegration(t *testing.T, scope kubebindv1alpha2.InformerScope) {
138141

139142
// kube-bind process
140143
t.Log("Perform binding process with browser")
141-
var kind, resource string
144+
var kind, resource, template string
142145
switch scope {
143146
case kubebindv1alpha2.ClusterScope:
144147
kind = "Sheriff"
145148
resource = "sheriffs"
149+
template = "sheriffs"
146150
case kubebindv1alpha2.NamespacedScope:
147151
kind = "Cowboy"
148152
resource = "cowboys"
153+
template = "cowboys"
149154
default:
150155
require.Fail(t, "unhandled scope %q", scope)
151156
}
152-
performBindingWithBrowser(t, backendAddr, providerClusterID, consumerCfg, consumerKubeconfig, resource)
157+
performBindingWithBrowser(t, backendAddr, providerClusterID, consumerCfg, consumerKubeconfig, resource, template)
153158

154159
t.Log("Testing resource creation and synchronization...")
155160
testKCPResourceSync(t, consumerCfg, providerCfg, scope, kind, resource)

0 commit comments

Comments
 (0)