Re-enable test_tags

* Refactor of layout-tags.yaml to single-tenant layout config dir.
* Build tags now added as ansible vars rather than env vars.
* Removes old layout config and custom add_tags function.

Change-Id: I1edfa505df7c9cc1a212f9483fe50ac088f1174e
Signed-off-by: Cullen Taylor <cullentaylor@outlook.com>
diff --git a/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/integration.yaml b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/integration.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/integration.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+  tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/merge.yaml b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/merge.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/merge.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+  tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test1.yaml b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test1.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test1.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+  tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test2.yaml b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test2.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-tags/playbooks/test2.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+  tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-tags/zuul.yaml b/tests/fixtures/config/single-tenant/git/layout-tags/zuul.yaml
new file mode 100644
index 0000000..c921c90
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-tags/zuul.yaml
@@ -0,0 +1,52 @@
+- pipeline:
+    name: check
+    manager: independent
+    source:
+      gerrit
+    trigger:
+      gerrit:
+        - event: patchset-created
+    success:
+      gerrit:
+        verified: 1
+    failure:
+      gerrit:
+        verified: -1
+
+- job:
+    name: merge
+    failure-message: Unable to merge change
+    hold-following-changes: true
+    tags:
+      - merge
+
+- job:
+    name: test1
+
+- job:
+    name: test2
+
+- job:
+    name: integration
+
+- project:
+    name: org/project1
+    check:
+      jobs:
+        - merge:
+            jobs:
+              - test1
+              - test2
+              - integration
+            tags:
+              - extratag
+
+- project:
+    name: org/project2
+    check:
+      jobs:
+        - merge:
+            jobs:
+              - test1
+              - test2
+              - integration
diff --git a/tests/fixtures/layout-tags.yaml b/tests/fixtures/layout-tags.yaml
deleted file mode 100644
index d5b8bf9..0000000
--- a/tests/fixtures/layout-tags.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-includes:
-  - python-file: tags_custom_functions.py
-
-pipelines:
-  - name: check
-    manager: IndependentPipelineManager
-    trigger:
-      gerrit:
-        - event: patchset-created
-    success:
-      gerrit:
-        verified: 1
-    failure:
-      gerrit:
-        verified: -1
-
-jobs:
-  - name: ^.*$
-    parameter-function: apply_tags
-  - name: ^.*-merge$
-    failure-message: Unable to merge change
-    hold-following-changes: true
-    tags: merge
-  - name: project1-merge
-    tags:
-      - project1
-      - extratag
-
-projects:
-  - name: org/project1
-    check:
-      - project1-merge:
-        - project1-test1
-        - project1-test2
-        - project1-project2-integration
-
-  - name: org/project2
-    check:
-      - project2-merge:
-        - project2-test1
-        - project2-test2
-        - project1-project2-integration
diff --git a/tests/fixtures/tags_custom_functions.py b/tests/fixtures/tags_custom_functions.py
deleted file mode 100644
index 67e7ef1..0000000
--- a/tests/fixtures/tags_custom_functions.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def apply_tags(item, job, params):
-    params['BUILD_TAGS'] = ' '.join(sorted(job.tags))
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 45b2257..d44369b 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -2750,11 +2750,9 @@
         self.assertEqual(B.data['status'], 'MERGED')
         self.assertEqual(B.reported, 2)
 
-    @skip("Disabled for early v3 development")
     def test_tags(self):
         "Test job tags"
-        self.config.set('zuul', 'layout_config',
-                        'tests/fixtures/layout-tags.yaml')
+        self.updateConfigLayout('layout-tags')
         self.sched.reconfigure(self.config)
 
         A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
@@ -2763,12 +2761,16 @@
         self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
         self.waitUntilSettled()
 
-        results = {'project1-merge': 'extratag merge project1',
-                   'project2-merge': 'merge'}
+        self.assertEqual(len(self.history), 8)
+
+        results = {self.getJobFromHistory('merge',
+                   project='org/project1').uuid: 'extratag merge',
+                   self.getJobFromHistory('merge',
+                   project='org/project2').uuid: 'merge'}
 
         for build in self.history:
-            self.assertEqual(results.get(build.name, ''),
-                             build.parameters.get('BUILD_TAGS'))
+            self.assertEqual(results.get(build.uuid, ''),
+                             build.parameters['vars']['zuul'].get('tags'))
 
     def test_timer(self):
         "Test that a periodic job is triggered"