Example #1
0
    def test_show_watch_metric(self):
        # Get one of the  watch rules created in test_show_watch
        # And add a metric datapoint
        watch = db_api.watch_rule_get(self.ctx, "HttpFailureAlarm")
        self.assertNotEqual(watch, None)
        values = {'watch_rule_id': watch.id,
                  'data': {
                        u'Namespace': u'system/linux',
                        u'ServiceFailure': {
                            u'Units': u'Counter', u'Value': 1}}}
        watch = db_api.watch_data_create(self.ctx, values)

        # Check there is one result returned
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(1, len(result))

        # Create another metric datapoint and check we get two
        watch = db_api.watch_data_create(self.ctx, values)
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(2, len(result))

        # Check the response has all keys defined in the engine API
        for key in engine_api.WATCH_DATA_KEYS:
            self.assertTrue(key in result[0])
Example #2
0
    def test_show_watch_metric(self):
        # Get one of the  watch rules created in test_show_watch
        # And add a metric datapoint
        watch = db_api.watch_rule_get_by_name(self.ctx, "HttpFailureAlarm")
        self.assertNotEqual(watch, None)
        values = {'watch_rule_id': watch.id,
                  'data': {
                        u'Namespace': u'system/linux',
                        u'ServiceFailure': {
                            u'Units': u'Counter', u'Value': 1}}}
        watch = db_api.watch_data_create(self.ctx, values)

        # Check there is one result returned
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(1, len(result))

        # Create another metric datapoint and check we get two
        watch = db_api.watch_data_create(self.ctx, values)
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(2, len(result))

        # Check the response has all keys defined in the engine API
        for key in engine_api.WATCH_DATA_KEYS:
            self.assertTrue(key in result[0])
Example #3
0
    def test_show_watch_metric(self):
        # Insert dummy watch rule into the DB
        values = {
            'stack_id': self.stack.id,
            'state': 'NORMAL',
            'name': u'HttpFailureAlarm',
            'rule': {
                u'EvaluationPeriods': u'1',
                u'AlarmActions': [u'WebServerRestartPolicy'],
                u'AlarmDescription': u'Restart the WikiDatabase',
                u'Namespace': u'system/linux',
                u'Period': u'300',
                u'ComparisonOperator': u'GreaterThanThreshold',
                u'Statistic': u'SampleCount',
                u'Threshold': u'2',
                u'MetricName': u'ServiceFailure'
            }
        }
        db_ret = db_api.watch_rule_create(self.ctx, values)
        self.assertNotEqual(db_ret, None)

        # And add a metric datapoint
        watch = db_api.watch_rule_get_by_name(self.ctx, "HttpFailureAlarm")
        self.assertNotEqual(watch, None)
        values = {
            'watch_rule_id': watch.id,
            'data': {
                u'Namespace': u'system/linux',
                u'ServiceFailure': {
                    u'Units': u'Counter',
                    u'Value': 1
                }
            }
        }
        watch = db_api.watch_data_create(self.ctx, values)

        # Check there is one result returned
        result = self.man.show_watch_metric(self.ctx,
                                            namespace=None,
                                            metric_name=None)
        self.assertEqual(1, len(result))

        # Create another metric datapoint and check we get two
        watch = db_api.watch_data_create(self.ctx, values)
        result = self.man.show_watch_metric(self.ctx,
                                            namespace=None,
                                            metric_name=None)
        self.assertEqual(2, len(result))

        # Cleanup, delete the dummy rule
        db_api.watch_rule_delete(self.ctx, "HttpFailureAlarm")

        # Check the response has all keys defined in the engine API
        for key in engine_api.WATCH_DATA_KEYS:
            self.assertTrue(key in result[0])
Example #4
0
    def test_show_watch_metric(self):
        # Insert dummy watch rule into the DB
        values = {'stack_id': self.stack.id,
                  'state': 'NORMAL',
                  'name': u'HttpFailureAlarm',
                   'rule': {
                        u'EvaluationPeriods': u'1',
                        u'AlarmActions': [u'WebServerRestartPolicy'],
                        u'AlarmDescription': u'Restart the WikiDatabase',
                        u'Namespace': u'system/linux',
                        u'Period': u'300',
                        u'ComparisonOperator': u'GreaterThanThreshold',
                        u'Statistic': u'SampleCount',
                        u'Threshold': u'2',
                        u'MetricName': u'ServiceFailure'}}
        db_ret = db_api.watch_rule_create(self.ctx, values)
        self.assertNotEqual(db_ret, None)

        # And add a metric datapoint
        watch = db_api.watch_rule_get_by_name(self.ctx, "HttpFailureAlarm")
        self.assertNotEqual(watch, None)
        values = {'watch_rule_id': watch.id,
                  'data': {
                        u'Namespace': u'system/linux',
                        u'ServiceFailure': {
                            u'Units': u'Counter', u'Value': 1}}}
        watch = db_api.watch_data_create(self.ctx, values)

        # Check there is one result returned
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(1, len(result))

        # Create another metric datapoint and check we get two
        watch = db_api.watch_data_create(self.ctx, values)
        result = self.man.show_watch_metric(self.ctx, namespace=None,
                                            metric_name=None)
        self.assertEqual(2, len(result))

        # Cleanup, delete the dummy rule
        db_api.watch_rule_delete(self.ctx, "HttpFailureAlarm")

        # Check the response has all keys defined in the engine API
        for key in engine_api.WATCH_DATA_KEYS:
            self.assertTrue(key in result[0])
Example #5
0
    def test_show_watch_metric(self):
        # Get one of the  watch rules created in test_show_watch
        # And add a metric datapoint
        watch = db_api.watch_rule_get_by_name(self.ctx, "HttpFailureAlarm")
        self.assertNotEqual(watch, None)
        values = {
            "watch_rule_id": watch.id,
            "data": {u"Namespace": u"system/linux", u"ServiceFailure": {u"Units": u"Counter", u"Value": 1}},
        }
        watch = db_api.watch_data_create(self.ctx, values)

        # Check there is one result returned
        result = self.man.show_watch_metric(self.ctx, namespace=None, metric_name=None)
        self.assertEqual(1, len(result))

        # Create another metric datapoint and check we get two
        watch = db_api.watch_data_create(self.ctx, values)
        result = self.man.show_watch_metric(self.ctx, namespace=None, metric_name=None)
        self.assertEqual(2, len(result))

        # Check the response has all keys defined in the engine API
        for key in engine_api.WATCH_DATA_KEYS:
            self.assertTrue(key in result[0])