Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

cherry-pick(release-v1.3.x): Ensure the desired install plan is approved in acceptance tests #1253

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
5 changes: 3 additions & 2 deletions test/acceptance/features/steps/olm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ def install_catalog_source(self):
return self.openshift.wait_for_package_manifest(self.package_name, self.operator_catalog_source_name, self.operator_catalog_channel)

def install_operator_subscription(self, csv_version=None, install_mode=InstallMode.Automatic):
csv_version_resolved = self.operator_subscription_csv_version if csv_version is None else csv_version
install_sub_output = self.openshift.create_operator_subscription(
self.package_name, self.operator_catalog_source_name, self.operator_catalog_channel, self.operator_catalog_namespace,
self.operator_subscription_csv_version if csv_version is None else csv_version, install_mode)
csv_version_resolved, install_mode)
if re.search(r'.*subscription.operators.coreos.com/%s\s(unchanged|created)' % self.package_name, install_sub_output) is None:
print("Failed to create {} operator subscription".format(self.package_name))
return False
self.openshift.approve_operator_subscription(self.package_name)
self.openshift.approve_operator_subscription(self.package_name, csv_version_resolved)
return True
20 changes: 15 additions & 5 deletions test/acceptance/features/steps/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def create_operator_subscription(self, package_name, operator_source_name, chann
return self.create_operator_subscription_to_namespace(package_name, self.operators_namespace, operator_source_name,
channel, operator_source_namespace, csv_version, install_mode)

def get_install_plan_for_subscription(self, subscription_name, subscription_namespace, csv_version=None):
def get_install_plan_for_subscription(self, subscription_name, subscription_namespace):
# wait for install plan
cmd = f"{ctx.cli} get subscription {subscription_name} -n {subscription_namespace} -o json | jq -rc '.status.installplan.name'"
polling2.poll(target=lambda: tuple(self.cmd.run(cmd)), check_success=lambda o: o[1] == 0 and o[0].startswith(
Expand All @@ -411,16 +411,26 @@ def get_install_plan_for_subscription(self, subscription_name, subscription_name

return install_plan.strip()

def approve_operator_subscription_in_namespace(self, name, namespace):
def approve_operator_subscription_in_namespace(self, name, namespace, csv_version=None):
# get the install plan
install_plan = self.get_install_plan_for_subscription(name, namespace)

# patch CSV for install plan
if csv_version is not None:
print(f"Patching {install_plan} install plan for {csv_version} CSV")
patch = f'{{"spec": {{"clusterServiceVersionNames": ["{csv_version}"] }}}}'
cmd = f"{ctx.cli} patch installplan {install_plan} -n {namespace} -p '{patch}' --type=merge"
(output, exit_code) = self.cmd.run(cmd)
assert exit_code == 0, f"Unable to patch CSV version for '{install_plan}' install plan:\n {output}"

# approve install plan
print(f"Approving {install_plan} install plan")
cmd = f'{ctx.cli} -n {namespace} patch installplan {install_plan} --type merge --patch \'{{"spec": {{"approved": true}}}}\''
(output, exit_code) = self.cmd.run(cmd)
assert exit_code == 0, f"Unable to patch the '{install_plan} install plan to approve it:\n{output}"
assert exit_code == 0, f"Unable to patch the {install_plan} install plan to approve it:\n{output}"

def approve_operator_subscription(self, name):
self.approve_operator_subscription_in_namespace(name, self.operators_namespace)
def approve_operator_subscription(self, name, csv_version=None):
self.approve_operator_subscription_in_namespace(name, self.operators_namespace, csv_version)

def get_resource_list_in_namespace(self, resource_plural, name_pattern, namespace):
print(f"Searching for {resource_plural} that matches {name_pattern} in {namespace} namespace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Feature: Support a number of existing operator-backed services out of the box
schedule: "0 4 * * *"
pxc:
size: 1
image: percona/percona-xtradb-cluster:8.0.27-18.1
image: docker.io/percona/percona-xtradb-cluster:8.0.27-18.1
volumeSpec:
persistentVolumeClaim:
resources:
Expand All @@ -202,10 +202,10 @@ Feature: Support a number of existing operator-backed services out of the box
haproxy:
enabled: true
size: 1
image: percona/percona-xtradb-cluster-operator:1.11.0-haproxy
image: docker.io/percona/percona-xtradb-cluster-operator:1.11.0-haproxy
logcollector:
enabled: true
image: percona/percona-xtradb-cluster-operator:1.11.0-logcollector
image: docker.io/percona/percona-xtradb-cluster-operator:1.11.0-logcollector
"""
* Condition ready=True for PerconaXtraDBCluster/minimal-cluster resource is met
When Service Binding is applied
Expand Down Expand Up @@ -269,7 +269,7 @@ Feature: Support a number of existing operator-backed services out of the box
schedule: "0 4 * * *"
pxc:
size: 1
image: percona/percona-xtradb-cluster:8.0.27-18.1
image: docker.io/percona/percona-xtradb-cluster:8.0.27-18.1
volumeSpec:
persistentVolumeClaim:
resources:
Expand All @@ -278,10 +278,10 @@ Feature: Support a number of existing operator-backed services out of the box
haproxy:
enabled: true
size: 1
image: percona/percona-xtradb-cluster-operator:1.11.0-haproxy
image: docker.io/percona/percona-xtradb-cluster-operator:1.11.0-haproxy
logcollector:
enabled: true
image: percona/percona-xtradb-cluster-operator:1.11.0-logcollector
image: docker.io/percona/percona-xtradb-cluster-operator:1.11.0-logcollector
"""
When Service Binding is applied
"""
Expand Down