コード例 #1
0
        public void TestCreate()
        {
            // Arrange
            var containerApi = MockContainerApi().Object;

            var dockerRunspaceProvider = new DockerRunspaceProvider(
                new RunspaceContainerCreateSpec()
            {
                ImageName   = TEST_IMAGE_NAME,
                NetworkName = TEST_NETWORK_NAME
            },
                TEST_DOCKER_ADDRESS,
                containerApi,
                false);

            // Act
            var actual = dockerRunspaceProvider.StartCreate();

            actual = dockerRunspaceProvider.WaitCreateCompletion(actual);

            // Assert
            Assert.AreEqual(TEST_RUNSPACE_ID, actual.Id);
            Assert.AreEqual(TEST_IP_ADDRESS, actual.Endpoint.Address.ToString());
            Assert.AreEqual(TEST_NETWORK_PORT, actual.Endpoint.Port);
        }
コード例 #2
0
        public void TestDockerExceptionHandledOnCreate()
        {
            // Arrange
            var containerApiMock = new Mock <IContainerApi>();

            // Mock ContainerCreate API
            containerApiMock.Setup(m => m.ContainerCreate(It.IsAny <ContainerConfig>(), null))
            .Throws(new ApiException());

            var containerApi = containerApiMock.Object;

            var dockerRunspaceProvider = new DockerRunspaceProvider(
                new RunspaceContainerCreateSpec()
            {
                ImageName   = TEST_IMAGE_NAME,
                NetworkName = TEST_NETWORK_NAME
            },
                TEST_DOCKER_ADDRESS,
                containerApi,
                false);

            // Act
            var actual = dockerRunspaceProvider.StartCreate();

            actual = dockerRunspaceProvider.WaitCreateCompletion(actual);

            // Assert
            Assert.AreEqual(RunspaceCreationState.Error, actual.CreationState);
            Assert.NotNull(actual.CreationError);
            Assert.AreEqual("Docker Engine ContainerCreate API failed", actual.CreationError.Message);
        }
コード例 #3
0
        //[Test]
        public void TestCreateSingleRunspace()
        {
            // Act
            var runspaceInfo = _runspaceProvider.StartCreate();

            runspaceInfo = _runspaceProvider.WaitCreateCompletion(runspaceInfo);

            // Assert
            Assert.NotNull(runspaceInfo);
            Assert.NotNull(runspaceInfo.Id);
            Assert.NotNull(runspaceInfo.Endpoint);
            Assert.NotNull(runspaceInfo.Endpoint.Address);
            Assert.IsTrue(runspaceInfo.Endpoint.Port > 0);

            // Prepare for TearDown
            _startedContainers.Add(runspaceInfo.Id);
        }