forked from kgateway-dev/kgateway
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing tests for external traffic policy gateway params (#10562)
- Loading branch information
1 parent
d1537f3
commit ca93dd0
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changelog: | ||
- type: NON_USER_FACING | ||
description: > | ||
Add missing e2e suite test for checking gateway param eternal traffic policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package kubeutils | ||
|
||
import ( | ||
"context" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
// GetService gets the service from the provided name/namespace | ||
func GetService( | ||
ctx context.Context, | ||
kubeClient *kubernetes.Clientset, | ||
serviceName string, | ||
serviceNamespace string, | ||
) (*corev1.Service, error) { | ||
|
||
service, err := kubeClient.CoreV1().Services(serviceNamespace).Get(ctx, serviceName, metav1.GetOptions{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return service, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package assertions | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/types" | ||
"github.com/solo-io/gloo/pkg/utils/kubeutils" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func (p *Provider) EventuallyExternalTrafficPolicy(ctx context.Context, service corev1.Service, externalTrafficPolicyMatcher types.GomegaMatcher) { | ||
p.Gomega.Eventually(func(innerG Gomega) { | ||
service, err := kubeutils.GetService(ctx, p.clusterContext.Clientset, service.Name, service.Namespace) | ||
innerG.Expect(err).NotTo(HaveOccurred(), "can get service") | ||
innerG.Expect(service.Spec.ExternalTrafficPolicy).To(externalTrafficPolicyMatcher, "externalTrafficPolicy to match") | ||
}). | ||
WithContext(ctx). | ||
WithTimeout(time.Second * 30). | ||
WithPolling(time.Millisecond * 200). | ||
Should(Succeed()) | ||
} |