Reset times in tasks on graph reset

It will stop pollution of subsequent orchestrations with time values
from previous runs.

Change-Id: I2b0e495f84768aee3545f33e388c9bfb20d76fa4
Closes-bug: 1554058
This commit is contained in:
Maciej Kwiek 2016-03-07 16:30:08 +01:00
parent cf1fd8d697
commit c281237a8f
2 changed files with 13 additions and 0 deletions

View File

@ -192,6 +192,8 @@ def reset(graph, state_list=None):
for n in graph:
if state_list is None or graph.node[n]['status'] in state_list:
graph.node[n]['status'] = states.PENDING.name
graph.node[n]['start_time'] = 0.0
graph.node[n]['end_time'] = 0.0
update_graph(graph)

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import networkx as nx
from solar.orchestration import graph
@ -20,3 +22,12 @@ from solar.orchestration import graph
def test_longest_path_time_returns_0_for_empty_graph():
g = nx.MultiDiGraph()
assert graph.longest_path_time(g) == 0.0
def test_reset_resets_times():
g = nx.MultiDiGraph()
g.add_node('task1', task=mock.Mock(), status='status', errmsg='',
start_time=1, end_time=4)
graph.reset(g)
assert int(g.node['task1']['start_time']) == 0
assert int(g.node['task1']['start_time']) == 0