Add missing tests in test_db_api

Registered by Boris Pavlovic on 2013-03-07

The goal of this bp is to add missing tests for a lot of methods in nova.db.api

At least we should add missing tests for methods that have session parameter that should be removed in bp db-session-cleanup. For example security_groups.

Blueprint information

Status:
Complete
Approver:
Russell Bryant
Priority:
High
Drafter:
Boris Pavlovic
Direction:
Approved
Assignee:
Boris Pavlovic
Definition:
Approved
Series goal:
Accepted for havana
Implementation:
Implemented
Milestone target:
milestone icon 2013.2
Started by
Boris Pavlovic on 2013-03-12
Completed by
Russell Bryant on 2013-07-24

Related branches

Sprints

Whiteboard

May be useful to look at a code coverage report, eg:
  http://logs.openstack.org/e237698/post/nova-coverage/5635/cover/nova_db_sqlalchemy_api.html

Oneliner to get list of all functions in db.api that are never called from test_db_api:
for i in `cat nova/db/api.py | grep "def " | tr '(' ' ' | awk '{ print $2}'`; do echo -n "$i " ; echo `cat nova/tests/test_db_api.py | grep db.$i | wc -l ` ; done | grep ' 0'

There are two types of groups that haven't tests:
a) important - if it has methods with session parameter that should be removed in db-session-cleanup or race condition in create, update methods.
b) not-so-important - If there is no session parameter and they doesn't have tests
Important groups should be fixed first:

⬥ IMPORTANT:
✓ floating_ip_* (race, session )
✓ fixed_ip_*
✓ securty_group_* (session)
✓ service_*
✓ security_group_rule_* (session)
✓ instance_type_* (race, session)
✓ instance_type_access (race)
✓ block_device_* (unnecessary calls of get_session method)
✓ key_pair_* (race)
✓ virtual_interface_* (bug 1062097)
✓ network_* (sesion)
✓ agent_build_* (session)
✓ reservation_*
✓ instance_metadata_* (session)
✓ insatance_system_metadata_* (session)
✓ instance_fault_*
✓ instance_action_*
⚒ instance_* (session)
⚒ migration_* (session, race)

⬥ NOT-SO-IMPORTANT:
✓ instance_type_extra_specs_*
✓ quota_*
✓ quota_class_*
✓ s3_image_*
✓ compute_node_*
✓ certificate_*
✓ provider_fw_rule_*
✓ console_pool_*
⚒ console_*
✓ cell_*
⚒ dnsdomain_*
⚒ bw_usage_*
⚒ *ec2*

Gerrit topic: https://review.openstack.org/#q,topic:bp/db-session-cleanup,n,z

Addressed by: https://review.openstack.org/24146
    Add mising tests for db.block_device_mapping_* methods

Gerrit topic: https://review.openstack.org/#q,topic:bug/1156227,n,z

Addressed by: https://review.openstack.org/24606
    Add missing tests for db.virtual_interface_* methods

Gerrit topic: https://review.openstack.org/#q,topic:bp/db-api-tests,n,z

Addressed by: https://review.openstack.org/24708
    Add missing tests for db.service_* methods

Gerrit topic: https://review.openstack.org/#q,topic:bp/db-enforce-unique-keys,n,z

Addressed by: https://review.openstack.org/25252
    Add missing tests for db.instance_type_* methods

Addressed by: https://review.openstack.org/25253
    Add missing tests for db.instance_type_access_* methods

Addressed by: https://review.openstack.org/26156
    Add missing tests for instance_type_extra_specs_* methods

Addressed by: https://review.openstack.org/27200
    Add unit tests for /db/api.py#fixed_ip_get_by_instance

Gerrit topic: https://review.openstack.org/#q,topic:tests_for_inst_extra_specs,n,z

Addressed by: https://review.openstack.org/27408
    Add missing test for db.instance_type_destroy method

