nova/nova/tests/unit/db
Kevin_Zheng 74e2a400b2 Exclude deleted service records when calling hypervisor statistics
Hypervisor statistics could be incorrect if not
exclude deleted service records from DB.

User may stop 'nova-compute' service on some
compute nodes and delete the service from nova.
When delete 'nova-compute' service, it performs
'soft-delete' to the corresponding db records in
both 'service' table and 'compute_nodes' table if
the compute_nodes record is old, i.e. it is linked
to the service record. For modern compute_nodes
records, they aren't linked to the services table
so deleting the services record will not delete
the compute_nodes record, and the ResourceTracker
won't recreate the compute_nodes record if the host
and hypervisor_hostname still match the existing
record, but restarting the process after deleting
the service will create a new services table record
with the same host/binary/topic.

If the 'nova-compute' service on that server
re-starts, it will automatically add a record
in 'compute_nodes' table (assuming it was deleted
because it was an old-style record) and also a correspoding
record in 'service' table, and if the host name
of the compute node did not change, the newly
created records in 'service' and 'compute_nodes'
table will be identical to the priously soft-deleted
records except the deleted row.

When calling Hypervisor-statistics, the DB layer
joined records across the whole deployment by
comparing records' host field selected from
serivce table and records' host field selected
from compute_nodes table, and the calculated
results could be multiplied if multiple records
from service table have the same host field,
and this scenario could happen if user perform
the above actions.

Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com>

Change-Id: I9dfa15f69f8ef9c6cb36b2734a8601bd73e9d6b3
Closes-Bug: #1692397
(cherry picked from commit 3d3e9cdd77)
2017-05-26 19:47:51 +00:00
..
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
fakes.py Trivial-Fix: Fix typos 2016-06-13 06:41:08 +00:00
test_db_api.py Exclude deleted service records when calling hypervisor statistics 2017-05-26 19:47:51 +00:00
test_migration_utils.py Unwind circular import issue with api / utils 2016-09-27 15:05:56 -04:00
test_migrations.py Add index on instances table across project_id and updated_at 2016-11-22 01:40:38 +00:00
test_models.py Test that new tables don't use soft deletes 2016-02-04 09:21:31 -05:00
test_sqlalchemy_migration.py Fix mitaka online migration for PCI devices 2017-04-20 15:13:13 -07:00