Skip to content

Commit 89e8b11

Browse files
author
Per Goncalves da Silva
committed
Add unintall feature test
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent dbc4af3 commit 89e8b11

File tree

4 files changed

+307
-22
lines changed

4 files changed

+307
-22
lines changed

test/e2e/features/install.feature

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ Feature: Install ClusterExtension
3030
Then ClusterExtension is rolled out
3131
And ClusterExtension is available
3232
And bundle "test-operator.1.2.0" is installed in version "1.2.0"
33-
And resource "networkpolicy/test-operator-network-policy" is installed
34-
And resource "configmap/test-configmap" is installed
35-
And resource "deployment/test-operator" is installed
33+
And ClusterExtension resources are created and labeled
3634

3735
@mirrored-registry
3836
Scenario Outline: Install latest available version from mirrored registry
@@ -57,9 +55,7 @@ Feature: Install ClusterExtension
5755
Then ClusterExtension is rolled out
5856
And ClusterExtension is available
5957
And bundle "<package-name>-operator.1.2.0" is installed in version "1.2.0"
60-
And resource "networkpolicy/test-operator-network-policy" is installed
61-
And resource "configmap/test-configmap" is installed
62-
And resource "deployment/test-operator" is installed
58+
And ClusterExtension resources are created and labeled
6359

6460
Examples:
6561
| package-name |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Feature: Uninstall ClusterExtension
2+
3+
As an OLM user I would like to uninstall a cluster extension,
4+
removing all resources previously installed/updated through the extension.
5+
6+
Background:
7+
Given OLM is available
8+
And ClusterCatalog "test" serves bundles
9+
And ServiceAccount "olm-sa" with needed permissions is available in ${TEST_NAMESPACE}
10+
And ClusterExtension is applied
11+
"""
12+
apiVersion: olm.operatorframework.io/v1
13+
kind: ClusterExtension
14+
metadata:
15+
name: ${NAME}
16+
spec:
17+
namespace: ${TEST_NAMESPACE}
18+
serviceAccount:
19+
name: olm-sa
20+
source:
21+
sourceType: Catalog
22+
catalog:
23+
packageName: test
24+
selector:
25+
matchLabels:
26+
"olm.operatorframework.io/metadata.name": test-catalog
27+
"""
28+
And bundle "test-operator.1.2.0" is installed in version "1.2.0"
29+
And ClusterExtension is rolled out
30+
31+
Scenario: Removing ClusterExtension triggers the extension uninstall, eventually removing all installed resources
32+
When ClusterExtension is removed
33+
Then ClusterExtension is uninstalled
34+
35+
Scenario: Removing ClusterExtension resources leads to all installed resources being removed even if the service account is no longer present
36+
When resource "serviceaccount/olm-sa" is removed
37+
# Ensure service account is gone before checking to ensure resources are cleaned up whether the service account
38+
# and its permissions are present on the cluster or not
39+
And resource "serviceaccount/olm-sa" is eventually not found
40+
And ClusterExtension is removed
41+
Then ClusterExtension is uninstalled

test/e2e/steps/hooks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1717
"k8s.io/component-base/featuregate"
1818
"k8s.io/klog/v2/textlogger"
19+
"sigs.k8s.io/controller-runtime/pkg/client"
1920

2021
"github.com/operator-framework/operator-controller/internal/operator-controller/features"
2122
)
@@ -32,6 +33,9 @@ type scenarioContext struct {
3233
removedResources []unstructured.Unstructured
3334
backGroundCmds []*exec.Cmd
3435
metricsResponse map[string]string
36+
37+
// set by ClusterExtensionIsRolledOut
38+
extensionObjects []client.Object
3539
}
3640

3741
type contextKey string

0 commit comments

Comments
 (0)