Esempio n. 1
0
 def test_with_authenticator(self):
     """
     Uses authenticator provided instead of creating new
     """
     _reactor, auth = mock.Mock(), mock.Mock()
     with self.sequence.consume():
         d = collect_metrics(_reactor, self.config, self.log, authenticator=auth)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.get_dispatcher.assert_called_once_with(_reactor, auth, self.log, mock.ANY, mock.ANY)
Esempio n. 2
0
 def test_with_client(self):
     """
     Uses client provided and does not disconnect it before returning
     """
     client = mock.Mock(spec=["disconnect"])
     with self.sequence.consume():
         d = collect_metrics("reactr", self.config, self.log, client=client)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.assertFalse(self.connect_cass_servers.called)
     self.assertFalse(client.disconnect.called)
Esempio n. 3
0
 def test_with_client(self):
     """
     Uses client provided and does not disconnect it before returning
     """
     client = mock.Mock(spec=['disconnect'])
     with self.sequence.consume():
         d = collect_metrics("reactr", self.config, self.log, client=client)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.assertFalse(self.connect_cass_servers.called)
     self.assertFalse(client.disconnect.called)
Esempio n. 4
0
 def test_without_metrics(self):
     """
     Doesnt add metrics to blueflood if metrics config is not there
     """
     sequence = SequenceDispatcher([(GetAllValidGroups(), const(self.groups))])
     self.get_dispatcher.return_value = sequence
     del self.config["metrics"]
     with sequence.consume():
         d = collect_metrics("reactor", self.config, self.log)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.assertFalse(self.add_to_cloud_metrics.called)
Esempio n. 5
0
 def test_without_metrics(self):
     """
     Doesnt add metrics to blueflood if metrics config is not there
     """
     sequence = SequenceDispatcher([(GetAllValidGroups(),
                                     const(self.groups))])
     self.get_dispatcher.return_value = sequence
     del self.config["metrics"]
     with sequence.consume():
         d = collect_metrics("reactor", self.config, self.log)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.assertFalse(self.add_to_cloud_metrics.called)
Esempio n. 6
0
 def test_with_authenticator(self):
     """
     Uses authenticator provided instead of creating new
     """
     _reactor, auth = mock.Mock(), mock.Mock()
     with self.sequence.consume():
         d = collect_metrics(_reactor,
                             self.config,
                             self.log,
                             authenticator=auth)
         self.assertEqual(self.successResultOf(d), "metrics")
     self.get_dispatcher.assert_called_once_with(_reactor, auth, self.log,
                                                 mock.ANY, mock.ANY)
Esempio n. 7
0
    def test_metrics_collected(self):
        """
        Metrics is collected after getting groups from cass and servers
        from nova and it is added to blueflood
        """
        _reactor = mock.Mock()

        with self.sequence.consume():
            d = collect_metrics(_reactor, self.config, self.log)
            self.assertEqual(self.successResultOf(d), "metrics")

        self.connect_cass_servers.assert_called_once_with(_reactor, "c")
        self.get_all_metrics.assert_called_once_with(
            self.get_dispatcher.return_value, self.lc_groups, self.log, _print=False
        )
        self.client.disconnect.assert_called_once_with()
Esempio n. 8
0
    def test_metrics_collected(self):
        """
        Metrics is collected after getting groups from cass and servers
        from nova and it is added to blueflood
        """
        _reactor = mock.Mock()

        with self.sequence.consume():
            d = collect_metrics(_reactor, self.config, self.log)
            self.assertEqual(self.successResultOf(d), "metrics")

        self.connect_cass_servers.assert_called_once_with(_reactor, 'c')
        self.get_all_metrics.assert_called_once_with(
            self.get_dispatcher.return_value,
            self.lc_groups,
            self.log,
            _print=False)
        self.client.disconnect.assert_called_once_with()