Skip to content

Commit 3b4e510

Browse files
committed
debug
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent 83a1003 commit 3b4e510

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

test/e2e/clusterinit/basic_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
package clusterinit
2020

2121
import (
22+
"fmt"
2223
"strings"
2324
"testing"
2425

@@ -180,6 +181,8 @@ metadata:
180181
// wait for the agent to do its work and initialize the cluster and ultimately remove the initializer
181182
targetWs = utils.WaitForWorkspaceInitialization(t, ctx, kcpClusterClient, rootCluster, targetWorkspace)
182183

184+
fmt.Printf("target ws spec: %+v\n", targetWs.Spec)
185+
183186
// connect into the new workspace and verify the generated content
184187
targetClient := kcpClusterClient.Cluster(rootCluster.Join(targetWorkspace))
185188

test/e2e/clusterinit/wait_for_ready_test.go

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
package clusterinit
2020

2121
import (
22+
"fmt"
2223
"strings"
2324
"testing"
2425

@@ -31,6 +32,7 @@ import (
3132
kcptenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1"
3233

3334
rbacv1 "k8s.io/api/rbac/v1"
35+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3436
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3537
"k8s.io/apimachinery/pkg/types"
3638
ctrlruntime "sigs.k8s.io/controller-runtime"
@@ -193,51 +195,23 @@ spec:
193195
// Verify the CRD exists in the target workspace and is Established
194196
targetClient := kcpClusterClient.Cluster(rootCluster.Join(targetWorkspace))
195197

196-
crd := utils.YAMLToUnstructured(t, `
197-
apiVersion: apiextensions.k8s.io/v1
198-
kind: CustomResourceDefinition
199-
metadata:
200-
name: widgets.example.com
201-
`)
202-
203-
if err := targetClient.Get(ctx, types.NamespacedName{Name: crd.GetName()}, crd); err != nil {
198+
crd := &apiextensionsv1.CustomResourceDefinition{}
199+
if err := targetClient.Get(ctx, types.NamespacedName{Name: "widgets.example.com"}, crd); err != nil {
204200
t.Fatalf("Failed to find CRD in target workspace: %v", err)
205201
}
206202

207-
// Verify the CRD has the Established condition set to True
208-
conditions, found, err := getConditions(crd.Object)
209-
if err != nil || !found {
210-
t.Fatal("CRD does not have conditions in status")
211-
}
203+
fmt.Printf("crd status: %+v\n", crd.Status)
212204

205+
// Verify the CRD has the Established condition set to True
213206
established := false
214-
for _, c := range conditions {
215-
condition, ok := c.(map[string]any)
216-
if !ok {
217-
continue
218-
}
219-
220-
cType := condition["type"].(string)
221-
cStatus := condition["status"].(string)
222-
if cType == "Established" && cStatus == "True" {
207+
for _, condition := range crd.Status.Conditions {
208+
if condition.Type == apiextensionsv1.Established && condition.Status == apiextensionsv1.ConditionTrue {
223209
established = true
224210
break
225211
}
226212
}
227213

228214
if !established {
229-
t.Fatal("Expected CRD to have Established=True condition, but it was not found or not True")
230-
}
231-
}
232-
233-
func getConditions(obj map[string]any) ([]any, bool, error) {
234-
status, ok := obj["status"].(map[string]any)
235-
if !ok {
236-
return nil, false, nil
237-
}
238-
conditions, ok := status["conditions"].([]any)
239-
if !ok {
240-
return nil, false, nil
215+
t.Fatal("Expected CRD to have Established=True condition, but has not.")
241216
}
242-
return conditions, true, nil
243217
}

0 commit comments

Comments
 (0)