예제 #1
0
    def setUp(self):
        super(TestWorkloadBalance, self).setUp()
        # fake metrics
        self.fake_metrics = self.fake_datasource_cls()

        p_datasource = mock.patch.object(strategies.WorkloadBalance,
                                         "datasource_backend",
                                         new_callable=mock.PropertyMock)
        self.m_datasource = p_datasource.start()
        self.addCleanup(p_datasource.stop)

        self.m_datasource.return_value = mock.Mock(
            statistic_aggregation=self.fake_metrics.mock_get_statistics_wb)
        self.strategy = strategies.WorkloadBalance(config=mock.Mock(
            datasource=self.datasource))
        self.strategy.input_parameters = utils.Struct()
        self.strategy.input_parameters.update({
            'metrics': 'cpu_util',
            'threshold': 25.0,
            'period': 300,
            'granularity': 300
        })
        self.strategy.threshold = 25.0
        self.strategy._period = 300
        self.strategy._meter = "cpu_util"
        self.strategy._granularity = 300
예제 #2
0
    def setUp(self):
        super(TestWorkloadBalance, self).setUp()
        # fake metrics
        self.fake_metrics = self.fake_datasource_cls()
        # fake cluster
        self.fake_cluster = faker_cluster_state.FakerModelCollector()

        p_model = mock.patch.object(
            strategies.WorkloadBalance, "compute_model",
            new_callable=mock.PropertyMock)
        self.m_model = p_model.start()
        self.addCleanup(p_model.stop)

        p_datasource = mock.patch.object(
            strategies.WorkloadBalance, self.datasource,
            new_callable=mock.PropertyMock)
        self.m_datasource = p_datasource.start()
        self.addCleanup(p_datasource.stop)

        p_audit_scope = mock.patch.object(
            strategies.WorkloadBalance, "audit_scope",
            new_callable=mock.PropertyMock
        )
        self.m_audit_scope = p_audit_scope.start()
        self.addCleanup(p_audit_scope.stop)

        self.m_audit_scope.return_value = mock.Mock()
        self.m_datasource.return_value = mock.Mock(
            statistic_aggregation=self.fake_metrics.mock_get_statistics_wb)
        self.strategy = strategies.WorkloadBalance(
            config=mock.Mock(datasource=self.datasource))
        self.strategy.input_parameters = utils.Struct()
        self.strategy.input_parameters.update({'metrics': 'cpu_util',
                                               'threshold': 25.0,
                                               'period': 300})
        self.strategy.threshold = 25.0
        self.strategy._period = 300
        self.strategy._meter = "cpu_util"