예제 #1
0
 def test_init_aggregates_one_agg_no_hosts(self, agg_get_all,
                                           mock_init_info):
     fake_agg = objects.Aggregate(id=1, hosts=[])
     agg_get_all.return_value = [fake_agg]
     self.host_manager = host_manager.HostManager()
     self.assertEqual({1: fake_agg}, self.host_manager.aggs_by_id)
     self.assertEqual({}, self.host_manager.host_aggregates_map)
예제 #2
0
 def test_delete_aggregate(self):
     fake_agg = objects.Aggregate(id=1, hosts=['fake-host'])
     self.host_manager.host_aggregates_map = collections.defaultdict(
         set, {'fake-host': set([1])})
     self.host_manager.aggs_by_id = {1: fake_agg}
     self.host_manager.delete_aggregate(fake_agg)
     self.assertEqual({}, self.host_manager.aggs_by_id)
     self.assertEqual({'fake-host': set([])},
                      self.host_manager.host_aggregates_map)
예제 #3
0
 def test_update_aggregates_remove_hosts(self):
     fake_agg = objects.Aggregate(id=1, hosts=['fake-host'])
     self.host_manager.update_aggregates([fake_agg])
     self.assertEqual({1: fake_agg}, self.host_manager.aggs_by_id)
     self.assertEqual({'fake-host': set([1])},
                      self.host_manager.host_aggregates_map)
     # Let's remove the host from the aggregate and update again
     fake_agg.hosts = []
     self.host_manager.update_aggregates([fake_agg])
     self.assertEqual({1: fake_agg}, self.host_manager.aggs_by_id)
     self.assertEqual({'fake-host': set([])},
                      self.host_manager.host_aggregates_map)
예제 #4
0
    def test_get_all_host_states_with_matching_aggs(self, svc_get_by_binary,
                                                    cn_get_all, update_from_cn,
                                                    mock_get_by_host):
        svc_get_by_binary.return_value = [objects.Service(host='fake')]
        cn_get_all.return_value = [
            objects.ComputeNode(host='fake', hypervisor_hostname='fake')
        ]
        mock_get_by_host.return_value = objects.InstanceList()
        fake_agg = objects.Aggregate(id=1)
        self.host_manager.host_aggregates_map = collections.defaultdict(
            set, {'fake': set([1])})
        self.host_manager.aggs_by_id = {1: fake_agg}

        self.host_manager.get_all_host_states('fake-context')
        host_state = self.host_manager.host_state_map[('fake', 'fake')]
        self.assertEqual([fake_agg], host_state.aggregates)
예제 #5
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from patron import objects
from patron.scheduler.filters import utils
from patron import test
from patron.tests.unit.scheduler import fakes

_AGGREGATE_FIXTURES = [
    objects.Aggregate(
        id=1,
        name='foo',
        hosts=['fake-host'],
        metadata={
            'k1': '1',
            'k2': '2'
        },
    ),
    objects.Aggregate(
        id=2,
        name='bar',
        hosts=['fake-host'],
        metadata={
            'k1': '3',
            'k2': '4'
        },
    ),
    objects.Aggregate(
        id=3,
예제 #6
0
 def test_update_aggregates(self):
     fake_agg = objects.Aggregate(id=1, hosts=['fake-host'])
     self.host_manager.update_aggregates([fake_agg])
     self.assertEqual({1: fake_agg}, self.host_manager.aggs_by_id)
     self.assertEqual({'fake-host': set([1])},
                      self.host_manager.host_aggregates_map)
예제 #7
0
 def test_update_aggregates(self, mock_update_aggs):
     aggregates = [objects.Aggregate(id=1)]
     self.client.update_aggregates(context=self.context,
                                   aggregates=aggregates)
     mock_update_aggs.assert_called_once_with(self.context, aggregates)
예제 #8
0
 def test_delete_aggregate(self, mock_delete_agg):
     aggregate = objects.Aggregate(id=1)
     self.client.delete_aggregate(context='context', aggregate=aggregate)
     mock_delete_agg.assert_called_once_with('context', aggregate)