public async Task ResourceReaperShouldTimeoutIfInitializationFails()
        {
            var resourceReaperTask = ResourceReaper.GetAndStartNewAsync(this.sessionId, null, "nginx");

            _ = await Assert.ThrowsAsync <ResourceReaperException>(() => resourceReaperTask);

            Assert.Equal(new[] { ResourceReaperState.Created, ResourceReaperState.InitializingConnection }, this.stateChanges);
        }
        public async Task GetAndStartNewAsyncShouldBeCancellableDuringInitializingConnection()
        {
            ResourceReaper.StateChanged += this.CancelOnInitializingConnection;

            var resourceReaperTask = ResourceReaper.GetAndStartNewAsync(this.sessionId, null, "nginx", TimeSpan.FromSeconds(60), this.cts.Token);

            _ = await Assert.ThrowsAsync <ResourceReaperException>(() => resourceReaperTask);

            Assert.Equal(new[] { ResourceReaperState.Created, ResourceReaperState.InitializingConnection }, this.stateChanges);
        }
        public async Task GetAndStartNewAsyncShouldBeCancellableDuringContainerStart()
        {
            ResourceReaper.StateChanged += this.CancelOnCreated;

            var resourceReaperTask = ResourceReaper.GetAndStartNewAsync(this.sessionId, null, "nginx", TimeSpan.FromSeconds(60), this.cts.Token);

            _ = await Assert.ThrowsAnyAsync <OperationCanceledException>(() => resourceReaperTask);

            Assert.Equal(new[] { ResourceReaperState.Created }, this.stateChanges);
        }
        public async Task DisposeAsyncShouldAwaitConnectionTerminatedState()
        {
            // Given
            var resourceReaper = await ResourceReaper.GetAndStartNewAsync(this.sessionId)
                                 .ConfigureAwait(false);

            // When
            await resourceReaper.DisposeAsync()
            .ConfigureAwait(false);

            // Then
            Assert.Equal(Enum.GetValues(typeof(ResourceReaperState)).Cast <ResourceReaperState>(), this.stateChanges);
        }
 public Task InitializeAsync()
 {
     return(Task.WhenAll(ResourceReaper.GetAndStartNewAsync(this.SessionId), this.volume.CreateAsync()));
 }
示例#6
0
 public async Task InitializeAsync()
 {
     this.resourceReaper = await ResourceReaper.GetAndStartNewAsync()
                           .ConfigureAwait(false);
 }