# so, host2 should win:
weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 1.0)
- self.assertEqual(
- utils.extract_host(weighed_host.obj.host), 'host2')
+ self.assertEqual(1.0, weighed_host.weight)
+ self.assertEqual('host2', utils.extract_host(weighed_host.obj.host))
def test_capacity_weight_multiplier1(self):
self.flags(capacity_weight_multiplier=-1.0)
# so, host4 should win:
weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 0.0)
- self.assertEqual(
- utils.extract_host(weighed_host.obj.host), 'host4')
+ self.assertEqual(0.0, weighed_host.weight)
+ self.assertEqual('host4', utils.extract_host(weighed_host.obj.host))
def test_capacity_weight_multiplier2(self):
self.flags(capacity_weight_multiplier=2.0)
# so, host2 should win:
weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 1.0 * 2)
- self.assertEqual(
- utils.extract_host(weighed_host.obj.host), 'host2')
+ self.assertEqual(1.0 * 2, weighed_host.weight)
+ self.assertEqual('host2', utils.extract_host(weighed_host.obj.host))
'size': 1}}
ret_host = sched.host_passes_filters(ctx, 'host1#lvm1',
request_spec, {})
- self.assertEqual(utils.extract_host(ret_host.host), 'host1')
+ self.assertEqual('host1', utils.extract_host(ret_host.host))
self.assertTrue(_mock_service_get_topic.called)
@mock.patch('cinder.db.service_get_all_by_topic')
'size': 1}}
ret_host = sched.host_passes_filters(ctx, 'host5#_pool0',
request_spec, {})
- self.assertEqual(utils.extract_host(ret_host.host), 'host5')
+ self.assertEqual('host5', utils.extract_host(ret_host.host))
self.assertTrue(_mock_service_get_topic.called)
@mock.patch('cinder.db.service_get_all_by_topic')
host_state = sched.find_retype_host(ctx, request_spec,
filter_properties={},
migration_policy='never')
- self.assertEqual(utils.extract_host(host_state.host), 'host4')
+ self.assertEqual('host4', utils.extract_host(host_state.host))
@mock.patch('cinder.db.service_get_all_by_topic')
def test_retype_with_pool_policy_never_migrate_pass(
host_state = sched.find_retype_host(ctx, request_spec,
filter_properties={},
migration_policy='never')
- self.assertEqual(host_state.host, 'host3#lvm3')
+ self.assertEqual('host3#lvm3', host_state.host)
@mock.patch('cinder.db.service_get_all_by_topic')
def test_retype_policy_never_migrate_fail(self, _mock_service_get_topic):
host_state = sched.find_retype_host(ctx, request_spec,
filter_properties={},
migration_policy='on-demand')
- self.assertEqual(utils.extract_host(host_state.host), 'host1')
+ self.assertEqual('host1', utils.extract_host(host_state.host))
@mock.patch('cinder.db.service_get_all_by_topic')
def test_retype_policy_demand_migrate_fail(self, _mock_service_get_topic):
host3_volume_capabs)
# Make sure dictionary isn't re-assigned
- self.assertEqual(self.host_manager.service_states, service_states)
+ self.assertEqual(service_states, self.host_manager.service_states)
# Make sure original dictionary wasn't copied
self.assertEqual(1, host1_volume_capabs['timestamp'])
expected = {'host1': host1_volume_capabs,
'host2': host2_volume_capabs,
'host3': host3_volume_capabs}
- self.assertDictMatch(service_states, expected)
+ self.assertDictMatch(expected, service_states)
@mock.patch('cinder.utils.service_is_up')
@mock.patch('cinder.db.service_get_all_by_topic')
for i in range(3):
volume_node = services[i]
host = volume_node['host']
- self.assertEqual(host_state_map[host].service, volume_node)
+ self.assertEqual(volume_node, host_state_map[host].service)
# Second test: Now service_is_up returns False for host3
_mock_service_is_up.reset_mock()
for i in range(2):
volume_node = services[i]
host = volume_node['host']
- self.assertEqual(host_state_map[host].service,
- volume_node)
+ self.assertEqual(volume_node,
+ host_state_map[host].service)
@mock.patch('cinder.db.service_get_all_by_topic')
@mock.patch('cinder.utils.service_is_up')
# Test update for existing host state
volume_capability.update(dict(total_capacity_gb=1000))
fake_host.update_from_volume_capability(volume_capability)
- self.assertEqual(fake_host.pools['_pool0'].total_capacity_gb, 1000)
+ self.assertEqual(1000, fake_host.pools['_pool0'].total_capacity_gb)
# Test update for existing host state with different backend name
volume_capability.update(dict(volume_backend_name='magic'))
vol_cap = {'timestamp': None}
fake_host.update_from_volume_capability(vol_cap)
- self.assertEqual(fake_host.total_capacity_gb, 0)
- self.assertEqual(fake_host.free_capacity_gb, None)
+ self.assertEqual(0, fake_host.total_capacity_gb)
+ self.assertEqual(None, fake_host.free_capacity_gb)
# Pool stats has been updated
self.assertEqual(0,
fake_host.pools['_pool0'].total_capacity_gb)
with mock.patch.object(api, 'volume_data_get_for_host',
fake_volume_data_get_for_host):
weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 0.0)
- self.assertEqual(utils.extract_host(weighed_host.obj.host),
- 'host1')
+ self.assertEqual(0.0, weighed_host.weight)
+ self.assertEqual('host1',
+ utils.extract_host(weighed_host.obj.host))
def test_volume_number_weight_multiplier2(self):
self.flags(volume_number_multiplier=1.0)
with mock.patch.object(api, 'volume_data_get_for_host',
fake_volume_data_get_for_host):
weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 1.0)
- self.assertEqual(utils.extract_host(weighed_host.obj.host),
- 'host5')
+ self.assertEqual(1.0, weighed_host.weight)
+ self.assertEqual('host5',
+ utils.extract_host(weighed_host.obj.host))