Skip to content
Merged
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
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ To run a specific e2e test locally:
$ make e2e-local TEST=TestCreateInstallPlanManualApproval
```

##### Updating test images

Sometimes you will need to update the index or bundle images used in the unit or e2e tests. To update those images, you will need to be logged into quay.io with membership in the `olmtest` organization. Then simply run `./scripts/build_e2e_test_images.sh` which will build all the required bundle images, push those to quay.io, build all the index images, and push those to quay.io as well.

Please be aware that these scripts push directly to the image tags used by the actual e2e tests.

The contents and Containerfiles of these bundles can be found in `./test/images/`.

[controller-runtime instructions]: https://pkg.go.dev/sigs.k8s.io/controller-runtime/tools/setup-envtest#section-readme

#### Building
Expand Down
30 changes: 30 additions & 0 deletions scripts/build_e2e_test_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

QUAY_REPO="${QUAY_REPO:-olmtest}"
SINGLE_BUNDLE_TAG="${BUNDLE_TAG:-objects-pdb-v2}"
SINGLE_BUNDLE_INDEX_TAG="${INDEX_TAG:-pdb-v2}"

# Busybox Operator Index Image
docker build -t quay.io/${QUAY_REPO}/busybox-bundle:1.0.0 ./test/images/busybox-index/busybox/1.0.0
docker build -t quay.io/${QUAY_REPO}/busybox-bundle:2.0.0 ./test/images/busybox-index/busybox/2.0.0

docker build -t quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0 ./test/images/busybox-index/busybox-dependency/1.0.0
docker build -t quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0 ./test/images/busybox-index/busybox-dependency/2.0.0

docker push quay.io/${QUAY_REPO}/busybox-bundle:1.0.0
docker push quay.io/${QUAY_REPO}/busybox-bundle:2.0.0
docker push quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0
docker push quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0

opm index add --bundles quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0,quay.io/olmtest/busybox-bundle:1.0.0 --tag quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker
docker push quay.io/${QUAY_REPO}/busybox-dependencies-index:1.0.0-with-ListBundles-method

opm index add --bundles quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0,quay.io/olmtest/busybox-bundle:2.0.0 --tag quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method --from-index quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker
docker push quay.io/${QUAY_REPO}/busybox-dependencies-index:2.0.0-with-ListBundles-method

# Single Bundle E2E Test Image
docker build -t quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG} ./test/images/single-bundle-index
docker push quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG}

opm index add --bundles quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG} --tag quay.io/${QUAY_REPO}/single-bundle-index:${INDEX_TAG} -c docker
docker push quay.io/${QUAY_REPO}/single-bundle-index:${INDEX_TAG}
19 changes: 0 additions & 19 deletions scripts/build_test_images.sh

This file was deleted.

11 changes: 9 additions & 2 deletions test/e2e/bundle_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes"
TeardownNamespace(generatedNamespace.GetName())
})

When("a bundle with a pdb, priorityclass, and VPA object is installed", func() {
When("a bundle that includes supported resources is installed", func() {
// Supported resources installed are a NetworkPolicy, pdb, priorityclass, and VPA object
const (
packageName = "busybox"
channelName = "alpha"
Expand All @@ -59,7 +60,7 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes"
By("first installing the VPA CRD on cluster")
const (
sourceName = "test-catalog"
imageName = "quay.io/olmtest/single-bundle-index:pdb-v1"
imageName = "quay.io/olmtest/single-bundle-index:pdb-v2"
)

By("create VPA CRD on cluster")
Expand Down Expand Up @@ -141,6 +142,7 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes"
pdbName = "busybox-pdb"
priorityClassName = "super-priority"
vpaName = "busybox-vpa"
networkPolicyName = "busybox-networkpolicy"
)

var resource = schema.GroupVersionResource{
Expand All @@ -164,6 +166,11 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes"
_, err := kubeClient.KubernetesInterface().PolicyV1().PodDisruptionBudgets(generatedNamespace.GetName()).Get(context.Background(), pdbName, metav1.GetOptions{})
return err
}).Should(Succeed(), "expected no error getting pdb object associated with CSV")

Eventually(func() error {
_, err := kubeClient.KubernetesInterface().NetworkingV1().NetworkPolicies(generatedNamespace.GetName()).Get(context.Background(), networkPolicyName, metav1.GetOptions{})
return err
}).Should(Succeed(), "expected no error finding networkpolicy object associated with CSV")
})

AfterEach(func() {
Expand Down
6 changes: 6 additions & 0 deletions test/images/busybox-index/busybox/1.0.0/manifests/csv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ spec:
command:
- sleep
- "9000"
permissions:
- serviceAccountName: busybox-operator
rules:
- apiGroups: ["networking.k8s.io"]
resources: ["networkpolicies"]
verbs: ["get", "list", "create", "update", "delete"]
strategy: deployment
installModes:
- supported: true
Expand Down
13 changes: 13 additions & 0 deletions test/images/single-bundle-image/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM scratch

# We are pushing an operator-registry bundle
# that has both metadata and manifests.
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=busybox
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha

COPY ./manifests/*.yaml /manifests/
COPY ./metadata/annotations.yaml /metadata/annotations.yaml
42 changes: 42 additions & 0 deletions test/images/single-bundle-image/manifests/csv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
name: busybox.v2.0.0
namespace: operators
spec:
description: busybox
displayName: busybox
install:
spec:
deployments:
- name: busybox
spec:
replicas: 1
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- command:
- sleep
- "9000"
image: busybox
name: busybox
strategy: deployment
installModes:
- supported: true
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: true
type: MultiNamespace
- supported: true
type: AllNamespaces
maturity: alpha
provider:
name: Red Hat
version: 2.0.0
8 changes: 8 additions & 0 deletions test/images/single-bundle-image/manifests/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: busybox-networkpolicy
spec:
podSelector: {}
policyTypes:
- Ingress
10 changes: 10 additions & 0 deletions test/images/single-bundle-image/manifests/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: busybox-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: busybox

7 changes: 7 additions & 0 deletions test/images/single-bundle-image/manifests/priorityclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: super-priority
description: This priority class should be used for XYZ service pods only.
globalDefault: false
value: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: busybox-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: busybox
updatePolicy:
updateMode: "Off"
7 changes: 7 additions & 0 deletions test/images/single-bundle-image/metadata/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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: "busybox"
operators.operatorframework.io.bundle.channels.v1: "alpha"
operators.operatorframework.io.bundle.channel.default.v1: "alpha"