public async Task GetsLogs()
        {
            var containerName = "lcldkr-logs-test";
            var client        = new DockerClient();

            try
            {
                client.RunOrReplace(
                    "hello-world",
                    tag: null,
                    args: new RunArguments {
                    Name = containerName
                });

                await client.WaitForLogEntryAsync(containerName, "Hello from Docker!", TimeSpan.FromSeconds(30));

                var logString = client.Logs(containerName);

                Assert.Contains("Hello from Docker!", logString);
            }
            finally
            {
                client.StopAndRemoveContainer(containerName);
            }
        }
        public void Inspects()
        {
            var containerName = "lcldkr-inspect-test";
            var client        = new DockerClient();

            try
            {
                client.RunOrReplace(
                    "ubuntu",
                    tag: null,
                    args: new RunArguments()
                {
                    Name = containerName
                },
                    command: "tail -f /dev/null"); //we want the container to stay running

                var ipString = client.Inspect(containerName, "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}");

                IPAddress ip;
                bool      isIp = IPAddress.TryParse(ipString, out ip);

                Assert.True(isIp);
            }
            finally
            {
                client.StopAndRemoveContainer(containerName);
            }
        }
        public async Task Waits_for_log_entry()
        {
            var client = new DockerClient();

            var containerName = "lcldkr-log-test";

            client.RunOrReplace("hello-world", containerName);

            await client.WaitForLogEntryAsync(containerName, "Hello from Docker!", TimeSpan.FromSeconds(30));

            client.StopAndRemoveContainer(containerName);
        }
        public void Runs_and_replaces_container()
        {
            var client = new DockerClient();

            var containerName = "lcldckr-test-2";

            client.RunOrReplace("ubuntu", containerName);

            var runningContainer = client
                                   .Ps(true, new[] { new NameFilter(containerName) })
                                   .SingleOrDefault();

            Assert.NotNull(runningContainer);

            client.RunOrReplace("ubuntu", containerName);

            client.StopAndRemoveContainer(containerName);

            runningContainer = client
                               .Ps(true, new[] { new NameFilter(containerName) })
                               .SingleOrDefault();

            Assert.Null(runningContainer);
        }
Example #5
0
        public ImpalaTestFixture()
        {
            var client = new DockerClient();

            client.PullImage("andreysabitov/impala-kudu");
            client.RunOrReplace("andreysabitov/impala-kudu", "latest", new RunArguments
            {
                Name         = "impala-test",
                HostName     = "impala-test",
                PortMappings = new Dictionary <string, string>
                {
                    { "21000", "21000" }
                }
            });

            IPAddress ip = IPAddress.Parse("127.0.0.1");

            // Wait for impala here so we dont scew test times
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            while (stopWatch.Elapsed < TimeSpan.FromMinutes(5))
            {
                try
                {
                    using (var tcpClient = new TcpClient())
                    {
                        tcpClient.Connect(ip, 21000);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(500));
                }
            }

            ImpalaIp = ip;
        }