Beispiel #1
0
        public async Task ComposeWaitForCustomLambdaShallWork()
        {
            var file = Path.Combine(Directory.GetCurrentDirectory(),
                                    (TemplateString)"Resources/ComposeTests/WordPress/docker-compose.yml");

            // @formatter:off
            using (Fd
                   .UseContainer()
                   .UseCompose()
                   .FromFile(file)
                   .RemoveOrphans()
                   .Wait("wordpress", (service, cnt) => {
                if (cnt > 60)
                {
                    throw new FluentDockerException("Failed to wait for wordpress service");
                }

                var res = "http://localhost:8000/wp-admin/install.php".DoRequest().Result;
                return(res.Code == HttpStatusCode.OK &&
                       res.Body.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1 ? 0 : 500);
            })
                   .Build().Start())
            // @formatter:on
            {
                // Since we have waited - this shall now always work.
                var installPage = await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
            }
        }
Beispiel #2
0
        public async Task WordPressDockerComposeServiceShallShowInstallScreen()
        {
            var file = Path.Combine(Directory.GetCurrentDirectory(),
                                    (TemplateString)"Resources/ComposeTests/WordPress/docker-compose.yml");

            // @formatter:off
            using (var svc = Fd
                             .UseContainer()
                             .UseCompose()
                             .FromFile(file)
                             .RemoveOrphans()
                             .WaitForHttp("wordpress", "http://localhost:8000/wp-admin/install.php")
                             .Build().Start())
            // @formatter:on
            {
                // We now have a running WordPress with a MySql database
                var installPage = await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
                Assert.AreEqual(1, svc.Hosts.Count);
                Assert.AreEqual(2, svc.Containers.Count);
                Assert.AreEqual(2, svc.Images.Count);
                Assert.AreEqual(5, svc.Services.Count);
            }
        }
Beispiel #3
0
        public async Task DockerComposePauseResumeShallWork()
        {
            var file = Path.Combine(Directory.GetCurrentDirectory(),
                                    (TemplateString)"Resources/ComposeTests/WordPress/docker-compose.yml");

            // @formatter:off
            using (var svc = Fd
                             .UseContainer()
                             .UseCompose()
                             .FromFile(file)
                             .RemoveOrphans()
                             .WaitForHttp("wordpress", "http://localhost:8000/wp-admin/install.php")
                             .Build().Start())
            // @formatter:on
            {
                // We now have a running WordPress with a MySql database
                var installPage = await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);

                svc.Pause();
                Assert.AreEqual(ServiceRunningState.Paused, svc.State);

                try
                {
                    await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                    Assert.Fail("The containers should be paused and thus no http get shall work");
                }
                catch (Exception)
                {
                    // We shall end up here
                }

                foreach (var container in svc.Containers)
                {
                    Assert.AreEqual(ServiceRunningState.Paused, container.State);
                    var cfg = container.GetConfiguration(true);
                    Assert.AreEqual(ServiceRunningState.Paused, cfg.State.ToServiceState());
                }

                svc.Start();
                Assert.AreEqual(ServiceRunningState.Running, svc.State);
                installPage = await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);

                foreach (var container in svc.Containers)
                {
                    Assert.AreEqual(ServiceRunningState.Running, container.State);
                    var cfg = container.GetConfiguration(true);
                    Assert.AreEqual(ServiceRunningState.Running, cfg.State.ToServiceState());
                }
            }
        }
Beispiel #4
0
        public async Task ComposeWaitForHttpShallWork()
        {
            var file = Path.Combine(Directory.GetCurrentDirectory(),
                                    (TemplateString)"Resources/ComposeTests/WordPress/docker-compose.yml");

            // @formatter:off
            using (Fd
                   .UseContainer()
                   .UseCompose()
                   .FromFile(file)
                   .RemoveOrphans()
                   .WaitForHttp("wordpress", "http://localhost:8000/wp-admin/install.php", continuation: (resp, cnt) =>
                                resp.Body.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1 ? 0 : 500)
                   .Build().Start())
            // @formatter:on
            {
                // Since we have waited - this shall now always work.
                var installPage = await HttpExtensions.Wget("http://localhost:8000/wp-admin/install.php");

                Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
            }
        }