Skip to content

self-test: error initializing mysql_system_database fixture #50

@nicoddemus

Description

@nicoddemus

https://github.com/pytest-dev/pytest-services/actions/runs/16306706692/job/46054240613

_________________________ ERROR at setup of test_mysql _________________________

run_services = True
mysql_data_dir = '/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql'
mysql_base_dir = '/usr'
mysql_defaults_file = '/tmp/pytest-of-runner/pytest-0/pytest-services0/defaults.cnf'
memory_temp_dir = '/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/tmp'
lock_dir = '/dev/shm/service-locks'
services_log = <Logger [local] pytest_services.log (DEBUG)>

    @pytest.fixture(scope='session')
    def mysql_system_database(
            run_services,
            mysql_data_dir,
            mysql_base_dir,
            mysql_defaults_file,
            memory_temp_dir,
            lock_dir,
            services_log,
    ):
        """Install database to given path."""
        if run_services:
            mysqld = shutil.which('mysqld')
            assert mysqld, 'You have to install mysqld script.'
    
            try:
                services_log.debug('Starting mysqld.')
>               check_output([
                    mysqld,
                    '--defaults-file={0}'.format(mysql_defaults_file),
                    '--initialize-insecure',
                    '--datadir={0}'.format(mysql_data_dir),
                    '--basedir={0}'.format(mysql_base_dir),
                    '--user={0}'.format(os.environ['USER'])
                ])

.tox/py/lib/python3.9/site-packages/pytest_services/mysql.py:63: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

popenargs = (['/usr/sbin/mysqld', '--defaults-file=/tmp/pytest-of-runner/pytest-0/pytest-services0/defaults.cnf', '--initialize-insecure', '--datadir=/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql', '--basedir=/usr', '--user=runner'],)
kwargs = {}
process = <Popen: returncode: 1 args: ['/usr/sbin/mysqld', '--defaults-file=/tmp/pytes...>
output = b''
err = b"mysqld: Can't create directory '/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql/' (OS errno 17 - File exist...908Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.42-0ubuntu0.24.04.2)  (Ubuntu).\n"
retcode = 1
cmd = ['/usr/sbin/mysqld', '--defaults-file=/tmp/pytest-of-runner/pytest-0/pytest-services0/defaults.cnf', '--initialize-insecure', '--datadir=/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql', '--basedir=/usr', '--user=runner']

    def check_output(*popenargs, **kwargs):
        """Run command with arguments and return its output (both stdout and stderr) as a byte string.
    
        If the exit code was non-zero it raises a CalledProcessWithOutputError.
        """
        if 'stdout' in kwargs:
            raise ValueError('stdout argument not allowed, it will be overridden.')
    
        if 'stderr' in kwargs:
            raise ValueError('stderr argument not allowed, it will be overridden.')
    
        process = subprocess.Popen(
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            *popenargs, **kwargs)
        output, err = process.communicate()
        retcode = process.poll()
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessWithOutputError(retcode, cmd, output, err)
Error: test_services.process.CalledProcessWithOutputError: Command '['/usr/sbin/mysqld', '--defaults-file=/tmp/pytest-of-runner/pytest-0/pytest-services0/defaults.cnf', '--initialize-insecure', '--datadir=/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql', '--basedir=/usr', '--user=runner']' returned non-zero exit status 1. with output: b'' and error: b"mysqld: Can't create directory '/dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql/' (OS errno 17 - File exists)\n2025-07-15T23:43:58.751649Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.42-0ubuntu0.24.04.2) initializing of server in progress as process 3966\n2025-07-15T23:43:58.752815Z 0 [ERROR] [MY-013236] [Server] The designated data directory /dev/shm/sr-be7ded3b29b7476d8842b5f4f2e6a525-local/mysql/ is unusable. You can remove all files that the server added to it.\n2025-07-15T23:43:58.752831Z 0 [ERROR] [MY-010119] [Server] Aborting\n2025-07-15T23:43:58.752908Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.42-0ubuntu0.24.04.2)  (Ubuntu).\n"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions