Skip to content

Conversation

jmccormick2001
Copy link

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.

└── example2
```

In the above proposed layout, the test metadata resides under a new
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

A few questions

  1. 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.

  2. 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 and operators.operatorframework.io.test.type.v1 because the scorecard+v1 mediatype specifies the keys?

  3. 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 the scorecard+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?

  4. As an MVP, is it reasonable for scorecard to assume that registry and scorecard files will be bundled together in a single image?

Copy link
Member

Choose a reason for hiding this comment

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

  1. What about a operators.operatorframework.io.test.mediatypes.v1 label that holds a list of test mediatypes?
  2. I think so based on how I'm interpreting the bundle enhancement, and it would make sense to assume it does. @ecordell @kevinrizza confirm?
  3. Good question.
  4. Probably, assuming we cannot run any of the current alpha scorecard tests without registry contents.

Copy link
Member

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"

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

@estroz estroz May 29, 2020

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Author

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.

Copy link
Member

@kensipe kensipe left a 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

  1. is this in the same image as operator?
  2. if separate, how are they associated?
  3. 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)

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.

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
Copy link
Member

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.

Jeff McCormick and others added 3 commits May 12, 2020 16:31
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
@estroz
Copy link
Member

estroz commented May 13, 2020

From offline discussion:

  • This PR should act as a guide for both future additive bundle specs and a set of "rules" for creating such a spec. The latter could be an addendum to the enhancement, or a separate doc in its own right.
  • Because the bundle format is extensible, there should be an abstraction over bundle.Dockerfile and annotations.yaml that allows label modification without giving users too much freedom to modify bundles. Not sure what that looks like yet, but it will likely involve some interface work in operator-registry.

@jmccormick2001
Copy link
Author

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.

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"
Copy link
Member

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
Copy link
Member

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"

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.

I would like to make sure we capture:

  1. 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.
  2. 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
Copy link
Member

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
Copy link
Member

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

Copy link
Member

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?

Copy link
Author

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.

@jmccormick2001
Copy link
Author

I updated this to show how a test framework other than scorecard would show up in the label nomenclature just as an example.

@jmccormick2001
Copy link
Author

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.

@jmccormick2001
Copy link
Author

@ecordell wdyt? did I miss any of your concerns/questions or items I need to address?

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.

One recommendation on labels and two nits.

└── example2
```

In the above proposed layout, the test metadata resides under a new
Copy link
Member

@estroz estroz May 29, 2020

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.

Jeff McCormick and others added 2 commits May 29, 2020 11:32
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.
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
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 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.

Copy link
Author

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.

Jeff McCormick and others added 2 commits June 11, 2020 14:27
Co-authored-by: Evan Cordell <cordell.evan@gmail.com>
@ecordell
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@joelanford
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2020
@shawn-hurley
Copy link
Member

/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.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2020
@jmccormick2001 jmccormick2001 merged commit f5d0096 into operator-framework:master Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants