File tree Expand file tree Collapse file tree 7 files changed +151
-0
lines changed Expand file tree Collapse file tree 7 files changed +151
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Benchmark Client
2
+
3
+ This test client provides simulation of various workloads when communicating with the go-control-plane management server.
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "log"
5
+ "os"
6
+ "runtime"
7
+ "time"
8
+
9
+ "github.com/envoyproxy/go-control-plane/benchmarks/client/xds"
10
+ "github.com/urfave/cli/v2"
11
+ )
12
+
13
+ func main () {
14
+ // Statically set the max procs
15
+ runtime .GOMAXPROCS (runtime .NumCPU ())
16
+
17
+ app := & cli.App {
18
+ Name : "xds-benchmark" ,
19
+ Usage : "xds benchmarking tool that simulates client workload" ,
20
+ Commands : []* cli.Command {
21
+ {
22
+ Name : "run" ,
23
+ Aliases : []string {"r" },
24
+ Usage : "run the benchmark with the provided duration" ,
25
+ Action : func (c * cli.Context ) error {
26
+ arg := c .Args ().First ()
27
+ dur , err := time .ParseDuration (arg )
28
+ if err != nil {
29
+ return err
30
+ }
31
+
32
+ sess , err := xds .NewSession ("localhost:50000" )
33
+ if err != nil {
34
+ return err
35
+ }
36
+
37
+ return sess .Simulate (dur )
38
+ },
39
+ },
40
+ },
41
+ }
42
+
43
+ err := app .Run (os .Args )
44
+ if err != nil {
45
+ log .Fatal (err )
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ package xds
2
+
3
+ // Options are configuration settings for the discovery object
4
+ type Options struct {
5
+ NodeID string
6
+ Zone string
7
+ Cluster string
8
+ ResourceNames []string // List of Envoy resource names to subscribe to
9
+ ResourceType string // ex: type.googleapis.com/envoy.api.v2.ClusterLoadAssignment
10
+ }
11
+
12
+ // Option follows the functional opts pattern
13
+ type Option func (* Options )
14
+
15
+ // WithNode will inject the node id into the configuration object
16
+ func WithNode (id string ) Option {
17
+ return func (o * Options ) {
18
+ o .NodeID = id
19
+ }
20
+ }
21
+
22
+ // WithZone will specificy which zone to use in the xDS discovery request
23
+ func WithZone (zone string ) Option {
24
+ return func (o * Options ) {
25
+ o .Zone = zone
26
+ }
27
+ }
28
+
29
+ // WithCluster will specificy which cluster the request is announcing as
30
+ func WithCluster (cluster string ) Option {
31
+ return func (o * Options ) {
32
+ o .Cluster = cluster
33
+ }
34
+ }
35
+
36
+ // WithResourceNames will inject a list of resources the user wants to place watches on
37
+ func WithResourceNames (names []string ) Option {
38
+ return func (o * Options ) {
39
+ o .ResourceNames = names
40
+ }
41
+ }
42
+
43
+ // WithResourceType will inject the specific resource type that a user wants to stream
44
+ func WithResourceType (resource string ) Option {
45
+ return func (o * Options ) {
46
+ o .ResourceType = resource
47
+ }
48
+ }
Original file line number Diff line number Diff line change
1
+ package xds
2
+
3
+ import (
4
+ "time"
5
+
6
+ "google.golang.org/grpc"
7
+ )
8
+
9
+ // Sess holds a grpc connection as well as config options to use during the simulation
10
+ type Sess struct {
11
+ Session * grpc.ClientConn
12
+ Opts Options
13
+ }
14
+
15
+ // NewSession will dial a new benchmarking session with the configured options
16
+ func NewSession (url string , opts ... Option ) (* Sess , error ) {
17
+ var options Options
18
+ for _ , o := range opts {
19
+ o (& options )
20
+ }
21
+
22
+ conn , err := grpc .Dial (url , grpc .WithBlock (), grpc .WithInsecure ())
23
+ if err != nil {
24
+ return nil , err
25
+ }
26
+
27
+ return & Sess {
28
+ Session : conn ,
29
+ Opts : options ,
30
+ }, nil
31
+ }
32
+
33
+ // Simulate will start an xDS stream which provides simulatest clients communicating with an xDS server
34
+ func (s * Sess ) Simulate (target time.Duration ) error {
35
+ // Create a loop that will continually do work until the elapsed time as passed
36
+ for timeout := time .After (target ); ; {
37
+ select {
38
+ case <- timeout :
39
+ return nil
40
+ default :
41
+ // Do some work
42
+
43
+ }
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ package xds
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ require (
11
11
github.com/pkg/profile v1.6.0
12
12
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
13
13
github.com/stretchr/testify v1.7.0
14
+ github.com/urfave/cli/v2 v2.3.0
14
15
go.opentelemetry.io/proto/otlp v0.7.0
15
16
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
16
17
google.golang.org/grpc v1.36.0
Original file line number Diff line number Diff line change @@ -47,10 +47,16 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
47
47
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM =
48
48
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 /go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA =
49
49
github.com/rogpeppe/fastuuid v1.2.0 /go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ =
50
+ github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q =
51
+ github.com/russross/blackfriday/v2 v2.0.1 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
52
+ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo =
53
+ github.com/shurcooL/sanitized_anchor_name v1.0.0 /go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc =
50
54
github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
51
55
github.com/stretchr/testify v1.5.1 /go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA =
52
56
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY =
53
57
github.com/stretchr/testify v1.7.0 /go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg =
58
+ github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M =
59
+ github.com/urfave/cli/v2 v2.3.0 /go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI =
54
60
go.opentelemetry.io/proto/otlp v0.7.0 h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8 =
55
61
go.opentelemetry.io/proto/otlp v0.7.0 /go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI =
56
62
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
You can’t perform that action at this time.
0 commit comments