Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions test/extended/olm/olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,25 +240,25 @@ var _ = g.Describe("[sig-operator] an end user can use OLM", func() {
oc = exutil.NewCLI("olm-23440")

buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
operatorGroup = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
sub = filepath.Join(buildPruningBaseDir, "subscription.yaml")
ogPath = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
subPath = filepath.Join(buildPruningBaseDir, "subscription.yaml")
catalogPath = filepath.Join(buildPruningBaseDir, "catalogsource.yaml")
)

files := []string{sub}
g.It("can subscribe to the operator", func() {
g.By("Cluster-admin user subscribe the operator resource")

// skip test if redhat-operators is not present or disabled
ok, err := hasRedHatOperatorsSource(oc)
// Configure OperatorGroup before tests
og, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", ogPath, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace())).OutputToFile("og.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", og).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
if !ok {
g.Skip("redhat-operators source not found in enabled sources")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we be concerned that this check was not working? Does that mean we're not actually disabling some aspect of the redhat-operators source when marketplace is not enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was testing the OperatorHub API, which still exists as part of a separate problem that I'm currently tracking -- I'll post a PR here when there are more updates.

}

// configure OperatorGroup before tests
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace())).OutputToFile("config.json")
// Configure CatalogSource before tests
const image = "registry.redhat.io/redhat/redhat-operator-index:v4.10"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is going to be a source of bit-rot someday.

can we identify the clusterversion and pick the version tag based on that, dynamically?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

or pull the value in from elsewhere? (i know we also have the challenge that the day we start v4.12, there may not be a v4.12 catalog published, so that could be a problem too... maybe n-1 is the tag to use)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've asked the same questions before and I think the long-term solution is for the catalog fixture to be built as a part of the test setup.

or pull the value in from elsewhere? (i know we also have the challenge that the day we start v4.12, there may not be a v4.12 catalog published, so that could be a problem too... maybe n-1 is the tag to use)

I like this, but it seems like we'd just be shifting the problem over one release; i.e. when we're testing 4.12, if we grabbed the n-1 tag, we'd be assuming the same image name and convention were carried over from 4.10 to 4.11 (since the test in 4.11 points at the image in 4.10) -- moreover, we'd still inherit the primary issue of today's tests: there's no guarantee that the content we're using as a fixture hasn't changed.

Copy link
Copy Markdown
Contributor

@bparees bparees Apr 11, 2022

Choose a reason for hiding this comment

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

yeah i guess maybe pinning to 4.10 and if someday that breaks on a v4.16 cluster, we can bump it at that point, is the most straightforward answer for now. not ideal, but not worth holding this up over.

catalog, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", catalogPath, "-p", "NAME=test-catalog", fmt.Sprintf("NAMESPACE=%s", oc.Namespace()), fmt.Sprintf("IMAGE=%s", image)).OutputToFile("catalog.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", catalog).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

o.Eventually(func() []string {
Expand Down Expand Up @@ -286,12 +286,10 @@ var _ = g.Describe("[sig-operator] an end user can use OLM", func() {
return parsed.Status.Namespaces
}, 5*time.Minute, time.Second).Should(o.Equal([]string{""}))

for _, v := range files {
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", v, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace()), "SOURCENAME=redhat-operators", "SOURCENAMESPACE=openshift-marketplace", "PACKAGE=cluster-logging", "CHANNEL=stable").OutputToFile("config.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
}
sub, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", subPath, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace()), "SOURCENAME=test-catalog", fmt.Sprintf("SOURCENAMESPACE=%s", oc.Namespace()), "PACKAGE=cluster-logging", "CHANNEL=stable").OutputToFile("sub.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", sub).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

var current string
o.Eventually(func() string {
Expand Down
37 changes: 37 additions & 0 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions test/extended/testdata/olm/catalogsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: catalogsource-template
objects:
- apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: "${NAME}"
namespace: "${NAMESPACE}"
spec:
sourceType: grpc
image: "${IMAGE}"
parameters:
- name: NAME
- name: NAMESPACE
- name: IMAGE
Comment thread
njhale marked this conversation as resolved.