def test_update_cluster_to_operational(self): task = Task(name='deploy', cluster=self.cluster, status='ready') self.db.add(task) self.db.commit() TaskHelper.update_cluster_status(task.uuid) self.assertEquals(self.cluster.status, 'operational')
def test_update_cluster_to_error_if_deploy_task_failed(self): task = Task(name='deploy', cluster=self.cluster, status='error') self.db.add(task) self.db.commit() TaskHelper.update_cluster_status(task.uuid) self.assertEquals(self.cluster.status, 'error')
def test_update_nodes_to_error_if_provision_task_failed(self): self.cluster.nodes[0].status = 'provisioning' self.cluster.nodes[0].progress = 12 task = Task(name='provision', cluster=self.cluster, status='error') self.db.add(task) self.db.commit() TaskHelper.update_cluster_status(task.uuid) self.assertEquals(self.cluster.status, 'error') self.node_should_be_error_with_type(self.cluster.nodes[0], 'provision') self.nodes_should_not_be_error(self.cluster.nodes[1:])
def test_do_not_set_cluster_to_error_if_validation_failed(self): for task_name in ['check_before_deployment', 'check_networks']: supertask = Task(name='deploy', cluster=self.cluster, status='error') check_task = Task(name=task_name, cluster=self.cluster, status='error') supertask.subtasks.append(check_task) self.db.add(check_task) self.db.commit() TaskHelper.update_cluster_status(supertask.uuid) self.assertEquals(self.cluster.status, 'new')
def test_do_not_set_cluster_to_error_if_validation_failed(self): for task_name in ['check_before_deployment', 'check_networks']: supertask = Task( name='deploy', cluster=self.cluster, status='error') check_task = Task( name=task_name, cluster=self.cluster, status='error') supertask.subtasks.append(check_task) self.db.add(check_task) self.db.commit() TaskHelper.update_cluster_status(supertask.uuid) self.assertEquals(self.cluster.status, 'new')
def test_update_if_parent_task_is_ready_all_nodes_should_be_ready(self): for node in self.cluster.nodes: node.status = 'ready' node.progress = 100 self.cluster.nodes[0].status = 'deploying' self.cluster.nodes[0].progress = 24 task = Task(name='deploy', cluster=self.cluster, status='ready') self.db.add(task) self.db.commit() TaskHelper.update_cluster_status(task.uuid) self.assertEquals(self.cluster.status, 'operational') for node in self.cluster.nodes: self.assertEquals(node.status, 'ready') self.assertEquals(node.progress, 100)