Skip to content

Commit

Permalink
[OSSM-5574] Update GatewayAPI version for OSSM2.5 (#649)
Browse files Browse the repository at this point in the history
* [OSSM-5574] Update GatewayAPI version for OSSM2.5

* [OSSM-5550] Update service type in GatewayAPI test to work in OCP on PSI
  • Loading branch information
mkralik3 authored Jan 15, 2024
1 parent d4a3fa9 commit 46f65cb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/tests/tasks/traffic/ingress/gatewayapi_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ingress

import (
"fmt"
"testing"

"github.com/maistra/maistra-test-tool/pkg/app"
"github.com/maistra/maistra-test-tool/pkg/tests/ossm"
"github.com/maistra/maistra-test-tool/pkg/util/check/assert"
"github.com/maistra/maistra-test-tool/pkg/util/env"
"github.com/maistra/maistra-test-tool/pkg/util/gatewayapi"
"github.com/maistra/maistra-test-tool/pkg/util/oc"
"github.com/maistra/maistra-test-tool/pkg/util/pod"
"github.com/maistra/maistra-test-tool/pkg/util/retry"
Expand All @@ -28,7 +30,8 @@ func TestGatewayApi(t *testing.T) {
ossm.DeployControlPlane(t)

t.LogStep("Install Gateway API CRD's")
shell.Executef(t, "kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null && echo 'Gateway API CRDs already installed' || kubectl apply -k github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.1")
shell.Executef(t, "kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null && echo 'Gateway API CRDs already installed' || kubectl apply -k github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=%s",
gatewayapi.GetSupportedVersion(env.GetSMCPVersion()))

oc.CreateNamespace(t, ns)

Expand Down Expand Up @@ -82,14 +85,14 @@ func TestGatewayApi(t *testing.T) {
})

t.LogStep("Wait for Gateway to be ready")
oc.WaitCondition(t, ns, "Gateway", "gateway", "Ready")
oc.WaitCondition(t, ns, "Gateway", "gateway", gatewayapi.GetWaitingCondition(env.GetSMCPVersion()))

t.LogStep("Verfiy the GatewayApi access the httpbin service using curl")
retry.UntilSuccess(t, func(t TestHelper) {
oc.Exec(t,
pod.MatchingSelector("app=istio-ingressgateway", meshNamespace),
"istio-proxy",
"curl http://gateway.foo.svc.cluster.local:8080/get -H Host:httpbin.example.com -s -o /dev/null -w %{http_code}",
fmt.Sprintf("curl http://%s.foo.svc.cluster.local:8080/get -H Host:httpbin.example.com -s -o /dev/null -w %%{http_code}", gatewayapi.GetDefaultServiceName(env.GetSMCPVersion(), "gateway", "istio")),
assert.OutputContains("200",
"Access the httpbin service with GatewayApi",
"Unable to access the httpbin service with GatewayApi"))
Expand Down Expand Up @@ -128,14 +131,14 @@ func TestGatewayApi(t *testing.T) {
})

t.LogStep("Wait for Gateway to be ready")
oc.WaitCondition(t, ns, "Gateway", "gateway", "Ready")
oc.WaitCondition(t, ns, "Gateway", "gateway", gatewayapi.GetWaitingCondition(env.GetSMCPVersion()))

t.LogStep("Verify the Gateway-Controller Profile access the httpbin service using curl")
retry.UntilSuccess(t, func(t TestHelper) {
oc.Exec(t,
pod.MatchingSelector("app=istiod", meshNamespace),
"discovery",
"curl http://gateway.foo.svc.cluster.local:8080/get -H Host:httpbin.example.com -s -o /dev/null -w %{http_code}",
fmt.Sprintf("curl http://%s.foo.svc.cluster.local:8080/get -H Host:httpbin.example.com -s -o /dev/null -w %%{http_code}", gatewayapi.GetDefaultServiceName(env.GetSMCPVersion(), "gateway", "ocp")),
assert.OutputContains("200",
"Access the httpbin service with GatewayApi",
"Unable to access the httpbin service with GatewayApi"))
Expand All @@ -149,6 +152,8 @@ const gatewayAndRouteYAML = `
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
annotations:
networking.istio.io/service-type: "ClusterIP"
name: gateway
spec:
gatewayClassName: {{ .GatewayClassName }}
Expand Down
44 changes: 44 additions & 0 deletions pkg/util/gatewayapi/gatewayapi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gatewayapi

import (
"github.com/maistra/maistra-test-tool/pkg/util/version"
)

func GetSupportedVersion(smcp version.Version) string {
switch smcp {
case version.SMCP_2_3:
return "v0.5.1"
case version.SMCP_2_4:
return "v0.5.1"
case version.SMCP_2_5:
return "v0.6.2"
default:
return "v0.6.2"
}
}

func GetDefaultServiceName(smcp version.Version, gatewayName string, className string) string {
switch smcp {
case version.SMCP_2_3:
return gatewayName
case version.SMCP_2_4:
return gatewayName
case version.SMCP_2_5:
return gatewayName + "-" + className
default:
return gatewayName + "-" + className
}
}

func GetWaitingCondition(smcp version.Version) string {
switch smcp {
case version.SMCP_2_3:
return "Ready"
case version.SMCP_2_4:
return "Ready"
case version.SMCP_2_5:
return "Programmed"
default:
return "Programmed"
}
}

0 comments on commit 46f65cb

Please sign in to comment.