def setUp(self):
     super(TestNotification, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.CONF.set_override("connection", "log://", group='database')
     self.CONF.set_override("store_events", False, group="notification")
     self.setup_messaging(self.CONF)
     self.srv = notification.NotificationService()
Exemple #2
0
    def setUp(self):
        super(TestCollector, self).setUp()
        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)
        self.CONF = self.useFixture(config.Config()).conf
        self.CONF.set_override("connection", "log://", group='database')
        self.srv = collector.CollectorService()
        self.CONF.publisher.metering_secret = 'not-so-secret'
        self.counter = sample.Sample(
            name='foobar',
            type='bad',
            unit='F',
            volume=1,
            user_id='jd',
            project_id='ceilometer',
            resource_id='cat',
            timestamp='NOW!',
            resource_metadata={},
        ).as_dict()

        self.utf8_msg = utils.meter_message_from_counter(
            sample.Sample(
                name=u'test',
                type=sample.TYPE_CUMULATIVE,
                unit=u'',
                volume=1,
                user_id=u'test',
                project_id=u'test',
                resource_id=u'test_run_tasks',
                timestamp=u'NOW!',
                resource_metadata={u'name': [([u'TestPublish'])]},
                source=u'testsource',
            ), 'not-so-secret')
Exemple #3
0
    def setUp(self):
        super(TestBase, self).setUp()

        self.useFixture(self.db_manager)

        self.CONF = self.useFixture(config.Config()).conf
        self.CONF.set_override('connection',
                               self.db_manager.connection,
                               group='database')

        with warnings.catch_warnings():
            warnings.filterwarnings(
                action='ignore',
                message='.*you must provide a username and password.*')
            try:
                self.conn = storage.get_connection(self.CONF)
            except storage.StorageBadVersion as e:
                self.skipTest(six.text_type(e))
        self.conn.upgrade()

        self.useFixture(
            oslo_mock.Patch('ceilometer.storage.get_connection',
                            return_value=self.conn))

        self.CONF([], project='ceilometer')

        # Set a default location for the pipeline config file so the
        # tests work even if ceilometer is not installed globally on
        # the system.
        self.CONF.set_override('pipeline_cfg_file',
                               self.path_get('etc/ceilometer/pipeline.yaml'))
Exemple #4
0
    def setUp(self):
        super(TestRPCAlarmPartitionCoordination, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.setup_messaging(self.CONF)

        self.coordinator_server = FakeCoordinator(self.transport)
        self.coordinator_server.rpc.start()
        eventlet.sleep()  # must be sure that fanout queue is created

        self.coordination = rpc_alarm.RPCAlarmPartitionCoordination()
        self.alarms = [
            alarms.Alarm(None,
                         info={
                             'name': 'instance_running_hot',
                             'meter_name': 'cpu_util',
                             'comparison_operator': 'gt',
                             'threshold': 80.0,
                             'evaluation_periods': 5,
                             'statistic': 'avg',
                             'state': 'ok',
                             'ok_actions': ['http://host:8080/path'],
                             'user_id': 'foobar',
                             'project_id': 'snafu',
                             'period': 60,
                             'alarm_id': str(uuid.uuid4()),
                             'matching_metadata': {
                                 'resource_id': 'my_instance'
                             }
                         }),
            alarms.Alarm(None,
                         info={
                             'name':
                             'group_running_idle',
                             'meter_name':
                             'cpu_util',
                             'comparison_operator':
                             'le',
                             'threshold':
                             10.0,
                             'statistic':
                             'max',
                             'evaluation_periods':
                             4,
                             'state':
                             'insufficient data',
                             'insufficient_data_actions':
                             ['http://other_host/path'],
                             'user_id':
                             'foobar',
                             'project_id':
                             'snafu',
                             'period':
                             300,
                             'alarm_id':
                             str(uuid.uuid4()),
                             'matching_metadata': {
                                 'metadata.user_metadata.AS': 'my_group'
                             }
                         }),
        ]
Exemple #5
0
    def setUp(self):
        super(TestPartitionedAlarmService, self).setUp()
        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)

        self.threshold_eval = mock.Mock()
        self.api_client = mock.MagicMock()
        self.CONF = self.useFixture(config.Config()).conf

        self.CONF.set_override('host', 'fake_host')
        self.CONF.set_override('partition_rpc_topic',
                               'fake_topic',
                               group='alarm')
        self.partitioned = service.PartitionedAlarmService()
        self.partitioned.tg = mock.Mock()
        self.partitioned.partition_coordinator = mock.Mock()
        self.extension_mgr = extension.ExtensionManager.make_test_instance([
            extension.Extension(
                'threshold',
                None,
                None,
                self.threshold_eval,
            ),
        ])
        self.partitioned.extension_manager = self.extension_mgr
    def setUp(self):
        super(TestAlarmNotifier, self).setUp()
        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)

        self.CONF = self.useFixture(config.Config()).conf
        self.service = service.AlarmNotifierService()
