Example #1
0
        public void ThrowsDeploymentsFailedExceptionForBadDeployments()
        {
            var badRevision = _deployer.PushRevision(new ApplicationSetRevision
            {
                ApplicationSetName = "HelloWorld",
                Version            = "BadWebLayerAppSpec",
                LocalDirectory     = ExampleRevisions.Directory("HelloWorld-BadWebLayerAppSpec"),
                StackName          = StackName
            });

            var expectedTail = string.Join("\n",
                                           @"LifecycleEvent - BeforeInstall",
                                           @"Script - \before-install.bat",
                                           @"[stdout]",
                                           @"[stdout]C:\Windows\system32>echo ""oh noes!"" ",
                                           @"[stdout]""oh noes!""",
                                           @"[stdout]",
                                           @"[stdout]C:\Windows\system32>exit 1 ",
                                           ""
                                           );

            try
            {
                _deployer.DeployRelease(badRevision, "CodeDeployRole");
                Assert.Fail("Expected DeploymentsFailedException");
            }
            catch (DeploymentsFailedException e)
            {
                Assert.That(e.FailedInstances.First().Tail, Is.EqualTo(expectedTail));
            }
        }
Example #2
0
        public void DeploymentManifestAllowsInstances()
        {
            var dir    = ExampleRevisions.BundleDirectory("HelloWorld-1.2.3", "WebLayer");
            var bundle = new Bundle("HelloWorld-1.2.3", dir, "SomeVersion", "SomeBucket", "SomeETag", "SomeStackName");

            Assert.That(bundle.TargetsAutoScalingDeploymentGroup, Is.False);
        }
Example #3
0
        public void DeploysCodeToInstancesInTheAutoScalingGroup()
        {
            var goodRevision = _deployer.PushRevision(new ApplicationSetRevision
            {
                ApplicationSetName = "HelloWorld",
                Version            = "GoodAutoScalingRevision",
                LocalDirectory     = ExampleRevisions.Directory("HelloWorld-AutoScaling"),
                StackName          = StackName
            });

            _deployer.DeployRelease(goodRevision, "CodeDeployRole");

            var publicDnsName = _stack.Outputs["publicDnsName"];
            var homePageUrl   = string.Format("http://{0}/index.aspx", publicDnsName);

            Console.WriteLine(homePageUrl);

            var webpageText = Retry.Do(() => Http.Get(homePageUrl), TimeSpan.FromSeconds(10));

            Assert.That(webpageText, Is.EqualTo("Hello, world!"));
        }
Example #4
0
        public void ThrowsDeploymentsFailedExceptionWhenNoInstancesWereMatched()
        {
            var badRevision = _deployer.PushRevision(new ApplicationSetRevision
            {
                ApplicationSetName = "HelloWorld",
                Version            = "Empty",
                LocalDirectory     = ExampleRevisions.Directory("HelloWorld-Empty"),
                StackName          = StackName
            });

            try
            {
                _deployer.DeployRelease(badRevision, "CodeDeployRole");
                Assert.Fail("Expected DeploymentsFailedException");
            }
            catch (DeploymentsFailedException e)
            {
                Assert.That(e.FailedInstances.Count(), Is.EqualTo(0));
                Assert.That(e.Message, Contains.Substring("No instances found"));
            }
        }
Example #5
0
        public void DeploysCodeToAppropriateInstances()
        {
            var goodRevision = _deployer.PushRevision(new ApplicationSetRevision
            {
                ApplicationSetName = "HelloWorld",
                Version            = "GoodRevision",
                LocalDirectory     = ExampleRevisions.Directory("HelloWorld-1.2.3"),
                StackName          = StackName
            });

            _deployer.DeployRelease(goodRevision, "CodeDeployRole");

            var publicDnsName = _stack.Outputs.First(o => o.Key == "publicDnsName").Value;
            var homePageUrl   = string.Format("http://{0}/index.aspx", publicDnsName);

            Console.WriteLine(homePageUrl);

            var webpageText = Retry.Do(() => { var html = Http.Get(homePageUrl); return(html); }, TimeSpan.FromSeconds(10));

            Assert.That(webpageText, Is.EqualTo("Hello, world!"));
        }
Example #6
0
        public void SetUp()
        {
            var awsEndpoint = TestConfiguration.AwsEndpoint;
            var credentials = new TestSuiteCredentials();

            _s3Client  = new AmazonS3Client(awsEndpoint);
            _iamClient = new AmazonIdentityManagementServiceClient(awsEndpoint);

            _awsConfiguration = new AwsConfiguration
            {
                IamRolePolicyDocument   = Roles.Path("s3-policy-new-bucket.json"),
                AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"),
                Bucket      = "s3-push-test",
                RoleName    = "SomeNewRole",
                AwsEndpoint = awsEndpoint,
                Credentials = credentials
            };

            _deployer            = new Deployer(_awsConfiguration);
            _localBuildDirectory = ExampleRevisions.Directory("HelloWorld-1.2.3");
            _applicationSetName  = "HelloWorld";
            _version             = "1.1.1";
            DeleteRolesAndPolicies();
        }
Example #7
0
        public void MissingDeploymentManifestThrowsUsefulError()
        {
            var dir = ExampleRevisions.BundleDirectory("HelloWorld-NoDeploySpec", "WebLayer");

            Assert.That(() => new Bundle("HelloWorld-NoDeploySpec", dir, "SomeVersion", "SomeBucket", "SomeETag", "SomeStackName"), Throws.InstanceOf <MissingDeploymentManifestException>());
        }