Automatically provide 'name' to project templates
Provide the short name of a project (anything after the last '/') to
project templates as the variable 'name'. If 'openstack/nova' invoked
a template, the variable 'name' would automatically be set to 'nova'
within the template.
Ideally this means that most template invocations in OpenStack's layout
will not need any variables defined.
Change-Id: I596744917c30c92041b8ea5b1f518d50fb64e59b
diff --git a/tests/fixtures/layout.yaml b/tests/fixtures/layout.yaml
index 2e113c2..98dfe86 100644
--- a/tests/fixtures/layout.yaml
+++ b/tests/fixtures/layout.yaml
@@ -112,14 +112,14 @@
- '{projectname}-test2'
- name: test-three-and-four
check:
- - '{projectname}-test3'
- - '{projectname}-test4'
+ - '{name}-test3'
+ - '{name}-test4'
- name: test-five
check:
- - '{projectname}-test5'
+ - '{name}-{something}-test5'
- name: test-five-also
check:
- - '{projectname}-test5'
+ - '{name}-{something}-test5'
projects:
- name: org/project
@@ -213,11 +213,10 @@
- name: test-one-and-two
projectname: project
- name: test-three-and-four
- projectname: project
- name: test-five
- projectname: project
+ something: foo
- name: test-five-also
- projectname: project
+ something: foo
check:
- project-test6
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 8fb8419..48f2281 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -1971,14 +1971,14 @@
'SUCCESS')
self.assertEqual(self.getJobFromHistory('project-test2').result,
'SUCCESS')
- self.assertEqual(self.getJobFromHistory('project-test3').result,
- 'SUCCESS')
- self.assertEqual(self.getJobFromHistory('project-test4').result,
- 'SUCCESS')
- # project-test5 should run twice because two templates define it
+ self.assertEqual(self.getJobFromHistory('layered-project-test3'
+ ).result, 'SUCCESS')
+ self.assertEqual(self.getJobFromHistory('layered-project-test4'
+ ).result, 'SUCCESS')
+ # test5 should run twice because two templates define it
test5_count = 0
for job in self.worker.build_history:
- if job.name == 'project-test5':
+ if job.name == 'layered-project-foo-test5':
test5_count += 1
self.assertEqual(job.result, 'SUCCESS')
self.assertEqual(test5_count, 2)