def test_main_no_sleep_with_no_command(self):
        def fake_sleep(sleep_time):
            raise Exception(cfg.CONF.command)

        self.useFixture(fixtures.MonkeyPatch('time.sleep', fake_sleep))
        collect.__main__(['os-collect-config', 'heat_local', '--config-file',
                          '/dev/null', '-i', '10'])
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     requests_impl_map = {'ec2': test_ec2.FakeRequests,
                          'cfn': test_cfn.FakeRequests(self)}
     collect.__main__(args=fake_args, requests_impl_map=requests_impl_map)
Beispiel #3
0
    def test_main_no_sleep_with_no_command(self):
        def fake_sleep(sleep_time):
            raise Exception(cfg.CONF.command)

        self.useFixture(fixtures.MonkeyPatch('time.sleep', fake_sleep))
        collect.__main__(['os-collect-config', 'heat_local', '--config-file',
                          '/dev/null', '-i', '10'])
Beispiel #4
0
 def test_main_with_splay(self, randrange_mock, sleep_mock):
     randrange_mock.return_value = 4
     collect.__main__(args=[
         'os-collect-config', 'heat_local', '-i', '10',
         '--min-polling-interval', '20', '-c', 'true', '--print', '--splay',
         '29'
     ])
     randrange_mock.assert_called_with(0, 29)
     sleep_mock.assert_called_with(4)
Beispiel #5
0
    def test_main_sleep(self):
        class ExpectedException(Exception):
            pass

        def fake_sleep(sleep_time):
            if sleep_time == 10:
                raise ExpectedException

        self.useFixture(fixtures.MonkeyPatch('time.sleep', fake_sleep))
        try:
            collect.__main__(
                ['os-collect-config', 'heat_local', '-i', '10', '-c', 'true'])
        except ExpectedException:
            pass
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     collector_kwargs_map = {
         'ec2': {'requests_impl': test_ec2.FakeRequests},
         'cfn': {'requests_impl': test_cfn.FakeRequests(self)},
         'heat': {
             'keystoneclient': test_heat.FakeKeystoneClient(self),
             'heatclient': test_heat.FakeHeatClient(self)
         }
     }
     collect.__main__(args=fake_args,
                      collector_kwargs_map=collector_kwargs_map)
    def test_main_sleep(self):
        class ExpectedException(Exception):
            pass

        def fake_sleep(sleep_time):
            self.assertEqual(10, sleep_time)
            raise ExpectedException

        self.useFixture(fixtures.MonkeyPatch('time.sleep', fake_sleep))
        try:
            collect.__main__(['os-collect-config', 'heat_local', '-i', '10',
                              '-c', 'true'])
        except ExpectedException:
            pass
Beispiel #8
0
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     collector_kwargs_map = {
         'ec2': {
             'requests_impl': test_ec2.FakeRequests
         },
         'cfn': {
             'requests_impl': test_cfn.FakeRequests(self)
         },
         'heat': {
             'keystoneclient': test_heat.FakeKeystoneClient(self),
             'heatclient': test_heat.FakeHeatClient(self),
             'discover_class': test_heat.FakeKeystoneDiscover
         },
         'request': {
             'requests_impl': test_request.FakeRequests
         },
         'zaqar': {
             'keystoneclient': test_zaqar.FakeKeystoneClient(self),
             'zaqarclient': test_zaqar.FakeZaqarClient(self),
             'discover_class': test_heat.FakeKeystoneDiscover
         },
     }
     with mock.patch.object(config_drive, 'get_metadata') as gm:
         gm.return_value = {}
         return collect.__main__(args=fake_args,
                                 collector_kwargs_map=collector_kwargs_map)
Beispiel #9
0
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     collector_kwargs_map = {
         'ec2': {'requests_impl': test_ec2.FakeRequests},
         'cfn': {'requests_impl': test_cfn.FakeRequests(self)},
         'heat': {
             'keystoneclient': test_heat.FakeKeystoneClient(self),
             'heatclient': test_heat.FakeHeatClient(self)
         },
         'request': {'requests_impl': test_request.FakeRequests},
         'zaqar': {
             'keystoneclient': test_zaqar.FakeKeystoneClient(self),
             'zaqarclient': test_zaqar.FakeZaqarClient(self)
         },
     }
     return collect.__main__(args=fake_args,
                             collector_kwargs_map=collector_kwargs_map)
 def _call_main(self, fake_args):
     requests_impl_map = {'ec2': test_ec2.FakeRequests,
                          'cfn': test_cfn.FakeRequests(self)}
     collect.__main__(args=fake_args, requests_impl_map=requests_impl_map)