Merge "Add the project under test to LIBS_FROM_GIT"

This commit is contained in:
Zuul 2018-06-25 08:30:02 +00:00 committed by Gerrit Code Review
commit d982367b5a
4 changed files with 32 additions and 16 deletions

View File

@ -22,11 +22,12 @@ Write the local.conf file for use by devstack
As a special case, the variable ``LIBS_FROM_GIT`` will be
constructed automatically from the projects which appear in the
``required-projects`` list defined by the job. To instruct
devstack to install a library from source rather than pypi, simply
add that library to the job's ``required-projects`` list. To
override the automatically-generated value, set ``LIBS_FROM_GIT``
in ``devstack_localrc`` to the desired value.
``required-projects`` list defined by the job plus the project of
the change under test. To instruct devstack to install a library
from source rather than pypi, simply add that library to the job's
``required-projects`` list. To override the
automatically-generated value, set ``LIBS_FROM_GIT`` in
``devstack_localrc`` to the desired value.
.. zuul:rolevar:: devstack_local_conf
:type: dict

View File

@ -207,12 +207,13 @@ class PluginGraph(DependencyGraph):
class LocalConf(object):
def __init__(self, localrc, localconf, base_services, services, plugins,
base_dir, projects):
base_dir, projects, project):
self.localrc = []
self.meta_sections = {}
self.plugin_deps = {}
self.base_dir = base_dir
self.projects = projects
self.project = project
if plugins:
self.handle_plugins(plugins)
if services or base_services:
@ -249,11 +250,15 @@ class LocalConf(object):
if k == 'LIBS_FROM_GIT':
lfg = True
if not lfg and self.projects:
if not lfg and (self.projects or self.project):
required_projects = []
for project_name, project_info in self.projects.items():
if project_info.get('required'):
required_projects.append(project_info['short_name'])
if self.projects:
for project_name, project_info in self.projects.items():
if project_info.get('required'):
required_projects.append(project_info['short_name'])
if self.project:
if self.project['short_name'] not in required_projects:
required_projects.append(self.project['short_name'])
if required_projects:
self.localrc.append('LIBS_FROM_GIT={}'.format(
','.join(required_projects)))
@ -291,6 +296,7 @@ def main():
base_dir=dict(type='path'),
path=dict(type='str'),
projects=dict(type='dict'),
project=dict(type='dict'),
)
)
@ -301,7 +307,8 @@ def main():
p.get('services'),
p.get('plugins'),
p.get('base_dir'),
p.get('projects'))
p.get('projects'),
p.get('project'))
lc.write(p['path'])
module.exit_json()

View File

@ -57,7 +57,8 @@ class TestDevstackLocalConf(unittest.TestCase):
p.get('services'),
p.get('plugins'),
p.get('base_dir'),
p.get('projects'))
p.get('projects'),
p.get('project'))
lc.write(p['path'])
plugins = []
@ -120,17 +121,22 @@ class TestDevstackLocalConf(unittest.TestCase):
'short_name': 'devstack-plugin',
},
}
project = {
'short_name': 'glance',
}
p = dict(base_services=[],
base_dir='./test',
path=os.path.join(self.tmpdir, 'test.local.conf'),
projects=projects)
projects=projects,
project=project)
lc = LocalConf(p.get('localrc'),
p.get('local_conf'),
p.get('base_services'),
p.get('services'),
p.get('plugins'),
p.get('base_dir'),
p.get('projects'))
p.get('projects'),
p.get('project'))
lc.write(p['path'])
lfg = None
@ -138,7 +144,7 @@ class TestDevstackLocalConf(unittest.TestCase):
for line in f:
if line.startswith('LIBS_FROM_GIT'):
lfg = line.strip().split('=')[1]
self.assertEqual('nova,oslo.messaging', lfg)
self.assertEqual('nova,oslo.messaging,glance', lfg)
def test_overridelibs_from_git(self):
"Test that LIBS_FROM_GIT can be overridden"
@ -168,7 +174,8 @@ class TestDevstackLocalConf(unittest.TestCase):
p.get('services'),
p.get('plugins'),
p.get('base_dir'),
p.get('projects'))
p.get('projects'),
p.get('project'))
lc.write(p['path'])
lfg = None

View File

@ -10,3 +10,4 @@
local_conf: "{{ devstack_local_conf|default(omit) }}"
base_dir: "{{ devstack_base_dir|default(omit) }}"
projects: "{{ zuul.projects }}"
project: "{{ zuul.project }}"