'Test that when we attempt to delete all the inventory for a resource
provider but another thread has already deleted that resource provider,
that we simply remove the resource provider from our local cache and
return.'

@mock.patch.object(report.LOG, 'debug')
@mock.patch.object(report.LOG, 'info')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.delete')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.get')
def test_delete_inventory_inventory_404(self, mock_get, mock_delete, mock_info, mock_debug):

    cn = self.compute_node
    rp = dict(uuid=cn.uuid, generation=42)
    self.client._resource_providers[cn.uuid] = rp
    mock_get.return_value.json.return_value = {'resource_provider_generation': 1, 'inventories': {'VCPU': {'total': 16}, 'MEMORY_MB': {'total': 1024}, 'DISK_GB': {'total': 10}}}
    mock_delete.return_value.status_code = 404
    mock_delete.return_value.headers = {'openstack-request-id': uuids.request_id}
    result = self.client._delete_inventory(cn.uuid)
    self.assertIsNone(result)
    self.assertNotIn(cn.uuid, self.client._resource_providers)
    self.assertTrue(mock_debug.called)
    self.assertIn('deleted    by    another    thread', mock_debug.call_args[0][0])
    self.assertEqual(uuids.request_id, mock_debug.call_args[0][1]['placement_req_id'])
