def test_nodegroup0(): name, addr = 'nodegroup', 'tcp://127.0.0.1:*' process_nodegroup0 = ProcessSpawner(NodeGroup, name, addr) client0 = RPCClient(name, process_nodegroup0.addr) n = 5 for i in range(n): client0.create_node('mynode{}'.format(i), '_MyTestNode') for i in range(n): client0.control_node('mynode{}'.format(i), 'configure') for i in range(n): client0.control_node('mynode{}'.format(i), 'initialize') for i in range(n): client0.control_node('mynode{}'.format(i), 'start') for i in range(n): client0.control_node('mynode{}'.format(i), 'stop') for i in range(n): client0.delete_node('mynode{}'.format(i)) process_nodegroup0.stop()
def test_host2(): process_host0 = ProcessSpawner(Host, 'host0', 'tcp://127.0.0.1:*') client0 = RPCClient('host0', process_host0.addr) client0.create_nodegroup('nodegroup 0.1', 'tcp://127.0.0.1:*') client0.create_nodegroup('nodegroup 0.2', 'tcp://127.0.0.1:*') time.sleep(2.) client0.close_nodegroup('nodegroup 0.1') client0.close_nodegroup('nodegroup 0.2') time.sleep(1.) process_host0.stop()
def test_cannot_delete_node_while_running(): name, addr = 'nodegroup', 'tcp://127.0.0.1:*' process_nodegroup0 = ProcessSpawner(NodeGroup, name, addr) client0 = RPCClient(name, process_nodegroup0.addr) client0.create_node('mynode', '_MyTestNode') client0.control_node('mynode', 'configure') client0.control_node('mynode', 'initialize') client0.control_node('mynode', 'start') with pytest.raises(RemoteCallException): # a running node cannot be delete client0.delete_node('mynode') client0.control_node('mynode', 'stop') client0.delete_node('mynode') process_nodegroup0.stop()
def basic_test_manager(): # Create a local Host to communicate with test_host = ProcessSpawner(Host, name="test-host", addr="tcp://127.0.0.1:*") host_cli = RPCClient(test_host.name, test_host.addr) mgr = ProcessSpawner(Manager, name="manager", addr="tcp://127.0.0.1:*") mcli = RPCClient(mgr.name, mgr.addr) # test connection to host host_name = test_host.name mcli.connect_host(host_name, test_host.addr) assert mcli.list_hosts() == [host_name] # create nodegroup and nodes assert mcli.list_nodegroups(host_name) == [] mcli.create_nodegroup(host_name, "nodegroup1") assert mcli.list_nodegroups(host_name) == ["nodegroup1"] assert mcli.list_nodes("nodegroup1") == [] mcli.create_node("nodegroup1", "node1", "_MyTestNode") assert mcli.list_nodes("nodegroup1") == ["node1"] mcli.control_node("node1", "start") mcli.control_node("node1", "stop") mcli.delete_node("node1") assert mcli.list_nodes("nodegroup1") == [] # mcli.close() # host_cli.close() mgr.stop() test_host.stop()
def test_host1(): process_host0 = ProcessSpawner(Host, 'host0', 'tcp://127.0.0.1:*') process_host1 = ProcessSpawner(Host, 'host1', 'tcp://127.0.0.1:*') client0 = RPCClient('host0', process_host0.addr) print('on ping: ', client0.ping()) time.sleep(1.) process_host0.stop() process_host1.stop()
def test_remotly_show_qwidget_node(): name, addr = 'nodegroup0', 'tcp://127.0.0.1:*' process_nodegroup0 = ProcessSpawner(NodeGroup, name, addr) client0 = RPCClient(name, process_nodegroup0.addr) client0.create_node('mynode', '_MyTestNodeQWidget') client0.control_node('mynode', 'show') name, addr = 'nodegroup1', 'tcp://127.0.0.1:*' process_nodegroup1 = ProcessSpawner(NodeGroup, name, addr) client1 = RPCClient(name, process_nodegroup1.addr) client1.create_node('mynode', '_MyTestNodeQWidget') client1.control_node('mynode', 'show') time.sleep(3.) process_nodegroup0.stop() process_nodegroup1.stop()