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

feat: data plane & envoyproxy resilience test suite #4862

Merged
merged 54 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
bfde99b
adding resilience test suite
alexwo Dec 6, 2024
35c9927
fix licensecheck
alexwo Dec 6, 2024
513dc2a
fixing lint
alexwo Dec 6, 2024
1a0a982
updating
alexwo Dec 6, 2024
4510213
updating
alexwo Dec 7, 2024
b3b606a
updadting
alexwo Dec 7, 2024
50dd963
updating
alexwo Dec 7, 2024
45e843a
updating
alexwo Dec 7, 2024
e46cc87
updating
alexwo Dec 7, 2024
683e613
updating
alexwo Dec 7, 2024
72e6819
updating
alexwo Dec 7, 2024
6dbd868
updating
alexwo Dec 7, 2024
487e3ee
updating
alexwo Dec 7, 2024
a1449ba
updating
alexwo Dec 7, 2024
c19ef36
updating
alexwo Dec 7, 2024
c8fa4a2
updating
alexwo Dec 7, 2024
0d89692
updating
alexwo Dec 7, 2024
0b60883
updating
alexwo Dec 7, 2024
c1219cd
updating
alexwo Dec 7, 2024
47a7654
Merge branch 'main' into resilience_test_suite
alexwo Dec 8, 2024
b32c63f
Merge branch 'main' into resilience_test_suite
alexwo Dec 9, 2024
e1ef0a4
updating
alexwo Dec 9, 2024
0aa22c0
updating
alexwo Dec 9, 2024
5fd0e0d
updating
alexwo Dec 9, 2024
3de805d
updating
alexwo Dec 9, 2024
ab3f340
updating
alexwo Dec 9, 2024
a63948e
Merge branch 'main' into resilience_test_suite
alexwo Dec 9, 2024
7a27a4e
Merge branch 'main' into resilience_test_suite
alexwo Dec 10, 2024
b4d931b
updating
alexwo Dec 10, 2024
944cc2c
Merge branch 'resilience_test_suite' of github.com:alexwo/gateway int…
alexwo Dec 10, 2024
7e8eb4f
updating
alexwo Dec 10, 2024
895e839
updating
alexwo Dec 10, 2024
68fc1b9
updating
alexwo Dec 10, 2024
4dd8ccb
updating
alexwo Dec 10, 2024
2199032
updating
alexwo Dec 10, 2024
122d1a4
updating
alexwo Dec 10, 2024
f8f575e
updating
alexwo Dec 10, 2024
ab6ff9c
updating
alexwo Dec 10, 2024
870cfec
Merge branch 'main' into resilience_test_suite
alexwo Dec 10, 2024
ae5de68
updating
alexwo Dec 11, 2024
0abcb33
Merge branch 'resilience_test_suite' of github.com:alexwo/gateway int…
alexwo Dec 11, 2024
42603cf
updating
alexwo Dec 11, 2024
c2cac08
Merge branch 'main' into resilience_test_suite
alexwo Dec 11, 2024
758d12f
Merge branch 'main' into resilience_test_suite
alexwo Dec 11, 2024
9422c81
updating
alexwo Dec 11, 2024
6033f82
Merge branch 'main' into resilience_test_suite
alexwo Dec 11, 2024
443284b
Merge branch 'main' into resilience_test_suite
alexwo Dec 12, 2024
289b5f0
Update test/resilience/tests/envoygateway.go
alexwo Dec 12, 2024
3e425a4
Merge branch 'main' into resilience_test_suite
alexwo Dec 12, 2024
9049271
updating
alexwo Dec 12, 2024
4ab45b1
updating
alexwo Dec 12, 2024
84be07e
updating
alexwo Dec 12, 2024
9b1b6c3
Merge branch 'main' into resilience_test_suite
alexwo Dec 13, 2024
50ca751
Merge branch 'main' into resilience_test_suite
alexwo Dec 13, 2024
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
13 changes: 13 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ jobs:

- name: Read Benchmark report
run: cat test/benchmark/benchmark_report/benchmark_report.md
resilience-test:
runs-on: ubuntu-latest
if: ${{ ! startsWith(github.event_name, 'push') }}
needs: [build]
steps:
- uses: actions/[email protected]
- uses: ./tools/github-actions/setup-deps
- name: Resilience Test
env:
KIND_NODE_TAG: v1.28.13
IMAGE_PULL_POLICY: IfNotPresent
CUSTOM_CNI: "true"
run: make resilience

publish:
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions test/resilience/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build resilience

package resilience

import "embed"

//go:embed testdata/*.yaml
var Manifests embed.FS
40 changes: 40 additions & 0 deletions test/resilience/resilience_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build resilience

package resilience

import (
"flag"
"io/fs"
"os"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/gateway-api/conformance/utils/flags"
"testing"

"github.com/envoyproxy/gateway/test/resilience/suite"
"github.com/envoyproxy/gateway/test/resilience/tests"
kubetest "github.com/envoyproxy/gateway/test/utils/kubernetes"
)

func TestResilience(t *testing.T) {
cli, _ := kubetest.NewClient(t)
// Parse benchmark options.
flag.Parse()
log.SetLogger(zap.New(zap.WriteTo(os.Stderr), zap.UseDevMode(true)))
bSuite, err := suite.NewResilienceTestSuite(
cli,
*suite.ReportSaveDir,
[]fs.FS{Manifests},
*flags.GatewayClassName,
)
if err != nil {
t.Fatalf("Failed to create the resillience test suit: %v", err)
}
t.Logf("Running %d resilience tests", len(tests.ResilienceTests))
bSuite.Run(t, tests.ResilienceTests)
}
14 changes: 14 additions & 0 deletions test/resilience/suite/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build resilience

