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

Xray performance test #330

Merged
merged 19 commits into from
Oct 6, 2023
Merged

Xray performance test #330

merged 19 commits into from
Oct 6, 2023

Conversation

okankoAMZ
Copy link
Contributor

@okankoAMZ okankoAMZ commented Aug 14, 2023

Description of the issue

We were missing an automated performance gathering for CloudWatchAgent's new feature, traces.

Description of changes

This PR is adding a performance test for xray traces by adding a mock http server to minimize wasted cloud resources. This is added to the already built in performance test, and does no require any user input. The test will create a mock server automatically and run trace generation on it.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Ran Performance Test and checked on Dynamo
https://github.com/aws/private-amazon-cloudwatch-agent-staging/actions/runs/6223948452/job/17362419385

@okankoAMZ okankoAMZ added the github_actions Pull requests that update GitHub Actions code label Aug 14, 2023
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch 18 times, most recently from 4770cee to a38cbff Compare August 16, 2023 19:00
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch 3 times, most recently from 24f8e38 to 6491d06 Compare September 6, 2023 14:37
generator/test_case_generator.go Show resolved Hide resolved
generator/test_case_generator.go Outdated Show resolved Hide resolved
@@ -0,0 +1,3 @@
# Mocked Servers

The servers themselves are very basic. They listen for a message and tend to set a flag to success upon receiving it. Typically, they are set up with two servers: one to mock the backend and one to report on the status of that mock (if endpoint is called, how many times, etc.). There's a built-in 15ms of latency between each message that's received. The status reporter will always be on port 8080 and support the `:8080/` (returns "healthcheck") and the `:8080/check-data` (returns "success" if mock has received messages) endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - I don't think that this documentation is worded in a way that helps people understand how it's used. I think a more procedural guide on running the mocked tests, or a step-by-step guide on what happens would illustrate it better. Avoid words like "typically".

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. There's room for improvement with the README.

mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Show resolved Hide resolved
mockserver/main.go Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch from c70faa8 to de1f4ab Compare September 18, 2023 14:52
util/common/traces.go Outdated Show resolved Hide resolved
validator/validators/basic/basic_validator.go Outdated Show resolved Hide resolved
util/common/traces.go Show resolved Hide resolved
test/xray/generator.go Outdated Show resolved Hide resolved
terraform/performance/main.tf Outdated Show resolved Hide resolved
terraform/performance/main.tf Outdated Show resolved Hide resolved

# Metric that the test needs to validate
metric_namespace: "CloudWatchAgentPerformance"
metric_validation:
Copy link
Contributor

Choose a reason for hiding this comment

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

So are we just validating that the metrics exist?

},
"insecure": true,
"metrics": {
"namespace": "CloudWatchAgentPerformance",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be in a different namespace since the metrics are specific to this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't for the other performance tests but I can change it

atomic.AddUint32(&ts.transactions, 1)

// Built-in latency
fmt.Printf("\033[31m Time: %d | data Received \033[0m \n", time.Now().Unix())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Mixture of fmt and log.

if t > 0 {
message = SuccessMessage
}
fmt.Printf("\033[31m Time: %d | checkData msg: %s | %d\033[0m \n", time.Now().Unix(), message, t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log necessary?

@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch 3 times, most recently from 2c4c8c1 to 7f07122 Compare October 3, 2023 18:58
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
@@ -109,6 +109,13 @@ resource "null_resource" "validator_linux" {
}
provisioner "remote-exec" {
inline = [
#mock server dependencies getting transfered.
"git clone --branch ${var.github_test_repo_branch} ${var.github_test_repo}",
"cd amazon-cloudwatch-agent-test && git checkout xray-performance-test", #@TODO remove before PR merge
Copy link
Contributor

Choose a reason for hiding this comment

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

is this TODO relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! i am waiting for the PR to be ready before I remove it so I can test the code before the merge

Copy link
Contributor

Choose a reason for hiding this comment

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

This should use the github_test_repo_branch var. You can specify it in your test workflow.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be cognizant about the file structure we are introducing. Does this need to be util/common/traces/common/common? What is the reason we are moving the file to begin with? Maybe a broader question, if it's supposed to be "common", why is it under /traces?

Copy link
Contributor

Choose a reason for hiding this comment

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

Still would like an answer for this

util/common/traces/generate.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
@@ -109,6 +109,13 @@ resource "null_resource" "validator_linux" {
}
provisioner "remote-exec" {
inline = [
#mock server dependencies getting transfered.
"git clone --branch ${var.github_test_repo_branch} ${var.github_test_repo}",
"cd amazon-cloudwatch-agent-test && git checkout xray-performance-test", #@TODO remove before PR merge
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use the github_test_repo_branch var. You can specify it in your test workflow.

util/common/traces/generate.go Outdated Show resolved Hide resolved
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch 2 times, most recently from 96ade68 to 9b05e93 Compare October 5, 2023 16:49
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch from 9b05e93 to 3651eea Compare October 5, 2023 16:51
mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Still would like an answer for this

util/common/traces/common/common.go Outdated Show resolved Hide resolved
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch 3 times, most recently from 8f0f12a to a6ea8bc Compare October 5, 2023 20:50
SaxyPandaBear
SaxyPandaBear previously approved these changes Oct 5, 2023
util/common/traces/base/base.go Show resolved Hide resolved
jefchien
jefchien previously approved these changes Oct 5, 2023
Copy link
Contributor

@jefchien jefchien left a comment

Choose a reason for hiding this comment

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

Some suggestions, but nothing blocking.

mockserver/README Outdated Show resolved Hide resolved
@@ -0,0 +1,3 @@
# Mocked Servers

The servers themselves are very basic. They listen for a message and tend to set a flag to success upon receiving it. Typically, they are set up with two servers: one to mock the backend and one to report on the status of that mock (if endpoint is called, how many times, etc.). There's a built-in 15ms of latency between each message that's received. The status reporter will always be on port 8080 and support the `:8080/` (returns "healthcheck") and the `:8080/check-data` (returns "success" if mock has received messages) endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. There's room for improvement with the README.

}

type TransactionPayload struct {
TransactionsPerMinute float64 `json:"GetNumberOfTransactionsPerMinute"`
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Try to keep the tag name and variable name the same.

mockserver/main.go Outdated Show resolved Hide resolved
mockserver/main.go Outdated Show resolved Hide resolved
}

// Starts an HTTP server that receives request from validator only to verify the data ingestion
func StartHttpServer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used elsewhere? Why isn't this just main?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not opposed to having the start function separate from main. It's redundant here, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using that for testing. I also like having a separate "main" function and have the argument flags in the func main instead.

validator/models/validation_config.go Outdated Show resolved Hide resolved
@okankoAMZ okankoAMZ dismissed stale reviews from jefchien and SaxyPandaBear via 8a81870 October 6, 2023 19:28
@okankoAMZ okankoAMZ force-pushed the xray-performance-test branch from a6ea8bc to 8a81870 Compare October 6, 2023 19:28

The verifier component can be accessed via a listener on port 8080. It provides information about the transactions, including:

- **Transactions per Minute:** You can obtain the transactions per minute by making a request to `/tpm`.
Copy link
Contributor

Choose a reason for hiding this comment

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

super mild nitpick, it would be nice to have an example cURL request, like

curl localhost:8080/tpm

# the output is [ something]

This is really trivial, imo, but something that is really helpful to document.

@okankoAMZ okankoAMZ merged commit 7c94832 into aws:main Oct 6, 2023
2 checks passed
@okankoAMZ okankoAMZ deleted the xray-performance-test branch October 6, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants