Skip to content

Commit 64c4eb8

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

3 files changed

Lines changed: 257 additions & 16 deletions

File tree

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)