We need to be able to use grenade to upgrade services within a release instead of upgrading services across releases. This will allow us to test the nova baremetal to ironic upgrade path and the nova network to neutron upgrade path. To do this refactor the DEVSTACK_GATE_GRENADE* variables. Condense them down to a single DEVSTACK_GATE_GRENADE variable that has more than just 0 and 1 binary states. This variable will state which type of grenade test to do and handle that within devstack gate. This change is backward and forward compatible for DEVSTACK_GATE_GRENADE=1 and DEVSTACK_GATE_GRENADE_PARTIAL_NCPU=1 in order to get this change through the gate without manual merging. Change-Id: I4f102e27b422a5260cd0d5e40e00a5addf87911a
150 lines
4.8 KiB
Python
Executable File
150 lines
4.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
#
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
import sys
|
|
import yaml
|
|
|
|
GRID = None
|
|
ALLOWED_BRANCHES = []
|
|
FALSE_VALUES = [None, '', '0', 'false', 'False', 'FALSE']
|
|
|
|
FORMAT = '%(asctime)s %(levelname)s: %(message)s'
|
|
logging.basicConfig(format=FORMAT)
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
def parse_features(fname):
|
|
with open(fname) as f:
|
|
return yaml.load(f)
|
|
|
|
|
|
def normalize_branch(branch):
|
|
if branch.startswith("feature/"):
|
|
# Feature branches chase master and should be tested
|
|
# as if they were the master branch.
|
|
branch = GRID['branches']['default']
|
|
elif branch.startswith("stable/"):
|
|
branch = branch[len("stable/"):]
|
|
elif branch.startswith("proposed/"):
|
|
branch = branch[len("proposed/"):]
|
|
for allowed in GRID['branches']['allowed']:
|
|
# If the branch name starts with one of our known
|
|
# named integrated release names treat that branch
|
|
# as belonging to the integrated release. This means
|
|
# proposed/foo* will be treated as the foo release.
|
|
if branch.startswith(allowed):
|
|
branch = allowed
|
|
break
|
|
else:
|
|
# Releases that are not named integreated releases
|
|
# should be tested as if they were the master branch
|
|
# as they occur between integrated releases when other
|
|
# projects are developing master.
|
|
branch = GRID['branches']['default']
|
|
if branch not in ALLOWED_BRANCHES:
|
|
LOG.error("unknown branch name %s" % branch)
|
|
sys.exit(1)
|
|
return branch
|
|
|
|
|
|
def configs_from_env():
|
|
configs = []
|
|
for k, v in os.environ.iteritems():
|
|
if k.startswith('DEVSTACK_GATE_'):
|
|
if v not in FALSE_VALUES:
|
|
f = k.split('DEVSTACK_GATE_')[1]
|
|
configs.append(f.lower())
|
|
return configs
|
|
|
|
|
|
def calc_services(branch, features):
|
|
services = set()
|
|
for feature in features:
|
|
services.update(GRID['features'][feature]['base'].get('services', []))
|
|
if branch in GRID['features'][feature]:
|
|
services.update(
|
|
GRID['features'][feature][branch].get('services', []))
|
|
|
|
# deletes always trump adds
|
|
for feature in features:
|
|
services.difference_update(
|
|
GRID['features'][feature]['base'].get('rm-services', []))
|
|
|
|
if branch in GRID['features'][feature]:
|
|
services.difference_update(
|
|
GRID['features'][feature][branch].get('rm-services', []))
|
|
return sorted(list(services))
|
|
|
|
|
|
def calc_features(branch, configs=[]):
|
|
LOG.debug("Branch: %s" % branch)
|
|
LOG.debug("Configs: %s" % configs)
|
|
features = set(GRID['config']['default'][branch])
|
|
# do all the adds first
|
|
for config in configs:
|
|
if config in GRID['config']:
|
|
features.update(GRID['config'][config].get('features', []))
|
|
|
|
# removes always trump
|
|
for config in configs:
|
|
if config in GRID['config']:
|
|
features.difference_update(
|
|
GRID['config'][config].get('rm-features', []))
|
|
return sorted(list(features))
|
|
|
|
|
|
def get_opts():
|
|
usage = """
|
|
Compute the test matrix for devstack gate jobs from a combination
|
|
of environmental feature definitions and flags.
|
|
"""
|
|
parser = argparse.ArgumentParser(description=usage)
|
|
parser.add_argument('-f', '--features',
|
|
default='features.yaml',
|
|
help="Yaml file describing the features matrix")
|
|
parser.add_argument('-b', '--branch',
|
|
default="master",
|
|
help="Branch to compute the matrix for")
|
|
parser.add_argument('-m', '--mode',
|
|
default="services",
|
|
help="What to return (services, compute-ext)")
|
|
return parser.parse_args()
|
|
|
|
|
|
def main():
|
|
global GRID
|
|
global ALLOWED_BRANCHES
|
|
opts = get_opts()
|
|
GRID = parse_features(opts.features)
|
|
ALLOWED_BRANCHES = GRID['branches']['allowed']
|
|
branch = normalize_branch(opts.branch)
|
|
|
|
features = calc_features(branch, configs_from_env())
|
|
LOG.debug("Features: %s " % features)
|
|
|
|
services = calc_services(branch, features)
|
|
LOG.debug("Services: %s " % services)
|
|
|
|
if opts.mode == "services":
|
|
print ",".join(services)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|