public async Task Test()
        {
            var containerName = GetType().FullName;

            var containerPort = 42006;

            var container = new TestUtil.DockerContainer(
                containerName,
                "postgres:9.6.11",
                new[]
            {
                $"-p {containerPort}:5432",
                "-e POSTGRES_PASSWORD=mysecretpassword"
            }
                );

            using (container)
            {
                container.Start();

                await TestUtil.WaitForDockerLogOutput(
                    containerName,
                    "LOG:  database system is ready to accept connections",
                    DateTime.UtcNow.AddMinutes(2)
                    );

                await TestUtil.WaitForTcpSocket(
                    "localhost",
                    containerPort,
                    DateTime.UtcNow.AddMinutes(1)
                    );

                await Task.Delay(TimeSpan.FromSeconds(5));

                var dbContextConnString =
                    $"Server=localhost;" +
                    $"Port={containerPort};" +
                    $"Database=orleans_ef_test;" +
                    $"User Id=postgres;" +
                    $"Password=mysecretpassword";

                void Callback(IServiceCollection services)
                {
                    services.AddEntityFrameworkNpgsql();
                    services.AddDbContext <OrleansEFContext>(options =>
                                                             options.UseNpgsql(dbContextConnString)
                                                             );
                }

                await TestSuite.Run(42000, Callback);
            }
        }
        public async Task Test()
        {
            var containerName = GetType().FullName;

            var containerPort = 3006;

            var databasePassword = "******";

            var container = new TestUtil.DockerContainer(
                containerName,
                "mcr.microsoft.com/mssql/server:2017-CU12-ubuntu",
                new[]
            {
                $"-p {containerPort}:1433",
                $"-e ACCEPT_EULA=Y",
                $"-e SA_PASSWORD={databasePassword}"
            }
                );

            using (container)
            {
                container.Start();

                await TestUtil.WaitForDockerLogOutput(
                    containerName,
                    "Server is listening on [ 'any' <ipv4> 1433].",
                    DateTime.UtcNow.AddMinutes(2)
                    );

                await TestUtil.WaitForTcpSocket(
                    "localhost",
                    containerPort,
                    DateTime.UtcNow.AddMinutes(1)
                    );

                await Task.Delay(TimeSpan.FromSeconds(5));

                var dbContextConnString =
                    $"Server=localhost,{containerPort};" +
                    $"Database=orleans_ef_test;" +
                    $"User Id=sa;" +
                    $"Password={databasePassword};";

                void Callback(IServiceCollection services) =>
                services.AddDbContext <OrleansEFContext>(options =>
                                                         options.UseSqlServer(dbContextConnString)
                                                         );

                await TestSuite.Run(3000, Callback);
            }
        }
Пример #3
0
        public async Task Test()
        {
            var containerName = GetType().FullName;

            var containerPort = 2006;

            var container = new TestUtil.DockerContainer(
                containerName,
                "cockroachdb/cockroach:v2.1.4",
                new[]
            {
                $"-p {containerPort}:26257",
                "-e MYSQL_ROOT_PASSWORD=my-secret-pw"
            },
                "start --insecure"
                );

            using (container)
            {
                container.Start();

                await TestUtil.WaitForDockerLogOutput(
                    containerName,
                    "nodeID:              1",
                    DateTime.UtcNow.AddMinutes(2)
                    );

                await TestUtil.WaitForTcpSocket(
                    "localhost",
                    containerPort,
                    DateTime.UtcNow.AddMinutes(1)
                    );

                var dbContextConnString =
                    $"Host=localhost;" +
                    $"Port={containerPort};" +
                    $"Database=orleans_ef_test;" +
                    $"Username=root;" +
                    $"SSL Mode=Disable;";

                void Callback(IServiceCollection services)
                {
                    services.AddEntityFrameworkNpgsql();
                    services.AddDbContext <OrleansEFContext>(options =>
                                                             options.UseNpgsql(dbContextConnString)
                                                             );
                }

                await TestSuite.Run(2000, Callback);
            }
        }
        public async Task Test()
        {
            var containerName = GetType().FullName;

            var containerPort = 20006;

            var container = new TestUtil.DockerContainer(
                containerName,
                "mysql:8.0.15",
                new[]
            {
                $"-p {containerPort}:3306",
                "-e MYSQL_ROOT_PASSWORD=my-secret-pw"
            }
                );

            using (container)
            {
                container.Start();

                await TestUtil.WaitForDockerLogOutput(
                    containerName,
                    "/usr/sbin/mysqld: ready for connections. Version: '8.0.15'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.",
                    DateTime.UtcNow.AddMinutes(2)
                    );

                await TestUtil.WaitForTcpSocket(
                    "localhost",
                    containerPort,
                    DateTime.UtcNow.AddMinutes(1)
                    );

                var dbContextConnString =
                    $"Server=localhost;" +
                    $"Port={containerPort};" +
                    $"Database=orleans_ef_test;" +
                    $"Uid=root;" +
                    $"Pwd=my-secret-pw";

                void Callback(IServiceCollection services)
                {
                    services.AddEntityFrameworkMySql();
                    services.AddDbContext <OrleansEFContext>(options =>
                                                             options.UseMySql(dbContextConnString)
                                                             );
                }

                await TestSuite.Run(20000, Callback);
            }
        }
        public async Task Test()
        {
            var containerName = GetType().FullName;

            var containerPort = 22006;

            var container = new TestUtil.DockerContainer(
                containerName,
                "mariadb:5.5.63",
                new[]
            {
                $"-p {containerPort}:3306",
                "-e MYSQL_ROOT_PASSWORD=my-secret-pw"
            }
                );

            using (container)
            {
                container.Start();

                await TestUtil.WaitForDockerLogOutput(
                    containerName,
                    "Version: '5.5.63-MariaDB-1~trusty'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution",
                    DateTime.UtcNow.AddMinutes(2)
                    );

                await TestUtil.WaitForTcpSocket(
                    "localhost",
                    containerPort,
                    DateTime.UtcNow.AddMinutes(1)
                    );

                var dbContextConnString =
                    $"Server=localhost;" +
                    $"Port={containerPort};" +
                    $"Database=orleans_ef_test;" +
                    $"Uid=root;" +
                    $"Pwd=my-secret-pw";

                void Callback(IServiceCollection services)
                {
                    services.AddEntityFrameworkMySql();
                    services.AddDbContext <OrleansEFContext>(options =>
                                                             options.UseMySql(dbContextConnString)
                                                             );
                }

                await TestSuite.Run(22000, Callback);
            }
        }