'Test Update Volume Stats.
Makes a mock query to the backend to collect stats on all physical
devices.'

@mock.patch('socket.gethostbyaddr')
def test_update_volume_stats(self, mock_gethost):

    def gethostbyaddr(addr):
        if ((addr == '8.8.8.8') or (addr == 'example.com')):
            return ('example.com', [], ['8.8.8.8'])
        else:
            return ('a.b.c.d', [], addr)
    mock_gethost.side_effect = gethostbyaddr
    backend_name = self.conf.volume_backend_name
    vendor_name = 'Violin    Memory,    Inc.'
    tot_gb = 2046
    free_gb = 1022
    phy_devices = '/batch/physicalresource/physicaldevice'
    conf = {'basic.get.side_effect': [PHY_DEVICES_RESPONSE]}
    self.driver.common.vmem_mg = self.setup_mock_concerto(m_conf=conf)
    result = self.driver._update_volume_stats()
    calls = [mock.call(phy_devices)]
    self.driver.common.vmem_mg.basic.get.assert_has_calls(calls)
    self.assertEqual(tot_gb, self.driver.stats['total_capacity_gb'])
    self.assertEqual(free_gb, self.driver.stats['free_capacity_gb'])
    self.assertEqual(backend_name, self.driver.stats['volume_backend_name'])
    self.assertEqual(vendor_name, self.driver.stats['vendor_name'])
    self.assertIsNone(result)