Gerrit topic: https://review.openstack.org/#q,topic:bug/1145216,n,z

Addressed by: https://review.openstack.org/27942
    Move db.fixed_ip_* tests from DbApiTestCase to FixedIpTestCase

Addressed by: https://review.openstack.org/27943
    Add missing tests for db.floating_ip_* methods

Addressed by: https://review.openstack.org/29639
    Moved sample network creation out of unittest base class constructor.

Addressed by: https://review.openstack.org/29377
    Add missing tests for nova.db.api.network_* methods

Addressed by: https://review.openstack.org/29749
    Add missing tests for nova.db.api.agent_build_* methods

Addressed by: https://review.openstack.org/29889
    Add missing tests for nova.db.api.quota_* methods

Gerrit topic: https://review.openstack.org/#q,topic:bug/1181967,n,z

Addressed by: https://review.openstack.org/30063
    Add missing tests for nova.db.api.quota_class_*

Addressed by: https://review.openstack.org/30074
    Add missing tests for db.api.reservation_*

Addressed by: https://review.openstack.org/30849
    Add tests for some db.security_group_* methods

Addressed by: https://review.openstack.org/30864
    Add missing tests for cell_* methods

Addressed by: https://review.openstack.org/30895
    Add tests for `db.console_pool_*()` functions.

Addressed by: https://review.openstack.org/30908
    Add missing tests for certificate_* methods

Addressed by: https://review.openstack.org/31034
    Add missing tests for s3_image_* methods

Addressed by: https://review.openstack.org/31056
    Add missing tests for nova.db.api.instance_system_metadata_*

Addressed by: https://review.openstack.org/31066
    Add missing tests for provider_fw_rule_* methods

Addressed by: https://review.openstack.org/31166
    Add missing tests for nova.db.api.instance_metadata_*

Addressed by: https://review.openstack.org/31187
    Add missing tests for db.api.instance_* methods

Addressed by: https://review.openstack.org/31499
    Add missing tests for compute_node_* methods

Gerrit topic: https://review.openstack.org/#q,topic:db-session-cleanup,n,z

Addressed by: https://review.openstack.org/31613
    Add tests for nova.db.api.security_group_rule_* methods. blueprint db-api-tests Change-Id: I20b63683da78bcb99e1f88cc10ca71a64f1f17a9

Addressed by: https://review.openstack.org/31799
    Refactored tests for db.api

Addressed by: https://review.openstack.org/31928
    Refactored tests for instance_fault_*

Addressed by: https://review.openstack.org/31929
    Refactored tests for instance_actions_*

Addressed by: https://review.openstack.org/32388
    Improved tests for instance_actions_*

Addressed by: https://review.openstack.org/33962
    Add missing tests for db.api.instance_* methods

Addressed by: https://review.openstack.org/35646
    Add missing tests for console_* methods.

Gerrit topic: https://review.openstack.org/#q,topic:bp/bp,n,z

Addressed by: https://review.openstack.org/37065
    Remove duplicated key_pair* tests from test_db_api.

Addressed by: https://review.openstack.org/37085
    dnsdomain_* tests refactoring in test_db_api

Addressed by: https://review.openstack.org/37206
    Move bw_usage_* tests in test_db_api to own test case.

Addressed by: https://review.openstack.org/37227
    Move test_security_group_update to SecurityGroupTestCase.

Addressed by: https://review.openstack.org/37248
    Move *_ec2_* tests in test_db_api to own test case.

Addressed by: https://review.openstack.org/37257
    Move test_stringified_ips to InstanceTestCase.

Addressed by: https://review.openstack.org/37273
    Move test_migration_get_unconfirmed_by_dest_compute to MigrationTestCase.

Addressed by: https://review.openstack.org/44010
    Improve db_sqlalchemy_api test coverage

Addressed by: https://review.openstack.org/40236
    Improve db_sqlalchemy_api test coverage

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.