def test_transaction_resp_update_transaction_status(self, _): task = self.env.create_task(name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id) NailgunReceiver.transaction_resp(task_uuid=task.uuid, status=consts.TASK_STATUSES.ready) self.db.refresh(task) self.assertEqual(consts.TASK_STATUSES.ready, task.status)
def test_transaction_resp_update_transaction_status(self, _): task = self.env.create_task( name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id ) NailgunReceiver.transaction_resp( task_uuid=task.uuid, status=consts.TASK_STATUSES.ready ) self.db.refresh(task) self.assertEqual(consts.TASK_STATUSES.ready, task.status)
def test_transaction_resp_update_node_attributes(self): task = self.env.create_task(name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id) node = self.cluster.nodes[0] node.status = consts.NODE_STATUSES.provisioned node.progress = 1 node.pending_addition = True NailgunReceiver.transaction_resp(task_uuid=task.uuid, nodes=[{ 'uid': node.uid, 'progress': 50, 'pending_addition': False }]) self.db.refresh(node) self.assertEqual(50, node.progress) self.assertFalse(node.pending_addition)
def test_transaction_resp_update_node_attributes(self): task = self.env.create_task( name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id ) node = self.cluster.nodes[0] node.status = consts.NODE_STATUSES.provisioned node.progress = 1 node.pending_addition = True NailgunReceiver.transaction_resp( task_uuid=task.uuid, nodes=[{ 'uid': node.uid, 'progress': 50, 'pending_addition': False }] ) self.db.refresh(node) self.assertEqual(50, node.progress) self.assertFalse(node.pending_addition)
def test_transaction_resp_does_not_fail_on_virtual_nodes(self): task = self.env.create_task(name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id, dry_run=True) NailgunReceiver.transaction_resp( task_uuid=task.uuid, status=consts.TASK_STATUSES.running, nodes=[ { 'uid': consts.MASTER_NODE_UID, 'status': consts.NODE_STATUSES.provisioned, }, { # cluster node uid is null 'uid': None, 'status': consts.NODE_STATUSES.provisioned, }, ])
def test_transaction_resp_does_not_fail_on_virtual_nodes(self): task = self.env.create_task( name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id, dry_run=True ) NailgunReceiver.transaction_resp( task_uuid=task.uuid, status=consts.TASK_STATUSES.running, nodes=[ { 'uid': consts.MASTER_NODE_UID, 'status': consts.NODE_STATUSES.provisioned, }, { # cluster node uid is null 'uid': None, 'status': consts.NODE_STATUSES.provisioned, }, ])
def test_transaction_resp_does_not_update_nodes_if_dry_run(self, _): task = self.env.create_task( name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id, dry_run=True ) self.cluster.status = consts.CLUSTER_STATUSES.operational node = self.cluster.nodes[0] node.status = consts.NODE_STATUSES.provisioned NailgunReceiver.transaction_resp( task_uuid=task.uuid, status=consts.TASK_STATUSES.ready, nodes=[{'uid': node.uid, 'status': consts.NODE_STATUSES.ready}] ) self.db.refresh(task) self.db.refresh(node) self.db.refresh(self.cluster) self.assertEqual(consts.TASK_STATUSES.ready, task.status) self.assertEqual(consts.NODE_STATUSES.provisioned, node.status) self.assertEqual( consts.CLUSTER_STATUSES.operational, self.cluster.status )
def test_transaction_resp_does_not_update_nodes_if_dry_run(self, _): task = self.env.create_task(name=consts.TASK_NAMES.deployment, status=consts.TASK_STATUSES.running, cluster_id=self.cluster.id, dry_run=True) self.cluster.status = consts.CLUSTER_STATUSES.operational node = self.cluster.nodes[0] node.status = consts.NODE_STATUSES.provisioned NailgunReceiver.transaction_resp(task_uuid=task.uuid, status=consts.TASK_STATUSES.ready, nodes=[{ 'uid': node.uid, 'status': consts.NODE_STATUSES.ready }]) self.db.refresh(task) self.db.refresh(node) self.db.refresh(self.cluster) self.assertEqual(consts.TASK_STATUSES.ready, task.status) self.assertEqual(consts.NODE_STATUSES.provisioned, node.status) self.assertEqual(consts.CLUSTER_STATUSES.operational, self.cluster.status)