-
Notifications
You must be signed in to change notification settings - Fork 7
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
Update Integration Tests #34
Conversation
working-directory: ./k6/graphql-api | ||
run: | | ||
bundle | ||
bundle exec puma -t 0:1 -p 9291 & | ||
./boot-servers.sh & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use boot-servers.sh
to clean this up and to make local testing simpler.
k6/boot-servers.sh
Outdated
HIVE_ENABLED=$hive_enabled \ | ||
PORT=$port \ | ||
LOG_LEVEL=$LOG_LEVEL \ | ||
bundle exec puma -C puma.rb | log_with_prefix "$prefix" & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start a puma server using puma.rb
as the config. See notes below about how this is different from before.
workers 2 | ||
threads 2, 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this was booted with one worker and one thread. Two workers and two threads lets us run with little more throughput. We are not load testing puma, here. So we may as well boot up a few workers.
vus: 5, | ||
iterations: 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dialling down the number of VUs (virtual users) so that we don't slam Puma with throughput. But amping up the iterations so we get better data on p95 response times.
k6/integration-test.js
Outdated
"http_req_duration{hive:enabled}": ["p(95)<15"], | ||
"http_req_duration{hive:disabled}": ["p(95)<15"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail if either of these has a p95 > 15 ms.
check(count, { | ||
"usage-api starts with 0 operations": (count) => count === 0, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New setup
with a check to make sure we reset the usage api counter before testing.
check(res, { | ||
"response body is GraphQL": (res) => res.body.includes("data"), | ||
}); | ||
check(res, { | ||
"response body is not a GraphQL error": (res) => | ||
!res.body.includes("errors"), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two new checks to ensure we get good data back.
k6/integration-test.js
Outdated
check(count, { | ||
"usage-api received 1000 operations": (count) => count === REQUEST_COUNT, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New check to ensure usage API received 1000 operations.
bdfc9c6
to
6893d38
Compare
e986dd1
to
22cfcf5
Compare
@@ -33,7 +33,8 @@ class Schema < GraphQL::Schema | |||
GraphQL::Hive, | |||
enabled: ENV["HIVE_ENABLED"] === "true", | |||
endpoint: "localhost", | |||
debug: true, | |||
debug: false, | |||
buffer_size: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a buffer_size of 1 because we have two puma processes running and we want every operation to get sent for the integration test.
k6/integration-test.js
Outdated
thresholds: { | ||
"http_req_duration{hive:enabled}": [ | ||
{ | ||
threshold: "p(95)<25", | ||
abortOnFail: true, | ||
}, | ||
], | ||
"http_req_duration{hive:disabled}": [ | ||
{ | ||
threshold: "p(95)<25", | ||
abortOnFail: true, | ||
}, | ||
], | ||
checks: [ | ||
{ | ||
threshold: "rate===1", | ||
abortOnFail: true, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do a non-zero exit code if any of these fail.
if ( | ||
data.metrics["http_req_duration{hive:enabled}"] && | ||
data.metrics["http_req_duration{hive:disabled}"] | ||
) { | ||
const withHive = | ||
data.metrics["http_req_duration{hive:enabled}"].values["avg"]; | ||
const withoutHive = | ||
data.metrics["http_req_duration{hive:disabled}"].values["avg"]; | ||
overheadPercentage = 100 - (withHive * 100.0) / withoutHive; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not accurate. On repeated tests I saw hive:enabled
1-15% faster than hive:disabled
. Instead of this check, I added a p95 threshold for both tests of 25ms, which seems to work well on github actions runners.
k6/integration-test.js
Outdated
"http_req_duration{hive:enabled}": [ | ||
{ | ||
threshold: "p(95)<25", | ||
abortOnFail: true, | ||
}, | ||
], | ||
"http_req_duration{hive:disabled}": [ | ||
{ | ||
threshold: "p(95)<25", | ||
abortOnFail: true, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are in lieu of the performance regression check that compared avg response time. 25 ms is set based on a few github actions runs to be sure these thresholds work on the runners provided.
let count = 0; | ||
for (let i = 0; i < 10; i++) { | ||
const res = http.get("http://localhost:8888/count"); | ||
count = JSON.parse(res.body).count; | ||
console.log(`📊 Total operations: ${count}`); | ||
if (count === REQUEST_COUNT) { | ||
break; | ||
} | ||
await sleep(1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps overkill, but this is incase one of the threads hasn't finished reporting by the time teardown
is run.
4a4e3f0
to
2faa8de
Compare
e837e3d
to
4bc9d6b
Compare
4bc9d6b
to
17944a5
Compare
3c67f2f
to
c6fe94d
Compare
"http_req_duration{hive:enabled}": [ | ||
{ | ||
// Set a threshold that works consistently on GitHub Actions runners | ||
threshold: "p(95)<50", | ||
abortOnFail: true, | ||
}, | ||
], | ||
"http_req_duration{hive:disabled}": [ | ||
{ | ||
threshold: "p(95)<50", | ||
abortOnFail: false, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a few tests I found that a P95 of 50 ms reliably passed on GitHub actions. The test will fail if hive:enabled crosses the threshold.
.github/workflows/integration.yml
Outdated
uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f | ||
with: | ||
working-directory: ./k6/graphql-api | ||
ruby-version: "3.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind adding a .ruby-version
file instead? so that all our CI / localdev tools willl just rely on a single source of truth for this?
It looks like setting working-directory
will dictate where setup-ruby
checks for the .ruby-version
file, but I believe we should be able to just add a symlink at ./k6/graphql-api/.ruby-version
to point to the root .ruby-version
file
.github/workflows/integration.yml
Outdated
- name: Use Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe same here? just with node-version-file
instead?
| reporting.author | Author of the latest change | Author of the latest change | | | ||
| reporting.commit | Git SHA or any identifier | git sha or any identifier | | | ||
| reporting.service_name | (Optional) Name of the service | | | | ||
| reporting.service_url | (Optional) URL of the service | | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using something to generate this table? seems like it would be a bit of a chore to update in the future but nbd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted the former Ruby Hash to this table manually. I thought this was easier to read in the rendered markdown. I can revert this, though, if you prefer the Ruby Hash version.
README.md
Outdated
```sh | ||
git clone https://github.com/your-username/your-repo-name.git | ||
cd your-repo-name | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just link to the official GitHub docs for forking instructions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.
lib/graphql-hive/version.rb
Outdated
@@ -2,6 +2,6 @@ | |||
|
|||
module Graphql | |||
module Hive | |||
VERSION = "0.4.3" | |||
VERSION = "0.4.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mentioned we didn't want to create a new release for this, so should we maintain the current version number?
Co-authored-by: Ryan Perry-Nguyen <[email protected]>
Co-authored-by: Ryan Perry-Nguyen <[email protected]>
This reverts commit cb40842.
d62b72a
to
8b79edb
Compare
8b79edb
to
4273f44
Compare
Closing this PR as the k6 tests tend to be flaky and aren't the best way of testing either benchmarks in CI or integration. |
The integration tests were returning false positives when running locally. This PR updates the integration tests to fail when thresholds are breached. Please see my self-review for an explanation.