Ejemplo n.º 1
0
            public async void ContainerShouldBeRemoved()
            {
                var client = Substitute.For <IContainerClient>();

                client.Handle.Returns(new ContainerHandle("asdfghjkl"));
                containerManager.AddContainer(client);

                await containerManager.DestroyContainerAsync(client);

                var destroyedClient = containerManager.GetContainer("asdfghjkl");

                Assert.Null(destroyedClient);
            }
Ejemplo n.º 2
0
        public bool Stop(HostControl hostControl)
        {
            log.Info("Stopping Warden");
            try
            {
                cancellationTokenSource.Cancel();

                Task.WaitAll(new[] { wardenServerTask }, (int)TimeSpan.FromSeconds(25).TotalMilliseconds);

                if (wardenServer.ClientListenException != null)
                {
                    log.Log(LogLevel.Error, String.Empty, wardenServer.ClientListenException);
                }

                var destroyTasks = new List <Task>();
                foreach (ContainerHandle handle in containerManager.Handles)
                {
                    try
                    {
                        log.Info("Destroying container handle {0}", handle.ToString());
                        destroyTasks.Add(containerManager.DestroyContainerAsync(handle));
                    }
                    catch (Exception e)
                    {
                        log.Log(LogLevel.Error, String.Empty, e);
                    }
                }
                Task.WaitAll(destroyTasks.ToArray(), 2000);
                containerManager.Dispose();
            }
            catch (Exception ex)
            {
                log.Log(LogLevel.Error, String.Empty, ex);
            }

            return(true);
        }