Пример #1
0
 def test_metrics_filter_missing_metrics(self):
     self.flags(weight_setting=['foo=1', 'bar=2'], group='metrics')
     filt_cls = metrics_filter.MetricsFilter()
     metrics = dict(foo=1)
     host = fakes.FakeHostState('host1',
                                'node1',
                                attribute_dict={'metrics': metrics})
     self.assertFalse(filt_cls.host_passes(host, None))
Пример #2
0
 def test_metrics_filter_missing_metrics(self):
     _ts_now = datetime.datetime(2015, 11, 11, 11, 0, 0)
     obj1 = objects.MonitorMetric(name='cpu.frequency',
                                  value=1000,
                                  timestamp=_ts_now,
                                  source='nova.virt.libvirt.driver')
     metrics_list = objects.MonitorMetricList(objects=[obj1])
     self.flags(weight_setting=['foo=1', 'bar=2'], group='metrics')
     filt_cls = metrics_filter.MetricsFilter()
     host = fakes.FakeHostState('host1', 'node1',
                                attribute_dict={'metrics': metrics_list})
     self.assertFalse(filt_cls.host_passes(host, None))
Пример #3
0
 def test_metrics_filter_pass(self):
     _ts_now = datetime.datetime(2015, 11, 11, 11, 0, 0)
     obj1 = objects.MonitorMetric(name='cpu.frequency',
                                  value=1000,
                                  timestamp=_ts_now,
                                  source='nova.virt.libvirt.driver')
     obj2 = objects.MonitorMetric(name='numa.membw.current',
                                  numa_membw_values={"0": 10, "1": 43},
                                  timestamp=_ts_now,
                                  source='nova.virt.libvirt.driver')
     metrics_list = objects.MonitorMetricList(objects=[obj1, obj2])
     self.flags(weight_setting=[
         'cpu.frequency=1', 'numa.membw.current=2'], group='metrics')
     filt_cls = metrics_filter.MetricsFilter()
     host = fakes.FakeHostState('host1', 'node1',
                                attribute_dict={'metrics': metrics_list})
     self.assertTrue(filt_cls.host_passes(host, None))