Openstack 版本:Queens
我在运行neutron-fwaas 与tap-as-a-service的单元测试时都遇到了这个问题
AssertionError: backend 'mysql' unavailable
AssertionError: backend 'postgresql' unavailable
网上搜了两三天,没有任何解决方案,对,是任何!!!最后我着急了,直接看他的报错信息分析源代码搞定了
在neutron/tests/functional/db/test_migrations.py中,有个做测试用的_TestModelsMigrations类,类的注释是这么写的
class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
'''Test for checking of equality models state and migrations.
For the opportunistic testing you need to set up a db named
'openstack_citest' with user 'openstack_citest' and password
'openstack_citest' on localhost.
The test will then use that db and user/password combo to run the tests.
For PostgreSQL on Ubuntu this can be done with the following commands::
sudo -u postgres psql
postgres=# create user openstack_citest with createdb login password
'openstack_citest';
postgres=# create database openstack_citest with owner
openstack_citest;
For MySQL on Ubuntu this can be done with the following commands::
mysql -u root
>create database openstack_citest;
>grant all privileges on openstack_citest.* to
openstack_citest@localhost identified by 'openstack_citest';
原来还要在mysql与postgresql里面创建opestack_citest用户与数据库啊
于是执行
sudo -u postgres psql
postgres=# create user openstack_citest with createdb login password
'openstack_citest';
postgres=# create database openstack_citest with owner
openstack_citest;
与
mysql -u root
>create database openstack_citest;
>grant all privileges on openstack_citest.* to openstack_citest@localhost
identified by 'openstack_citest';
然后在tox.ini所在的目录执行
tox -e py27
仍然报错
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError)
(1044, u"Access denied for user 'openstack_citest'@'localhost'
to database 'abojtodlis'") [SQL: 'CREATE DATABASE abojtodlis']
(Background on this error at: http://sqlalche.me/e/e3q8)
查了一下,是openstack_citest这个用户没有创建数据库的权限,
在mysql命令中输入下面的命令即可
mysql> grant all privileges on *.* to openstack_citest@localhost identified by 'openstack_citest';
最后搞定