-
Notifications
You must be signed in to change notification settings - Fork 1.8k
internal/scorecard/alpha: add parallelism support #3434
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
entries: | ||
- description: > | ||
Changes the scorecard configuration format to include a new top-level | ||
`stages` field, which allows users to define stages of tests and to | ||
enable parallelism within each stage. | ||
|
||
kind: "change" | ||
|
||
# Is this a breaking change? | ||
breaking: true | ||
|
||
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS | ||
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST! | ||
# | ||
# The generator auto-detects the PR number from the commit | ||
# message in which this file was originally added. | ||
# | ||
# What is the pull request number (without the "#")? | ||
# pull_request_override: 0 | ||
|
||
|
||
# Migration can be defined to automatically add a section to | ||
# the migration guide. This is required for breaking changes. | ||
migration: | ||
header: Add stages to scorecard configuration file | ||
body: | | ||
Update your scorecard configuration file to contain a new top-level | ||
stages field, and move your test definitions under one or more stages. | ||
|
||
**Example** | ||
|
||
```yaml | ||
tests: | ||
- image: quay.io/operator-framework/scorecard-test:dev | ||
entrypoint: | ||
- scorecard-test | ||
- basic-check-spec | ||
labels: | ||
suite: basic | ||
test: basic-check-spec-test | ||
``` | ||
|
||
should be converted to | ||
|
||
```yaml | ||
stages: | ||
- tests: | ||
- image: quay.io/operator-framework/scorecard-test:dev | ||
entrypoint: | ||
- scorecard-test | ||
- basic-check-spec | ||
labels: | ||
suite: basic | ||
test: basic-check-spec-test | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
tests: | ||
- image: quay.io/username/custom-scorecard-tests:dev | ||
entrypoint: | ||
- custom-scorecard-tests | ||
- customtest1 | ||
labels: | ||
suite: custom | ||
test: customtest1 | ||
- image: quay.io/username/custom-scorecard-tests:dev | ||
entrypoint: | ||
- custom-scorecard-tests | ||
- customtest2 | ||
labels: | ||
suite: custom | ||
test: customtest2 | ||
stages: | ||
- tests: | ||
- image: quay.io/username/custom-scorecard-tests:dev | ||
entrypoint: | ||
- custom-scorecard-tests | ||
- customtest1 | ||
labels: | ||
suite: custom | ||
test: customtest1 | ||
- image: quay.io/username/custom-scorecard-tests:dev | ||
entrypoint: | ||
- custom-scorecard-tests | ||
- customtest2 | ||
labels: | ||
suite: custom | ||
test: customtest2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,17 +42,17 @@ func (r PodTestRunner) getTestStatus(ctx context.Context, p *v1.Pod) (output *v1 | |
// run based on user selection | ||
func (o Scorecard) List() v1alpha3.TestList { | ||
output := v1alpha3.NewTestList() | ||
tests := o.selectTests() | ||
|
||
for _, test := range tests { | ||
item := v1alpha3.NewTest() | ||
item.Spec = v1alpha3.TestSpec{ | ||
Image: test.Image, | ||
Entrypoint: test.Entrypoint, | ||
Labels: test.Labels, | ||
for _, stage := range o.Config.Stages { | ||
tests := o.selectTests(stage) | ||
for _, test := range tests { | ||
item := v1alpha3.NewTest() | ||
item.Spec = v1alpha3.TestSpec{ | ||
Image: test.Image, | ||
Entrypoint: test.Entrypoint, | ||
Labels: test.Labels, | ||
} | ||
output.Items = append(output.Items, item) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usually nor happy with for inside to another for, however, I think it will not have too many items so 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the only way this works 😄 This isn't an O(n^2) problem like it seems like you're referring to. Stages are just groups of tests. This function is (generally) O(number of tests) regardless of whether stages are introduced or not. |
||
} | ||
output.Items = append(output.Items, item) | ||
} | ||
|
||
return output | ||
} |
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.
Is it possible to have duplicate tests across stages? I suspect this wouldn't be common if so.
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.
As far as I know, there is nothing that would prevent it. Scorecard would happily run it twice and report the results twice. It would probably also handle duplicate tests in a single stage the same way.
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.
Running duplicates is obviously fine. Test names listed may be duplicates though, which looks a little weird.