Skip to content

commands/.../scorecard: modularize tests and implement weights #994

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

Merged
merged 28 commits into from
Mar 6, 2019

Conversation

AlexNPavel
Copy link
Contributor

Description of the change: This PR defines new structs for: the variables that scorecard tests need access to, scores, tests, and test suites. It defines each test and test suite using these new structs and now weights the tests based on how important they should be in the final score. It also splits checkSpecAndStat (as that was acutally 2 separate tests plus a readiness checker) and moves the readiness checking functionality into its own function.

Motivation for the change: Closes #960

@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 24, 2019
retryInterval int
}

type Score struct {
Copy link
Member

Choose a reason for hiding this comment

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

Godoc

@AlexNPavel AlexNPavel force-pushed the modularize-scorecard branch from 3f2bb45 to c786e4f Compare January 25, 2019 20:09
@AlexNPavel AlexNPavel force-pushed the modularize-scorecard branch from 7e3ea09 to 2af721a Compare January 31, 2019 22:40
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 6, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 6, 2019
@AlexNPavel AlexNPavel force-pushed the modularize-scorecard branch from a26f1e1 to 33984a8 Compare February 7, 2019 00:31
@AlexNPavel
Copy link
Contributor Author

This PR has been refactored with the new design suggestions

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

Overall looks great, but I'd like to see unification of return types and method receivers as per my comment.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2019
@hasbro17
Copy link
Contributor

hasbro17 commented Mar 4, 2019

Overall SGTM. Just some nits and perhaps we can add more godocs for all the new structs in test_definitions.go.

@AlexNPavel AlexNPavel closed this Mar 4, 2019
@AlexNPavel AlexNPavel reopened this Mar 4, 2019
@AlexNPavel
Copy link
Contributor Author

Whoops, hit the wrong button

@AlexNPavel
Copy link
Contributor Author

/cc @shawn-hurley @joelanford

Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

LGTM after nit

@hasbro17
Copy link
Contributor

hasbro17 commented Mar 4, 2019

Unrelated to the scope of this PR but just wanted to make a note on SpecDescriptorsTest and StatusDescriptorsTest that we could address later on:
Not all spec and status fields need to have a spec and status descriptor.
It's only recommended to have descriptors for spec and status fields that are useful to show on the console.
See the descriptors section in https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#owned-crds

So it's likely that no CSVs will ever fully pass those tests. Perhaps we should make note of that in the Suggestions for these tests to not force users to assign descriptors to all fields.
@estroz Might be related to #1162 Have to take a look at that but I'm not sure if we generate descriptors for all spec and status fields.

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

LGTM

I did notice that we're using global variables in a few places (e.g. deploymentName, proxyPodGlobal), and I'm wondering if it's possible to eliminate more of them. I don't think that's necessary in this PR, but something to think about for a future PR.

}
if err != nil && err != wait.ErrWaitTimeout {
return err
// checkSpec checks that the spec block exists
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this godoc is correct.

func checkStatusUpdate(runtimeClient client.Client, obj *unstructured.Unstructured) error {
test := scorecardTest{testType: basicOperator, name: "Operator actions are reflected in status", maximumPoints: 1}
err := runtimeClient.Get(context.TODO(), types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, obj)
// checkStatus checks that the status block exists
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this godoc is correct

}
}

type WritingIntoCRsHasEffectTest struct {
Copy link
Member

Choose a reason for hiding this comment

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

Godoc for these types please

Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

LGTM except for godocs and potential layout changes

BasicTestConfig
}

func NewWritingIntoCRsHasEffectTest(conf BasicTestConfig) *WritingIntoCRsHasEffectTest {
Copy link
Member

Choose a reason for hiding this comment

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

godoc for these functions please

}
}

type WritingIntoCRsHasEffectTest struct {
Copy link
Member

Choose a reason for hiding this comment

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

Have we considered making files for each type with its own run function next to it?

It is a minor layout thing, but will make it easier to find the actual test later one IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be a useful change and make it easier to find things. I think that should be done in a follow up PR though.

@AlexNPavel
Copy link
Contributor Author

Added godocs for all new exported functions, structs, and interface.

/cc @shawn-hurley

@AlexNPavel AlexNPavel merged commit e32aada into operator-framework:master Mar 6, 2019
@AlexNPavel AlexNPavel deleted the modularize-scorecard branch March 6, 2019 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants