예제 #1
0
class BlackoutTestCase(unittest.TestCase):
    def setUp(self):
        self.client = Client()

        self.blackout = """
            {
                "blackout": {
                    "createTime": "2021-04-14T20:36:06.453Z",
                    "customer": null,
                    "duration": 3600,
                    "endTime": "2021-04-14T21:36:06.453Z",
                    "environment": "Production",
                    "event": "node_down",
                    "group": "Network",
                    "href": "http://local.alerta.io:8080/blackout/5ed223a3-27dc-4c4c-97d1-504f107d8a1a",
                    "id": "5ed223a3-27dc-4c4c-97d1-504f107d8a1a",
                    "origin": "foo/xyz",
                    "priority": 8,
                    "remaining": 3600,
                    "resource": "web01",
                    "service": [
                      "Web",
                      "App"
                    ],
                    "startTime": "2021-04-14T20:36:06.453Z",
                    "status": "active",
                    "tags": [
                      "london",
                      "linux"
                    ],
                    "text": "Network outage in Bracknell",
                    "user": "******"
                },
                "id": "5ed223a3-27dc-4c4c-97d1-504f107d8a1a",
                "status": "ok"
            }
        """

    @requests_mock.mock()
    def test_blackout(self, m):
        m.post('http://*****:*****@alerta.dev')
예제 #2
0
class BlackoutTestCase(unittest.TestCase):
    def setUp(self):
        self.client = Client()

        self.blackout = """
            {
                "blackout": {
                    "createTime": "2018-08-26T20:45:04.622Z",
                    "customer": null,
                    "duration": 3600,
                    "endTime": "2018-08-26T21:45:04.622Z",
                    "environment": "Production",
                    "event": null,
                    "group": null,
                    "href": "http://localhost:8080/blackout/e18a4be8-60d7-4ce2-9b3d-f18d814f7b85",
                    "id": "e18a4be8-60d7-4ce2-9b3d-f18d814f7b85",
                    "priority": 3,
                    "remaining": 3599,
                    "resource": null,
                    "service": [
                        "Network"
                    ],
                    "startTime": "2018-08-26T20:45:04.622Z",
                    "status": "active",
                    "tags": [
                        "london",
                        "linux"
                    ],
                    "text": "Network outage in Bracknell",
                    "user": "******"
                },
                "id": "e18a4be8-60d7-4ce2-9b3d-f18d814f7b85",
                "status": "ok"
            }
        """

    @requests_mock.mock()
    def test_blackout(self, m):
        m.post('http://*****:*****@alerta.io')
예제 #3
0
class AlertTestCase(unittest.TestCase):
    def setUp(self):
        self.client = Client(endpoint='http://api:8080', key='demo-key')

    def test_blackout(self):
        blackout = self.client.create_blackout(environment='Production',
                                               service=['Web', 'App'],
                                               resource='web01',
                                               event='node_down',
                                               group='Network',
                                               tags=['london', 'linux'])
        blackout_id = blackout.id

        self.assertEqual(blackout.environment, 'Production')
        self.assertEqual(blackout.service, ['Web', 'App'])
        self.assertIn('london', blackout.tags)
        self.assertIn('linux', blackout.tags)

        blackout = self.client.update_blackout(blackout_id,
                                               environment='Development',
                                               group='Network',
                                               text='updated blackout')
        self.assertEqual(blackout.environment, 'Development')
        self.assertEqual(blackout.group, 'Network')
        self.assertEqual(blackout.text, 'updated blackout')

        blackout = self.client.create_blackout(environment='Production',
                                               service=['Core'],
                                               group='Network')

        blackouts = self.client.get_blackouts()
        self.assertEqual(len(blackouts), 2)

        self.client.delete_blackout(blackout_id)

        blackouts = self.client.get_blackouts()
        self.assertEqual(len(blackouts), 1)
예제 #4
0
class BlackoutTestCase(unittest.TestCase):
    def setUp(self):
        self.client = Client()

        self.blackout = """
            {
              "blackout": {
                "customer": null,
                "duration": 300,
                "endTime": "2017-10-03T08:26:00.948Z",
                "environment": "Production",
                "event": "node_down",
                "group": "Network",
                "href": "http://localhost:8080/blackout/8eb1504f-cb48-433d-854c-b31e06284af9",
                "id": "8eb1504f-cb48-433d-854c-b31e06284af9",
                "priority": 3,
                "remaining": 299,
                "resource": "web01",
                "service": [
                  "Web",
                  "App"
                ],
                "startTime": "2017-10-03T08:21:00.948Z",
                "status": "active",
                "tags": [
                  "london",
                  "linux"
                ]
              },
              "id": "8eb1504f-cb48-433d-854c-b31e06284af9",
              "status": "ok"
            }
        """

    @requests_mock.mock()
    def test_blackout(self, m):
        m.post('http://localhost:8080/blackout', text=self.blackout)
        alert = self.client.create_blackout(environment='Production',
                                            service=['Web', 'App'],
                                            resource='web01',
                                            event='node_down',
                                            group='Network',
                                            tags=["london", "linux"])
        self.assertEqual(alert.environment, 'Production')
        self.assertEqual(alert.service, ['Web', 'App'])
        self.assertEqual(alert.resource, 'web01')
        self.assertIn("london", alert.tags)