Exemplo n.º 1
0
    def test_instances(self, publish, _get_stats_by_database):
        def side_effect(host, port, user, pwd, slony_db, slony_schema, node):
            if (slony_db, slony_schema) == ('postgres', '_postgres'):
                return [('foo', 7)]
            elif (slony_db, slony_schema) == ('data', '_data'):
                return [('bar', 14)]

        _get_stats_by_database.side_effect = side_effect

        config = get_collector_config(
            'SlonyCollector', {
                'instances': {
                    'alpha': {
                        'slony_db': 'postgres',
                        'slony_schema': '_postgres',
                    },
                    'beta': {
                        'slony_db': 'data',
                        'slony_schema': '_data',
                    },
                }
            })

        collector = SlonyCollector(config, None)
        collector.collect()

        self.assertPublished(publish, 'foo', 7)
        self.assertPublished(publish, 'bar', 14)
Exemplo n.º 2
0
    def test_override_user_password_nodestr(self, _get_stats_by_database):
        config = get_collector_config(
            'SlonyCollector', {
                'instances': {
                    'alpha': {
                        'slony_db': 'postgres',
                        'slony_schema': '_postgres',
                        'user': '******',
                        'password': '******',
                        'slony_node_string': '(.*)',
                    },
                    'beta': {
                        'slony_db': 'data',
                        'slony_schema': '_data',
                        'user': '******',
                        'password': '******',
                        'slony_node_string': 'Node (.*)',
                    },
                }
            })

        collector = SlonyCollector(config, None)
        collector.collect()

        _get_stats_by_database.assert_any_call('localhost', 5432, 'postgres',
                                               'postgres', 'postgres',
                                               '_postgres', '(.*)')
        _get_stats_by_database.assert_any_call('localhost', 5432, 'data',
                                               'data', 'data', '_data',
                                               'Node (.*)')
Exemplo n.º 3
0
 def setUp(self):
     config = get_collector_config('SlonyCollector', {})
     self.collector = SlonyCollector(config, None)