Fully qualify project configuration names
The layout stores the configuration of a project in the ProjectConfig
class (not the Project class -- that represents the abstract idea
of a project independent of Zuul, the ProjectConfig represents a
particular Zuul configuration operating on that project). Therefore,
in the continuing effort to fully qualify project names, index
ProjectConfig objects by their canonical project name. Use that
name when looking for a ProjectConfig to find the jobs to run for
a given change.
Story: 2000953
Change-Id: I733a66369c969770e57c2fa8b30822bd15e1aca7
diff --git a/tests/base.py b/tests/base.py
index 16332bf..78b2ea0 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1927,7 +1927,9 @@
def getPipeline(self, name):
return self.sched.abide.tenants.values()[0].layout.pipelines.get(name)
- def updateConfigLayout(self, path):
+ def updateConfigLayout(self, path, project_repos=None):
+ if project_repos is None:
+ project_repos = []
root = os.path.join(self.test_root, "config")
if not os.path.exists(root):
os.makedirs(root)
@@ -1939,7 +1941,26 @@
gerrit:
config-repos:
- %s
- """ % path)
+ project-repos:
+ - org/project
+ - org/project1
+ - org/project2
+ - org/project3
+ - org/project4
+ - org/project5
+ - org/project6
+ - org/one-job-project
+ - org/nonvoting-project
+ - org/templated-project
+ - org/layered-project
+ - org/node-project
+ - org/conflict-project
+ - org/noop-project
+ - org/experimental-project
+ - org/no-jobs-project\n""" % path)
+
+ for repo in project_repos:
+ f.write(" - %s\n" % repo)
f.close()
self.config.set('zuul', 'tenant_config',
os.path.join(FIXTURE_DIR, f.name))
diff --git a/tests/fixtures/config/duplicate-pipeline/main.yaml b/tests/fixtures/config/duplicate-pipeline/main.yaml
index ba2d8f5..5e1bc6e 100755
--- a/tests/fixtures/config/duplicate-pipeline/main.yaml
+++ b/tests/fixtures/config/duplicate-pipeline/main.yaml
@@ -4,3 +4,5 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project
diff --git a/tests/fixtures/config/merges/main.yaml b/tests/fixtures/config/merges/main.yaml
index a22ed5c..039706f 100644
--- a/tests/fixtures/config/merges/main.yaml
+++ b/tests/fixtures/config/merges/main.yaml
@@ -4,3 +4,9 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project-cherry-pick
+ - org/project-merge
+ - org/project-merge-branches
+ - org/project-merge-resolve
+
diff --git a/tests/fixtures/config/multi-tenant-semaphore/main.yaml b/tests/fixtures/config/multi-tenant-semaphore/main.yaml
index b1c47b1..7e05d13 100644
--- a/tests/fixtures/config/multi-tenant-semaphore/main.yaml
+++ b/tests/fixtures/config/multi-tenant-semaphore/main.yaml
@@ -5,6 +5,9 @@
config-repos:
- common-config
- tenant-one-config
+ project-repos:
+ - org/project1
+ - org/project2
- tenant:
name: tenant-two
@@ -13,3 +16,6 @@
config-repos:
- common-config
- tenant-two-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/multi-tenant/main.yaml b/tests/fixtures/config/multi-tenant/main.yaml
index b1c47b1..4ce2510 100644
--- a/tests/fixtures/config/multi-tenant/main.yaml
+++ b/tests/fixtures/config/multi-tenant/main.yaml
@@ -5,6 +5,8 @@
config-repos:
- common-config
- tenant-one-config
+ project-repos:
+ - org/project1
- tenant:
name: tenant-two
@@ -13,3 +15,5 @@
config-repos:
- common-config
- tenant-two-config
+ project-repos:
+ - org/project2
diff --git a/tests/fixtures/config/one-job-project/main.yaml b/tests/fixtures/config/one-job-project/main.yaml
index a22ed5c..2211390 100644
--- a/tests/fixtures/config/one-job-project/main.yaml
+++ b/tests/fixtures/config/one-job-project/main.yaml
@@ -4,3 +4,5 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/one-job-project
diff --git a/tests/fixtures/config/openstack/main.yaml b/tests/fixtures/config/openstack/main.yaml
index 95a0952..aa2615d 100644
--- a/tests/fixtures/config/openstack/main.yaml
+++ b/tests/fixtures/config/openstack/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- project-config
+ project-repos:
+ - openstack/nova
+ - openstack/keystone
\ No newline at end of file
diff --git a/tests/fixtures/config/requirements/email/main.yaml b/tests/fixtures/config/requirements/email/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/email/main.yaml
+++ b/tests/fixtures/config/requirements/email/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/newer-than/main.yaml b/tests/fixtures/config/requirements/newer-than/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/newer-than/main.yaml
+++ b/tests/fixtures/config/requirements/newer-than/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/older-than/main.yaml b/tests/fixtures/config/requirements/older-than/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/older-than/main.yaml
+++ b/tests/fixtures/config/requirements/older-than/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/reject-username/main.yaml b/tests/fixtures/config/requirements/reject-username/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/reject-username/main.yaml
+++ b/tests/fixtures/config/requirements/reject-username/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/reject/main.yaml b/tests/fixtures/config/requirements/reject/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/reject/main.yaml
+++ b/tests/fixtures/config/requirements/reject/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/state/main.yaml b/tests/fixtures/config/requirements/state/main.yaml
index a22ed5c..70af14b 100644
--- a/tests/fixtures/config/requirements/state/main.yaml
+++ b/tests/fixtures/config/requirements/state/main.yaml
@@ -4,3 +4,7 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - current-project
+ - open-project
+ - status-project
diff --git a/tests/fixtures/config/requirements/username/main.yaml b/tests/fixtures/config/requirements/username/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/username/main.yaml
+++ b/tests/fixtures/config/requirements/username/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/vote1/main.yaml b/tests/fixtures/config/requirements/vote1/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/vote1/main.yaml
+++ b/tests/fixtures/config/requirements/vote1/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/requirements/vote2/main.yaml b/tests/fixtures/config/requirements/vote2/main.yaml
index a22ed5c..c388705 100644
--- a/tests/fixtures/config/requirements/vote2/main.yaml
+++ b/tests/fixtures/config/requirements/vote2/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ - org/project2
diff --git a/tests/fixtures/config/single-tenant/main.yaml b/tests/fixtures/config/single-tenant/main.yaml
index d9868fa..096e34e 100644
--- a/tests/fixtures/config/single-tenant/main.yaml
+++ b/tests/fixtures/config/single-tenant/main.yaml
@@ -6,3 +6,18 @@
- common-config
project-repos:
- org/project
+ - org/project1
+ - org/project2
+ - org/project3
+ - org/project4
+ - org/project5
+ - org/project6
+ - org/one-job-project
+ - org/nonvoting-project
+ - org/templated-project
+ - org/layered-project
+ - org/node-project
+ - org/conflict-project
+ - org/noop-project
+ - org/experimental-project
+ - org/no-jobs-project
diff --git a/tests/fixtures/config/success-url/main.yaml b/tests/fixtures/config/success-url/main.yaml
index a22ed5c..841f74d 100644
--- a/tests/fixtures/config/success-url/main.yaml
+++ b/tests/fixtures/config/success-url/main.yaml
@@ -4,3 +4,5 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/docs
diff --git a/tests/fixtures/config/templated-project/main.yaml b/tests/fixtures/config/templated-project/main.yaml
index a22ed5c..3b297a7 100644
--- a/tests/fixtures/config/templated-project/main.yaml
+++ b/tests/fixtures/config/templated-project/main.yaml
@@ -4,3 +4,6 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/templated-project
+ - org/layered-project
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml
index 302dfcf..8353732 100644
--- a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml
@@ -33,10 +33,13 @@
name: project-test2
- project:
- name: org/project1
+ name: review.example.com/org/project1
review_check:
jobs:
- project-test1
+
+- project:
+ name: another.example.com/org/project1
another_check:
jobs:
- project-test2
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
index 730cc7e..72e43f5 100644
--- a/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
@@ -4,3 +4,8 @@
review_gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project1
+ another_gerrit:
+ project-repos:
+ - org/project1
diff --git a/tests/fixtures/config/zuultrigger/parent-change-enqueued/main.yaml b/tests/fixtures/config/zuultrigger/parent-change-enqueued/main.yaml
index a22ed5c..d9868fa 100644
--- a/tests/fixtures/config/zuultrigger/parent-change-enqueued/main.yaml
+++ b/tests/fixtures/config/zuultrigger/parent-change-enqueued/main.yaml
@@ -4,3 +4,5 @@
gerrit:
config-repos:
- common-config
+ project-repos:
+ - org/project
diff --git a/tests/unit/test_model.py b/tests/unit/test_model.py
index a40054f..04b0e0a 100644
--- a/tests/unit/test_model.py
+++ b/tests/unit/test_model.py
@@ -165,6 +165,7 @@
layout.addPipeline(pipeline)
queue = model.ChangeQueue(pipeline)
project = model.Project('project', self.source)
+ tenant.addProjectRepo(project)
base = configloader.JobParser.fromYaml(tenant, layout, {
'_source_context': self.context,
@@ -431,6 +432,7 @@
def test_job_inheritance_job_tree(self):
tenant = model.Tenant('tenant')
layout = model.Layout()
+ tenant.addProjectRepo(self.project)
pipeline = model.Pipeline('gate', layout)
layout.addPipeline(pipeline)
@@ -511,6 +513,7 @@
layout.addPipeline(pipeline)
queue = model.ChangeQueue(pipeline)
project = model.Project('project', self.source)
+ tenant.addProjectRepo(project)
base = configloader.JobParser.fromYaml(tenant, layout, {
'_source_context': self.context,
@@ -591,6 +594,7 @@
self.layout.addJob(job)
project2 = model.Project('project2', self.source)
+ self.tenant.addProjectRepo(project2)
context2 = model.SourceContext(project2, 'master',
'test', True)
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 41e8463..e1d00f6 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -1498,8 +1498,8 @@
# https://bugs.executepad.net/zuul/+bug/1078946
# This test assumes the repo is already cloned; make sure it is
tenant = self.sched.abide.tenants.get('tenant-one')
- url = self.fake_gerrit.getGitUrl(
- tenant.layout.project_configs.get('org/project1'))
+ trusted, project = tenant.getProject('org/project1')
+ url = self.fake_gerrit.getGitUrl(project)
self.merge_server.merger.addProject('org/project1', url)
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
A.addPatchset(large=True)
@@ -2881,7 +2881,7 @@
self.assertEqual(A.reported, 2)
def test_repo_deleted(self):
- self.updateConfigLayout('layout-repo-deleted')
+ self.updateConfigLayout('layout-repo-deleted', ['org/delete-project'])
self.sched.reconfigure(self.config)
self.init_repo("org/delete-project")