Browse code

Merge "Add the project under test to LIBS_FROM_GIT"

Zuul authored on 2018/06/25 17:30:02
Showing 4 changed files
... ...
@@ -22,11 +22,12 @@ Write the local.conf file for use by devstack
22 22
 
23 23
    As a special case, the variable ``LIBS_FROM_GIT`` will be
24 24
    constructed automatically from the projects which appear in the
25
-   ``required-projects`` list defined by the job.  To instruct
26
-   devstack to install a library from source rather than pypi, simply
27
-   add that library to the job's ``required-projects`` list.  To
28
-   override the automatically-generated value, set ``LIBS_FROM_GIT``
29
-   in ``devstack_localrc`` to the desired value.
25
+   ``required-projects`` list defined by the job plus the project of
26
+   the change under test.  To instruct devstack to install a library
27
+   from source rather than pypi, simply add that library to the job's
28
+   ``required-projects`` list.  To override the
29
+   automatically-generated value, set ``LIBS_FROM_GIT`` in
30
+   ``devstack_localrc`` to the desired value.
30 31
 
31 32
 .. zuul:rolevar:: devstack_local_conf
32 33
    :type: dict
... ...
@@ -207,12 +207,13 @@ class PluginGraph(DependencyGraph):
207 207
 class LocalConf(object):
208 208
 
209 209
     def __init__(self, localrc, localconf, base_services, services, plugins,
210
-                 base_dir, projects):
210
+                 base_dir, projects, project):
211 211
         self.localrc = []
212 212
         self.meta_sections = {}
213 213
         self.plugin_deps = {}
214 214
         self.base_dir = base_dir
215 215
         self.projects = projects
216
+        self.project = project
216 217
         if plugins:
217 218
             self.handle_plugins(plugins)
218 219
         if services or base_services:
... ...
@@ -249,11 +250,15 @@ class LocalConf(object):
249 249
                 if k == 'LIBS_FROM_GIT':
250 250
                     lfg = True
251 251
 
252
-        if not lfg and self.projects:
252
+        if not lfg and (self.projects or self.project):
253 253
             required_projects = []
254
-            for project_name, project_info in self.projects.items():
255
-                if project_info.get('required'):
256
-                    required_projects.append(project_info['short_name'])
254
+            if self.projects:
255
+                for project_name, project_info in self.projects.items():
256
+                    if project_info.get('required'):
257
+                        required_projects.append(project_info['short_name'])
258
+            if self.project:
259
+                if self.project['short_name'] not in required_projects:
260
+                    required_projects.append(self.project['short_name'])
257 261
             if required_projects:
258 262
                 self.localrc.append('LIBS_FROM_GIT={}'.format(
259 263
                     ','.join(required_projects)))
... ...
@@ -291,6 +296,7 @@ def main():
291 291
             base_dir=dict(type='path'),
292 292
             path=dict(type='str'),
293 293
             projects=dict(type='dict'),
294
+            project=dict(type='dict'),
294 295
         )
295 296
     )
296 297
 
... ...
@@ -301,7 +307,8 @@ def main():
301 301
                    p.get('services'),
302 302
                    p.get('plugins'),
303 303
                    p.get('base_dir'),
304
-                   p.get('projects'))
304
+                   p.get('projects'),
305
+                   p.get('project'))
305 306
     lc.write(p['path'])
306 307
 
307 308
     module.exit_json()
... ...
@@ -57,7 +57,8 @@ class TestDevstackLocalConf(unittest.TestCase):
57 57
                        p.get('services'),
58 58
                        p.get('plugins'),
59 59
                        p.get('base_dir'),
60
-                       p.get('projects'))
60
+                       p.get('projects'),
61
+                       p.get('project'))
61 62
         lc.write(p['path'])
62 63
 
63 64
         plugins = []
... ...
@@ -120,17 +121,22 @@ class TestDevstackLocalConf(unittest.TestCase):
120 120
                 'short_name': 'devstack-plugin',
121 121
             },
122 122
         }
123
+        project = {
124
+            'short_name': 'glance',
125
+        }
123 126
         p = dict(base_services=[],
124 127
                  base_dir='./test',
125 128
                  path=os.path.join(self.tmpdir, 'test.local.conf'),
126
-                 projects=projects)
129
+                 projects=projects,
130
+                 project=project)
127 131
         lc = LocalConf(p.get('localrc'),
128 132
                        p.get('local_conf'),
129 133
                        p.get('base_services'),
130 134
                        p.get('services'),
131 135
                        p.get('plugins'),
132 136
                        p.get('base_dir'),
133
-                       p.get('projects'))
137
+                       p.get('projects'),
138
+                       p.get('project'))
134 139
         lc.write(p['path'])
135 140
 
136 141
         lfg = None
... ...
@@ -138,7 +144,7 @@ class TestDevstackLocalConf(unittest.TestCase):
138 138
             for line in f:
139 139
                 if line.startswith('LIBS_FROM_GIT'):
140 140
                     lfg = line.strip().split('=')[1]
141
-        self.assertEqual('nova,oslo.messaging', lfg)
141
+        self.assertEqual('nova,oslo.messaging,glance', lfg)
142 142
 
143 143
     def test_overridelibs_from_git(self):
144 144
         "Test that LIBS_FROM_GIT can be overridden"
... ...
@@ -168,7 +174,8 @@ class TestDevstackLocalConf(unittest.TestCase):
168 168
                        p.get('services'),
169 169
                        p.get('plugins'),
170 170
                        p.get('base_dir'),
171
-                       p.get('projects'))
171
+                       p.get('projects'),
172
+                       p.get('project'))
172 173
         lc.write(p['path'])
173 174
 
174 175
         lfg = None
... ...
@@ -10,3 +10,4 @@
10 10
     local_conf: "{{ devstack_local_conf|default(omit) }}"
11 11
     base_dir: "{{ devstack_base_dir|default(omit) }}"
12 12
     projects: "{{ zuul.projects }}"
13
+    project: "{{ zuul.project }}"
13 14
\ No newline at end of file