Skip to content

Commit

Permalink
Fix gateway failover test
Browse files Browse the repository at this point in the history
The gateway failover test fails to locate gateway resource node in
On-premise environments.
All environments created in a public cloud platforms sets the node in a
Gateway resource without any suffix.
On-premise environment may set node name in a way, that suffix will be
defined in Gateway resource.

Search for node in a Gateway resource in both ways - with and without a
suffix.
  • Loading branch information
MaxBab committed Oct 19, 2023
1 parent 11b7ad5 commit 6fad68c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/e2e/framework/gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ var gatewayGVR = &schema.GroupVersionResource{

func (f *Framework) AwaitGatewayWithStatus(cluster ClusterIndex, name, status string) *unstructured.Unstructured {
gwClient := gatewayClient(cluster)
// Set short name without a suffix as exists in the Gateway resource
name = strings.Split(name, ".")[0]
obj := AwaitUntil(fmt.Sprintf("await Gateway on %q with status %q", name, status),
func() (interface{}, error) {
resGw, err := gwClient.Get(context.TODO(), name, metav1.GetOptions{})
// Some environments sets a node in Gateway resource without a suffix
short_name := strings.Split(name, ".")[0]
if resGw == nil {
resGw, err = gwClient.Get(context.TODO(), short_name, metav1.GetOptions{})
}
if apierrors.IsNotFound(err) {
return nil, nil //nolint:nilnil // We want to repeat but let the checker known that nothing was found.
}
Expand Down Expand Up @@ -106,11 +109,14 @@ func (f *Framework) AwaitGatewayRemoved(cluster ClusterIndex, name string) {

func (f *Framework) AwaitGatewayFullyConnected(cluster ClusterIndex, name string) *unstructured.Unstructured {
gwClient := gatewayClient(cluster)
// Set short name without a suffix as exists in the Gateway resource
name = strings.Split(name, ".")[0]
obj := AwaitUntil(fmt.Sprintf("await Gateway on %q with status active and connections UP", name),
func() (interface{}, error) {
resGw, err := gwClient.Get(context.TODO(), name, metav1.GetOptions{})
// Some environments sets a node in Gateway resource without a suffix
short_name := strings.Split(name, ".")[0]
if resGw == nil {
resGw, err = gwClient.Get(context.TODO(), short_name, metav1.GetOptions{})
}
if apierrors.IsNotFound(err) {
return nil, nil //nolint:nilnil // We want to repeat but let the checker known that nothing was found.
}
Expand Down

0 comments on commit 6fad68c

Please sign in to comment.