diff options
author | James E. Blair <jim@acmegating.com> | 2023-02-10 09:39:54 -0800 |
---|---|---|
committer | James E. Blair <jim@acmegating.com> | 2023-02-10 15:03:13 -0800 |
commit | fbddc72ec817051c3b616226d6fddd1eba6e7f11 (patch) | |
tree | 5ea63bef7c86c82eb1aacaf8bb18861bfb7996d1 | |
parent | 98dcd51d90972b0a2ba6c6993300158a6d5e7b2d (diff) | |
download | zuul-fbddc72ec817051c3b616226d6fddd1eba6e7f11.tar.gz |
Remove layout_uuid from PipelineState create call
This argument is no longer necessary because it is set via an inderect
route through the pipeline and tenant objects. Remove it, and also
validate that it is set correctly in unit tests.
Change-Id: I62ce18a61a416cbc397866838f8ac3b0ec1bd564
-rw-r--r-- | tests/unit/test_zk.py | 16 | ||||
-rw-r--r-- | zuul/manager/__init__.py | 2 | ||||
-rw-r--r-- | zuul/model.py | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/tests/unit/test_zk.py b/tests/unit/test_zk.py index f5c1fd4c4..b5697ee36 100644 --- a/tests/unit/test_zk.py +++ b/tests/unit/test_zk.py @@ -2052,10 +2052,11 @@ class TestPipelineInit(ZooKeeperBaseTestCase): layout = model.Layout(tenant) tenant.layout = layout pipeline.state = model.PipelineState.create( - pipeline, layout.uuid, pipeline.state) + pipeline, pipeline.state) context = ZKContext(self.zk_client, None, None, self.log) pipeline.state.refresh(context) self.assertTrue(self.zk_client.client.exists(pipeline.state.getPath())) + self.assertEqual(pipeline.state.layout_uuid, layout.uuid) def test_pipeline_state_existing_object(self): # Test the initialize-on-refresh code path with a pre-existing object @@ -2065,7 +2066,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase): tenant.layout = layout pipeline.manager = mock.Mock() pipeline.state = model.PipelineState.create( - pipeline, layout.uuid, pipeline.state) + pipeline, pipeline.state) pipeline.change_list = model.PipelineChangeList.create( pipeline) context = ZKContext(self.zk_client, None, None, self.log) @@ -2077,6 +2078,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase): self.assertTrue( self.zk_client.client.exists(pipeline.change_list.getPath())) self.assertTrue(self.zk_client.client.exists(pipeline.state.getPath())) + self.assertEqual(pipeline.state.layout_uuid, layout.uuid) def test_pipeline_change_list_new_object(self): # Test the initialize-on-refresh code path with no existing object @@ -2085,13 +2087,16 @@ class TestPipelineInit(ZooKeeperBaseTestCase): layout = model.Layout(tenant) tenant.layout = layout pipeline.state = model.PipelineState.create( - pipeline, layout.uuid, pipeline.state) + pipeline, pipeline.state) pipeline.change_list = model.PipelineChangeList.create( pipeline) context = ZKContext(self.zk_client, None, None, self.log) pipeline.change_list.refresh(context) self.assertTrue( self.zk_client.client.exists(pipeline.change_list.getPath())) + pipeline.manager = mock.Mock() + pipeline.state.refresh(context) + self.assertEqual(pipeline.state.layout_uuid, layout.uuid) def test_pipeline_change_list_new_object_without_lock(self): # Test the initialize-on-refresh code path if we don't have @@ -2101,7 +2106,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase): layout = model.Layout(tenant) tenant.layout = layout pipeline.state = model.PipelineState.create( - pipeline, layout.uuid, pipeline.state) + pipeline, pipeline.state) pipeline.change_list = model.PipelineChangeList.create( pipeline) context = ZKContext(self.zk_client, None, None, self.log) @@ -2109,3 +2114,6 @@ class TestPipelineInit(ZooKeeperBaseTestCase): pipeline.change_list.refresh(context, allow_init=False) self.assertIsNone( self.zk_client.client.exists(pipeline.change_list.getPath())) + pipeline.manager = mock.Mock() + pipeline.state.refresh(context) + self.assertEqual(pipeline.state.layout_uuid, layout.uuid) diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py index e85d5124e..36361df11 100644 --- a/zuul/manager/__init__.py +++ b/zuul/manager/__init__.py @@ -108,7 +108,7 @@ class PipelineManager(metaclass=ABCMeta): # These will be out of date until they are refreshed later. self.pipeline.state = PipelineState.create( - self.pipeline, layout.uuid, self.pipeline.state) + self.pipeline, self.pipeline.state) self.pipeline.change_list = PipelineChangeList.create( self.pipeline) diff --git a/zuul/model.py b/zuul/model.py index 3b6a49710..39e5302bc 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -643,7 +643,7 @@ class PipelineState(zkobject.ZKObject): return obj @classmethod - def create(cls, pipeline, layout_uuid, old_state=None): + def create(cls, pipeline, old_state=None): # If we are resetting an existing pipeline, we will have an # old_state, so just clean up the object references there and # let the next refresh handle updating any data. |