Exemple #1
0
    def test_notification_delete_cluster_failed(self):
        cluster = self.env.create_cluster(api=False)
        receiver = rcvr.NailgunReceiver()

        task = Task(uuid=str(uuid.uuid4()),
                    name="cluster_deletion",
                    cluster_id=cluster.id)
        self.db.add(task)
        self.db.commit()

        kwargs = {
            'task_uuid': task.uuid,
            'status': 'error',
            'error': 'Cluster deletion fake error'
        }

        receiver.remove_cluster_resp(**kwargs)

        notifications = self.db.query(Notification).filter_by(
            cluster_id=cluster.id).all()
        self.assertEqual(len(notifications), 1)
        self.assertEqual(notifications[0].status, "unread")
        self.assertEqual(notifications[0].topic, "error")
        self.assertEqual(notifications[0].cluster_id, cluster.id)
        self.assertEqual(notifications[0].message,
                         "Cluster deletion fake error")
Exemple #2
0
    def test_notification_deploy_error_with_nodes(self):
        cluster = self.env.create(api=False,
                                  nodes_kwargs=[{
                                      'status':
                                      consts.NODE_STATUSES.error,
                                      'error_type':
                                      consts.NODE_ERRORS.deploy
                                  }])
        receiver = rcvr.NailgunReceiver()

        task = Task(uuid=str(uuid.uuid4()),
                    name="super",
                    cluster_id=cluster.id)
        self.db.add(task)
        self.db.flush()

        kwargs = {
            'task_uuid': task.uuid,
            'status': 'error',
        }

        receiver.deploy_resp(**kwargs)

        notifications = self.db.query(Notification).filter_by(
            cluster_id=cluster.id).all()
        self.assertEqual(len(notifications), 1)
        self.assertEqual(notifications[0].status, "unread")
        self.assertEqual(notifications[0].topic, "error")
Exemple #3
0
    def test_notification_delete_cluster_done(self):
        cluster = self.env.create_cluster(api=False)
        cluster_name = cluster.name
        receiver = rcvr.NailgunReceiver()

        task = Task(uuid=str(uuid.uuid4()),
                    name="cluster_deletion",
                    cluster_id=cluster.id)
        self.db.add(task)
        self.db.commit()

        kwargs = {
            'task_uuid': task.uuid,
            'status': 'ready',
        }

        receiver.remove_cluster_resp(**kwargs)

        notifications = self.db.query(Notification).all()
        self.assertEqual(len(notifications), 1)
        self.assertEqual(notifications[0].status, "unread")
        self.assertEqual(notifications[0].topic, "done")
        self.assertEqual(
            notifications[0].message, "Environment '%s' and all its nodes "
            "are deleted" % cluster_name)
Exemple #4
0
    def setUp(self):
        super(TestDhcpCheckTask, self).setUp()
        self.receiver = rcvr.NailgunReceiver()
        self.env.create(cluster_kwargs={},
                        nodes_kwargs=[{
                            "api": False
                        }, {
                            "api": False
                        }])
        cluster_db = self.env.clusters[0]
        self.node1, self.node2 = self.env.nodes

        self.task = Task(name="check_dhcp", cluster_id=cluster_db.id)
        self.db.add(self.task)
        self.db.commit()
Exemple #5
0
    def test_notification_deploy_error_without_nodes(self):
        cluster = self.env.create_cluster(api=False)
        receiver = rcvr.NailgunReceiver()

        task = Task(uuid=str(uuid.uuid4()),
                    name="super",
                    cluster_id=cluster.id)
        self.db.add(task)
        self.db.flush()

        kwargs = {
            'task_uuid': task.uuid,
            'status': 'error',
        }

        receiver.deploy_resp(**kwargs)

        notifications = self.db.query(Notification).filter_by(
            cluster_id=cluster.id).all()
        self.assertEqual(len(notifications), 0)
Exemple #6
0
    def setUp(self):
        super(TestClusterUpdate, self).setUp()
        self.receiver = rcvr.NailgunReceiver()
        cluster_id = self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False, "status": consts.NODE_STATUSES.deploying},
                {"api": False, "status": consts.NODE_STATUSES.deploying}],
        )['id']
        self.cluster = self.db.query(Cluster).get(cluster_id)
        self.cluster.pending_release_id = self.cluster.release_id
        self.cluster.status = consts.CLUSTER_STATUSES.update
        self.db.commit()

        self.task = Task(
            uuid=str(uuid.uuid4()),
            name=consts.TASK_NAMES.update,
            cluster_id=self.cluster.id
        )
        self.db.add(self.task)
        self.db.commit()
Exemple #7
0
    def test_notification_deploy_done(self):
        cluster = self.env.create_cluster(api=False)
        receiver = rcvr.NailgunReceiver()

        task = Task(uuid=str(uuid.uuid4()),
                    name="super",
                    cluster_id=cluster.id)
        self.db.add(task)
        self.db.commit()

        kwargs = {
            'task_uuid': task.uuid,
            'status': 'ready',
        }

        receiver.deploy_resp(**kwargs)

        notifications = self.db.query(Notification).filter_by(
            cluster_id=cluster.id).all()
        self.assertEqual(len(notifications), 1)
        self.assertEqual(notifications[0].status, "unread")
        self.assertEqual(notifications[0].topic, "done")
Exemple #8
0
 def setUp(self):
     super(BaseReciverTestCase, self).setUp()
     self.receiver = rcvr.NailgunReceiver()
Exemple #9
0
 def setUp(self):
     super(TestConsumer, self).setUp()
     self.receiver = rcvr.NailgunReceiver()
Exemple #10
0
 def setUp(self):
     super(TestVerifyNetworks, self).setUp()
     self.receiver = rcvr.NailgunReceiver()