Re-enable requirement status tests
Enable a couple of the basic state requirement tests together. These are
really simple and it doesn't seem like they really each need there own
tests classes.
Change-Id: Iee2293ccc1b7fb0cd5fc3ab0d373b3cd600aed3c
diff --git a/tests/fixtures/config/requirements/state/git/common-config/zuul.yaml b/tests/fixtures/config/requirements/state/git/common-config/zuul.yaml
new file mode 100644
index 0000000..9491bff
--- /dev/null
+++ b/tests/fixtures/config/requirements/state/git/common-config/zuul.yaml
@@ -0,0 +1,74 @@
+- pipeline:
+ name: current-check
+ manager: independent
+ source:
+ gerrit
+ require:
+ current-patchset: True
+ trigger:
+ gerrit:
+ - event: patchset-created
+ - event: comment-added
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+
+- pipeline:
+ name: open-check
+ manager: independent
+ source:
+ gerrit
+ require:
+ open: True
+ trigger:
+ gerrit:
+ - event: patchset-created
+ - event: comment-added
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+
+- pipeline:
+ name: status-check
+ manager: independent
+ source:
+ gerrit
+ require:
+ status: NEW
+ trigger:
+ gerrit:
+ - event: patchset-created
+ - event: comment-added
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+
+- job:
+ name: project-job
+
+- project:
+ name: current-project
+ current-check:
+ jobs:
+ - project-job
+
+- project:
+ name: open-project
+ open-check:
+ jobs:
+ - project-job
+
+- project:
+ name: status-project
+ status-check:
+ jobs:
+ - project-job
diff --git a/tests/fixtures/config/requirements/state/git/current-project/README b/tests/fixtures/config/requirements/state/git/current-project/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/requirements/state/git/current-project/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/requirements/state/git/open-project/README b/tests/fixtures/config/requirements/state/git/open-project/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/requirements/state/git/open-project/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/requirements/state/git/status-project/README b/tests/fixtures/config/requirements/state/git/status-project/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/requirements/state/git/status-project/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/requirements/state/main.yaml b/tests/fixtures/config/requirements/state/main.yaml
new file mode 100644
index 0000000..a22ed5c
--- /dev/null
+++ b/tests/fixtures/config/requirements/state/main.yaml
@@ -0,0 +1,6 @@
+- tenant:
+ name: tenant-one
+ source:
+ gerrit:
+ config-repos:
+ - common-config
diff --git a/tests/fixtures/layout-requirement-current-patchset.yaml b/tests/fixtures/layout-requirement-current-patchset.yaml
deleted file mode 100644
index 405077e..0000000
--- a/tests/fixtures/layout-requirement-current-patchset.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-pipelines:
- - name: check
- manager: IndependentPipelineManager
- require:
- current-patchset: True
- trigger:
- gerrit:
- - event: patchset-created
- - event: comment-added
- success:
- gerrit:
- verified: 1
- failure:
- gerrit:
- verified: -1
-
-projects:
- - name: org/project
- check:
- - project-check
diff --git a/tests/fixtures/layout-requirement-open.yaml b/tests/fixtures/layout-requirement-open.yaml
deleted file mode 100644
index e62719d..0000000
--- a/tests/fixtures/layout-requirement-open.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-pipelines:
- - name: check
- manager: IndependentPipelineManager
- require:
- open: True
- trigger:
- gerrit:
- - event: patchset-created
- - event: comment-added
- success:
- gerrit:
- verified: 1
- failure:
- gerrit:
- verified: -1
-
-projects:
- - name: org/project
- check:
- - project-check
diff --git a/tests/fixtures/layout-requirement-status.yaml b/tests/fixtures/layout-requirement-status.yaml
deleted file mode 100644
index af33468..0000000
--- a/tests/fixtures/layout-requirement-status.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-pipelines:
- - name: check
- manager: IndependentPipelineManager
- require:
- status: NEW
- trigger:
- gerrit:
- - event: patchset-created
- - event: comment-added
- success:
- gerrit:
- verified: 1
- failure:
- gerrit:
- verified: -1
-
-projects:
- - name: org/project
- check:
- - project-check
diff --git a/tests/test_requirements.py b/tests/test_requirements.py
index 1c61aa1..f2bdece 100644
--- a/tests/test_requirements.py
+++ b/tests/test_requirements.py
@@ -264,26 +264,20 @@
self.assertEqual(self.history[1].name, job)
-class TestRequirements(ZuulTestCase):
- """Test pipeline and trigger requirements"""
+class TestRequirementsState(ZuulTestCase):
+ """Requirements with simple state requirement"""
- tenant_config_file = 'config/requirements/main.yaml'
+ tenant_config_file = 'config/requirements/state/main.yaml'
- @skip("Disabled for early v3 development")
def test_pipeline_require_current_patchset(self):
- "Test pipeline requirement: current-patchset"
- self.updateConfigLayout(
- 'tests/fixtures/layout-requirement-current-patchset.yaml')
- self.sched.reconfigure(self.config)
- self.registerJobs()
# Create two patchsets and let their tests settle out. Then
# comment on first patchset and check that no additional
# jobs are run.
- A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
- self.fake_gerrit.addEvent(A.addApproval('CRVW', 1))
+ A = self.fake_gerrit.addFakeChange('current-project', 'master', 'A')
+ self.fake_gerrit.addEvent(A.addApproval('code-review', 1))
self.waitUntilSettled()
A.addPatchset()
- self.fake_gerrit.addEvent(A.addApproval('CRVW', 1))
+ self.fake_gerrit.addEvent(A.addApproval('code-review', 1))
self.waitUntilSettled()
self.assertEqual(len(self.history), 2) # one job for each ps
@@ -298,44 +292,36 @@
self.waitUntilSettled()
self.assertEqual(len(self.history), 3)
- @skip("Disabled for early v3 development")
def test_pipeline_require_open(self):
- "Test pipeline requirement: open"
- self.updateConfigLayout(
- 'tests/fixtures/layout-requirement-open.yaml')
- self.sched.reconfigure(self.config)
- self.registerJobs()
-
- A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+ A = self.fake_gerrit.addFakeChange('open-project', 'master', 'A',
status='MERGED')
- self.fake_gerrit.addEvent(A.addApproval('CRVW', 2))
+ self.fake_gerrit.addEvent(A.addApproval('code-review', 2))
self.waitUntilSettled()
self.assertEqual(len(self.history), 0)
- B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
- self.fake_gerrit.addEvent(B.addApproval('CRVW', 2))
+ B = self.fake_gerrit.addFakeChange('open-project', 'master', 'B')
+ self.fake_gerrit.addEvent(B.addApproval('code-review', 2))
self.waitUntilSettled()
self.assertEqual(len(self.history), 1)
- @skip("Disabled for early v3 development")
def test_pipeline_require_status(self):
- "Test pipeline requirement: status"
- self.updateConfigLayout(
- 'tests/fixtures/layout-requirement-status.yaml')
- self.sched.reconfigure(self.config)
- self.registerJobs()
-
- A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+ A = self.fake_gerrit.addFakeChange('status-project', 'master', 'A',
status='MERGED')
- self.fake_gerrit.addEvent(A.addApproval('CRVW', 2))
+ self.fake_gerrit.addEvent(A.addApproval('code-review', 2))
self.waitUntilSettled()
self.assertEqual(len(self.history), 0)
- B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
- self.fake_gerrit.addEvent(B.addApproval('CRVW', 2))
+ B = self.fake_gerrit.addFakeChange('status-project', 'master', 'B')
+ self.fake_gerrit.addEvent(B.addApproval('code-review', 2))
self.waitUntilSettled()
self.assertEqual(len(self.history), 1)
+
+class TestRequirements(ZuulTestCase):
+ """Test pipeline and trigger requirements"""
+
+ tenant_config_file = 'config/requirements/main.yaml'
+
def _test_require_reject_username(self, project, job):
"Test negative username's match"
# Should only trigger if Jenkins hasn't voted.