Run pre-commit: black, whitespaces, rst
This commit is contained in:
@@ -86,10 +86,12 @@ class EachScheduling(object):
|
||||
if deadnode.gateway.spec == node.gateway.spec:
|
||||
dead_collection = self.node2collection[deadnode]
|
||||
if collection != dead_collection:
|
||||
msg = report_collection_diff(dead_collection,
|
||||
collection,
|
||||
deadnode.gateway.id,
|
||||
node.gateway.id)
|
||||
msg = report_collection_diff(
|
||||
dead_collection,
|
||||
collection,
|
||||
deadnode.gateway.id,
|
||||
node.gateway.id,
|
||||
)
|
||||
self.log(msg)
|
||||
return
|
||||
pending = self._removed2pending.pop(deadnode)
|
||||
|
||||
@@ -23,7 +23,7 @@ class LoadFileScheduling(LoadScopeScheduling):
|
||||
def __init__(self, config, log=None):
|
||||
super(LoadFileScheduling, self).__init__(config, log)
|
||||
if log is None:
|
||||
self.log = Producer('loadfilesched')
|
||||
self.log = Producer("loadfilesched")
|
||||
else:
|
||||
self.log = log.loadfilesched
|
||||
|
||||
@@ -49,4 +49,4 @@ class LoadFileScheduling(LoadScopeScheduling):
|
||||
example/loadsuite/test/test_delta.py
|
||||
example/loadsuite/epsilon/__init__.py
|
||||
"""
|
||||
return nodeid.split('::', 1)[0]
|
||||
return nodeid.split("::", 1)[0]
|
||||
|
||||
@@ -133,10 +133,9 @@ class LoadScheduling(object):
|
||||
assert self.collection
|
||||
if collection != self.collection:
|
||||
other_node = next(iter(self.node2collection.keys()))
|
||||
msg = report_collection_diff(self.collection,
|
||||
collection,
|
||||
other_node.gateway.id,
|
||||
node.gateway.id)
|
||||
msg = report_collection_diff(
|
||||
self.collection, collection, other_node.gateway.id, node.gateway.id
|
||||
)
|
||||
self.log(msg)
|
||||
return
|
||||
self.node2collection[node] = list(collection)
|
||||
@@ -226,7 +225,7 @@ class LoadScheduling(object):
|
||||
|
||||
# XXX allow nodes to have different collections
|
||||
if not self._check_nodes_have_same_collection():
|
||||
self.log('**Different tests collected, aborting run**')
|
||||
self.log("**Different tests collected, aborting run**")
|
||||
return
|
||||
|
||||
# Collections are identical, create the index of pending items.
|
||||
@@ -238,8 +237,7 @@ class LoadScheduling(object):
|
||||
# Send a batch of tests to run. If we don't have at least two
|
||||
# tests per node, we have to send them all so that we can send
|
||||
# shutdown signals and get all nodes working.
|
||||
initial_batch = max(len(self.pending) // 4,
|
||||
2 * len(self.nodes))
|
||||
initial_batch = max(len(self.pending) // 4, 2 * len(self.nodes))
|
||||
|
||||
# distribute tests round-robin up to the batch size
|
||||
# (or until we run out)
|
||||
@@ -271,18 +269,15 @@ class LoadScheduling(object):
|
||||
same_collection = True
|
||||
for node, collection in node_collection_items[1:]:
|
||||
msg = report_collection_diff(
|
||||
col,
|
||||
collection,
|
||||
first_node.gateway.id,
|
||||
node.gateway.id,
|
||||
col, collection, first_node.gateway.id, node.gateway.id
|
||||
)
|
||||
if msg:
|
||||
same_collection = False
|
||||
self.log(msg)
|
||||
if self.config is not None:
|
||||
rep = CollectReport(
|
||||
node.gateway.id, 'failed',
|
||||
longrepr=msg, result=[])
|
||||
node.gateway.id, "failed", longrepr=msg, result=[]
|
||||
)
|
||||
self.config.hook.pytest_collectreport(report=rep)
|
||||
|
||||
return same_collection
|
||||
|
||||
@@ -93,7 +93,7 @@ class LoadScopeScheduling(object):
|
||||
self.registered_collections = OrderedDict()
|
||||
|
||||
if log is None:
|
||||
self.log = Producer('loadscopesched')
|
||||
self.log = Producer("loadscopesched")
|
||||
else:
|
||||
self.log = log.loadscopesched
|
||||
|
||||
@@ -187,8 +187,7 @@ class LoadScopeScheduling(object):
|
||||
break
|
||||
else:
|
||||
raise RuntimeError(
|
||||
'Unable to identify crashitem on a workload with '
|
||||
'pending items'
|
||||
"Unable to identify crashitem on a workload with " "pending items"
|
||||
)
|
||||
|
||||
# Made uncompleted work unit available again
|
||||
@@ -224,10 +223,7 @@ class LoadScopeScheduling(object):
|
||||
other_node = next(iter(self.registered_collections.keys()))
|
||||
|
||||
msg = report_collection_diff(
|
||||
self.collection,
|
||||
collection,
|
||||
other_node.gateway.id,
|
||||
node.gateway.id
|
||||
self.collection, collection, other_node.gateway.id, node.gateway.id
|
||||
)
|
||||
self.log(msg)
|
||||
return
|
||||
@@ -255,9 +251,7 @@ class LoadScopeScheduling(object):
|
||||
scope, work_unit = self.workqueue.popitem(last=False)
|
||||
|
||||
# Keep track of the assigned work
|
||||
assigned_to_node = self.assigned_work.setdefault(
|
||||
node, default=OrderedDict()
|
||||
)
|
||||
assigned_to_node = self.assigned_work.setdefault(node, default=OrderedDict())
|
||||
assigned_to_node[scope] = work_unit
|
||||
|
||||
# Ask the node to execute the workload
|
||||
@@ -292,14 +286,11 @@ class LoadScopeScheduling(object):
|
||||
example/loadsuite/test/test_delta.py::Delta1
|
||||
example/loadsuite/epsilon/__init__.py
|
||||
"""
|
||||
return nodeid.rsplit('::', 1)[0]
|
||||
return nodeid.rsplit("::", 1)[0]
|
||||
|
||||
def _pending_of(self, workload):
|
||||
"""Return the number of pending tests in a workload."""
|
||||
pending = sum(
|
||||
list(scope.values()).count(False)
|
||||
for scope in workload.values()
|
||||
)
|
||||
pending = sum(list(scope.values()).count(False) for scope in workload.values())
|
||||
return pending
|
||||
|
||||
def _reschedule(self, node):
|
||||
@@ -317,7 +308,7 @@ class LoadScopeScheduling(object):
|
||||
if not self.workqueue:
|
||||
return
|
||||
|
||||
self.log('Number of units waiting for node:', len(self.workqueue))
|
||||
self.log("Number of units waiting for node:", len(self.workqueue))
|
||||
|
||||
# Check that the node is almost depleted of work
|
||||
# 2: Heuristic of minimum tests to enqueue more work
|
||||
@@ -348,13 +339,11 @@ class LoadScopeScheduling(object):
|
||||
|
||||
# Check that all nodes collected the same tests
|
||||
if not self._check_nodes_have_same_collection():
|
||||
self.log('**Different tests collected, aborting run**')
|
||||
self.log("**Different tests collected, aborting run**")
|
||||
return
|
||||
|
||||
# Collections are identical, create the final list of items
|
||||
self.collection = list(
|
||||
next(iter(self.registered_collections.values()))
|
||||
)
|
||||
self.collection = list(next(iter(self.registered_collections.values())))
|
||||
if not self.collection:
|
||||
return
|
||||
|
||||
@@ -368,12 +357,12 @@ class LoadScopeScheduling(object):
|
||||
extra_nodes = len(self.nodes) - len(self.workqueue)
|
||||
|
||||
if extra_nodes > 0:
|
||||
self.log('Shuting down {0} nodes'.format(extra_nodes))
|
||||
self.log("Shuting down {0} nodes".format(extra_nodes))
|
||||
|
||||
for _ in range(extra_nodes):
|
||||
unused_node, assigned = self.assigned_work.popitem(last=True)
|
||||
|
||||
self.log('Shuting down unused node {0}'.format(unused_node))
|
||||
self.log("Shuting down unused node {0}".format(unused_node))
|
||||
unused_node.shutdown()
|
||||
|
||||
# Assign initial workload
|
||||
@@ -402,10 +391,7 @@ class LoadScopeScheduling(object):
|
||||
|
||||
for node, collection in node_collection_items[1:]:
|
||||
msg = report_collection_diff(
|
||||
col,
|
||||
collection,
|
||||
first_node.gateway.id,
|
||||
node.gateway.id,
|
||||
col, collection, first_node.gateway.id, node.gateway.id
|
||||
)
|
||||
if not msg:
|
||||
continue
|
||||
@@ -416,12 +402,7 @@ class LoadScopeScheduling(object):
|
||||
if self.config is None:
|
||||
continue
|
||||
|
||||
rep = CollectReport(
|
||||
node.gateway.id,
|
||||
'failed',
|
||||
longrepr=msg,
|
||||
result=[]
|
||||
)
|
||||
rep = CollectReport(node.gateway.id, "failed", longrepr=msg, result=[])
|
||||
self.config.hook.pytest_collectreport(report=rep)
|
||||
|
||||
return same_collection
|
||||
|
||||
Reference in New Issue
Block a user