[Sanity] Override nested params of global config in Jenkins
* Added possibility to overwrite the nested parameters (dictionaries)
in Jenkins. Jenkins EXTRA_PARAMS will have the "override_config"
key which can override partially/fully all options in global
config in YAML format.
* global_config.yaml has now YAML format with lists started with dash
Depends on:
https://gerrit.mcp.mirantis.com/#/c/54895/
https://gerrit.mcp.mirantis.com/#/c/54897/
Change-Id: I8a122cd4307fd6ea341d92fa25f5324ac8eb9f08
Related-Prod: #PROD-29371
diff --git a/test_set/cvp-sanity/global_config.yaml b/test_set/cvp-sanity/global_config.yaml
index c71b309..b0cba57 100644
--- a/test_set/cvp-sanity/global_config.yaml
+++ b/test_set/cvp-sanity/global_config.yaml
@@ -23,13 +23,13 @@
# Use as env variable as
# export skipped_nodes=mtr01.local,log02.local
# TEMPORARY: please do not comment this setting.
-skipped_nodes: [""]
+skipped_nodes: []
# List of groups (short name, e.g. dbs) to skip in group tests
# Use as env variable as
# export skipped_groups=mtr,log
# TEMPORARY: please do not comment this setting.
-skipped_groups: [""]
+skipped_groups: []
# Groups can be defined using pillars.
# Uncomment this section to enable this.
@@ -38,49 +38,62 @@
# 1) you don't need to separate kvm and kvm_glusterfs nodes
# 2) Use I@pillar or mask like ctl* for targetting nodes
-groups: {
- cmp: 'I@nova:compute',
- ctl: 'I@keystone:server',
- msg: 'I@rabbitmq:server',
- dbs: 'I@galera:*',
- prx: 'I@nginx:server',
- mon: 'I@prometheus:server and not I@influxdb:server',
- log: 'I@kibana:server',
- mtr: 'I@influxdb:server',
- kvm: 'I@salt:control',
- cid: 'I@docker:host and not I@prometheus:server and not I@kubernetes:*',
- ntw: 'I@opencontrail:database',
- ceph_mon: 'I@ceph:mon',
- ceph_osd: 'I@ceph:osd',
- k8-ctl: 'I@etcd:server',
- k8-cmp: 'I@kubernetes:* and not I@etcd:*',
- cfg: 'I@salt:master',
- gtw: 'I@neutron:gateway'
-}
+groups:
+ cmp: 'I@nova:compute'
+ ctl: 'I@keystone:server'
+ msg: 'I@rabbitmq:server'
+ dbs: 'I@galera:*'
+ prx: 'I@nginx:server'
+ mon: 'I@prometheus:server and not I@influxdb:server'
+ log: 'I@kibana:server'
+ mtr: 'I@influxdb:server'
+ kvm: 'I@salt:control'
+ cid: 'I@docker:host and not I@prometheus:server and not I@kubernetes:*'
+ ntw: 'I@opencontrail:database'
+ ceph_mon: 'I@ceph:mon'
+ ceph_osd: 'I@ceph:osd'
+ k8-ctl: 'I@etcd:server'
+ k8-cmp: 'I@kubernetes:* and not I@etcd:*'
+ cfg: 'I@salt:master'
+ gtw: 'I@neutron:gateway'
# mtu test setting
# this test may skip groups (see example)
test_mtu:
- { #"skipped_groups": ["dbs"]
- "skipped_ifaces": ["bonding_masters", "lo", "veth", "tap", "cali", "qv", "qb", "br-int",
- "vxlan", "virbr0", "virbr0-nic", "docker0", "o-hm0", "vnet"]}
+ skipped_groups: []
+ skipped_ifaces:
+ - bonding_masters
+ - lo
+ - veth
+ - tap
+ - cali
+ - qv
+ - qb
+ - br-int
+ - vxlan
+ - virbr0
+ - virbr0-nic
+ - docker0
+ - o-hm0
+ - vnet
# mask for interfaces to skip
# test duplicate ips
# do not comment this section
test_duplicate_ips:
- {
- "skipped_ifaces": ["lo", "virbr0", "docker_gwbridge", "docker0"]}
+ skipped_ifaces:
+ - lo
+ - virbr0
+ - docker_gwbridge
+ - docker0
# packages test 'test_packages_are_latest' setting
# this can skip scecial packages
# True value for 'skip_test' will skip this test. Set False to run the test.
# TODO: remove default False value when prod env is fixed
test_packages:
- { # "skipped_packages": ["update-notifier-common", "wget"]
- "skipped_packages": [""],
- "skip_test": True
- }
+ skipped_packages: []
+ skip_test: 'true'
# specify what mcp version (tag) is deployed
drivetrain_version: ''
@@ -91,13 +104,13 @@
# ntp test setting
# this test may skip specific node (use fqdn)
-ntp_skipped_nodes: [""]
+ntp_skipped_nodes: []
# packages need to skip in
# test_check_package_versions
-skipped_packages: [""]
+skipped_packages: []
# test_check_module_versions
-skipped_modules: [""]
+skipped_modules: []
# test_check_services
-skipped_services: [""]
+skipped_services: []
diff --git a/test_set/cvp-sanity/tests/test_packet_checker.py b/test_set/cvp-sanity/tests/test_packet_checker.py
index c132294..40c7bd7 100644
--- a/test_set/cvp-sanity/tests/test_packet_checker.py
+++ b/test_set/cvp-sanity/tests/test_packet_checker.py
@@ -93,7 +93,7 @@
def test_packages_are_latest(local_salt_client, nodes_in_group):
config = utils.get_configuration()
skip = config.get("test_packages")["skip_test"]
- if skip:
+ if skip.lower() == 'true':
pytest.skip("Test for the latest packages is disabled")
skipped_pkg = config.get("test_packages")["skipped_packages"]
group, nodes = nodes_in_group
diff --git a/test_set/cvp-sanity/utils/__init__.py b/test_set/cvp-sanity/utils/__init__.py
index 2ee6704..bcdf01f 100644
--- a/test_set/cvp-sanity/utils/__init__.py
+++ b/test_set/cvp-sanity/utils/__init__.py
@@ -5,7 +5,6 @@
import sys, traceback
import time
import json
-import pytest
import logging
@@ -198,6 +197,7 @@
os.path.dirname(os.path.abspath(__file__)), "../global_config.yaml")
with open(global_config_file, 'r') as file:
global_config = yaml.load(file, Loader=yaml.SafeLoader)
+
for param in global_config.keys():
if param in os.environ.keys():
if ',' in os.environ[param]:
@@ -207,4 +207,19 @@
else:
global_config[param] = os.environ[param]
+ if 'OVERRIDE_CONFIG' in os.environ.keys():
+ try:
+ override_config = yaml.load(
+ os.environ['OVERRIDE_CONFIG'], Loader=yaml.SafeLoader)\
+ .get('override_config')
+ if override_config:
+ for key in override_config:
+ if isinstance(global_config[key], dict):
+ for k in override_config[key]:
+ global_config[key][k] = override_config[key][k]
+ else:
+ global_config[key] = override_config[key]
+ except Exception:
+ pass
+
return global_config