summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/test
diff options
context:
space:
mode:
authorRodolfo Carvalho <rhcarvalho@gmail.com>2017-07-13 19:27:23 +0200
committerRodolfo Carvalho <rhcarvalho@gmail.com>2017-07-17 11:30:19 +0200
commit163d440065fa1db79f0900a859007c9d8873a40d (patch)
tree4b4b02e03be7b8b8832b500cadca27db4474ff2a /roles/openshift_health_checker/test
parent6bc1b8649cbf549a98d1af90eb6de590b0eb3695 (diff)
downloadopenshift-163d440065fa1db79f0900a859007c9d8873a40d.tar.gz
openshift-163d440065fa1db79f0900a859007c9d8873a40d.tar.bz2
openshift-163d440065fa1db79f0900a859007c9d8873a40d.tar.xz
openshift-163d440065fa1db79f0900a859007c9d8873a40d.zip
Make aos_version module handle multiple versions
Some packages are supported at more than one major.minor version at the same time. Support is added keeping backward compatibility: the 'version' key can be either a string (single version) or a list of versions.
Diffstat (limited to 'roles/openshift_health_checker/test')
-rw-r--r--roles/openshift_health_checker/test/aos_version_test.py89
1 files changed, 73 insertions, 16 deletions
diff --git a/roles/openshift_health_checker/test/aos_version_test.py b/roles/openshift_health_checker/test/aos_version_test.py
index 532a3e511..4100f6c70 100644
--- a/roles/openshift_health_checker/test/aos_version_test.py
+++ b/roles/openshift_health_checker/test/aos_version_test.py
@@ -18,14 +18,40 @@ expected_pkgs = {
}
-@pytest.mark.parametrize('pkgs', [
- # all found
- [Package('spam', '3.2.1'), Package('eggs', '3.2.1')],
- # found with more specific version
- [Package('spam', '3.2.1'), Package('eggs', '3.2.1.5')],
+@pytest.mark.parametrize('pkgs,expected_pkgs_dict', [
+ (
+ # all found
+ [Package('spam', '3.2.1'), Package('eggs', '3.2.1')],
+ expected_pkgs,
+ ),
+ (
+ # found with more specific version
+ [Package('spam', '3.2.1'), Package('eggs', '3.2.1.5')],
+ expected_pkgs,
+ ),
+ (
+ [Package('ovs', '2.6'), Package('ovs', '2.4')],
+ {
+ "ovs": {
+ "name": "ovs",
+ "version": ["2.6", "2.7"],
+ "check_multi": False,
+ }
+ },
+ ),
+ (
+ [Package('ovs', '2.7')],
+ {
+ "ovs": {
+ "name": "ovs",
+ "version": ["2.6", "2.7"],
+ "check_multi": False,
+ }
+ },
+ ),
])
-def test_check_precise_version_found(pkgs):
- aos_version._check_precise_version_found(pkgs, expected_pkgs)
+def test_check_precise_version_found(pkgs, expected_pkgs_dict):
+ aos_version._check_precise_version_found(pkgs, expected_pkgs_dict)
@pytest.mark.parametrize('pkgs,expect_not_found', [
@@ -81,36 +107,67 @@ def test_check_precise_version_found_fail(pkgs, expect_not_found):
assert list(expect_not_found.values()) == e.value.problem_pkgs
-@pytest.mark.parametrize('pkgs', [
- [],
- # more precise but not strictly higher
- [Package('spam', '3.2.1.9')],
+@pytest.mark.parametrize('pkgs,expected_pkgs_dict', [
+ (
+ [],
+ expected_pkgs,
+ ),
+ (
+ # more precise but not strictly higher
+ [Package('spam', '3.2.1.9')],
+ expected_pkgs,
+ ),
+ (
+ [Package('ovs', '2.7')],
+ {
+ "ovs": {
+ "name": "ovs",
+ "version": ["2.6", "2.7"],
+ "check_multi": False,
+ }
+ },
+ ),
])
-def test_check_higher_version_found(pkgs):
- aos_version._check_higher_version_found(pkgs, expected_pkgs)
+def test_check_higher_version_found(pkgs, expected_pkgs_dict):
+ aos_version._check_higher_version_found(pkgs, expected_pkgs_dict)
-@pytest.mark.parametrize('pkgs,expect_higher', [
+@pytest.mark.parametrize('pkgs,expected_pkgs_dict,expect_higher', [
(
[Package('spam', '3.3')],
+ expected_pkgs,
['spam-3.3'], # lower precision, but higher
),
(
[Package('spam', '3.2.1'), Package('eggs', '3.3.2')],
+ expected_pkgs,
['eggs-3.3.2'], # one too high
),
(
[Package('eggs', '1.2.3'), Package('eggs', '3.2.1.5'), Package('eggs', '3.4')],
+ expected_pkgs,
['eggs-3.4'], # multiple versions, one is higher
),
(
[Package('eggs', '3.2.1'), Package('eggs', '3.4'), Package('eggs', '3.3')],
+ expected_pkgs,
['eggs-3.4'], # multiple versions, two are higher
),
+ (
+ [Package('ovs', '2.8')],
+ {
+ "ovs": {
+ "name": "ovs",
+ "version": ["2.6", "2.7"],
+ "check_multi": False,
+ }
+ },
+ ['ovs-2.8'],
+ ),
])
-def test_check_higher_version_found_fail(pkgs, expect_higher):
+def test_check_higher_version_found_fail(pkgs, expected_pkgs_dict, expect_higher):
with pytest.raises(aos_version.FoundHigherVersion) as e:
- aos_version._check_higher_version_found(pkgs, expected_pkgs)
+ aos_version._check_higher_version_found(pkgs, expected_pkgs_dict)
assert set(expect_higher) == set(e.value.problem_pkgs)