Пример #1
0
        public void GetExecutionPlan_WhereTaskHasDependencyNotSpecifiedForHost_AddsDependencyToPlan()
        {
            // Arrange
            var taskblock = typeof(InheritDependencies);
            var host = new Host
            {
                Hostname = SomeHostname
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task1", "Task2"))
            };

            // Act
            var manager = new DeploymentManager<InheritDependencies>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #2
0
        public void GetExecutionPlan_WhereTaskHasDuplicateExplicitHostsProvided_ReturnsOnePlan()
        {
            // Arrange
            var taskblock = typeof(DuplicateExplicitHosts);
            var host = new Host
            {
                Hostname = SomeHostname
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task1"))
            };

            // Act
            var manager = new DeploymentManager<DuplicateExplicitHosts>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #3
0
        public void GetExecutionPlan_WhereTaskNotIncludedAsDependency_IsNotPresentInPlan()
        {
            // Arrange
            var taskblock = typeof(UnusedTask);
            var host = new Host
            {
                Hostname = SomeHostname
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task2", "Task3"))
            };

            // Act
            var manager = new DeploymentManager<UnusedTask>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #4
0
        public void GetExecutionPlan_WhereTaskHasOverlappingHostAndRole_ReturnsOnePlan()
        {
            // Arrange
            var taskblock = typeof(OverlappingHostAndRole);
            var host = new Host
            {
                Hostname = SomeHostname,
                Roles = new[] { SomeRole }
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task1"))
            };

            // Act
            var manager = new DeploymentManager<OverlappingHostAndRole>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #5
0
        public void GetExecutionPlan_WhereTaskHasOneRoleAttributeAndMultipleHostsProvided_ReturnsMultiplePlans()
        {
            // Arrange
            var taskblock = typeof(RoleMultipleHosts);
            var host = new Host
            {
                Hostname = SomeHostname,
                Roles = new[] { SomeRole }
            };
            var host2 = new Host
            {
                Hostname = SomeHostname2,
                Roles = new[] { SomeRole }
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host,
                    host2
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task1")),
                new ExecutionPlan(host2, taskblock.GetObjMethods("Task1"))
            };

            // Act
            var manager = new DeploymentManager<RoleMultipleHosts>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #6
0
        public void GetExecutionPlan_WhereTaskHasOneHostAttributeAndAliasProvided_ReturnsOnePlan()
        {
            // Arrange
            var taskblock = typeof(HostAttrs);
            var host = new Host
            {
                Alias = SomeHostname,
                Hostname = "something else"
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Task1"))
            };

            // Act
            var manager = new DeploymentManager<HostAttrs>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(
                expected.OrderBy(p => p.Host.Hostname).ToList(),
                actual.OrderBy(p => p.Host.Hostname).ToList());
        }
Пример #7
0
        public void GetExecutionPlan_WhereTaskHasInitializationAndCleanup_ReturnsInitializationFirstAndCleanupLast()
        {
            // Arrange
            var taskblock = typeof(InitializationAndCleanup);
            var host = new Host
            {
                Hostname = SomeHostname
            };
            var config = new DeploymentConfig
            {
                Hosts = new[]
                {
                    host
                }
            };

            var expected = new List<ExecutionPlan>
            {
                new ExecutionPlan(host, taskblock.GetObjMethods("Init", "Task1", "Cleanup"))
            };

            // Act
            var manager = new DeploymentManager<InitializationAndCleanup>(config);
            var actual = manager.GetExecutionPlans();

            // Assert
            CollectionAssert.AreEqual(expected.ToList(), actual.ToList());
        }