pytest-services icon indicating copy to clipboard operation
pytest-services copied to clipboard

Can't initialise MySQL 5.7 in Ubuntu 16.04 (in-memory)

Open olegpidsadnyi opened this issue 9 years ago • 1 comments

There are few issues noticed while trying mysql fixture in Ubuntu 16.04 and MySQL 5.7.

Ubuntu is changing /dev/shm to /run/shm. MySQL is changing instantiation to "mysqld --initialize". MySQL can't initialise data folder unless it doesn't exist. So creation of the defaults.cnf has to be stored in another directory. MySQL can't access (read/write) folders that pytest process is creating in the /run/shm, including tmp.

It might become problematic with upgrades of Ubuntu.

olegpidsadnyi avatar Dec 02 '16 20:12 olegpidsadnyi

I think the solution is to simply use docker for most if not all services:

@pytest.fixture(scope='session')
def mysql_watcher(
        request, run_services, watcher_getter, mysql_system_database, mysql_pid, mysql_socket, mysql_data_dir,
        mysql_defaults_file):
    """The mysqld process watcher."""
    if run_services:
        return watcher_getter('docker', [
           'run',
           '--rm',
           '-e',
           'MYSQL_ROOT_PASSWORD={0}'.format(mysql_password),
           'mysql:{0}'.format(mysql_version),
        ], checker=lambda: os.path.exists(mysql_socket))

of course it requires docker to be installed for test nodes, but ONLY docker then, and not all kinds of outdated software rubbish

bubenkoff avatar Dec 02 '16 21:12 bubenkoff