package suite

import "flag"

var (
ReportSaveDir = flag.String("report-save-dir", "benchmark_report", "The dir where to save the benchmark test report.")
)
115 changes: 115 additions & 0 deletions test/resilience/suite/suite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build resilience

package suite

import (
"context"
"github.com/envoyproxy/gateway/test/utils/kubernetes"
"io/fs"
"sigs.k8s.io/gateway-api/conformance/utils/roundtripper"
"testing"
"time"

opt "github.com/envoyproxy/gateway/internal/cmd/options"
kube "github.com/envoyproxy/gateway/internal/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/gateway-api/conformance/utils/config"
)

const (
BenchmarkTestScaledKey = "benchmark-test/scaled"
BenchmarkTestClientKey = "benchmark-test/client"
DefaultControllerName = "gateway.envoyproxy.io/gatewayclass-controller"
)

type ResilienceTest struct {
ShortName string
Description string
Test func(*testing.T, *ResilienceTestSuite)
}

type ResilienceTestSuite struct {
Client client.Client
TimeoutConfig config.TimeoutConfig
ControllerName string
ReportSaveDir string
KubeActions *kubernetes.KubeActions
// Labels
scaledLabels map[string]string // indicate which resources are scaled

// Clients that for internal usage.
kubeClient kube.CLIClient // required for getting logs from pod\
ManifestFS []fs.FS
GatewayClassName string
RoundTripper roundtripper.RoundTripper
}

func NewResilienceTestSuite(client client.Client, reportDir string, manifestFS []fs.FS, gcn string) (*ResilienceTestSuite, error) {
var (
timeoutConfig = config.TimeoutConfig{}
)

// Reset some timeout config for the benchmark test.
config.SetupTimeoutConfig(&timeoutConfig)
timeoutConfig.RouteMustHaveParents = 180 * time.Second
roundTripper := &roundtripper.DefaultRoundTripper{Debug: true, TimeoutConfig: timeoutConfig}
// Initial various client.
kubeClient, err := kube.NewCLIClient(opt.DefaultConfigFlags.ToRawKubeConfigLoader())
if err != nil {
return nil, err
}
KubeActions := kubernetes.NewKubeHelper(client, kubeClient)
return &ResilienceTestSuite{
Client: client,
ManifestFS: manifestFS,
TimeoutConfig: timeoutConfig,
ControllerName: DefaultControllerName,
ReportSaveDir: reportDir,
GatewayClassName: gcn,
scaledLabels: map[string]string{
BenchmarkTestScaledKey: "true",
},
KubeActions: KubeActions,
kubeClient: kubeClient,
RoundTripper: roundTripper,
}, nil
}

func (rts *ResilienceTestSuite) WithResCleanUp(ctx context.Context, t *testing.T, f func() (client.Object, error)) error {
res, err := f()
t.Cleanup(func() {
t.Logf("Start to cleanup resilsence test resources")
if deleteErr := rts.Client.Delete(ctx, res); deleteErr != nil {
}

t.Logf("Clean up complete!")
})
return err
}

func (rts *ResilienceTestSuite) Kube() *kubernetes.KubeActions {
return rts.KubeActions
}

func (rts *ResilienceTestSuite) Run(t *testing.T, tests []ResilienceTest) {
t.Logf("Running %d resilience tests", len(tests))
for _, test := range tests {
t.Logf("Running resilience test: %s", test.ShortName)
test.Test(t, rts)
}
}

func (rts *ResilienceTestSuite) RegisterCleanup(t *testing.T, ctx context.Context, object client.Object) {
t.Cleanup(func() {
t.Logf("Start to cleanup resilsence test resources")
if deleteErr := rts.Client.Delete(ctx, object); deleteErr != nil {
}

t.Logf("Clean up complete!")
})
}
110 changes: 110 additions & 0 deletions test/resilience/testdata/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
apiVersion: v1
kind: Namespace
metadata:
name: gateway-resilience
---
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
namespace: gateway-resilience
name: envoy-gateway
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: custom-proxy-config
namespace: gateway-resilience
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: all-namespaces
namespace: gateway-resilience
spec:
gatewayClassName: "{GATEWAY_CLASS_NAME}"
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes:
namespaces:
from: All
---
apiVersion: v1
kind: Service
metadata:
name: backend
namespace: gateway-resilience
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 8080
name: http11
targetPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
namespace: gateway-resilience
labels:
app: backend
spec:
replicas: 2
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
# From https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/echo-basic/echo-basic.go
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SERVICE_NAME
value: backend
resources:
requests:
cpu: 10m
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: backend
namespace: gateway-resilience
spec:
parentRefs:
- name: all-namespaces
rules:
- matches:
- path:
type: PathPrefix
value: /welcome
backendRefs:
- name: backend
port: 8080
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: custom-proxy-config
namespace: gateway-resilience
spec:
provider:
type: Kubernetes
kubernetes:

16 changes: 16 additions & 0 deletions test/resilience/testdata/route_changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: backend
namespace: gateway-resilience
spec:
parentRefs:
- name: all-namespaces
rules:
- matches:
- path:
type: PathPrefix
value: /route-change
backendRefs:
- name: backend
port: 8080
Loading
Loading