Skip to content
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

test: skip image polling test if running in a kind cluster #2425

Closed
wants to merge 1 commit into from
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
12 changes: 11 additions & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ make file and use `-dryRun` with `-focus` and see if the regex would trigger you

## Build infrastructure

Note that the make file target `e2e-local` is executed by the github workflow `.github/workflows/e2e-tests.yml` and uses two parallel `go test` processes.
Note that the make file target `e2e-local` is executed by the github workflow `.github/workflows/e2e-tests.yml` and uses two parallel `go test` processes.

## Running on minikube

The e2e suite is also runnable on a minikube cluster. First spin up the minikube cluster manually with the desired provisioner,
then run `make run-local` to deploy OLM onto the cluster. Tests can be run by invoking ginkgo and passing the required command line
arguments to the test suite. For example to run a specific test:

```bash
GO111MODULE=on GOFLAGS="-mod=vendor" go run github.com/onsi/ginkgo/ginkgo -focus "static provider" -v --progress ./test/e2e -- -namespace=operators -olmNamespace=olm -dummyImage=bitnami/nginx:latest
```
7 changes: 4 additions & 3 deletions test/e2e/catalog_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"net"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -641,8 +640,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
})

It("image update", func() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
Skip("This spec fails when run using KIND cluster. See https://github.com/operator-framework/operator-lifecycle-manager/issues/1380 for more details")
if ok, err := inKind(c); ok && err == nil {
Skip("This spec fails when run using KIND cluster. See https://github.com/operator-framework/operator-lifecycle-manager/issues/2420 for more details")
} else if err != nil {
Skip("Could not determine whether running in a kind cluster. Skipping.")
}
// Create an image based catalog source from public Quay image
// Use a unique tag as identifier
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,21 @@ func HaveMessage(goal string) gtypes.GomegaMatcher {
return plan.Status.Message
}, ContainSubstring(goal))
}

func inKind(client operatorclient.ClientInterface) (bool, error) {
nodes, err := client.KubernetesInterface().CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to also use context.Background() instead of context.TODO() here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I wasn't sure about whether to thread a context through -- might be ok leaving as is for now

if err != nil {
// error finding nodes
return false, err
}
Comment on lines +924 to +927
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be easier to just default to false, and avoid returning an error entirely, if we run into an error while listing out the nodes. This would allow call sites to avoid needing to check whether there's an error (and improve readability decreasing the number of conditional chains). Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I had it that way originally, but a failure listing the nodes is an error. I think it should be treated as one, even if it makes the function more complex

for _, node := range nodes.Items {
if !strings.HasPrefix(node.GetName(), "kind-") {
continue
}
if !strings.HasSuffix(node.GetName(), "-control-plane") {
continue
}
return true, nil
}
return false, nil
Comment on lines +928 to +937
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Testing this logic out locally and it seemed to catch the default kind node name and any other variations, like `kind-123432-control-plane, and correctly filtered out cluster environment we don't care about in the context of this function.

}