Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E2E panic due to invalid nil check #1447

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/e2e/framework/clusterglobalegressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ func AwaitAllocatedEgressIPs(client dynamic.ResourceInterface, name string) []st
return resGip, err
},
func(result interface{}) (bool, string, error) {
if result == nil {
obj := result.(*unstructured.Unstructured)
if obj == nil {
return false, fmt.Sprintf("Egress IP resource %q not found yet", name), nil
}

globalIPs := getGlobalIPs(result.(*unstructured.Unstructured))
globalIPs := getGlobalIPs(obj)
if len(globalIPs) == 0 {
return false, fmt.Sprintf("Egress IP resource %q exists but allocatedIPs not available yet", name), nil
}
Expand Down
8 changes: 2 additions & 6 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,8 @@ func DetectGlobalnet() {
}
return clusters, err
}, func(result interface{}) (bool, string, error) {
if result == nil {
return false, "No Cluster found", nil
}

clusterList := result.(*unstructured.UnstructuredList)
if len(clusterList.Items) == 0 {
if clusterList == nil || len(clusterList.Items) == 0 {
return false, "No Cluster found", nil
}

Expand Down Expand Up @@ -343,7 +339,7 @@ func fetchClusterIDs() {

return ds, err
}, func(result interface{}) (bool, string, error) {
if result == nil {
if result.(*appsv1.DaemonSet) == nil {
return false, "No DaemonSet found", nil
}

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/framework/gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func (f *Framework) AwaitGatewayWithStatus(cluster ClusterIndex, name, status st
return findGateway(cluster, name)
},
func(result interface{}) (bool, string, error) {
if result == nil {
gw := result.(*unstructured.Unstructured)
if gw == nil {
return false, "gateway not found yet", nil
}

gw := result.(*unstructured.Unstructured)
haStatus := NestedString(gw.Object, "status", "haStatus")
if haStatus != status {
return false, fmt.Sprintf("gateway %q exists but has wrong status %q, expected %q", gw.GetName(), haStatus, status), nil
Expand Down Expand Up @@ -118,11 +118,11 @@ func (f *Framework) AwaitGatewayFullyConnected(cluster ClusterIndex, name string
return findGateway(cluster, name)
},
func(result interface{}) (bool, string, error) {
if result == nil {
gw := result.(*unstructured.Unstructured)
if gw == nil {
return false, "gateway not found yet", nil
}

gw := result.(*unstructured.Unstructured)
haStatus := NestedString(gw.Object, "status", "haStatus")
if haStatus != "active" {
return false, fmt.Sprintf("Gateway %q exists but not active yet",
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/globalingressips.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func (f *Framework) AwaitGlobalIngressIP(cluster ClusterIndex, name, namespace s
return resGip, err
},
func(result interface{}) (bool, string, error) {
if result == nil {
obj := result.(*unstructured.Unstructured)
if obj == nil {
return false, fmt.Sprintf("GlobalEgressIP %s not found yet", name), nil
}

globalIP := getGlobalIP(result.(*unstructured.Unstructured))
globalIP := getGlobalIP(obj)
if globalIP == "" {
return false, fmt.Sprintf("GlobalIngress %q exists but allocatedIP not available yet",
name), nil
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (f *Framework) AwaitUntilAnnotationOnPod(cluster ClusterIndex, annotation,
}
return pod, err
}, func(result interface{}) (bool, string, error) {
if result == nil {
pod := result.(*v1.Pod)
if pod == nil {
return false, "No Pod found", nil
}

pod := result.(*v1.Pod)
if pod.GetAnnotations()[annotation] == "" {
return false, fmt.Sprintf("Pod %q does not have annotation %q yet", podName, annotation), nil
}
Expand Down
Loading