def test_schedule_actions_all_services(self): services = [ { 'template': 'github.com/threefoldtech/0-robot/node/0.0.1', 'service': 'node1', }, { 'template': 'github.com/threefoldtech/0-robot/node/0.0.1', 'service': 'node2', }, { 'template': 'github.com/threefoldtech/0-robot/vm/0.0.1', 'service': 'vm1', }, ] service_created, err_code, err_msg = instantiate_services(services) assert err_code is None assert err_msg is None actions = [{'action': 'start'}] tasks = [] for action_item in actions: tasks.extend(_schedule_action(action_item)) self.assertEqual(len(tasks), 3)
def test_schedule_actions(self): services = [ { 'template': 'github.com/zero-os/0-robot/node/0.0.1', 'service': 'name', }, { 'template': 'github.com/zero-os/0-robot/vm/0.0.1', 'service': 'name', }, ] service_created, err_code, err_msg = instantiate_services(services) assert err_code is None assert err_msg is None actions = [ { 'template': 'github.com/zero-os/0-robot/node', 'name': 'name', 'action': 'start' }, ] tasks = [] for action_item in actions: tasks.extend(_schedule_action(action_item)) self.assertEqual(len(tasks), 1)
def test_instantiate_service(self): services = [ { 'template': 'github.com/threefoldtech/0-robot/node/0.0.1', 'service': 'name', }, { 'template': 'github.com/threefoldtech/0-robot/vm/0.0.1', 'service': 'name', }, ] service_created, err_code, err_msg = instantiate_services(services) assert err_code is None assert err_msg is None self.assertEqual(len(scol.list_services()), 2) self.assertEqual( len( scol.find( template_uid='github.com/threefoldtech/0-robot/node/0.0.1') ), 1) self.assertEqual( len( scol.find( template_uid='github.com/threefoldtech/0-robot/vm/0.0.1')), 1)
def test_instantiate_service_error(self): services = [ { 'template': 'github.com/threefoldtech/0-robot/node/0.0.1', 'service': 'node1', 'data': {}, }, { 'template': 'github.com/threefoldtech/0-robot/validate/0.0.1', 'service': 'name', 'data': {}, }, ] service_created, err_code, err_msg = instantiate_services(services) assert err_code == 500 assert err_msg == 'fail to create service name github.com/threefoldtech/0-robot/validate/0.0.1' assert len(service_created) == 1 assert len(scol.list_services( )) == 0, "service created during a failed blueprint, should be deleted"
def test_instantiate_service_error(self): services = [ { 'template': 'github.com/zero-os/0-robot/node/0.0.1', 'service': 'node1', 'data': {}, }, { 'template': 'github.com/zero-os/0-robot/validate/0.0.1', 'service': 'name', 'data': {}, }, ] service_created, err_code, err_msg = instantiate_services(services) assert err_code == 500 assert err_msg == 'required need to be specified in the data' assert len(service_created) == 1 assert len(scol.list_services( )) == 0, "service created during a failed blueprint, should be deleted"