test_migrations test does not do what it is supposed to do

Bug #1481875 reported by Chris Dent
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Aodh
Fix Released
Critical
Liusheng

Bug Description

aodh/tests/storage/sqlalchemy/test_migrations.py has a couple of issues:

* it is not isolated from /etc/aodh/aodh.conf so will attempt to use the config located there to run the test. When this happens if the database pointed to by aodh.conf exists then the test will fail because the alarm_history table already exists:

raise InternalError(errno, errorvalue)
oslo_db.exception.DBError: (pymysql.err.InternalError) (1050, u"Table 'alarm_history' already exists") [SQL: u'\nCREATE TABLE alarm_history (\n\tevent_id VARCHAR(128) NOT NULL, \n\talarm_id VARCHAR(128), \n\ton_behalf_of VARCHAR(128), \n\tproject_id VARCHAR(128), \n\tuser_id VARCHAR(128), \n\ttype VARCHAR(20), \n\tdetail TEXT, \n\ttimestamp DECIMAL(20, 6), \n\tPRIMARY KEY (event_id)\n)\n\n']

* If you get rid of the aodh.conf, such that there is no config then the test will do this:

{0} aodh.tests.storage.sqlalchemy.test_migrations.ModelsMigrationsSync.test_models_sync ... SKIPPED: The db connection option should be specified.

Presumably the test should be subclassing the db.TestBase and doing some form of scenario or mixin handling to use the db URL that is provided in the environment by the setup-*.sh script?

(I'm not entirely sure about this actually, but the test uses a mock that reference something I cannot see from the test so I have no idea what's _actually_ supposed to happen in the test.)

Julien Danjou (jdanjou)
Changed in aodh:
importance: Undecided → Critical
status: New → Triaged
milestone: none → 1.0.0rc1
Revision history for this message
Liusheng (liusheng) wrote :

It is similar with Gnocchi, I wonder if this test need to create table ? I can run this test OK in my environment with aodh installed and running. the database connection is set with "connection = mysql://root:password@127.0.0.1/aodh?charset=utf8" in aodh.conf

see:

root@monasca:/opt/stack/aodh# python setup.py testr --testr-args aodh.tests.storage.sqlalchemy.test_migrations.ModelsMigrationsSync
running testr
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-600} \
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./aodh/tests} -t . --list
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-600} \
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./aodh/tests} -t . --load-list /tmp/tmpWau2_I
Ran 1 tests in 0.087s (-0.003s)
PASSED (id=4)
root@monasca:/opt/stack/aodh# vi tox.ini
root@monasca:/opt/stack/aodh# python setup.py testr --slowest --testr-args aodh.tests.storage.sqlalchemy.test_migrations.ModelsMigrationsSync
running testr
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-600} \
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./aodh/tests} -t . --list
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-600} \
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./aodh/tests} -t . --load-list /tmp/tmpq0HTKu
Ran 1 tests in 0.084s (-0.002s)
PASSED (id=5)
Slowest Tests
Test id Runtime (s)
----------------------------------------------------------------------------------- -----------
aodh.tests.storage.sqlalchemy.test_migrations.ModelsMigrationsSync.test_models_sync 0.082

I will try to find a way to try to make this test run with real backend scenario.

Changed in aodh:
assignee: nobody → Liusheng (liusheng)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to aodh (master)

Fix proposed to branch: master
Review: https://review.openstack.org/210187

Changed in aodh:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to aodh (master)

Reviewed: https://review.openstack.org/210187
Committed: https://git.openstack.org/cgit/openstack/aodh/commit/?id=a3d8780049636f2bdc901b1b4aa32c75ee40236c
Submitter: Jenkins
Branch: master

commit a3d8780049636f2bdc901b1b4aa32c75ee40236c
Author: liu-sheng <email address hidden>
Date: Fri Aug 7 11:00:47 2015 +0800

    Use storage scenario test base to test migration

    This change make the migration test running based on real storage backend
    scenario.

    Change-Id: If4cb8960406545bfa4157be40879f1fbf301724c
    Closes-Bug: 1481875

Changed in aodh:
status: In Progress → Fix Committed
Julien Danjou (jdanjou)
Changed in aodh:
milestone: 1.0.0rc1 → 1.0.0
Thierry Carrez (ttx)
Changed in aodh:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.