Skip to content

Commit

Permalink
update_ns_package (#686)
Browse files Browse the repository at this point in the history
Co-authored-by: Praneeth Bajjuri <[email protected]>
  • Loading branch information
pbajjuri20 and Praneeth Bajjuri authored May 14, 2024
1 parent 63f4cd2 commit f6d4229
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 98 deletions.
19 changes: 10 additions & 9 deletions pkg/tests/tasks/traffic/circuit_breaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,36 @@ import (
"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/ns"
"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"
"github.com/maistra/maistra-test-tool/pkg/util/test"

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

func TestCircuitBreaking(t *testing.T) {
NewTest(t).Id("T6").Groups(Full, InterOp, ARM).Run(func(t TestHelper) {
t.Log("This test checks whether the circuit breaker functions correctly. Check documentation: https://istio.io/latest/docs/tasks/traffic-management/circuit-breaking/")

ns := "bookinfo"
t.Cleanup(func() {
oc.RecreateNamespace(t, ns)
oc.RecreateNamespace(t, ns.Bookinfo)
})

ossm.DeployControlPlane(t)

t.LogStep("Install httpbin and fortio")
app.InstallAndWaitReady(t, app.Httpbin(ns), app.Fortio(ns))
app.InstallAndWaitReady(t, app.Httpbin(ns.Bookinfo), app.Fortio(ns.Bookinfo))

t.LogStep("Configure circuit breaker destination rule")
oc.ApplyString(t, ns, httpbinCircuitBreaker)
oc.ApplyString(t, ns.Bookinfo, httpbinCircuitBreaker)

t.LogStep("Verify connection with curl: expect 200 OK")
retry.UntilSuccess(t, func(t test.TestHelper) {
httpbinIP := oc.GetServiceClusterIP(t, ns, "httpbin")
httpbinIP := oc.GetServiceClusterIP(t, ns.Bookinfo, "httpbin")
oc.Exec(t,
pod.MatchingSelector("app=fortio", ns),
pod.MatchingSelector("app=fortio", ns.Bookinfo),
"fortio",
fmt.Sprintf(`/usr/bin/fortio curl -quiet -resolve %s http://httpbin:8000/get`, httpbinIP),
assert.OutputContains("200",
Expand All @@ -66,9 +67,9 @@ func TestCircuitBreaking(t *testing.T) {
t.LogStep("Trip the circuit breaker by sending 50 requests to httpbin with 2 connections")
t.Log("We expect request with response code 503")
retry.UntilSuccess(t, func(t test.TestHelper) {
httpbinIP := oc.GetServiceClusterIP(t, ns, "httpbin")
httpbinIP := oc.GetServiceClusterIP(t, ns.Bookinfo, "httpbin")
msg := oc.Exec(t,
pod.MatchingSelector("app=fortio", ns),
pod.MatchingSelector("app=fortio", ns.Bookinfo),
"fortio",
fmt.Sprintf("/usr/bin/fortio load -c %d -qps 0 -n %d -loglevel Warning -resolve %s http://httpbin:8000/get", connection, reqCount, httpbinIP))

Expand All @@ -85,7 +86,7 @@ func TestCircuitBreaking(t *testing.T) {
t.LogStep("Validate the circuit breaker is tripped by checking the istio-proxy log")
t.Log("Verify istio-proxy pilot-agent stats, expected upstream_rq_pending_overflow value to be more than zero")
oc.Exec(t,
pod.MatchingSelector("app=fortio", ns),
pod.MatchingSelector("app=fortio", ns.Bookinfo),
"istio-proxy",
"pilot-agent request GET stats | grep httpbin | grep pending",
assertProxyContainsUpstreamRqPendingOverflow)
Expand Down
20 changes: 10 additions & 10 deletions pkg/tests/tasks/traffic/egress/egress_wildcard_hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,42 @@ import (
"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/ns"
"github.com/maistra/maistra-test-tool/pkg/util/oc"

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

func TestEgressWildcard(t *testing.T) {
NewTest(t).Id("T16").Groups(Full, InterOp, ARM).Run(func(t TestHelper) {
t.Log("This test checks if the wildcard in the ServiceEntry and Gateway works as expected for Egress traffic.")

ns := "bookinfo"

ossm.DeployControlPlane(t)

t.LogStep("Install the sleep pod")
app.InstallAndWaitReady(t, app.Sleep(ns))
app.InstallAndWaitReady(t, app.Sleep(ns.Bookinfo))
t.Cleanup(func() {
app.Uninstall(t, app.Sleep(ns))
app.Uninstall(t, app.Sleep(ns.Bookinfo))
})

t.NewSubTest("ServiceEntry").Run(func(t TestHelper) {
t.LogStep("Configure ServiceEntry with wildcard host *.wikipedia.org")
oc.ApplyString(t, ns, EgressWildcardServiceEntry)
oc.ApplyString(t, ns.Bookinfo, EgressWildcardServiceEntry)
t.Cleanup(func() {
oc.DeleteFromString(t, ns, EgressWildcardServiceEntry)
oc.DeleteFromString(t, ns.Bookinfo, EgressWildcardServiceEntry)
})

assertExternalRequestSuccess(t, ns)
assertExternalRequestSuccess(t, ns.Bookinfo)
})

t.NewSubTest("Gateway").Run(func(t TestHelper) {
t.LogStep("Configure egress Gateway with wildcard host *.wikipedia.org")
oc.ApplyTemplate(t, ns, EgressWildcardGatewayTemplate, smcp)
oc.ApplyTemplate(t, ns.Bookinfo, EgressWildcardGatewayTemplate, smcp)
t.Cleanup(func() {
oc.DeleteFromTemplate(t, ns, EgressWildcardGatewayTemplate, smcp)
oc.DeleteFromTemplate(t, ns.Bookinfo, EgressWildcardGatewayTemplate, smcp)
})

assertExternalRequestSuccess(t, ns)
assertExternalRequestSuccess(t, ns.Bookinfo)
})
})
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/tests/tasks/traffic/fault_injection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/maistra/maistra-test-tool/pkg/util/check/assert"
"github.com/maistra/maistra-test-tool/pkg/util/curl"
"github.com/maistra/maistra-test-tool/pkg/util/env"
"github.com/maistra/maistra-test-tool/pkg/util/ns"
"github.com/maistra/maistra-test-tool/pkg/util/oc"
"github.com/maistra/maistra-test-tool/pkg/util/retry"
. "github.com/maistra/maistra-test-tool/pkg/util/test"
Expand All @@ -40,25 +41,24 @@ var (

func TestFaultInjection(t *testing.T) {
NewTest(t).Id("T2").Groups(Full, InterOp, ARM).Run(func(t TestHelper) {
ns := "bookinfo"

t.Cleanup(func() {
oc.RecreateNamespace(t, ns)
oc.RecreateNamespace(t, ns.Bookinfo)
os.Remove(env.GetRootDir() + `/testdata/resources/html/modified-productpage-test-user-v2-rating-unavailable.html`)
})

ossm.DeployControlPlane(t)

t.LogStep("Install Bookinfo")
app.InstallAndWaitReady(t, app.Bookinfo(ns))
app.InstallAndWaitReady(t, app.Bookinfo(ns.Bookinfo))

testUserCookieJar := app.BookinfoLogin(t, meshNamespace)

oc.ApplyString(t, ns, app.BookinfoVirtualServicesAllV1)
oc.ApplyString(t, ns, app.BookinfoVirtualServiceReviewsV2)
oc.ApplyString(t, ns.Bookinfo, app.BookinfoVirtualServicesAllV1)
oc.ApplyString(t, ns.Bookinfo, app.BookinfoVirtualServiceReviewsV2)

t.NewSubTest("ratings-fault-delay").Run(func(t TestHelper) {
oc.ApplyString(t, ns, ratingsVirtualServiceWithFixedDelay)
oc.ApplyString(t, ns.Bookinfo, ratingsVirtualServiceWithFixedDelay)

t.LogStep("check if productpage shows 'error fetching product reviews' due to delay injection")
retry.UntilSuccess(t, func(t TestHelper) {
Expand All @@ -75,7 +75,7 @@ func TestFaultInjection(t *testing.T) {
})

t.NewSubTest("ratings-fault-abort").Run(func(t TestHelper) {
oc.ApplyString(t, ns, ratingsVirtualServiceWithHttpStatus500)
oc.ApplyString(t, ns.Bookinfo, ratingsVirtualServiceWithHttpStatus500)

expectedResponseFile := TestreviewV2(t, "productpage-test-user-v2-rating-unavailable.html")

Expand Down
26 changes: 13 additions & 13 deletions pkg/tests/tasks/traffic/ingress/gatewayapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"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/ns"
"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 @@ -23,7 +24,6 @@ func TestGatewayApi(t *testing.T) {
if env.GetSMCPVersion().LessThan(version.SMCP_2_3) {
t.Skip("TestGatewayApi was added in v2.3")
}
ns := "foo"

smcpName := env.GetDefaultSMCPName()

Expand All @@ -33,17 +33,17 @@ func TestGatewayApi(t *testing.T) {
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)
oc.CreateNamespace(t, ns.Foo)

t.NewSubTest("Deploy the Kubernetes Gateway API").Run(func(t test.TestHelper) {

t.Cleanup(func() {
oc.RecreateNamespace(t, meshNamespace)
oc.RecreateNamespace(t, ns)
oc.RecreateNamespace(t, ns.Foo)
})

t.LogStep("Install httpbin")
app.InstallAndWaitReady(t, app.Httpbin(ns))
app.InstallAndWaitReady(t, app.Httpbin(ns.Foo))

t.LogStep("Deploy the Gateway SMCP")

Expand Down Expand Up @@ -79,13 +79,13 @@ func TestGatewayApi(t *testing.T) {
}

t.LogStep("Deploy the Gateway API configuration including a single exposed route (i.e., /get)")
oc.ApplyTemplate(t, ns, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "istio"})
oc.ApplyTemplate(t, ns.Foo, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "istio"})
t.Cleanup(func() {
oc.DeleteFromTemplate(t, ns, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "istio"})
oc.DeleteFromTemplate(t, ns.Foo, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "istio"})
})

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

t.LogStep("Verfiy the GatewayApi access the httpbin service using curl")
retry.UntilSuccess(t, func(t TestHelper) {
Expand All @@ -106,11 +106,11 @@ func TestGatewayApi(t *testing.T) {

t.Cleanup(func() {
oc.RecreateNamespace(t, meshNamespace)
oc.RecreateNamespace(t, ns)
oc.RecreateNamespace(t, ns.Foo)
})

t.LogStep("Install httpbin")
app.InstallAndWaitReady(t, app.Httpbin(ns))
app.InstallAndWaitReady(t, app.Httpbin(ns.Foo))

t.LogStep("Deploy SMCP with the profile")
oc.ApplyTemplate(t,
Expand All @@ -121,17 +121,17 @@ func TestGatewayApi(t *testing.T) {

t.LogStep("delete default SMMR and create custom SMMR")
oc.DeleteFromString(t, meshNamespace, defaultSMMR)
oc.ApplyTemplate(t, meshNamespace, createSMMR, map[string]string{"Member": ns})
oc.ApplyTemplate(t, meshNamespace, createSMMR, map[string]string{"Member": ns.Foo})
oc.WaitSMMRReady(t, meshNamespace)

t.LogStep("Deploy the Gateway API configuration including a single exposed route (i.e., /get)")
oc.ApplyTemplate(t, ns, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "ocp"})
oc.ApplyTemplate(t, ns.Foo, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "ocp"})
t.Cleanup(func() {
oc.DeleteFromTemplate(t, ns, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "ocp"})
oc.DeleteFromTemplate(t, ns.Foo, gatewayAndRouteYAML, map[string]string{"GatewayClassName": "ocp"})
})

t.LogStep("Wait for Gateway to be ready")
oc.WaitCondition(t, ns, "Gateway", "gateway", gatewayapi.GetWaitingCondition(env.GetSMCPVersion()))
oc.WaitCondition(t, ns.Foo, "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) {
Expand Down
11 changes: 6 additions & 5 deletions pkg/tests/tasks/traffic/ingress/ingress_gateways_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/maistra/maistra-test-tool/pkg/util/curl"
"github.com/maistra/maistra-test-tool/pkg/util/env"
"github.com/maistra/maistra-test-tool/pkg/util/istio"
"github.com/maistra/maistra-test-tool/pkg/util/ns"
"github.com/maistra/maistra-test-tool/pkg/util/oc"
"github.com/maistra/maistra-test-tool/pkg/util/request"
"github.com/maistra/maistra-test-tool/pkg/util/retry"
Expand All @@ -34,21 +35,21 @@ import (

func TestIngressGateways(t *testing.T) {
NewTest(t).Id("T8").Groups(Full, InterOp, ARM).Run(func(t TestHelper) {
ns := "bookinfo"

t.Cleanup(func() {
oc.RecreateNamespace(t, ns)
oc.RecreateNamespace(t, ns.Bookinfo)
})

ossm.DeployControlPlane(t)

t.LogStep("Install httpbin")
app.InstallAndWaitReady(t, app.Httpbin(ns))
app.InstallAndWaitReady(t, app.Httpbin(ns.Bookinfo))

gatewayHTTP := istio.GetIngressGatewayHost(t, meshNamespace)

t.NewSubTest("TrafficManagement_ingress_status_200_test").Run(func(t TestHelper) {
t.LogStep("Create httpbin Gateway and VirtualService with host set to httpbin.example.com")
oc.ApplyString(t, ns, httpbinGateway1)
oc.ApplyString(t, ns.Bookinfo, httpbinGateway1)

if env.GetSMCPVersion().GreaterThanOrEqual(version.SMCP_2_5) {
createRoute(t, meshNamespace, "httpbin.example.com", "http2", "istio-ingressgateway")
Expand All @@ -65,7 +66,7 @@ func TestIngressGateways(t *testing.T) {

t.NewSubTest("TrafficManagement_ingress_headers_test").Run(func(t TestHelper) {
t.LogStep("Create httpbin Gateway and VirtualService with host set to *")
oc.ApplyString(t, ns, httpbinGateway2)
oc.ApplyString(t, ns.Bookinfo, httpbinGateway2)

t.LogStep("Check if httpbin service is reachable through istio-ingressgateway")
retry.UntilSuccess(t, func(t TestHelper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/maistra/maistra-test-tool/pkg/util/curl"
"github.com/maistra/maistra-test-tool/pkg/util/env"
"github.com/maistra/maistra-test-tool/pkg/util/istio"
"github.com/maistra/maistra-test-tool/pkg/util/ns"
"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/request"
Expand All @@ -36,22 +37,20 @@ func TestIngressWithoutTlsTermination(t *testing.T) {
t.Log("This test validates configuring an Gateway with TLS PassThrough")
t.Log("Doc reference: https://istio.io/v1.14/docs/tasks/traffic-management/ingress/ingress-sni-passthrough/")

ns := "bookinfo"

t.Cleanup(func() {
oc.DeleteFromString(t, ns, nginxIngressGateway)
app.Uninstall(t, app.Nginx(ns))
oc.DeleteFromString(t, ns.Bookinfo, nginxIngressGateway)
app.Uninstall(t, app.Nginx(ns.Bookinfo))
})

ossm.DeployControlPlane(t)

t.LogStep("Create NGINX Deployment")
app.InstallAndWaitReady(t, app.Nginx(ns))
app.InstallAndWaitReady(t, app.Nginx(ns.Bookinfo))

t.LogStep("Verify NGINX server is running by connecting to it via loopback")
retry.UntilSuccess(t, func(t test.TestHelper) {
oc.Exec(t,
pod.MatchingSelector("run=my-nginx", ns),
pod.MatchingSelector("run=my-nginx", ns.Bookinfo),
"istio-proxy",
"curl -sS -v -k --resolve nginx.example.com:8443:127.0.0.1 https://nginx.example.com:8443",
assert.OutputContains(
Expand All @@ -61,7 +60,7 @@ func TestIngressWithoutTlsTermination(t *testing.T) {
})

t.LogStep("Configure Gateway resource with TLS passthrough for host nginx.example.com")
oc.ApplyString(t, ns, nginxIngressGateway)
oc.ApplyString(t, ns.Bookinfo, nginxIngressGateway)

if env.GetSMCPVersion().GreaterThanOrEqual(version.SMCP_2_5) {
createRouteWithTLS(t, meshNamespace, "nginx.example.com", "https", "istio-ingressgateway", "passthrough")
Expand Down
Loading

0 comments on commit f6d4229

Please sign in to comment.