From a2aaf9bf04a694ab4dee9d2daf8f6c573b8892eb Mon Sep 17 00:00:00 2001 From: Michael Elovskikh Date: Thu, 20 Oct 2016 09:32:59 +0500 Subject: [PATCH] Rename init_distribute() to more clear schedule() --- testing/test_dsession.py | 22 +++++++++++----------- xdist/dsession.py | 14 ++++++-------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/testing/test_dsession.py b/testing/test_dsession.py index 2abd976..dbc96a1 100644 --- a/testing/test_dsession.py +++ b/testing/test_dsession.py @@ -64,7 +64,7 @@ class TestEachScheduling: assert sched.collection_is_completed assert sched.node2collection[node1] == collection assert sched.node2collection[node2] == collection - sched.init_distribute() + sched.schedule() assert sched.tests_finished() assert node1.sent == ['ALL'] assert node2.sent == ['ALL'] @@ -83,7 +83,7 @@ class TestEachScheduling: sched.addnode_collection(node1, collection) assert sched.collection_is_completed assert sched.node2collection[node1] == collection - sched.init_distribute() + sched.schedule() assert sched.tests_finished() crashitem = sched.remove_node(node1) assert crashitem @@ -106,7 +106,7 @@ class TestLoadScheduling: assert sched.collection_is_completed assert sched.node2collection[node1] == collection assert sched.node2collection[node2] == collection - sched.init_distribute() + sched.schedule() assert not sched.pending assert sched.tests_finished() assert len(node1.sent) == 1 @@ -116,7 +116,7 @@ class TestLoadScheduling: sched.remove_item(node1, node1.sent[0]) assert sched.tests_finished() - def test_init_distribute_batch_size(self, testdir): + def test_schedule_batch_size(self, testdir): config = testdir.parseconfig() sched = LoadScheduling(2, config) sched.addnode(MockNode()) @@ -125,7 +125,7 @@ class TestLoadScheduling: col = ["xyz"] * (6) sched.addnode_collection(node1, col) sched.addnode_collection(node2, col) - sched.init_distribute() + sched.schedule() # assert not sched.tests_finished() sent1 = node1.sent sent2 = node2.sent @@ -143,7 +143,7 @@ class TestLoadScheduling: assert node1.sent == [0, 2, 4, 5] assert not sched.pending - def test_init_distribute_fewer_tests_than_nodes(self, testdir): + def test_schedule_fewer_tests_than_nodes(self, testdir): config = testdir.parseconfig() sched = LoadScheduling(2, config) sched.addnode(MockNode()) @@ -153,7 +153,7 @@ class TestLoadScheduling: col = ["xyz"] * 2 sched.addnode_collection(node1, col) sched.addnode_collection(node2, col) - sched.init_distribute() + sched.schedule() # assert not sched.tests_finished() sent1 = node1.sent sent2 = node2.sent @@ -163,7 +163,7 @@ class TestLoadScheduling: assert sent3 == [] assert not sched.pending - def test_init_distribute_fewer_than_two_tests_per_node(self, testdir): + def test_schedule_fewer_than_two_tests_per_node(self, testdir): config = testdir.parseconfig() sched = LoadScheduling(2, config) sched.addnode(MockNode()) @@ -173,7 +173,7 @@ class TestLoadScheduling: col = ["xyz"] * 5 sched.addnode_collection(node1, col) sched.addnode_collection(node2, col) - sched.init_distribute() + sched.schedule() # assert not sched.tests_finished() sent1 = node1.sent sent2 = node2.sent @@ -191,7 +191,7 @@ class TestLoadScheduling: collection = ["test_file.py::test_func"] sched.addnode_collection(node, collection) assert sched.collection_is_completed - sched.init_distribute() + sched.schedule() assert not sched.pending crashitem = sched.remove_node(node) assert crashitem == collection[0] @@ -223,7 +223,7 @@ class TestLoadScheduling: sched.addnode(node2) sched.addnode_collection(node1, ["a.py::test_1"]) sched.addnode_collection(node2, ["a.py::test_2"]) - sched.init_distribute() + sched.schedule() assert len(collect_hook.reports) == 1 rep = collect_hook.reports[0] assert 'Different tests were collected between' in rep.longrepr diff --git a/xdist/dsession.py b/xdist/dsession.py index f33f649..3032e11 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -78,7 +78,7 @@ class EachScheduling: list. When the collection is already completed this submission is from a node which was restarted to replace a dead node. In this case we already assign the pending items - here. In either case ``.init_distribute()`` will instruct the + here. In either case ``.schedule()`` will instruct the node to start running the required tests. """ assert node in self.node2pending @@ -115,7 +115,7 @@ class EachScheduling: self._removed2pending[node] = pending return crashitem - def init_distribute(self): + def schedule(self): """Schedule the test items on the nodes If the node's pending list is empty it is a new node which @@ -170,7 +170,7 @@ class LoadScheduling: :collection: The one collection once it is validated to be identical between all the nodes. It is initialised to None - until ``.init_distribute()`` is called. + until ``.schedule()`` is called. :pending: List of indices of globally pending tests. These are tests which have not yet been allocated to a chunk for a node @@ -258,7 +258,7 @@ class LoadScheduling: assert node in self.node2pending if self.collection_is_completed: # A new node has been added later, perhaps an original one died. - # .init_distribute() should have + # .schedule() should have # been called by now assert self.collection if collection != self.collection: @@ -335,7 +335,7 @@ class LoadScheduling: self.check_schedule(node) return crashitem - def init_distribute(self): + def schedule(self): """Initiate distribution of the test collection Initiate scheduling of the items across the nodes. If this @@ -345,8 +345,6 @@ class LoadScheduling: This is called by the ``DSession.slave_collectionfinish`` hook if ``.collection_is_completed`` is True. - - XXX Perhaps this method should have been called ".schedule()". """ assert self.collection_is_completed @@ -653,7 +651,7 @@ class DSession: self.terminal.write_line("") self.terminal.write_line("scheduling tests via %s" % ( self.sched.__class__.__name__)) - self.sched.init_distribute() + self.sched.schedule() def slave_logstart(self, node, nodeid, location): """Emitted when a node calls the pytest_runtest_logstart hook."""