Fix dynamic layout with regex approval filters
In case the layout includes some regex approval filters (like
username) the dynamic layout creation fails during deepcopy of the
pipelines [1]. This is caused by Github/GerritApprovalFilter overwriting
stuff in the original data structure. Fix this by using the already
existing deepcopied data structures.
To test this an unused pipeline with approval filters for Github and
Gerrit is added to the dynamic layout test cases. This triggers the
deepcopy error without the fix in every test_dynamic_* test case.
[1] Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/zuul/manager/__init__.py", line 453, in _loadDynamicLayout
include_config_projects=False)
File "/usr/lib/python3.6/site-packages/zuul/configloader.py", line 1478, in createDynamicLayout
config = tenant.config_projects_config.copy()
File "/usr/lib/python3.6/site-packages/zuul/model.py", line 2150, in copy
r.pipelines = copy.deepcopy(self.pipelines)
File "/usr/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
...
File "/usr/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python3.6/copy.py", line 161, in deepcopy
y = copier(memo)
TypeError: cannot deepcopy this pattern object
Change-Id: I4f7f74787aa91e938d0e2f07bd15b4e21d49cb88
diff --git a/tests/fixtures/config/in-repo/git/common-config/zuul.yaml b/tests/fixtures/config/in-repo/git/common-config/zuul.yaml
index d4ffad6..bfd6199 100644
--- a/tests/fixtures/config/in-repo/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/in-repo/git/common-config/zuul.yaml
@@ -52,6 +52,23 @@
Verified: 0
precedence: high
+# This pipeline is there to ensure that dynamic pipeline copy operations also
+# work with regex approval filters.
+- pipeline:
+ name: pipeline-with-regex
+ manager: independent
+ require:
+ gerrit:
+ approval:
+ - Code-Review: 2
+ username: maintainer
+ require:
+ github:
+ review:
+ - username: '^(herp|derp)$'
+ type: approved
+ trigger: {}
+
- job:
name: common-config-test
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index e52eea9..5dd3f4e 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -5293,6 +5293,7 @@
class TestSemaphoreInRepo(ZuulTestCase):
+ config_file = 'zuul-connections-gerrit-and-github.conf'
tenant_config_file = 'config/in-repo/main.yaml'
def test_semaphore_in_repo(self):
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 7dcb4ae..aa091e5 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -70,6 +70,7 @@
class TestInRepoConfig(ZuulTestCase):
# A temporary class to hold new tests while others are disabled
+ config_file = 'zuul-connections-gerrit-and-github.conf'
tenant_config_file = 'config/in-repo/main.yaml'
def test_in_repo_config(self):
@@ -712,6 +713,7 @@
# sure we exercise that code, in this test we allow Zuul to create
# keys for the project on startup.
create_project_keys = True
+ config_file = 'zuul-connections-gerrit-and-github.conf'
tenant_config_file = 'config/in-repo/main.yaml'
def test_key_generation(self):