示例#1
0
def mk_metric_config_data(**overrides):
    return utils.add_dicts({
        'target': 'a.last',
        'bucket_size': '1h',
        'null_filter': 'zeroize',
        'metadata': {'name': 'max of a'}
    }, overrides)
示例#2
0
 def mk_widget_config(self, **overrides):
     return WidgetConfig(utils.add_dicts({
         'type': 'diamondash.widgets.widget.Widget',
         'name': 'toy',
         'title': 'Toy',
         'width': 2
     }, overrides))
示例#3
0
def mk_config_data(**overrides):
    return utils.add_dicts({
        'name': 'test-histogram',
        'target': 'some.target',
        'time_range': '1d',
        'backend': {'type': 'diamondash.tests.utils.ToyBackend'}
    }, overrides)
示例#4
0
    def test_add_dicts(self):
        original = {'a': 1}
        defaults = {'a': 0, 'b': 2}
        self.assertEqual(
            utils.add_dicts(defaults, original), {'a': 1, 'b': 2})
        self.assertEqual(original, {'a': 1})
        self.assertEqual(defaults, {'a': 0, 'b': 2})

        original = {'a': 1}
        defaults1 = {'a': 0, 'b': 2}
        defaults2 = {'b': 3, 'c': 4}
        self.assertEqual(
            utils.add_dicts(defaults1, defaults2, original),
            {'a': 1, 'b': 3, 'c': 4})
        self.assertEqual(original, {'a': 1})
        self.assertEqual(defaults1, {'a': 0, 'b': 2})
        self.assertEqual(defaults2, {'b': 3, 'c': 4})
示例#5
0
def mk_config_data(**overrides):
    return utils.add_dicts({
        'name': 'some-widget',
        'target': 'some.target',
        'title': 'Some LValue Widget',
        'width': 2,
        'time_range': '5s',
        'backend': {'type': 'diamondash.tests.utils.ToyBackend'}
    }, overrides)
示例#6
0
    def parse_widget(self, config):
        type_cls = utils.load_class_by_string(config['type'])

        if issubclass(type_cls, DynamicWidget):
            config['backend'] = utils.add_dicts(
                self.backend_dict,
                config.get('backend', {}))

        config_cls = Config.for_type(config['type'])
        return config_cls(config)
示例#7
0
def mk_config_data(**overrides):
    return utils.add_dicts({
        'name': 'test-chart-widget',
        'graphite_url': 'fake_graphite_url',
        'metrics': [
            {'name': 'random sum', 'target': 'vumi.random.count.sum'},
            {'name': 'random avg', 'target': 'vumi.random.timer.avg'}],
        'time_range': '1d',
        'null_filter': 'zeroize',
        'backend': {'type': 'diamondash.tests.utils.ToyBackend'}
    }, overrides)
示例#8
0
def mk_dashboard_config_data(**overrides):
    return utils.add_dicts({
        'name': 'Some Dashboard',
        'request_interval': '2s',
        'share_id': 'some-share-id',
        'widgets': [{
            'name': 'Widget 1',
            'type': 'diamondash.tests.utils.ToyDynamicWidget',
        }, {
            'name': 'Widget 2',
            'type': 'diamondash.widgets.widget.Widget',
        }],
    }, overrides)
示例#9
0
def mk_server_config_data(**overrides):
    return utils.add_dicts({
        'backend': {
            'type': 'diamondash.tests.utils.ToyBackend',
            'url': 'http://127.0.0.1:3000',
        },
        'dashboards': [
            mk_dashboard_config_data(
                name='Dashboard 1',
                share_id='dashboard-1-share-id'),
            mk_dashboard_config_data(
                name='Dashboard 2',
                share_id='dashboard-2-share-id')]
    }, overrides)
示例#10
0
    def parse(cls, config):
        if 'url' not in config:
            raise ConfigError("GraphiteBackend needs a 'url' config field.")

        metric_underrides = dict(
            (k, config.pop(k))
            for k in cls.METRIC_UNDERRIDES if k in config)

        config['metrics'] = [
            utils.add_dicts(metric_underrides, m) for m in config['metrics']]

        config['metrics'] = [
            GraphiteMetricConfig(m) for m in config['metrics']]

        return config
示例#11
0
def mk_backend_config_data(**overrides):
    return utils.add_dicts({
        'null_filter': 'zeroize',
        'bucket_size': '5m',
        'time_alignment': 'round',
        'url': 'http://some-graphite-url.moc:8080/',
        'metrics': [{
            'target': 'a.last',
            'null_filter': 'zeroize',
            'metadata': {'name': 'max of a'}
        }, {
            'target': 'b.sum',
            'null_filter': 'skip',
            'metadata': {'name': 'sum of b'}
        }]
    }, overrides)
示例#12
0
def mk_config_data(**overrides):
    return utils.add_dicts({
        'name': 'Some Dashboard',
        'poll_interval': '2s',
        'share_id': 'some-dashboard-share-id',
        'widgets': [
            {
                'name': 'widget1',
                'type': 'diamondash.widgets.widget.Widget',
            },
            'new_row',
            {
                'name': 'widget2',
                'type': 'diamondash.tests.utils.ToyDynamicWidget',
            }
        ],
        'backend': {
            'type': 'diamondash.tests.utils.ToyBackend',
            'url': 'http://127.0.0.1:3000',
        }
    }, overrides)
示例#13
0
 def _apply_dashboard_defaults(cls, config, dashboard_config):
     return utils.add_dicts({
         'backend': config['backend'],
         'poll_interval': config['poll_interval'],
     }, dashboard_config)
示例#14
0
 def from_file(cls, filename, **defaults):
     items = utils.add_dicts(defaults, yaml.safe_load(open(filename)))
     return cls(items)
示例#15
0
 def _parse(cls, items):
     items = utils.add_dicts(cls.DEFAULTS, items)
     return cls.parse(items)
示例#16
0
def mk_metric_config_data(**overrides):
    return utils.add_dicts({
        'target': 'a.last',
    }, overrides)