Pages

Friday 10 March 2017

Running Cinder Migration Unit Tests

Cinder has some unit tests for migration. If you want to run them on your computer, you'll need to set up database administrator accounts for your backends, and export an environment variable before running the test:
One-liner:
for backend in \
    mysql+pymysql://root:secret@localhost/mysql \
    postgresql://postgres:secret@localhost/cinder \
    sqlite:///somefile.db \
; do
    OS_TEST_DBAPI_ADMIN_CONNECTION=$backend \
        python -m subunit.run cinder.tests.unit.test_migrations |
            subunit2pyunit
done


MySQL
OS_TEST_DBAPI_ADMIN_CONNECTION='mysql+pymysql://root:secret@localhost/mysql'\
 python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit

PostgreSQL
OS_TEST_DBAPI_ADMIN_CONNECTION='postgresql://postgres:secret@localhost/cinder'\
 python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit

SQLite
OS_TEST_DBAPI_ADMIN_CONNECTION='sqlite:///somefile.db'\
 python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit