Exemplo n.º 1
0
        public async Task MultiProjectPurgeTest()
        {
            using var projectDirectory = CopySampleProjectDirectory("multi-project");

            var projectFile   = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
            var tyeDir        = new DirectoryInfo(Path.Combine(projectDirectory.DirectoryPath, ".tye"));
            var outputContext = new OutputContext(_sink, Verbosity.Debug);
            var application   = await ApplicationFactory.CreateAsync(outputContext, projectFile);

            var host = new TyeHost(application.ToHostingApplication(), Array.Empty <string>())
            {
                Sink = _sink,
            };

            try
            {
                await TestHelpers.StartHostAndWaitForReplicasToStart(host);

                var pids       = GetAllAppPids(host.Application);
                var containers = GetAllContainerIds(host.Application);

                Assert.True(Directory.Exists(tyeDir.FullName));
                Assert.Subset(new HashSet <int>(GetAllPids()), new HashSet <int>(pids));
                Assert.Subset(new HashSet <string>(await DockerAssert.GetRunningContainersIdsAsync(_output)),
                              new HashSet <string>(containers));

                await TestHelpers.PurgeHostAndWaitForGivenReplicasToStop(host,
                                                                         GetAllReplicasNames(host.Application));

                var runningPids = new HashSet <int>(GetAllPids());
                Assert.True(pids.All(pid => !runningPids.Contains(pid)));
                var runningContainers =
                    new HashSet <string>(await DockerAssert.GetRunningContainersIdsAsync(_output));
                Assert.True(containers.All(c => !runningContainers.Contains(c)));
            }
            finally
            {
                await host.DisposeAsync();

                Assert.False(Directory.Exists(tyeDir.FullName));
            }
        }
Exemplo n.º 2
0
        public async Task FrontendBackendPurgeTest()
        {
            using var projectDirectory = CopyTestProjectDirectory("frontend-backend");

            var projectFile   = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
            var tyeDir        = new DirectoryInfo(Path.Combine(projectDirectory.DirectoryPath, ".tye"));
            var outputContext = new OutputContext(_sink, Verbosity.Debug);
            var application   = await ApplicationFactory.CreateAsync(outputContext, projectFile);

            var host = new TyeHost(application.ToHostingApplication(), new HostOptions())
            {
                Sink = _sink,
            };

            try
            {
                await TestHelpers.StartHostAndWaitForReplicasToStart(host);

                var pids = GetAllAppPids(host.Application);

                Assert.True(Directory.Exists(tyeDir.FullName));
                Assert.Subset(new HashSet <int>(GetAllPids()), new HashSet <int>(pids));

                await TestHelpers.PurgeHostAndWaitForGivenReplicasToStop(host,
                                                                         GetAllReplicasNames(host.Application));

                var runningPids = new HashSet <int>(GetAllPids());
                Assert.True(pids.All(pid => !runningPids.Contains(pid)));
            }
            finally
            {
                await host.DisposeAsync();

                Assert.False(Directory.Exists(tyeDir.FullName));
            }
        }