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

test(e2e): speedup universal tests #12716

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func configure(
protocol core_mesh.Protocol,
) error {
switch protocol {
case core_mesh.ProtocolHTTP, core_mesh.ProtocolHTTP2:
case core_mesh.ProtocolHTTP, core_mesh.ProtocolHTTP2, core_mesh.ProtocolGRPC:
for _, rule := range fromRules {
conf := rule.Conf.(api.Conf)
from := rule.Subset
Expand Down
38 changes: 20 additions & 18 deletions test/e2e_env/universal/meshretry/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ func GrpcRetry() {
WithProtocol("grpc"),
WithTransparentProxy(true),
)).
// remove default policies after https://github.com/kumahq/kuma/issues/3325
Install(TrafficRouteUniversal(meshName)).
Setup(universal.Cluster)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -45,23 +43,27 @@ func GrpcRetry() {

E2EAfterAll(func() {
Expect(universal.Cluster.DeleteMeshApps(meshName)).To(Succeed())
Expect(universal.Cluster.GetKumactlOptions().RunKumactl("delete", "dataplane", "fake-echo-server", "-m", meshName)).To(Succeed())
Expect(universal.Cluster.DeleteMesh(meshName)).To(Succeed())
})

It("should retry on GRPC connection failure", func() {
echoServerDataplane := fmt.Sprintf(`
type: Dataplane
faultInjection := fmt.Sprintf(`
type: MeshFaultInjection
mesh: "%s"
name: fake-echo-server
networking:
address: 241.0.0.1
inbound:
- port: 7777
servicePort: 7777
tags:
kuma.io/service: test-server
kuma.io/protocol: grpc
name: mesh-fault-injecton-500-grpc
spec:
targetRef:
kind: MeshService
name: test-server
from:
- targetRef:
kind: MeshService
name: test-client
default:
http:
- abort:
httpStatus: 503
percentage: "50.0"
`, meshName)
meshRetryPolicy := fmt.Sprintf(`
type: MeshRetry
Expand Down Expand Up @@ -100,8 +102,8 @@ spec:
g.Expect(grpcSuccessStats(g)).To(stats.BeGreaterThanZero())
}, "30s", "1s").Should(Succeed())

By("Adding a faulty dataplane")
Expect(universal.Cluster.Install(YamlUniversal(echoServerDataplane))).To(Succeed())
By("Adding a fault injection")
Expect(universal.Cluster.Install(YamlUniversal(faultInjection))).To(Succeed())

By("Clean counters")
Expect(admin.ResetCounters()).To(Succeed())
Expand All @@ -112,7 +114,7 @@ spec:
defer func() { lastFailureStats = failureStats.Stats[0] }()
g.Expect(failureStats).To(stats.BeGreaterThanZero())
g.Expect(failureStats).To(stats.BeGreaterThan(lastFailureStats))
}, "60s", "5s").MustPassRepeatedly(3).Should(Succeed())
}, "30s", "5s").Should(Succeed())

By("Apply a MeshRetry policy")
Expect(universal.Cluster.Install(YamlUniversal(meshRetryPolicy))).To(Succeed())
Expand All @@ -127,6 +129,6 @@ spec:
defer func() { lastFailureStats = failureStats.Stats[0] }()
g.Expect(failureStats).To(Not(stats.BeGreaterThan(lastFailureStats)))
g.Expect(grpcSuccessStats(g)).To(stats.BeGreaterThanZero())
}, "30s", "5s").MustPassRepeatedly(3).Should(Succeed())
}, "30s", "5s").Should(Succeed())
})
}
63 changes: 26 additions & 37 deletions test/e2e_env/universal/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package retry

import (
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -36,24 +35,25 @@ func Policy() {

E2EAfterAll(func() {
Expect(universal.Cluster.DeleteMeshApps(meshName)).To(Succeed())
Expect(universal.Cluster.GetKumactlOptions().RunKumactl("delete", "dataplane", "fake-echo-server", "-m", meshName)).To(Succeed())
Expect(universal.Cluster.DeleteMesh(meshName)).To(Succeed())
})

It("should retry on HTTP connection failure", func() {
echoServerDataplane := fmt.Sprintf(`
type: Dataplane
fiPolicy := fmt.Sprintf(`
type: FaultInjection
mesh: "%s"
name: fake-echo-server
networking:
address: 241.0.0.1
inbound:
- port: 7777
servicePort: 7777
tags:
kuma.io/service: test-server
kuma.io/protocol: http
`, meshName)
name: fi-retry
sources:
- match:
kuma.io/service: demo-client
destinations:
- match:
kuma.io/service: test-server
kuma.io/protocol: http
conf:
abort:
httpStatus: 500
percentage: 50`, meshName)
retryPolicy := fmt.Sprintf(`
type: Retry
mesh: "%s"
Expand All @@ -75,32 +75,22 @@ conf:
universal.Cluster, "demo-client", "test-server.mesh",
)
g.Expect(err).ToNot(HaveOccurred())
}).Should(Succeed())
Consistently(func(g Gomega) {
// -m 8 to wait for 8 seconds to beat the default 5s connect timeout
_, err := client.CollectEchoResponse(
universal.Cluster, "demo-client", "test-server.mesh",
client.WithMaxTime(8),
)
g.Expect(err).ToNot(HaveOccurred())
}).Should(Succeed())
}, "30s", "1s").MustPassRepeatedly(3).Should(Succeed())

By("Adding a faulty dataplane")
Expect(universal.Cluster.Install(YamlUniversal(echoServerDataplane))).To(Succeed())
By("Adding a fault injection")
Expect(universal.Cluster.Install(YamlUniversal(fiPolicy))).To(Succeed())

By("Check some errors happen")
var errs []error
for i := 0; i < 50; i++ {
time.Sleep(time.Millisecond * 100)
_, err := client.CollectEchoResponse(
Eventually(func(g Gomega) {
response, err := client.CollectFailure(
universal.Cluster, "demo-client", "test-server.mesh",
client.WithMaxTime(8),
client.NoFail(),
client.OutputFormat(`{ "received": { "status": %{response_code} } }`),
)
if err != nil {
errs = append(errs, err)
}
}
Expect(errs).ToNot(BeEmpty())

g.Expect(err).ToNot(HaveOccurred())
g.Expect(response.ResponseCode).To(Equal(500))
}, "30s", "100ms").Should(Succeed())

By("Apply a retry policy")
Expect(universal.Cluster.Install(YamlUniversal(retryPolicy))).To(Succeed())
Expand All @@ -109,9 +99,8 @@ conf:
Eventually(func(g Gomega) {
_, err := client.CollectEchoResponse(
universal.Cluster, "demo-client", "test-server.mesh",
client.WithMaxTime(8),
)
g.Expect(err).ToNot(HaveOccurred())
}, "1m", "1s", MustPassRepeatedly(3)).Should(Succeed())
}, "60s", "1s").MustPassRepeatedly(3).Should(Succeed())
})
}
Loading