Exemple #1
0
        private static async Task StartMySqlContainer(int port)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(
                DOCKER_PROCESS,
                $"run --rm --name {MY_SQL_CONTAINER_NAME} -p{port}:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e TZ=Europe/London -d mysql:latest --max-connections=1000");
            Process startProcess = Process.Start(startInfo);
            await startProcess.WaitForExitAsync();

            string connectionString = MySqlTestHelper.GetMySqlConnectionString();

            while (true)
            {
                try
                {
                    MySqlTestHelper.OpenConnection(connectionString);
                }
                catch
                {
                    Console.WriteLine("Waiting for My SQL to initialise...");
                    Thread.Sleep(5000);
                    continue;
                }

                break;
            }
        }