<s> '''<STR_LIT>''' <EOL> import threading <EOL> from actuator import * <EOL> from actuator . config import _Dependency , _ConfigTask , StructuralTask , with_config_options <EOL> from actuator . infra import IPAddressable <EOL> MyConfig = None <EOL> search_path = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def setup ( ) : <EOL> global MyConfig <EOL> class MyTestConfig ( ConfigModel ) : <EOL> with_searchpath ( * search_path ) <EOL> t1 = NullTask ( "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 ) <EOL> MyConfig = MyTestConfig <EOL> def make_dep_tuple_set ( config ) : <EOL> return set ( [ ( d . from_task . path , d . to_task . path ) for d in config . get_class_dependencies ( ) ] ) <EOL> def pretty_deps ( deps ) : <EOL> return [ ( "<STR_LIT>" . format ( d . from_task . name , str ( id ( d . from_task ) ) [ - <NUM_LIT:4> : ] ) , <EOL> "<STR_LIT>" . format ( d . to_task . name , str ( id ( d . to_task ) ) [ - <NUM_LIT:4> : ] ) ) <EOL> for d in deps ] <EOL> def test01 ( ) : <EOL> assert MyConfig <EOL> def test02 ( ) : <EOL> expected_path = set ( search_path ) <EOL> assert expected_path == set ( MyConfig . __searchpath__ ) <EOL> def test03 ( ) : <EOL> assert <NUM_LIT:1> == len ( MyConfig . __dependencies__ ) <EOL> def test04 ( ) : <EOL> try : <EOL> class T4Config ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" ) <EOL> with_dependencies ( t1 | "<STR_LIT>" ) <EOL> raise Exception ( "<STR_LIT>" ) <EOL> except : <EOL> assert True <EOL> def test05 ( ) : <EOL> try : <EOL> _ = _Dependency ( NullTask ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> raise Exception ( "<STR_LIT>" ) <EOL> except : <EOL> assert True <EOL> def test06 ( ) : <EOL> try : <EOL> _ = _Dependency ( "<STR_LIT>" , NullTask ( "<STR_LIT>" ) ) <EOL> raise Exception ( "<STR_LIT>" ) <EOL> except : <EOL> assert True <EOL> def test07 ( ) : <EOL> assert <NUM_LIT:2> == len ( MyConfig . _node_dict ) <EOL> def test08 ( ) : <EOL> try : <EOL> class TC8 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 , <EOL> t2 | t3 , <EOL> t3 | t1 ) <EOL> assert False , "<STR_LIT>" <EOL> except ConfigException , _ : <EOL> assert True <EOL> def test09 ( ) : <EOL> class TC9 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> assert make_dep_tuple_set ( TC9 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test10 ( ) : <EOL> try : <EOL> class TC10 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 | t1 ) <EOL> assert False , "<STR_LIT>" <EOL> except ConfigException , _ : <EOL> assert True <EOL> def test10a ( ) : <EOL> try : <EOL> class TC10a ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t1 ) <EOL> assert False , "<STR_LIT>" <EOL> except ConfigException , _ : <EOL> assert True <EOL> def test11 ( ) : <EOL> try : <EOL> class TC11 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 | t4 ) <EOL> with_dependencies ( t3 | t4 | t5 ) <EOL> with_dependencies ( t4 | t2 ) <EOL> assert False , "<STR_LIT>" <EOL> except ConfigException , _ : <EOL> assert True <EOL> def test12 ( ) : <EOL> class TC12 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t2 ) | t3 ) <EOL> assert make_dep_tuple_set ( TC12 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test13 ( ) : <EOL> class TC13 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t2 | t3 ) | t4 ) <EOL> assert make_dep_tuple_set ( TC13 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test14 ( ) : <EOL> class TC14 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t2 ) | TaskGroup ( t3 , t4 ) ) <EOL> assert make_dep_tuple_set ( TC14 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test15 ( ) : <EOL> class TC15 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 | t2 , t3 | t4 ) ) <EOL> assert make_dep_tuple_set ( TC15 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test16 ( ) : <EOL> class TC16 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | TaskGroup ( t2 , t3 ) ) <EOL> assert make_dep_tuple_set ( TC16 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test17 ( ) : <EOL> class TC17 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t6 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t7 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t8 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t9 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t0 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 | t2 , TaskGroup ( t3 , t4 ) ) | t5 | <EOL> TaskGroup ( TaskGroup ( t6 , t7 , t8 ) , t9 | t0 ) ) <EOL> assert make_dep_tuple_set ( TC17 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test18 ( ) : <EOL> class TC18 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , TaskGroup ( t2 , TaskGroup ( t3 ) ) ) ) <EOL> assert make_dep_tuple_set ( TC18 ) == set ( ) <EOL> def test19 ( ) : <EOL> class TC19 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 ) <EOL> with_dependencies ( t2 | t3 ) <EOL> assert make_dep_tuple_set ( TC19 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test20 ( ) : <EOL> class TC20 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t6 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t7 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t8 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t9 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t0 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 | t2 , TaskGroup ( t3 , t4 ) ) | t5 ) <EOL> with_dependencies ( t5 | TaskGroup ( TaskGroup ( t6 , t7 , t8 ) , t9 | t0 ) ) <EOL> assert make_dep_tuple_set ( TC20 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test21 ( ) : <EOL> class TC21 ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 ) <EOL> with_dependencies ( t2 | t3 ) <EOL> with_dependencies ( t1 | t2 ) <EOL> assert make_dep_tuple_set ( TC21 ) == set ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> def test22 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t3 , t2 | t3 ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t2 ) | t3 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test23 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t1 | t2 ) ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test24 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 , t2 , t3 ) , t1 | t3 ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TaskGroup ( t1 | t3 , t2 ) ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test25 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | TaskGroup ( t2 , t3 ) ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | t3 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test26 ( ) : <EOL> TG = TaskGroup <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( TG ( TG ( t1 , t2 , t3 ) , t4 | t5 ) , <EOL> t2 | t4 , <EOL> t3 | t5 ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t2 | t4 | t5 , <EOL> t3 | t5 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> class Capture ( object ) : <EOL> def __init__ ( self ) : <EOL> self . performed = [ ] <EOL> def __call__ ( self , name , task ) : <EOL> self . performed . append ( ( name , task ) ) <EOL> def pos ( self , name , task ) : <EOL> return self . performed . index ( ( name , task ) ) <EOL> class ReportingTask ( _ConfigTask , StructuralTask ) : <EOL> def __init__ ( self , name , target = None , report = lambda n , o : ( n , o ) , ** kwargs ) : <EOL> super ( ReportingTask , self ) . __init__ ( name , task_role = target , ** kwargs ) <EOL> self . target = target <EOL> self . report = report <EOL> def get_init_args ( self ) : <EOL> args , kwargs = super ( ReportingTask , self ) . get_init_args ( ) <EOL> try : <EOL> kwargs . pop ( "<STR_LIT>" ) <EOL> except Exception , _ : <EOL> pass <EOL> kwargs [ "<STR_LIT:target>" ] = self . target <EOL> kwargs [ "<STR_LIT>" ] = self . report <EOL> return args , kwargs <EOL> def perform ( self ) : <EOL> comp = self . get_task_role ( ) <EOL> if not isinstance ( comp , basestring ) : <EOL> if isinstance ( comp . name , basestring ) : <EOL> comp = comp . name <EOL> else : <EOL> comp = comp . name . value ( ) <EOL> self . report ( comp , self . name ) <EOL> class BogusServerRef ( IPAddressable ) : <EOL> def get_ip ( self ) : <EOL> return "<STR_LIT>" <EOL> admin_ip = property ( get_ip ) <EOL> def test27 ( ) : <EOL> cap = Capture ( ) <EOL> class PingNamespace ( NamespaceModel ) : <EOL> ping_target = Role ( "<STR_LIT>" , host_ref = BogusServerRef ( ) ) <EOL> ns = PingNamespace ( ) <EOL> class PingConfig ( ConfigModel ) : <EOL> ping_task = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> cfg = PingConfig ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert cap . performed <EOL> def test28 ( ) : <EOL> cap = Capture ( ) <EOL> class PingNamespace ( NamespaceModel ) : <EOL> ping_target = Role ( "<STR_LIT>" , host_ref = BogusServerRef ( ) ) <EOL> ns = PingNamespace ( ) <EOL> class PingConfig ( ConfigModel ) : <EOL> t3 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap , repeat_count = <NUM_LIT:1> ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap , repeat_count = <NUM_LIT:1> ) <EOL> t1 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap , repeat_count = <NUM_LIT:1> ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> cfg = PingConfig ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( cap . pos ( "<STR_LIT>" , PingConfig . t1 . name ) < <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t2 . name ) < <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t3 . name ) ) <EOL> def test29 ( ) : <EOL> cap = Capture ( ) <EOL> class PingNamespace ( NamespaceModel ) : <EOL> ping_target = Role ( "<STR_LIT>" , host_ref = BogusServerRef ( ) ) <EOL> ns = PingNamespace ( ) <EOL> class PingConfig ( ConfigModel ) : <EOL> t3 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> t1 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> t4 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> t5 = ReportingTask ( "<STR_LIT>" , target = PingNamespace . ping_target , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 , <EOL> t4 | t2 , <EOL> t4 | t3 , <EOL> t5 | t3 ) <EOL> cfg = PingConfig ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( cap . pos ( "<STR_LIT>" , PingConfig . t1 . name ) < <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t2 . name ) < <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t3 . name ) and <EOL> cap . performed [ - <NUM_LIT:1> ] == ( "<STR_LIT>" , PingConfig . t3 . name ) and <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t4 . name ) < <EOL> cap . pos ( "<STR_LIT>" , PingConfig . t2 . name ) ) <EOL> def test30 ( ) : <EOL> cap = Capture ( ) <EOL> class ElasticNamespace ( NamespaceModel ) : <EOL> ping_targets = MultiRole ( Role ( "<STR_LIT>" , host_ref = BogusServerRef ( ) ) ) <EOL> pong_targets = MultiRole ( Role ( "<STR_LIT>" , host_ref = BogusServerRef ( ) ) ) <EOL> ns = ElasticNamespace ( ) <EOL> class ElasticConfig ( ConfigModel ) : <EOL> ping = ReportingTask ( "<STR_LIT>" , target = ElasticNamespace . ping_targets , report = cap ) <EOL> pong = ReportingTask ( "<STR_LIT>" , target = ElasticNamespace . pong_targets , report = cap ) <EOL> with_dependencies ( ping | pong ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . ping_targets [ i ] <EOL> cfg = ElasticConfig ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( len ( ns . ping_targets ) == <NUM_LIT:5> and <EOL> ( set ( [ "<STR_LIT:0>" , "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" ] ) == set ( ns . ping_targets . keys ( ) ) ) and <EOL> len ( ns . pong_targets ) == <NUM_LIT:0> ) <EOL> def test31 ( ) : <EOL> class VarCapture ( _ConfigTask ) : <EOL> def __init__ ( self , name , task_role , ** kwargs ) : <EOL> super ( VarCapture , self ) . __init__ ( name , task_role = task_role , ** kwargs ) <EOL> self . vars = { } <EOL> def perform ( self ) : <EOL> vv = self . _model_instance . namespace_model_instance . comp . get_visible_vars ( ) <EOL> self . vars . update ( { v . name : v . get_value ( self . get_task_role ( ) ) <EOL> for v in vv . values ( ) } ) <EOL> class SimpleNS ( NamespaceModel ) : <EOL> with_variables ( Var ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:1>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:2>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:3>" ) ) <EOL> comp = Role ( "<STR_LIT>" , host_ref = "<STR_LIT>" ) . add_variable ( Var ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> class SimpleCfg ( ConfigModel ) : <EOL> comp_task = VarCapture ( "<STR_LIT>" , SimpleNS . comp ) <EOL> ns = SimpleNS ( ) <EOL> cfg = SimpleCfg ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT:1>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT:2>" ) <EOL> def test32 ( ) : <EOL> class VarCapture ( _ConfigTask ) : <EOL> def __init__ ( self , name , task_role , ** kwargs ) : <EOL> super ( VarCapture , self ) . __init__ ( name , task_role = task_role , ** kwargs ) <EOL> self . vars = { } <EOL> def perform ( self ) : <EOL> vv = self . _model_instance . namespace_model_instance . get_visible_vars ( ) <EOL> self . vars . update ( { v . name : v . get_value ( self . get_task_role ( ) ) <EOL> for v in vv . values ( ) } ) <EOL> class SimpleNS ( NamespaceModel ) : <EOL> with_variables ( Var ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:1>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:2>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:3>" ) ) <EOL> comp = Role ( "<STR_LIT>" , host_ref = "<STR_LIT>" ) . add_variable ( Var ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> class SimpleCfg ( ConfigModel ) : <EOL> comp_task = VarCapture ( "<STR_LIT>" , SimpleNS . comp ) <EOL> ns = SimpleNS ( ) <EOL> cfg = SimpleCfg ( ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT:3>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT:1>" and <EOL> cfg . comp_task . vars [ "<STR_LIT>" ] == "<STR_LIT:2>" ) <EOL> def test33 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | t2 & t3 ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | t3 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test34 ( ) : <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | ( t2 & t3 ) ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t1 | t2 | t3 , t1 | t3 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test35 ( ) : <EOL> TG = TaskGroup <EOL> class First ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( ( t1 & t2 & t3 ) & ( t4 | t5 ) , <EOL> t2 | t4 , <EOL> t3 | t5 ) <EOL> class Second ( ConfigModel ) : <EOL> t1 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t2 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t3 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t4 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> t5 = NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) <EOL> with_dependencies ( t2 | t4 | t5 , <EOL> t3 | t5 ) <EOL> assert make_dep_tuple_set ( First ) == make_dep_tuple_set ( Second ) <EOL> def test36 ( ) : <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) , NS . grid ) <EOL> cfg = Cfg ( ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . grid [ i ] <EOL> cfg . set_namespace ( ns ) <EOL> cfg . grid_prep . fix_arguments ( ) <EOL> assert len ( cfg . grid_prep . instances ) == <NUM_LIT:5> <EOL> def test37 ( ) : <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) , NS . grid ) <EOL> cfg = Cfg ( ) <EOL> _ = ns . grid [ <NUM_LIT:0> ] <EOL> cfg . set_namespace ( ns ) <EOL> cfg . grid_prep . fix_arguments ( ) <EOL> assert ( len ( cfg . grid_prep . instances ) == <NUM_LIT:1> and <EOL> cfg . grid_prep . instances . value ( ) [ <NUM_LIT:0> ] . name == "<STR_LIT>" ) <EOL> def test38 ( ) : <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , NullTask ( "<STR_LIT>" , path = "<STR_LIT>" ) , NS . grid ) <EOL> cfg = Cfg ( ) <EOL> _ = ns . grid [ <NUM_LIT:0> ] <EOL> cfg . set_namespace ( ns ) <EOL> cfg . grid_prep . fix_arguments ( ) <EOL> assert ( len ( cfg . grid_prep . instances ) == <NUM_LIT:1> and <EOL> cfg . grid_prep . instances . value ( ) [ <NUM_LIT:0> ] . name == "<STR_LIT>" ) <EOL> def test39 ( ) : <EOL> cap = Capture ( ) <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , ReportingTask ( "<STR_LIT>" , report = cap ) , <EOL> NS . grid ) <EOL> cfg = Cfg ( ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . grid [ i ] <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert len ( cfg . grid_prep . instances ) == <NUM_LIT:5> and len ( cap . performed ) == <NUM_LIT:5> <EOL> def test40 ( ) : <EOL> cap = Capture ( ) <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> static = Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , ReportingTask ( "<STR_LIT>" , report = cap ) , <EOL> NS . grid ) <EOL> before = ReportingTask ( "<STR_LIT>" , target = NS . static , report = cap ) <EOL> after = ReportingTask ( "<STR_LIT>" , target = NS . static , report = cap ) <EOL> with_dependencies ( before | grid_prep | after ) <EOL> cfg = Cfg ( ) <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> _ = ns . grid [ i ] <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert ( len ( cfg . grid_prep . instances ) == <NUM_LIT:3> and <EOL> len ( cap . performed ) == <NUM_LIT:5> and <EOL> ( cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) > cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) > cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) > cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) ) ) <EOL> def test41 ( ) : <EOL> cap = Capture ( ) <EOL> class NS ( NamespaceModel ) : <EOL> grid = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , ReportingTask ( "<STR_LIT>" , report = cap ) , <EOL> NS . q . grid ) <EOL> cfg = Cfg ( ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . grid [ i ] <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert len ( cfg . grid_prep . instances ) == <NUM_LIT:5> and len ( cap . performed ) == <NUM_LIT:5> <EOL> def test42 ( ) : <EOL> cap = Capture ( ) <EOL> class NS ( NamespaceModel ) : <EOL> grid1 = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> grid2 = MultiRole ( Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> grid_prep = MultiTask ( "<STR_LIT>" , ReportingTask ( "<STR_LIT>" , report = cap ) , <EOL> NS . q . union ( NS . q . grid1 , NS . q . grid2 ) ) <EOL> cfg = Cfg ( ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> _ = ns . grid1 [ i ] <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> _ = ns . grid2 [ i ] <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> no_delay = True ) <EOL> ea . perform_config ( ) <EOL> assert len ( cfg . grid_prep . instances ) == <NUM_LIT:8> and len ( cap . performed ) == <NUM_LIT:8> <EOL> def test43 ( ) : <EOL> """<STR_LIT>""" <EOL> cap = Capture ( ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) <EOL> ns = NS ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> with_config_options ( default_task_role = NS . task_performer ) <EOL> a_task = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> cfg = Cfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> assert cfg . a_task . get_task_host ( ) == "<STR_LIT:127.0.0.1>" <EOL> def test44 ( ) : <EOL> """<STR_LIT>""" <EOL> cap = Capture ( ) <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> class Cfg ( ConfigModel ) : <EOL> with_config_options ( default_task_role = NS . task_performer ) <EOL> a_task = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> cfg = Cfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> assert cfg . a_task . get_task_host ( ) == "<STR_LIT:127.0.0.1>" <EOL> def test44a ( ) : <EOL> """<STR_LIT>""" <EOL> cap = Capture ( ) <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> infra . setup_server . fix_arguments ( ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> ns . task_performer . fix_arguments ( ) <EOL> class Cfg ( ConfigModel ) : <EOL> a_task = ReportingTask ( "<STR_LIT>" , report = cap , target = NS . task_performer ) <EOL> cfg = Cfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> cfg . a_task . fix_arguments ( ) <EOL> assert cfg . a_task . get_task_host ( ) == "<STR_LIT:127.0.0.1>" <EOL> def test45 ( ) : <EOL> """<STR_LIT>""" <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> infra . setup_server . fix_arguments ( ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> ns . task_performer . fix_arguments ( ) <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> task = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = ConfigClassTask ( "<STR_LIT>" , InnerCfg , task_role = NS . task_performer ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert len ( cap . performed ) == <NUM_LIT:1> <EOL> def test46 ( ) : <EOL> """<STR_LIT>""" <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> t1 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t3 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = ConfigClassTask ( "<STR_LIT>" , InnerCfg , task_role = NS . task_performer ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert ( len ( cap . performed ) == <NUM_LIT:3> and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def test47 ( ) : <EOL> """<STR_LIT>""" <EOL> class IPGen ( object ) : <EOL> def __init__ ( self ) : <EOL> self . host_part = <NUM_LIT:0> <EOL> def __call__ ( self , context ) : <EOL> self . host_part += <NUM_LIT:1> <EOL> return "<STR_LIT>" . format ( self . host_part ) <EOL> ipgen = IPGen ( ) <EOL> class Infra ( InfraModel ) : <EOL> setup_server = MultiResource ( StaticServer ( "<STR_LIT>" , ipgen ) ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_role = MultiRole ( Role ( "<STR_LIT>" , <EOL> host_ref = ctxt . model . infra . setup_server [ ctxt . name ] ) ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> _ = ns . task_role [ i ] <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> t1 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t3 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = MultiTask ( "<STR_LIT>" , <EOL> ConfigClassTask ( "<STR_LIT>" , InnerCfg ) , <EOL> NS . q . task_role . all ( ) ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert len ( cap . performed ) == <NUM_LIT:9> <EOL> def test48 ( ) : <EOL> """<STR_LIT>""" <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> default = Role ( "<STR_LIT:default>" , host_ref = "<STR_LIT>" ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> t1 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t3 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = ConfigClassTask ( "<STR_LIT>" , InnerCfg , task_role = NS . task_performer ) <EOL> final = ReportingTask ( "<STR_LIT>" , target = NS . default , report = cap ) <EOL> with_dependencies ( wrapped_task | final ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert ( len ( cap . performed ) == <NUM_LIT:4> and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT:default>" , "<STR_LIT>" ) ) <EOL> def test49 ( ) : <EOL> """<STR_LIT>""" <EOL> class Infra ( InfraModel ) : <EOL> setup_server = StaticServer ( "<STR_LIT>" , "<STR_LIT:127.0.0.1>" ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_performer = Role ( "<STR_LIT>" , host_ref = Infra . setup_server ) <EOL> default = Role ( "<STR_LIT:default>" , host_ref = "<STR_LIT>" ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> t1 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t3 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = ConfigClassTask ( "<STR_LIT>" , InnerCfg , task_role = NS . task_performer ) <EOL> initial = ReportingTask ( "<STR_LIT>" , target = NS . default , report = cap ) <EOL> final = ReportingTask ( "<STR_LIT>" , target = NS . default , report = cap ) <EOL> with_dependencies ( initial | wrapped_task | final ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert ( len ( cap . performed ) == <NUM_LIT:5> and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT:default>" , "<STR_LIT>" ) and <EOL> cap . pos ( "<STR_LIT:default>" , "<STR_LIT>" ) < cap . pos ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def test50 ( ) : <EOL> """<STR_LIT>""" <EOL> class IPGen ( object ) : <EOL> def __init__ ( self ) : <EOL> self . host_part = <NUM_LIT:0> <EOL> def __call__ ( self , context ) : <EOL> self . host_part += <NUM_LIT:1> <EOL> return "<STR_LIT>" . format ( self . host_part ) <EOL> ipgen = IPGen ( ) <EOL> class Infra ( InfraModel ) : <EOL> setup_server = MultiResource ( StaticServer ( "<STR_LIT>" , ipgen ) ) <EOL> infra = Infra ( "<STR_LIT>" ) <EOL> class NS ( NamespaceModel ) : <EOL> task_role = MultiRole ( Role ( "<STR_LIT>" , <EOL> host_ref = ctxt . model . infra . setup_server [ ctxt . name ] ) ) <EOL> default = Role ( "<STR_LIT:default>" , "<STR_LIT>" ) <EOL> ns = NS ( ) <EOL> ns . set_infra_model ( infra ) <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> _ = ns . task_role [ i ] <EOL> cap = Capture ( ) <EOL> class InnerCfg ( ConfigModel ) : <EOL> t1 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t2 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> t3 = ReportingTask ( "<STR_LIT>" , report = cap ) <EOL> with_dependencies ( t1 | t2 | t3 ) <EOL> class OuterCfg ( ConfigModel ) : <EOL> wrapped_task = MultiTask ( "<STR_LIT>" , <EOL> ConfigClassTask ( "<STR_LIT>" , InnerCfg ) , <EOL> NS . q . task_role . all ( ) ) <EOL> initial = ReportingTask ( "<STR_LIT>" , target = NS . default , report = cap ) <EOL> final = ReportingTask ( "<STR_LIT>" , target = NS . default , report = cap ) <EOL> with_dependencies ( initial | wrapped_task | final ) <EOL> cfg = OuterCfg ( ) <EOL> cfg . set_namespace ( ns ) <EOL> ea = ExecutionAgent ( config_model_instance = cfg , namespace_model_instance = ns , <EOL> infra_model_instance = infra , no_delay = True ) <EOL> try : <EOL> ea . perform_config ( ) <EOL> except ExecutionException , e : <EOL> import traceback <EOL> for task , etype , value , tb in ea . get_aborted_tasks ( ) : <EOL> print "<STR_LIT>" . format ( task . name ) <EOL> traceback . print_exception ( etype , value , tb ) <EOL> print <EOL> assert False , e . message <EOL> assert ( len ( cap . performed ) == <NUM_LIT:11> and <EOL> cap . pos ( "<STR_LIT:default>" , "<STR_LIT>" ) == len ( cap . performed ) - <NUM_LIT:1> and <EOL> cap . pos ( "<STR_LIT:default>" , "<STR_LIT>" ) == <NUM_LIT:0> ) <EOL> def test51 ( ) : <EOL> class SkipemNS ( NamespaceModel ) : <EOL> with_variables ( Var ( "<STR_LIT>" , "<STR_LIT:1>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT:2>" ) , <EOL> Var ( "<STR_LIT>" , "<STR_LIT>" , in_env = False ) ) <EOL> r = Role ( "<STR_LIT>" , host_ref = "<STR_LIT:127.0.0.1>" ) <EOL> ns = SkipemNS ( ) <EOL> class SkipConfig ( ConfigModel ) : <EOL> t = NullTask ( "<STR_LIT>" , task_role = SkipemNS . r ) <EOL> cfg = SkipConfig ( ) <EOL> cfg . set_namespace ( ns ) <EOL> assert "<STR_LIT>" in cfg . t . task_variables ( ) and "<STR_LIT>" not in cfg . t . task_variables ( for_env = True ) <EOL> def do_all ( ) : <EOL> setup ( ) <EOL> for k , v in globals ( ) . items ( ) : <EOL> if k . startswith ( "<STR_LIT:test>" ) and callable ( v ) : <EOL> v ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> do_all ( ) </s>