Exemple #7
0
    def setUp(self):
        super(TestBase, self).setUp()

        engine = urlparse.urlparse(self.db_url).scheme

        # NOTE(Alexei_987) Shortcut to skip expensive db setUp
        test_method = self._get_test_method()
        if (hasattr(test_method, '_run_with')
                and engine not in test_method._run_with):
            raise testcase.TestSkipped(
                'Test is not applicable for %s' % engine)

        self.db_manager = self._get_driver_manager(engine)(self.db_url)
        self.useFixture(self.db_manager)

        self.conn = self.db_manager.connection
        self.conn.upgrade()

        self.useFixture(oslo_mock.Patch('ceilometer.storage.get_connection',
                                        return_value=self.conn))

        self.CONF = self.useFixture(config.Config()).conf
        self.CONF([], project='ceilometer')

        # Set a default location for the pipeline config file so the
        # tests work even if ceilometer is not installed globally on
        # the system.
        self.CONF.import_opt('pipeline_cfg_file', 'ceilometer.pipeline')
        self.CONF.set_override(
            'pipeline_cfg_file',
            self.path_get('etc/ceilometer/pipeline.yaml')
        )
 def setUp(self):
     super(TestPublish, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.published = []
     self.rpc_unreachable = False
     self.useFixture(
         fixtures.MonkeyPatch("ceilometer.openstack.common.rpc.cast",
                              self.faux_cast))
 def setUp(self):
     super(TestSwiftMiddleware, self).setUp()
     self.pipeline_manager = self._faux_pipeline_manager()
     self.useFixture(
         PatchObject(pipeline,
                     'setup_pipeline',
                     side_effect=self._fake_setup_pipeline))
     self.CONF = self.useFixture(config.Config()).conf
Exemple #10
0
    def setUp(self):
        super(TestPublish, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf

        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)

        self.published = []
Exemple #11
0
 def setUp(self):
     super(TestImagePollsterPageSize, self).setUp()
     self.context = context.get_admin_context()
     self.manager = TestManager()
     self.useFixture(
         mockpatch.PatchObject(glance._Base,
                               'get_glance_client',
                               side_effect=self.fake_get_glance_client))
     self.CONF = self.useFixture(config.Config()).conf
Exemple #12
0
 def setUp(self):
     super(TestAlarmNotifier, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.setup_messaging(self.CONF)
     self.service = service.AlarmNotifierService()
     self.useFixture(
         mockpatch.Patch(
             'ceilometer.openstack.common.context.generate_request_id',
             self._fake_generate_request_id))
Exemple #13
0
    def setUp(self):
        super(FunctionalTest, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.setup_messaging(self.CONF)

        self.CONF.set_override("auth_version", "v2.0",
                               group=OPT_GROUP_NAME)
        self.CONF.set_override("policy_file",
                               self.path_get('etc/ceilometer/policy.json'))
        self.app = self._make_app()
 def setUp(self):
     super(TestCoordinate, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.test_interval = 120
     self.CONF.set_override('evaluation_interval',
                            self.test_interval,
                            group='alarm')
     self.api_client = mock.Mock()
     self.override_start = datetime.datetime(2012, 7, 2, 10, 45)
     timeutils.utcnow.override_time = self.override_start
     self.partition_coordinator = coordination.PartitionCoordinator()
     self.partition_coordinator.coordination_rpc = mock.Mock()
Exemple #15
0
 def setUp(self):
     super(TestNovaClient, self).setUp()
     self._flavors_count = 0
     self._images_count = 0
     self.nv = nova_client.Client()
     self.useFixture(
         mockpatch.PatchObject(self.nv.nova_client.flavors,
                               'get',
                               side_effect=self.fake_flavors_get))
     self.useFixture(
         mockpatch.PatchObject(self.nv.nova_client.images,
                               'get',
                               side_effect=self.fake_images_get))
     self.CONF = self.useFixture(config.Config()).conf
Exemple #16
0
    def setUp(self):
        super(TestCase, self).setUp()
        self.tempdir = self.useFixture(fixtures.TempDir())
        self.useFixture(fixtures.FakeLogger())
        self.useFixture(config.Config())
        moxfixture = self.useFixture(moxstubout.MoxStubout())
        self.mox = moxfixture.mox
        self.stubs = moxfixture.stubs

        cfg.CONF([], project='ceilometer')

        # Set a default location for the pipeline config file so the
        # tests work even if ceilometer is not installed globally on
        # the system.
        cfg.CONF.set_override('pipeline_cfg_file',
                              self.path_get('etc/ceilometer/pipeline.yaml'))
Exemple #17
0
 def setUp(self):
     super(TestCoordinate, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.test_interval = 120
     self.CONF.set_override('evaluation_interval',
                            self.test_interval,
                            group='alarm')
     self.api_client = mock.Mock()
     self.override_start = datetime.datetime(2012, 7, 2, 10, 45)
     timeutils.utcnow.override_time = self.override_start
     self.partition_coordinator = coordination.PartitionCoordinator()
     self.partition_coordinator.coordination_rpc = mock.Mock()
     #add extra logger to check exception conditions and logged content
     self.output = StringIO.StringIO()
     self.str_handler = logging.StreamHandler(self.output)
     coordination.LOG.logger.addHandler(self.str_handler)
Exemple #18
0
 def setUp(self):
     super(TestCollector, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.CONF.set_override("connection", "log://", group='database')
     self.srv = collector.CollectorService('the-host', 'the-topic')
     self.counter = sample.Sample(
         name='foobar',
         type='bad',
         unit='F',
         volume=1,
         user_id='jd',
         project_id='ceilometer',
         resource_id='cat',
         timestamp='NOW!',
         resource_metadata={},
     ).as_dict()
Exemple #19
0
 def setUp(self):
     super(BaseAgentManagerTestCase, self).setUp()
     self.setup_manager()
     self.mgr.pollster_manager = self.create_extension_manager()
     self.pipeline_cfg = [
         {
             'name': "test_pipeline",
             'interval': 60,
             'counters': ['test'],
             'transformers': [],
             'publishers': ["test"],
         },
     ]
     self.setup_pipeline()
     self.CONF = self.useFixture(config.Config()).conf
     self.CONF.set_override('pipeline_cfg_file',
                            self.path_get('etc/ceilometer/pipeline.yaml'))
Exemple #20
0
    def setUp(self):
        super(TestEventEndpoint, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.CONF([])
        self.CONF.set_override("connection", "log://", group='database')
        self.CONF.set_override("store_events", True, group="notification")
        self.setup_messaging(self.CONF)

        self.mock_dispatcher = mock.MagicMock()
        self.endpoint = event_endpoint.EventsNotificationEndpoint()
        (self.endpoint.dispatcher_manager) = (
            extension.ExtensionManager.make_test_instance([
                extension.Extension('test', None, None, self.mock_dispatcher)
            ]))
        self.endpoint.event_converter = mock.MagicMock()
        self.endpoint.event_converter.to_event.return_value = mock.MagicMock(
            event_type='test.test')
Exemple #21
0
    def setUp(self):
        super(TestCollector, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.CONF.import_opt("connection",
                             "ceilometer.openstack.common.db.options",
                             group="database")
        self.CONF.set_override("connection", "log://", group='database')
        self.CONF.set_override('metering_secret',
                               'not-so-secret',
                               group='publisher')
        self._setup_messaging()

        self.counter = sample.Sample(
            name='foobar',
            type='bad',
            unit='F',
            volume=1,
            user_id='jd',
            project_id='ceilometer',
            resource_id='cat',
            timestamp=timeutils.utcnow().isoformat(),
            resource_metadata={},
        ).as_dict()

        self.utf8_msg = utils.meter_message_from_counter(
            sample.Sample(
                name=u'test',
                type=sample.TYPE_CUMULATIVE,
                unit=u'',
                volume=1,
                user_id=u'test',
                project_id=u'test',
                resource_id=u'test_run_tasks',
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata={u'name': [([u'TestPublish'])]},
                source=u'testsource',
            ), 'not-so-secret')

        self.srv = collector.CollectorService()

        self.useFixture(
            mockpatch.PatchObject(
                self.srv.tg,
                'add_thread',
                side_effect=self._dummy_thread_group_add_thread))
Exemple #22
0
 def setUp(self):
     super(BaseAgentManagerTestCase, self).setUp()
     self.mgr = self.create_manager()
     self.mgr.pollster_manager = self.create_pollster_manager()
     self.pipeline_cfg = [{
         'name': "test_pipeline",
         'interval': 60,
         'counters': ['test'],
         'resources': ['test://'] if self.source_resources else [],
         'transformers': [],
         'publishers': ["test"],
     }, ]
     self.setup_pipeline()
     self.CONF = self.useFixture(config.Config()).conf
     self.CONF.set_override(
         'pipeline_cfg_file',
         self.path_get('etc/ceilometer/pipeline.yaml')
     )
     self.useFixture(mockpatch.PatchObject(
         publisher, 'get_publisher', side_effect=self.get_publisher))
    def setUp(self):
        super(TestRealNotification, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.setup_messaging(self.CONF, 'nova')

        pipeline = yaml.dump([{
            'name': 'test_pipeline',
            'interval': 5,
            'counters': ['instance', 'memory'],
            'transformers': [],
            'publishers': ['test://'],
        }])

        self.expected_samples = 2

        pipeline_cfg_file = fileutils.write_to_tempfile(content=pipeline,
                                                        prefix="pipeline",
                                                        suffix="yaml")
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)
        self.srv = notification.NotificationService()
        self.publisher = test_publisher.TestPublisher("")
    def setUp(self):
        super(TestCoordinate, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)

        self.test_interval = 120
        self.CONF.set_override('evaluation_interval',
                               self.test_interval,
                               group='alarm')
        self.api_client = mock.Mock()
        self.override_start = datetime.datetime(2012, 7, 2, 10, 45)
        patcher = mock.patch.object(timeutils, 'utcnow')
        self.addCleanup(patcher.stop)
        self.mock_utcnow = patcher.start()
        self.mock_utcnow.return_value = self.override_start
        self.partition_coordinator = coordination.PartitionCoordinator()
        self.partition_coordinator.coordination_rpc = mock.Mock()
        #add extra logger to check exception conditions and logged content
        self.output = six.moves.StringIO()
        self.str_handler = logging.StreamHandler(self.output)
        coordination.LOG.logger.addHandler(self.str_handler)
    def setUp(self):
        super(TestRealNotification, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.useFixture(oslo.messaging.conffixture.ConfFixture(self.CONF))

        pipeline = yaml.dump([{
            'name': 'test_pipeline',
            'interval': 5,
            'counters': ['*'],
            'transformers': [],
            'publishers': ['test://'],
        }])
        pipeline_cfg_file = fileutils.write_to_tempfile(content=pipeline,
                                                        prefix="pipeline",
                                                        suffix="yaml")
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)
        self.CONF.set_override("notification_driver", "messaging")
        self.CONF.set_override("control_exchange", "nova")
        messaging.setup('fake://')
        self.addCleanup(messaging.cleanup)

        self.srv = notification.NotificationService()
    def setUp(self):
        super(TestCoordinate, self).setUp()
        self.CONF = self.useFixture(config.Config()).conf
        self.setup_messaging(self.CONF)

        self.test_interval = 120
        self.CONF.import_opt('evaluation_interval',
                             'ceilometer.alarm.service',
                             group='alarm')
        self.CONF.set_override('evaluation_interval',
                               self.test_interval,
                               group='alarm')
        self.api_client = mock.Mock()
        self.override_start = datetime.datetime(2012, 7, 2, 10, 45)
        patcher = mock.patch.object(timeutils, 'utcnow')
        self.addCleanup(patcher.stop)
        self.mock_utcnow = patcher.start()
        self.mock_utcnow.return_value = self.override_start
        self.partition_coordinator = coordination.PartitionCoordinator()
        self.partition_coordinator.coordination_rpc = mock.Mock()
        # add extra logger to check exception conditions and logged content
        self.str_handler = MockLoggingHandler()
        coordination.LOG.logger.addHandler(self.str_handler)
Exemple #27
0
 def setUp(self):
     super(TestUDPPublisher, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.CONF.publisher.metering_secret = 'not-so-secret'
Exemple #28
0
 def setUp(self):
     super(TestDispatcherFile, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
 def setUp(self):
     super(TestAlarmNotifier, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.service = service.AlarmNotifierService('somehost', 'sometopic')
Exemple #30
0
 def setUp(self):
     super(MessagingTests, self).setUp()
     self.CONF = self.useFixture(config.Config()).conf
     self.useFixture(oslo.messaging.conffixture.ConfFixture(self.CONF))