Merge "Change PENDING_RETRY to ERROR_RETRY in soft_stop"
This commit is contained in:
commit
d06c647c28
@ -71,7 +71,7 @@ class Scheduler(base.Worker):
|
|||||||
plan = graph.get_graph(plan_uid)
|
plan = graph.get_graph(plan_uid)
|
||||||
for n in plan:
|
for n in plan:
|
||||||
if plan.node[n]['status'] in (
|
if plan.node[n]['status'] in (
|
||||||
states.PENDING.name, states.PENDING_RETRY.name):
|
states.PENDING.name, states.ERROR_RETRY.name):
|
||||||
plan.node[n]['status'] = states.SKIPPED.name
|
plan.node[n]['status'] = states.SKIPPED.name
|
||||||
graph.update_graph(plan)
|
graph.update_graph(plan)
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from solar.orchestration import graph
|
||||||
|
from solar.orchestration.traversal import states
|
||||||
from solar.orchestration.workers.scheduler import Scheduler
|
from solar.orchestration.workers.scheduler import Scheduler
|
||||||
|
|
||||||
|
|
||||||
@ -21,3 +23,15 @@ def test_scheduler_next_fails_with_empty_plan():
|
|||||||
scheduler = Scheduler(None)
|
scheduler = Scheduler(None)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
scheduler.next({}, 'nonexistent_uid')
|
scheduler.next({}, 'nonexistent_uid')
|
||||||
|
|
||||||
|
|
||||||
|
def test_soft_stop(simple_plan):
|
||||||
|
# graph.save_graph(simple_plan)
|
||||||
|
uid = simple_plan.graph['uid']
|
||||||
|
|
||||||
|
scheduler = Scheduler(None)
|
||||||
|
scheduler.soft_stop({}, uid)
|
||||||
|
|
||||||
|
plan = graph.get_graph(uid)
|
||||||
|
for n in plan:
|
||||||
|
assert plan.node[n]['status'] == states.SKIPPED.name
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
from pytest import fixture
|
from pytest import fixture
|
||||||
|
|
||||||
@ -21,43 +19,35 @@ from solar.orchestration import graph
|
|||||||
from solar.orchestration.traversal import states
|
from solar.orchestration.traversal import states
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
def test_simple_plan_plan_created_and_loaded(simple_plan):
|
||||||
def simple():
|
plan = graph.get_plan(simple_plan.graph['uid'])
|
||||||
simple_path = os.path.join(
|
|
||||||
os.path.dirname(os.path.realpath(__file__)), 'orch_fixtures',
|
|
||||||
'simple.yaml')
|
|
||||||
return graph.create_plan(simple_path)
|
|
||||||
|
|
||||||
|
|
||||||
def test_simple_plan_created_and_loaded(simple):
|
|
||||||
plan = graph.get_plan(simple.graph['uid'])
|
|
||||||
assert set(plan.nodes()) == {'just_fail', 'echo_stuff'}
|
assert set(plan.nodes()) == {'just_fail', 'echo_stuff'}
|
||||||
|
|
||||||
|
|
||||||
def test_reset_all_states(simple):
|
def test_reset_all_states(simple_plan):
|
||||||
for n in simple:
|
for n in simple_plan:
|
||||||
simple.node[n]['status'] == states.ERROR.name
|
simple_plan.node[n]['status'] == states.ERROR.name
|
||||||
graph.reset(simple)
|
graph.reset(simple_plan)
|
||||||
|
|
||||||
for n in simple:
|
for n in simple_plan:
|
||||||
assert simple.node[n]['status'] == states.PENDING.name
|
assert simple_plan.node[n]['status'] == states.PENDING.name
|
||||||
|
|
||||||
|
|
||||||
def test_reset_only_provided(simple):
|
def test_reset_only_provided(simple_plan):
|
||||||
simple.node['just_fail']['status'] = states.ERROR.name
|
simple_plan.node['just_fail']['status'] = states.ERROR.name
|
||||||
simple.node['echo_stuff']['status'] = states.SUCCESS.name
|
simple_plan.node['echo_stuff']['status'] = states.SUCCESS.name
|
||||||
|
|
||||||
graph.reset(simple, [states.ERROR.name])
|
graph.reset(simple_plan, [states.ERROR.name])
|
||||||
|
|
||||||
assert simple.node['just_fail']['status'] == states.PENDING.name
|
assert simple_plan.node['just_fail']['status'] == states.PENDING.name
|
||||||
assert simple.node['echo_stuff']['status'] == states.SUCCESS.name
|
assert simple_plan.node['echo_stuff']['status'] == states.SUCCESS.name
|
||||||
|
|
||||||
|
|
||||||
def test_wait_finish(simple):
|
def test_wait_finish(simple_plan):
|
||||||
for n in simple:
|
for n in simple_plan:
|
||||||
simple.node[n]['status'] = states.SUCCESS.name
|
simple_plan.node[n]['status'] = states.SUCCESS.name
|
||||||
graph.update_graph(simple)
|
graph.update_graph(simple_plan)
|
||||||
assert next(graph.wait_finish(simple.graph['uid'], 10)) == {
|
assert next(graph.wait_finish(simple_plan.graph['uid'], 10)) == {
|
||||||
'SKIPPED': 0,
|
'SKIPPED': 0,
|
||||||
'SUCCESS': 2,
|
'SUCCESS': 2,
|
||||||
'NOOP': 0,
|
'NOOP': 0,
|
||||||
@ -68,11 +58,11 @@ def test_wait_finish(simple):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_several_updates(simple):
|
def test_several_updates(simple_plan):
|
||||||
simple.node['just_fail']['status'] = states.ERROR.name
|
simple_plan.node['just_fail']['status'] = states.ERROR.name
|
||||||
graph.update_graph(simple)
|
graph.update_graph(simple_plan)
|
||||||
|
|
||||||
assert next(graph.wait_finish(simple.graph['uid'], 10)) == {
|
assert next(graph.wait_finish(simple_plan.graph['uid'], 10)) == {
|
||||||
'SKIPPED': 0,
|
'SKIPPED': 0,
|
||||||
'SUCCESS': 0,
|
'SUCCESS': 0,
|
||||||
'NOOP': 0,
|
'NOOP': 0,
|
||||||
@ -82,10 +72,10 @@ def test_several_updates(simple):
|
|||||||
'ERROR_RETRY': 0,
|
'ERROR_RETRY': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
simple.node['echo_stuff']['status'] = states.ERROR.name
|
simple_plan.node['echo_stuff']['status'] = states.ERROR.name
|
||||||
graph.update_graph(simple)
|
graph.update_graph(simple_plan)
|
||||||
|
|
||||||
assert next(graph.wait_finish(simple.graph['uid'], 10)) == {
|
assert next(graph.wait_finish(simple_plan.graph['uid'], 10)) == {
|
||||||
'SKIPPED': 0,
|
'SKIPPED': 0,
|
||||||
'SUCCESS': 0,
|
'SUCCESS': 0,
|
||||||
'NOOP': 0,
|
'NOOP': 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user