示例#1
0
        public async Task Execute_MultipleWebAppSlotsWithTags_WebAppWithTags_CreatesCorrectTargets()
        {
            // Arrange
            var variables = new CalamariVariables();
            var context   = new RunningDeployment(variables);

            CreateVariables(context);
            var log = new InMemoryLog();
            var sut = new TargetDiscoveryBehaviour(log);

            // Set expected tags on each slot of the web app AND the web app itself
            var tags = new Dictionary <string, string>
            {
                { TargetTags.EnvironmentTagName, EnvironmentName },
                { TargetTags.RoleTagName, Role },
            };

            await CreateOrUpdateTestWebApp(tags);
            await CreateOrUpdateTestWebAppSlots(tags);

            // Act
            await sut.Execute(context);

            var serviceMessageToCreateWebAppTarget = TargetDiscoveryHelpers.CreateWebAppTargetCreationServiceMessage(resourceGroupName, appName, AccountId, Role, null);

            log.StandardOut.Should().Contain(serviceMessageToCreateWebAppTarget.ToString(), "A target should be created for the web app itself as well as for the slots");

            // Assert
            foreach (var slotName in slotNames)
            {
                var serviceMessageToCreateTargetForSlot = TargetDiscoveryHelpers.CreateWebAppDeploymentSlotTargetCreationServiceMessage(resourceGroupName, appName, slotName, AccountId, Role, null);
                log.StandardOut.Should().Contain(serviceMessageToCreateTargetForSlot.ToString());
            }
        }
示例#2
0
        public async Task Execute_WebAppWithNonMatchingTags_CreatesNoTargets()
        {
            // Arrange
            var variables = new CalamariVariables();
            var context   = new RunningDeployment(variables);

            this.CreateVariables(context);
            var log = new InMemoryLog();
            var sut = new TargetDiscoveryBehaviour(log);

            // Set expected tags on our web app
            var tags = new Dictionary <string, string>
            {
                { TargetTags.EnvironmentTagName, EnvironmentName },
                { TargetTags.RoleTagName, "a-different-role" },
            };

            await CreateOrUpdateTestWebApp(tags);

            // Act
            await sut.Execute(context);

            // Assert
            var serviceMessageToCreateWebAppTarget = TargetDiscoveryHelpers.CreateWebAppTargetCreationServiceMessage(resourceGroupName, appName, AccountId, Role, null);

            log.StandardOut.Should().NotContain(serviceMessageToCreateWebAppTarget.ToString(), "The web app target should not be created as the role tag did not match");
        }
示例#3
0
        public async Task Execute_MultipleWebAppSlotsWithPartialTags_WebAppWithPartialTags_CreatesNoTargets()
        {
            // Arrange
            var variables = new CalamariVariables();
            var context   = new RunningDeployment(variables);

            CreateVariables(context);
            var log = new InMemoryLog();
            var sut = new TargetDiscoveryBehaviour(log);

            // Set partial tags on each slot of the web app AND the remaining ones on the web app itself
            var webAppTags = new Dictionary <string, string>
            {
                { TargetTags.EnvironmentTagName, EnvironmentName },
            };

            var slotTags = new Dictionary <string, string>
            {
                { TargetTags.RoleTagName, Role },
            };

            await CreateOrUpdateTestWebApp(webAppTags);
            await CreateOrUpdateTestWebAppSlots(slotTags);

            // Act
            await sut.Execute(context);

            var serviceMessageToCreateWebAppTarget = TargetDiscoveryHelpers.CreateWebAppTargetCreationServiceMessage(resourceGroupName, appName, AccountId, Role, null);

            log.StandardOut.Should().NotContain(serviceMessageToCreateWebAppTarget.ToString(), "A target should not be created for the web app as the tags directly on the web app do not match, even though when combined with the slot tags they do");

            // Assert
            foreach (var slotName in slotNames)
            {
                var serviceMessageToCreateTargetForSlot = TargetDiscoveryHelpers.CreateWebAppDeploymentSlotTargetCreationServiceMessage(resourceGroupName, appName, slotName, AccountId, Role, null);
                log.StandardOut.Should().NotContain(serviceMessageToCreateTargetForSlot.ToString(), "A target should not be created for the web app slot as the tags directly on the slot do not match, even though when combined with the web app tags they do");
            }
        }