-
Notifications
You must be signed in to change notification settings - Fork 37
enhancement to add test metadata into the bundle #18
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
enhancement to add test metadata into the bundle #18
Conversation
└── example2 | ||
``` | ||
|
||
In the above proposed layout, the test metadata resides under a new |
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.
The spec for labels/annotations should be used here as well (see the bundle enhancement)
For these tests, I would think something along these lines:
annotations:
operators.operatorframework.io.test.mediatype.v1: "scorecard+v1"
operators.operatorframework.io.test.config.v1: "/tests/scorecard/config.yaml"
# optional
operators.operatorframework.io.test.type.v1: "kuttl"
For reference, this is what they look like for an operator bundle:
annotations:
operators.operatorframework.io.bundle.mediatype.v1: "registry+v1"
operators.operatorframework.io.bundle.manifests.v1: "path/to/manifests/"
operators.operatorframework.io.bundle.metadata.v1: "path/to/metadata/"
# optional
operators.operatorframework.io.bundle.package.v1: "$packageName"
operators.operatorframework.io.bundle.channels.v1: "alpha,stable"
operators.operatorframework.io.bundle.channel.default.v1: "stable"
The advantage of defining the test bundle this way is that we are free to combine / split these as needed.
A combined manifest / test bundle might look like this:
annotations:
operators.operatorframework.io.bundle.mediatype.v1: "registry+v1"
operators.operatorframework.io.bundle.manifests.v1: "/manifests/"
operators.operatorframework.io.bundle.metadata.v1: "/metadata/"
operators.operatorframework.io.bundle.package.v1: "couchbase"
operators.operatorframework.io.bundle.channels.v1: "alpha,stable"
operators.operatorframework.io.bundle.channel.default.v1: "stable"
operators.operatorframework.io.test.mediatype.v1: "scorecard+v1"
operators.operatorframework.io.test.config.v1: "/tests/scorecard/config.yaml"
operators.operatorframework.io.test.type.v1: "kuttl"
or they could be two separate images, each with their own metadata.
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.
A few questions
-
Would it make sense to leave room in the bundle spec for multiple sets of test metadata to exist simultaneously in the same image?
Or would we just have two separate test bundles, each with their own mediatype?
I don't think SDK or scorecard has this use case at the moment, but once the community sees scorecard test metadata packaged into a bundle image, I could see other test frameworks and tools jumping into the fold.
-
Does the mediatype define the other label keys that are expected to exist?
So in the scorecard case, scorecard could query the image labels, and check to see if
operators.operatorframework.io.test.mediatype.v1 == "scorecard+v1"
If it finds that, it knows look for
operators.operatorframework.io.test.config.v1
andoperators.operatorframework.io.test.type.v1
because thescorecard+v1
mediatype specifies the keys? -
Some scorecard tests verify bundle contents, and other scorecard tests run kuttl. So in the case where the
registry+v1
files are in a different image than thescorecard+v1
files, will the bundle image reference handed to scorecard be a manifest list that contains pointers to the separate images? And then scorecard would iterate those images querying the labels to see if it needs to pull the image contents? -
As an MVP, is it reasonable for scorecard to assume that registry and scorecard files will be bundled together in a single image?
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.
- What about a
operators.operatorframework.io.test.mediatypes.v1
label that holds a list of test mediatypes? - I think so based on how I'm interpreting the bundle enhancement, and it would make sense to assume it does. @ecordell @kevinrizza confirm?
- Good question.
- Probably, assuming we cannot run any of the current
alpha scorecard
tests without registry contents.
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.
What about a operators.operatorframework.io.test.mediatypes.v1 label that holds a list of test mediatypes?
That strikes me as something that could get unweidly, but not sure. Looking at the bundle spec, it isn't clear to me if there is a specific syntax to the label keys. Can the labels be parsed into a map[string]interface{}
such that array indexing would work? Or is it purely dot-delimited?
For example, can I define an array of tests via these labels?
operators.operatorframework.io.test[0].mediatype.v1: "scorecard+v1"
operators.operatorframework.io.test[0].scorecard.config.v1: "/tests/scorecard/config.yaml"
operators.operatorframework.io.test[1].mediatype.v1: "othertestframework+v1"
operators.operatorframework.io.test[1].othertestframework.foo.v1: "bar"
Another option could be to give scorecard it's own special key:
operators.operatorframework.io.scorecard.mediatype.v1: "scorecard+v1"
operators.operatorframework.io.scorecard.config.v1: "/tests/scorecard/config.yaml"
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.
An array is weird because you can't "index" on labels since they're just a map key. Having a scorecard-only key makes more sense.
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 it make sense to leave room in the bundle spec for multiple sets of test metadata to exist simultaneously in the same image?
+1 I think it does
As an MVP, is it reasonable for scorecard to assume that registry and scorecard files will be bundled together in a single image?
I actually think that we do not want to support a "test" only bundle. That manifests and metadata are required for the scorecard config
Rather then a list of labels, could we have a "test" config that describes different types of tests that is versioned. ....test.mediatype.v1: "operatorframework+v1"
and a location label associated like config.
Then we create a new config that can describe tests. This file will assume that it is in the top-level directory for the rest of the tests. Maybe a little easier way of managing this?
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.
@shawn-hurley defining another config for tests sounds like overkill. We only really need the mediaType and config path for each test anyway. Can we leverage the fact that operator-framework owns the operators.operatorframework.io
portion of label keys instead?
Then we could do something like what we originally had and force users to set different domains:
# Ours
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
operators.operatorframework.io.test.config.v1: tests/scorecard/config.yaml
# Custom
operators.other.domain.test.mediatype.v1: custom+v1
operators.other.domain.test.config.v1: tests/custom/config.yaml
...
We control the scorecard+v1
mediaType, so if other operator-framework-owned test types need to be added (ex. kuttl) we can increment versions or change mediaType names.
Another option is to set a different subdomain test
on label keys:
# Ours
test.operatorframework.io.scorecard.mediatype.v1: scorecard+v1
test.operatorframework.io.scorecard.config.v1: tests/scorecard/config.yaml
# Custom
test.operatorframework.io.custom.mediatype.v1: custom+v1
test.operatorframework.io.custom.config.v1: tests/scorecard/config.yaml
...
Personally I prefer the former because it distinguishes ownership of labels and is flexible enough for our needs.
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 control the scorecard+v1 mediaType, so if other operator-framework-owned test types need to be added (ex. kuttl) we can increment versions or change mediaType names.
Makes sense to me.
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.
@jmccormick2001 this never got addressed
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.
@shawn-hurley if you are ok with Eric's suggestion I'll update the enhancement to include, if not, then I can re-open this PR where we can discuss it further.
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 have similar questions to @joelanford
- is this in the same image as operator?
- if separate, how are they associated?
- if together, is the image running as operator in cluster and a separate instance running tests? or running tests from the cluster (which seems odd)
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.
Looks good so far. Some nits and a question about generalizing this.
|
||
### Non-Goals | ||
|
||
This enhancement is scoped to define the location within the bundle for |
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.
A thought: generalizing this PR to provide a spec for adding arbitrary items to a bundle image (what are the requirements, labels, etc), and using scorecard test definitions as a living example, would allow us to write more succinct bundle-modifying EPs in the future. This is assuming there isn't already a spec for doing so.
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
From offline discussion:
|
I updated the enhancement to add the proposed annotations plus mention that operator-registry would need to have an API to add this sort of metadata into a bundle. |
enhancements/scorecard-metadata.md
Outdated
operators.operatorframework.io.test.mediatype.v1: "scorecard+v1" | ||
operators.operatorframework.io.test.config.v1: "/tests/scorecard/config.yaml" | ||
# optional | ||
operators.operatorframework.io.test.type.v1: "kuttl" |
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.
What does operators.operatorframework.io.test.type.v1: "kuttl"
convey and how would we act on it?
└── example2 | ||
``` | ||
|
||
In the above proposed layout, the test metadata resides under a new |
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.
What about a operators.operatorframework.io.test.mediatypes.v1 label that holds a list of test mediatypes?
That strikes me as something that could get unweidly, but not sure. Looking at the bundle spec, it isn't clear to me if there is a specific syntax to the label keys. Can the labels be parsed into a map[string]interface{}
such that array indexing would work? Or is it purely dot-delimited?
For example, can I define an array of tests via these labels?
operators.operatorframework.io.test[0].mediatype.v1: "scorecard+v1"
operators.operatorframework.io.test[0].scorecard.config.v1: "/tests/scorecard/config.yaml"
operators.operatorframework.io.test[1].mediatype.v1: "othertestframework+v1"
operators.operatorframework.io.test[1].othertestframework.foo.v1: "bar"
Another option could be to give scorecard it's own special key:
operators.operatorframework.io.scorecard.mediatype.v1: "scorecard+v1"
operators.operatorframework.io.scorecard.config.v1: "/tests/scorecard/config.yaml"
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 would like to make sure we capture:
- The ability for other types of tests to be added. The initial version may only contain the scorecard tests, but that is ok if the design is extensible.
- The ability to version the tests that are added. Scorecard v1 tests look like X and maybe in a year or two we have a breaking change, we would want to be able to determine if the tests in the bundle are v1 or v2.
└── example2 | ||
``` | ||
|
||
In the above proposed layout, the test metadata resides under a new |
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 it make sense to leave room in the bundle spec for multiple sets of test metadata to exist simultaneously in the same image?
+1 I think it does
As an MVP, is it reasonable for scorecard to assume that registry and scorecard files will be bundled together in a single image?
I actually think that we do not want to support a "test" only bundle. That manifests and metadata are required for the scorecard config
Rather then a list of labels, could we have a "test" config that describes different types of tests that is versioned. ....test.mediatype.v1: "operatorframework+v1"
and a location label associated like config.
Then we create a new config that can describe tests. This file will assume that it is in the top-level directory for the rest of the tests. Maybe a little easier way of managing this?
operators.operatorframework.io.test.type.v1: "kuttl" | ||
``` | ||
|
||
For the purpose of this enhancement, scorecard would assume that its test |
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 commented above, I think we want to make this a hard requirement
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.
It's probably worth thinking about stripping test data for disconnected clusters?
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 added a note in there into the user story and API description about the need to add/update/remove custom metadata like this to support disconnected environments. Good catch.
I updated this to show how a test framework other than scorecard would show up in the label nomenclature just as an example. |
I removed the annotation that specified kuttl, I didn't see what its purpose would be in the context of scorecard. Scorecard will just process tests as it finds them within the scorecard metadata essentially, regardless if they are kuttl or not. The only value I could think of in having a kuttl annotation is if some other tooling outside of scorecard cared about what types of scorecard tests were being run, I'm not aware of that being a requirement at this point. |
@ecordell wdyt? did I miss any of your concerns/questions or items I need to address? |
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.
One recommendation on labels and two nits.
└── example2 | ||
``` | ||
|
||
In the above proposed layout, the test metadata resides under a new |
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.
@shawn-hurley defining another config for tests sounds like overkill. We only really need the mediaType and config path for each test anyway. Can we leverage the fact that operator-framework owns the operators.operatorframework.io
portion of label keys instead?
Then we could do something like what we originally had and force users to set different domains:
# Ours
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
operators.operatorframework.io.test.config.v1: tests/scorecard/config.yaml
# Custom
operators.other.domain.test.mediatype.v1: custom+v1
operators.other.domain.test.config.v1: tests/custom/config.yaml
...
We control the scorecard+v1
mediaType, so if other operator-framework-owned test types need to be added (ex. kuttl) we can increment versions or change mediaType names.
Another option is to set a different subdomain test
on label keys:
# Ours
test.operatorframework.io.scorecard.mediatype.v1: scorecard+v1
test.operatorframework.io.scorecard.config.v1: tests/scorecard/config.yaml
# Custom
test.operatorframework.io.custom.mediatype.v1: custom+v1
test.operatorframework.io.custom.config.v1: tests/scorecard/config.yaml
...
Personally I prefer the former because it distinguishes ownership of labels and is flexible enough for our needs.
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
removed the kuttl files from the example, here we assume that we control what is under tests/scorecard so an example of that is not useful to call out.
…upport disconnected environments
enhancements/scorecard-metadata.md
Outdated
For the purpose of this enhancement, scorecard would assume that its test | ||
metadata would be in the same bundle image as the operator image. | ||
|
||
The operator-registry API would need to be updated to support an ability |
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.
Can we quickly clarify what this means?
I'm interpreting this as: "the operator-registry github repo will contain a golang API that can be used to add custom metadata to a bundle image".
We could write a separate enhancement for it, but there is some ux to hash out for how this is exposed via libraries or opm
.
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.
@ecordell see what you think about the updates I made, I tried to get it more specific to operator-registry repo golang API.
Co-authored-by: Evan Cordell <cordell.evan@gmail.com>
…r-registry API requirements
/lgtm |
/lgtm |
…like other catalog images
/lgtm I am a little worried that the user stories may require more work and design. We should consider updating this enhancement as we implement them. |
This PR is an enhancement to allow test metadata to be added into a bundle, this will enable testing against a bundle. For operator-sdk scorecard development underway, we would make use of this feature to co-locate tests with the operator metadata. End users would use this feature to add test metadata, update test metadata within their operator bundles. Test frameworks would need an ability to extract test metadata from bundles when executing tests.