Skip to content

Commit

Permalink
Do not check package version on non-master/node
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcarvalho committed Apr 10, 2017
1 parent 3ea629b commit 656932a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class PackageVersion(NotContainerizedMixin, OpenShiftCheck):
tags = ["preflight"]

def run(self, tmp, task_vars):
group_names = get_var(task_vars, "group_names", default=[])

if 'masters' not in group_names and 'nodes' not in group_names:
return {'changed': False}

rpm_prefix = get_var(task_vars, "openshift", "common", "service_type")
openshift_release = get_var(task_vars, "openshift_release")

Expand Down
32 changes: 31 additions & 1 deletion roles/openshift_health_checker/test/package_version_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import pytest

from openshift_checks.package_version import PackageVersion


def test_package_version():
@pytest.mark.parametrize('group_names', [
['masters'],
['nodes'],
['masters', 'nodes'],
['masters', 'etcd'],
])
def test_package_version(group_names):
task_vars = dict(
openshift=dict(common=dict(service_type='origin')),
openshift_release='v3.5',
group_names=group_names,
)
return_value = object()

Expand All @@ -19,3 +28,24 @@ def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None)
check = PackageVersion(execute_module=execute_module)
result = check.run(tmp=None, task_vars=task_vars)
assert result is return_value


@pytest.mark.parametrize('group_names', [
[],
['etcd'],
['lb'],
['nfs'],
])
def test_package_version_skip_when_not_master_nor_node(group_names):
task_vars = dict(
openshift=dict(common=dict(service_type='origin')),
openshift_release='v3.5',
group_names=group_names,
)

def execute_module(*args):
raise AssertionError('should not be called')

check = PackageVersion(execute_module=execute_module)
result = check.run(tmp=None, task_vars=task_vars)
assert result == {'changed': False}

0 comments on commit 656932a

Please sign in to comment.