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

✨ add benchmark test for scans #1067

Merged
merged 5 commits into from
Jan 28, 2024
Merged

✨ add benchmark test for scans #1067

merged 5 commits into from
Jan 28, 2024

Conversation

imilchev
Copy link
Member

@imilchev imilchev commented Jan 24, 2024

add benchmark testing that compares every commit in a PR with latest main. If the diff is above 150%, it errors out and it comments on the violating commit. Looks like this 6e83272#comments

we also get a job summary like this https://github.com/mondoohq/cnspec/actions/runs/7643019168#summary-20824279571

Copy link
Contributor

github-actions bot commented Jan 24, 2024

Test Results

290 tests  ±0   289 ✅ ±0   18s ⏱️ -1s
 23 suites +1     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 32333c8. ± Comparison against base commit b4f5c3f.

♻️ This comment has been updated with latest results.

@imilchev imilchev force-pushed the ivan/benchmarks branch 16 times, most recently from be5441a to 81a36fd Compare January 24, 2024 16:12
@imilchev imilchev marked this pull request as ready for review January 24, 2024 16:19
Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

This is great to see the benchmark tests coming to cnspec.

@@ -0,0 +1,63 @@
name: Benchmark main
Copy link
Member

Choose a reason for hiding this comment

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

Can we simply call this benchmark>

Copy link
Member Author

Choose a reason for hiding this comment

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

this one runs only on the main branch, that's why I called it Benchmark main

@@ -84,6 +84,49 @@ jobs:
name: Event File
path: ${{ github.event_path }}

go-bench:
Copy link
Member

Choose a reason for hiding this comment

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

Why do we implement this twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

in this file we run the benchmark for a PR. It compares the results with the results of the latest commit on main. The implementation for the main branch is different because it runs the benchmark and then uploads the benchmark results in the cache, such that PRs start comparing results with that commit.

It's a slightly different flow but I couldn't combine the 2 into a single job

{
Connections: []*inventory.Config{
{
Type: "k8s",
Copy link
Member

Choose a reason for hiding this comment

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

Normally we do not have any provider installed by default. Do we not need to ensure the k8s provider is installed. If so we also would need to clean this up afterwards to not mess with other tests.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this will fail after we merged #1060

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it will fail. When we run a scan, the required provider is auto-installed if it's not present. That should be fine. Since the goal of this benchmark is not to test provider installation or uninstall, I don't think it's necessary to cleanup providers. Here we only care about the CPU and memory usage during a scan

Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Great work @imilchev Would love to see this for cnquery as well.

@chris-rock chris-rock merged commit 1d98fa1 into main Jan 28, 2024
12 checks passed
@chris-rock chris-rock deleted the ivan/benchmarks branch January 28, 2024 13:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants