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

Specify additional specific load generator options in mesheryctl perf #8148

Merged
merged 26 commits into from
Aug 2, 2023

Conversation

abdullah1308
Copy link
Contributor

@abdullah1308 abdullah1308 commented Jul 12, 2023

Notes for Reviewers

This PR fixes #8047

Signed commits

  • Yes, I signed my commits.

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@github-actions
Copy link

github-actions bot commented Jul 12, 2023

@abdullah1308 abdullah1308 changed the title Specify additional specific load generator options in mesheryctl perf [WIP] Specify additional specific load generator options in mesheryctl perf Jul 12, 2023
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308 abdullah1308 changed the title [WIP] Specify additional specific load generator options in mesheryctl perf Specify additional specific load generator options in mesheryctl perf Jul 13, 2023
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Copy link
Contributor

@MUzairS15 MUzairS15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also provide a sample config? More better a recording which showcases additional options being used.

performanceProfileData, err := provider.GetPerformanceProfile(req, profileID)
if err != nil {
h.log.Error(err)
http.Error(w, ErrLoadCertificate(err).Error(), http.StatusInternalServerError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return correct error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdullah1308 does this make sense?

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

@leecalcote @MUzairS15 resolved suggestions

@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Patch coverage: 4.51% and project coverage change: -0.01% ⚠️

Comparison is base (8fab97c) 5.22% compared to head (e343ced) 5.21%.
Report is 43 commits behind head on master.

❗ Current head e343ced differs from pull request most recent head c0b2ce9. Consider uploading reports for the commit c0b2ce9 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #8148      +/-   ##
=========================================
- Coverage    5.22%   5.21%   -0.01%     
=========================================
  Files         124     124              
  Lines       17522   17628     +106     
=========================================
+ Hits          915     919       +4     
- Misses      16435   16537     +102     
  Partials      172     172              
Flag Coverage Δ
e2etests ?
gointegrationtests 5.21% <4.51%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
mesheryctl/internal/cli/root/perf/profile.go 1.96% <0.00%> (-0.11%) ⬇️
server/handlers/error.go 0.00% <0.00%> (ø)
server/handlers/load_test_handler.go 0.00% <0.00%> (ø)
server/helpers/load_test_interface.go 0.00% <0.00%> (ø)
mesheryctl/internal/cli/root/perf/apply.go 4.19% <8.33%> (+0.54%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@suhail34 suhail34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MUzairS15
Copy link
Contributor

MUzairS15 commented Jul 18, 2023

@abdullah1308 A working demo will be helpful via mesheryctl indicating additional falgs were used.

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@alphaX86
Copy link
Member

@abdullah1308 run go run doc.go within mesheryctl folder and push changes here for docs page preview.

P.S: I know I didn't include the CI run for that but I disabled that to avoid several pushes by l5io bot

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

@abdullah1308 run go run doc.go within mesheryctl folder and push changes here for docs page preview.

P.S: I know I didn't include the CI run for that but I disabled that to avoid several pushes by l5io bot

@alphaX86 unable to run it now :/
I do have the file ../../docs/pages/reference/mesheryctl/mesheryctl-app-import.md locally though.

abrafi@AbMacAir mesheryctl % go run doc/doc.go
Scanning available commands...
Generating markdown docs...
20:06:54 open ../../docs/pages/reference/mesheryctl/mesheryctl-app-import.md: no such file or directory
exit status 1

@gyohuangxin
Copy link
Member

Related to #8203 which @luigidematteis is working on.

mesheryctl perf apply meshery-profile --url "https://google.com" --useCert

// Execute a Performance test creating a new performance profile and pass certificate to be used
mesheryctl perf apply meshery-profile-new --url "https://google.com" --certPath path/to/cert.pem --useCert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the one flag --certPath is enough, what is the purpose of --useCert?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gyohuangxin Currently the API supports running a test with/without the certificate contained in a performance profile. --useCert is a boolean flag to toggle this behaviour.

--certPath is used to add a certificate to a new profile being created. A certificate can be added to a test profile only while creating it. Currently server-side there isn't a way to include a certificate for a single run.

I was initially considering having only one flag that does both of the above behaviours. But the CLI library doesn't permit a flag to have both a boolean behaviour and an argument behaviour. Hence I've broken it down into 2 flags.

Hence

mesheryctl perf apply meshery-profile-new --url "https://google.com" --certPath path/to/cert.pem --useCert

causes a new profile to be created with the specified certificate and --useCert causes the certificate to be used when the test is run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood about adding "--useCert" to allow the user to choose whether to use a certificate in the performance profile. But can we replace it with "--disableCert" and set its default value to false? Because I think it may be confusing that I need to add --useCert when I have --certPath set. If we use --disableCert, we don't need to explicitly add another flag and keep the command concise, like

mesheryctl perf apply meshery-profile-new --url "https://google.com" --certPath path/to/cert.pem 

If someone doesn't want to use the certificates in a proformance profile, then he can use --disableCert

mesheryctl perf apply meshery-profile --url "https://google.com" --disableCert

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gyohuangxin I like the idea having certificates being used by default. I'll change the flag to --disableCert.

@leecalcote
Copy link
Member

a couple of merge conflicts popped up.

@vishalvivekm
Copy link
Member

@abdullah1308 Let's discuss this on Meshery Dev call. Please add this as an agenda item in the meeting minutes if you would. :)

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

abdullah1308 commented Jul 19, 2023

@MUzairS15

Command Run (Fortio)

mesheryctl perf apply meshery-profile-new --url "https://google.com" --load-generator fortio --options '{"MethodOverride": "POST"}'

Debug Log

DEBU[0060] options string: {"MethodOverride": "POST"} 

DEBU[0060] Fortio config: fhttp.HTTPRunnerOptions{RunnerOptions:periodic.RunnerOptions{RunType:"", Runners:[]periodic.Runnable(nil), QPS:-1, Duration:30000000000, NumThreads:1, Percentiles:[]float64{50, 75, 90, 99, 99.9}, Resolution:0.001, Out:(*os.File)(0x14000134008), Labels:"danbnldw -_- https://google.com", Stop:(*periodic.Aborter)(nil), Exactly:0, Jitter:false, Uniform:false, RunID:0, Offset:0, AccessLogger:periodic.AccessLogger(nil), NoCatchUp:false, ID:"", genTime:(*time.Time)(nil)}, HTTPOptions:fhttp.HTTPOptions{TLSOptions:fhttp.TLSOptions{Insecure:false, MTLS:false, CACert:"", Cert:"", Key:"", UnixDomainSocket:""}, URL:"https://google.com", NumConnections:0, Compression:false, DisableFastClient:true, HTTP10:false, H2:false, DisableKeepAlive:false, AllowHalfClose:false, FollowRedirects:true, initDone:false, https:false, Resolve:"", extraHeaders:http.Header(nil), hostOverride:"", HTTPReqTimeOut:3000000000, UserCredentials:"", ContentType:"", Payload:[]uint8(nil), MethodOverride:"", LogErrors:false, ID:0, UniqueID:0, SequentialWarmup:false, ConnReuseRange:[2]int{0, 0}, NoResolveEachConn:false, Offset:0, Resolution:0, ClientTrace:(fhttp.CreateClientTrace)(nil), Transport:(fhttp.CreateTransport)(nil), PayloadReader:io.Reader(nil), DataWriter:io.Writer(nil)}, Profiler:"", AllowInitialErrors:true, AbortOn:0}

DEBU[0060] Fortio config with options: fhttp.HTTPRunnerOptions{RunnerOptions:periodic.RunnerOptions{RunType:"", Runners:[]periodic.Runnable(nil), QPS:-1, Duration:30000000000, NumThreads:1, Percentiles:[]float64{50, 75, 90, 99, 99.9}, Resolution:0.001, Out:(*os.File)(0x14000134008), Labels:"danbnldw -_- https://google.com", Stop:(*periodic.Aborter)(nil), Exactly:0, Jitter:false, Uniform:false, RunID:0, Offset:0, AccessLogger:periodic.AccessLogger(nil), NoCatchUp:false, ID:"", genTime:(*time.Time)(nil)}, HTTPOptions:fhttp.HTTPOptions{TLSOptions:fhttp.TLSOptions{Insecure:false, MTLS:false, CACert:"", Cert:"", Key:"", UnixDomainSocket:""}, URL:"https://google.com", NumConnections:0, Compression:false, DisableFastClient:true, HTTP10:false, H2:false, DisableKeepAlive:false, AllowHalfClose:false, FollowRedirects:true, initDone:false, https:false, Resolve:"", extraHeaders:http.Header(nil), hostOverride:"", HTTPReqTimeOut:3000000000, UserCredentials:"", ContentType:"", Payload:[]uint8(nil), MethodOverride:"POST", LogErrors:false, ID:0, UniqueID:0, SequentialWarmup:false, ConnReuseRange:[2]int{0, 0}, NoResolveEachConn:false, Offset:0, Resolution:0, ClientTrace:(fhttp.CreateClientTrace)(nil), Transport:(fhttp.CreateTransport)(nil), PayloadReader:io.Reader(nil), DataWriter:io.Writer(nil)}, Profiler:"", AllowInitialErrors:true, AbortOn:0}

Command Run (Wrk2)

mesheryctl perf apply meshery-profile-test-3 --url "https://google.com" --load-generator wrk2 --options '{"DurationInSeconds": 15, "Thread": 3}'

Debug Log

DEBU[0272] options string: {"DurationInSeconds": 15, "Thread": 3}

DEBU[0272] GoWrk2 config: &api.GoWRK2Config{Thread:1, DurationInSeconds:30, RQPS:-1, URL:"https://google.com", Labels:"ofutebdj -_- https://google.com", Percentiles:[]float64{50, 75, 90, 99, 99.99, 99.999}, Args:[]string(nil)} 

DEBU[0272] GoWrk2 config with options: &api.GoWRK2Config{Thread:3, DurationInSeconds:15, RQPS:-1, URL:"https://google.com", Labels:"ofutebdj -_- https://google.com", Percentiles:[]float64{50, 75, 90, 99, 99.99, 99.999}, Args:[]string(nil)}

Unable to demo example for nighthawk as I'm on MacOS.

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

abdullah1308 commented Jul 19, 2023

Latest help docs

abrafi@AbMacAir mesheryctl % ./mesheryctl perf apply -h
Run Performance test using existing profiles or using flags

Usage:
  mesheryctl perf apply <profile-name> [flags]

Examples:

// Execute a Performance test with the specified performance profile
mesheryctl perf apply meshery-profile [flags]

// Execute a Performance test with creating a new performance profile
mesheryctl perf apply meshery-profile-new --url "https://google.com"

// Execute a Performance test creating a new performance profile and pass certificate to be used 
mesheryctl perf apply meshery-profile-new --url "https://google.com" --cert-path path/to/cert.pem

// Execute a performance profile without using the certificate present in the profile
mesheryctl perf apply meshery-profile --url "https://google.com" --disable-cert

// Run Performance test using SMP compatible test configuration
// If the profile already exists, the test will be run overriding the values with the ones provided in the configuration file
mesheryctl perf apply meshery-profile -f path/to/perf-config.yaml

// Run performance test using SMP compatible test configuration and override values with flags
mesheryctl perf apply meshery-profile -f path/to/perf-config.yaml [flags]

// Choice of load generator - fortio, wrk2 or nighthawk (default: fortio)
mesheryctl perf apply meshery-profile --load-generator wrk2

// Execute a Performance test with specified queries per second
mesheryctl perf apply meshery-profile --url https://192.168.1.15/productpage --qps 30

// Execute a Performance test with specified service mesh
mesheryctl perf apply meshery-profile --url https://192.168.1.15/productpage --mesh istio

// Execute a Performance test creating a new performance profile and pass options to the load generator used
// If any options are already present in the profile or passed through flags, the --options flag will take precedence over the profile and flag options 
// Options for nighthawk - https://github.com/layer5io/getnighthawk/blob/v1.0.5/pkg/proto/options.pb.go#L882-L1018
// Options for fortio - https://github.com/fortio/fortio/blob/v1.57.0/fhttp/httprunner.go#L77-L84
// Options for wrk2 - https://github.com/layer5io/gowrk2/blob/v0.6.1/api/gowrk2.go#L47-L53
mesheryctl perf apply meshery-profile-new --url "https://google.com" --options [filepath|json-string]
mesheryctl perf apply meshery-profile-new --url "https://google.com" --options path/to/options.json
mesheryctl perf apply meshery-profile-new --url "https://google.com" --load-generator nighthawk --options '{"requestsPerSecond": 10, "maxPendingRequests": 5}'
mesheryctl perf apply meshery-profile-new --url "https://google.com" --load-generator fortio --options '{"MethodOverride": "POST"}'
mesheryctl perf apply meshery-profile-new --url "https://google.com" --load-generator wrk2 --options '{"DurationInSeconds": 15, "Thread": 3}'


Flags:
  -b, --body string                  (optional) Load test body. Can be a filepath/string
      --cert-path string             (optional) Path to the certificate to be used for the load test
      --concurrent-requests string   (optional) Number of Parallel Requests
      --disable-cert                 (optional) Do not use certificate present in the profile
      --duration string              (optional) Length of test (e.g. 10s, 5m, 2h). For more, see https://golang.org/pkg/time/#ParseDuration
  -f, --file string                  (optional) File containing SMP-compatible test configuration. For more, see https://github.com/layer5io/service-mesh-performance-specification
  -h, --help                         help for apply
      --load-generator string        (optional) Load-Generator to be used (fortio/wrk2/nighthawk)
      --mesh string                  (optional) Name of the Service Mesh
      --name string                  (optional) Name of the Test
      --options string               (optional) Additional options to be passed to the load generator. Can be a json string or a filepath containing json
      --qps string                   (optional) Queries per second
      --url string                   (optional) Endpoint URL to test (required with --profile)

Global Flags:
      --config string          path to config file (default "/Users/abrafi/.meshery/config.yaml")
  -o, --output-format string   (optional) format to display in [json|yaml]
  -t, --token string           (required) Path to meshery auth config
  -v, --verbose                verbose output
  -y, --yes                    (optional) assume yes for user interactive prompts.

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@leecalcote
Copy link
Member

I wonder if we might toss the set of available load generator-specific flags into https://docs.meshery.io/tasks/performance-management

@abdullah1308
Copy link
Contributor Author

❗ nighthawk doesn't work

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

abdullah1308 commented Jul 23, 2023

Nighthawk works ✅
Dependant PR - layer5io/getnighthawk#321
A new getnighthawk release is required, following which the getnighthawk version needs to be updated in Meshery.

Copy link
Member

@gyohuangxin gyohuangxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@gyohuangxin
Copy link
Member

Ready to be merged?

@MUzairS15
Copy link
Contributor

@abdullah1308 What’s holding this?

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308
Copy link
Contributor Author

@MUzairS15 @gyohuangxin This PR should be ready for merge.

Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
Signed-off-by: abdullah1308 <abdullahrafi.1308@gmail.com>
@abdullah1308 abdullah1308 merged commit 1c3277b into meshery:master Aug 2, 2023
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mesheryctl] Perf: Flag to specify any additional specific load generator options
8 participants