Rename init_distribute() to more clear schedule()
This commit is contained in:
@@ -64,7 +64,7 @@ class TestEachScheduling:
|
|||||||
assert sched.collection_is_completed
|
assert sched.collection_is_completed
|
||||||
assert sched.node2collection[node1] == collection
|
assert sched.node2collection[node1] == collection
|
||||||
assert sched.node2collection[node2] == collection
|
assert sched.node2collection[node2] == collection
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
assert sched.tests_finished()
|
assert sched.tests_finished()
|
||||||
assert node1.sent == ['ALL']
|
assert node1.sent == ['ALL']
|
||||||
assert node2.sent == ['ALL']
|
assert node2.sent == ['ALL']
|
||||||
@@ -83,7 +83,7 @@ class TestEachScheduling:
|
|||||||
sched.addnode_collection(node1, collection)
|
sched.addnode_collection(node1, collection)
|
||||||
assert sched.collection_is_completed
|
assert sched.collection_is_completed
|
||||||
assert sched.node2collection[node1] == collection
|
assert sched.node2collection[node1] == collection
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
assert sched.tests_finished()
|
assert sched.tests_finished()
|
||||||
crashitem = sched.remove_node(node1)
|
crashitem = sched.remove_node(node1)
|
||||||
assert crashitem
|
assert crashitem
|
||||||
@@ -106,7 +106,7 @@ class TestLoadScheduling:
|
|||||||
assert sched.collection_is_completed
|
assert sched.collection_is_completed
|
||||||
assert sched.node2collection[node1] == collection
|
assert sched.node2collection[node1] == collection
|
||||||
assert sched.node2collection[node2] == collection
|
assert sched.node2collection[node2] == collection
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
assert not sched.pending
|
assert not sched.pending
|
||||||
assert sched.tests_finished()
|
assert sched.tests_finished()
|
||||||
assert len(node1.sent) == 1
|
assert len(node1.sent) == 1
|
||||||
@@ -116,7 +116,7 @@ class TestLoadScheduling:
|
|||||||
sched.remove_item(node1, node1.sent[0])
|
sched.remove_item(node1, node1.sent[0])
|
||||||
assert sched.tests_finished()
|
assert sched.tests_finished()
|
||||||
|
|
||||||
def test_init_distribute_batch_size(self, testdir):
|
def test_schedule_batch_size(self, testdir):
|
||||||
config = testdir.parseconfig()
|
config = testdir.parseconfig()
|
||||||
sched = LoadScheduling(2, config)
|
sched = LoadScheduling(2, config)
|
||||||
sched.addnode(MockNode())
|
sched.addnode(MockNode())
|
||||||
@@ -125,7 +125,7 @@ class TestLoadScheduling:
|
|||||||
col = ["xyz"] * (6)
|
col = ["xyz"] * (6)
|
||||||
sched.addnode_collection(node1, col)
|
sched.addnode_collection(node1, col)
|
||||||
sched.addnode_collection(node2, col)
|
sched.addnode_collection(node2, col)
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
# assert not sched.tests_finished()
|
# assert not sched.tests_finished()
|
||||||
sent1 = node1.sent
|
sent1 = node1.sent
|
||||||
sent2 = node2.sent
|
sent2 = node2.sent
|
||||||
@@ -143,7 +143,7 @@ class TestLoadScheduling:
|
|||||||
assert node1.sent == [0, 2, 4, 5]
|
assert node1.sent == [0, 2, 4, 5]
|
||||||
assert not sched.pending
|
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()
|
config = testdir.parseconfig()
|
||||||
sched = LoadScheduling(2, config)
|
sched = LoadScheduling(2, config)
|
||||||
sched.addnode(MockNode())
|
sched.addnode(MockNode())
|
||||||
@@ -153,7 +153,7 @@ class TestLoadScheduling:
|
|||||||
col = ["xyz"] * 2
|
col = ["xyz"] * 2
|
||||||
sched.addnode_collection(node1, col)
|
sched.addnode_collection(node1, col)
|
||||||
sched.addnode_collection(node2, col)
|
sched.addnode_collection(node2, col)
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
# assert not sched.tests_finished()
|
# assert not sched.tests_finished()
|
||||||
sent1 = node1.sent
|
sent1 = node1.sent
|
||||||
sent2 = node2.sent
|
sent2 = node2.sent
|
||||||
@@ -163,7 +163,7 @@ class TestLoadScheduling:
|
|||||||
assert sent3 == []
|
assert sent3 == []
|
||||||
assert not sched.pending
|
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()
|
config = testdir.parseconfig()
|
||||||
sched = LoadScheduling(2, config)
|
sched = LoadScheduling(2, config)
|
||||||
sched.addnode(MockNode())
|
sched.addnode(MockNode())
|
||||||
@@ -173,7 +173,7 @@ class TestLoadScheduling:
|
|||||||
col = ["xyz"] * 5
|
col = ["xyz"] * 5
|
||||||
sched.addnode_collection(node1, col)
|
sched.addnode_collection(node1, col)
|
||||||
sched.addnode_collection(node2, col)
|
sched.addnode_collection(node2, col)
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
# assert not sched.tests_finished()
|
# assert not sched.tests_finished()
|
||||||
sent1 = node1.sent
|
sent1 = node1.sent
|
||||||
sent2 = node2.sent
|
sent2 = node2.sent
|
||||||
@@ -191,7 +191,7 @@ class TestLoadScheduling:
|
|||||||
collection = ["test_file.py::test_func"]
|
collection = ["test_file.py::test_func"]
|
||||||
sched.addnode_collection(node, collection)
|
sched.addnode_collection(node, collection)
|
||||||
assert sched.collection_is_completed
|
assert sched.collection_is_completed
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
assert not sched.pending
|
assert not sched.pending
|
||||||
crashitem = sched.remove_node(node)
|
crashitem = sched.remove_node(node)
|
||||||
assert crashitem == collection[0]
|
assert crashitem == collection[0]
|
||||||
@@ -223,7 +223,7 @@ class TestLoadScheduling:
|
|||||||
sched.addnode(node2)
|
sched.addnode(node2)
|
||||||
sched.addnode_collection(node1, ["a.py::test_1"])
|
sched.addnode_collection(node1, ["a.py::test_1"])
|
||||||
sched.addnode_collection(node2, ["a.py::test_2"])
|
sched.addnode_collection(node2, ["a.py::test_2"])
|
||||||
sched.init_distribute()
|
sched.schedule()
|
||||||
assert len(collect_hook.reports) == 1
|
assert len(collect_hook.reports) == 1
|
||||||
rep = collect_hook.reports[0]
|
rep = collect_hook.reports[0]
|
||||||
assert 'Different tests were collected between' in rep.longrepr
|
assert 'Different tests were collected between' in rep.longrepr
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class EachScheduling:
|
|||||||
list. When the collection is already completed this
|
list. When the collection is already completed this
|
||||||
submission is from a node which was restarted to replace a
|
submission is from a node which was restarted to replace a
|
||||||
dead node. In this case we already assign the pending items
|
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.
|
node to start running the required tests.
|
||||||
"""
|
"""
|
||||||
assert node in self.node2pending
|
assert node in self.node2pending
|
||||||
@@ -115,7 +115,7 @@ class EachScheduling:
|
|||||||
self._removed2pending[node] = pending
|
self._removed2pending[node] = pending
|
||||||
return crashitem
|
return crashitem
|
||||||
|
|
||||||
def init_distribute(self):
|
def schedule(self):
|
||||||
"""Schedule the test items on the nodes
|
"""Schedule the test items on the nodes
|
||||||
|
|
||||||
If the node's pending list is empty it is a new node which
|
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
|
:collection: The one collection once it is validated to be
|
||||||
identical between all the nodes. It is initialised to None
|
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
|
:pending: List of indices of globally pending tests. These are
|
||||||
tests which have not yet been allocated to a chunk for a node
|
tests which have not yet been allocated to a chunk for a node
|
||||||
@@ -258,7 +258,7 @@ class LoadScheduling:
|
|||||||
assert node in self.node2pending
|
assert node in self.node2pending
|
||||||
if self.collection_is_completed:
|
if self.collection_is_completed:
|
||||||
# A new node has been added later, perhaps an original one died.
|
# A new node has been added later, perhaps an original one died.
|
||||||
# .init_distribute() should have
|
# .schedule() should have
|
||||||
# been called by now
|
# been called by now
|
||||||
assert self.collection
|
assert self.collection
|
||||||
if collection != self.collection:
|
if collection != self.collection:
|
||||||
@@ -335,7 +335,7 @@ class LoadScheduling:
|
|||||||
self.check_schedule(node)
|
self.check_schedule(node)
|
||||||
return crashitem
|
return crashitem
|
||||||
|
|
||||||
def init_distribute(self):
|
def schedule(self):
|
||||||
"""Initiate distribution of the test collection
|
"""Initiate distribution of the test collection
|
||||||
|
|
||||||
Initiate scheduling of the items across the nodes. If this
|
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
|
This is called by the ``DSession.slave_collectionfinish`` hook
|
||||||
if ``.collection_is_completed`` is True.
|
if ``.collection_is_completed`` is True.
|
||||||
|
|
||||||
XXX Perhaps this method should have been called ".schedule()".
|
|
||||||
"""
|
"""
|
||||||
assert self.collection_is_completed
|
assert self.collection_is_completed
|
||||||
|
|
||||||
@@ -653,7 +651,7 @@ class DSession:
|
|||||||
self.terminal.write_line("")
|
self.terminal.write_line("")
|
||||||
self.terminal.write_line("scheduling tests via %s" % (
|
self.terminal.write_line("scheduling tests via %s" % (
|
||||||
self.sched.__class__.__name__))
|
self.sched.__class__.__name__))
|
||||||
self.sched.init_distribute()
|
self.sched.schedule()
|
||||||
|
|
||||||
def slave_logstart(self, node, nodeid, location):
|
def slave_logstart(self, node, nodeid, location):
|
||||||
"""Emitted when a node calls the pytest_runtest_logstart hook."""
|
"""Emitted when a node calls the pytest_runtest_logstart hook."""
|
||||||
|
|||||||
Reference in New Issue
Block a user