public WebAppWithDockerFileTests() { _httpHelper = new HttpHelper(); var cloudFormationClient = new AmazonCloudFormationClient(); _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient); var ecsClient = new AmazonECSClient(); _ecsHelper = new ECSHelper(ecsClient); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); var serviceProvider = serviceCollection.BuildServiceProvider(); _app = serviceProvider.GetService <App>(); Assert.NotNull(_app); _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>(); Assert.NotNull(_interactiveService); _testAppManager = new TestAppManager(); }
public async Task GenerateRecommendationsFromCompatibleDeploymentProject() { // ARRANGE var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); var webAppWithDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var orchestrator = await GetOrchestrator(webAppWithDockerFilePath); await _commandLineWrapper.Run("git init", tempDirectoryPath); var saveDirectoryPathEcsProject = Path.Combine(tempDirectoryPath, "ECS-CDK"); var customEcsRecipeName = "Custom ECS Fargate Recipe"; // Select ECS Fargate recipe await Utilities.CreateCDKDeploymentProjectWithRecipeName(webAppWithDockerFilePath, customEcsRecipeName, "1", saveDirectoryPathEcsProject); // Get custom recipe IDs var customEcsRecipeId = await GetCustomRecipeId(Path.Combine(saveDirectoryPathEcsProject, "ECS-CDK.recipe")); // ACT var recommendations = await orchestrator.GenerateRecommendationsFromSavedDeploymentProject(saveDirectoryPathEcsProject); // ASSERT recommendations.Count.ShouldEqual(1); recommendations[0].Name.ShouldEqual("Custom ECS Fargate Recipe"); recommendations[0].Recipe.Id.ShouldEqual(customEcsRecipeId); recommendations[0].Recipe.RecipePath.ShouldEqual(Path.Combine(saveDirectoryPathEcsProject, "ECS-CDK.recipe")); }
public async Task LocateCustomRecipePathsWithoutManifestFile() { var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); var webAppWithDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var webAppNoDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppNoDockerFile"); var webAppWithDockerCsproj = Path.Combine(webAppWithDockerFilePath, "WebAppWithDockerFile.csproj"); var webAppNoDockerCsproj = Path.Combine(webAppNoDockerFilePath, "WebAppNoDockerFile.csproj"); var solutionDirectoryPath = tempDirectoryPath; var customRecipeLocator = BuildCustomRecipeLocator(); await _commandLineWrapper.Run("git init", tempDirectoryPath); // ARRANGE - Create 2 CDK deployment projects that contain the custom recipe snapshot await Utilities.CreateCDKDeploymentProject(webAppWithDockerFilePath, Path.Combine(tempDirectoryPath, "MyCdkApp1")); await Utilities.CreateCDKDeploymentProject(webAppWithDockerFilePath, Path.Combine(tempDirectoryPath, "MyCdkApp2")); // ACT - Fetch custom recipes corresponding to a different target application (under source control) without a deployment-manifest file. var customRecipePaths = await customRecipeLocator.LocateCustomRecipePaths(webAppNoDockerCsproj, solutionDirectoryPath); // ASSERT File.Exists(Path.Combine(webAppNoDockerFilePath, "aws-deployments.json")).ShouldBeFalse(); customRecipePaths.Count.ShouldEqual(2); customRecipePaths.ShouldContain(Path.Combine(tempDirectoryPath, "MyCdkApp1")); customRecipePaths.ShouldContain(Path.Combine(tempDirectoryPath, "MyCdkApp1")); }
public async Task InvalidSaveCdkDirectoryInsideProjectDirectory() { var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); await _commandLineWrapper.Run("git init", tempDirectoryPath); var targetApplicationProjectPath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var saveDirectoryPath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile", "MyCdkApp"); await Utilities.CreateCDKDeploymentProject(targetApplicationProjectPath, saveDirectoryPath, false); }
public DeploymentManifestFileTests() { _fileManager = new FileManager(); _directoryManager = new DirectoryManager(); _testDirectoryManager = new TestDirectoryManager(); _testAppManager = new TestAppManager(); var targetApplicationPath = _testAppManager.GetProjectPath(Path.Combine("testapps", "WebAppWithDockerFile", "WebAppWithDockerFile.csproj"));; _targetApplicationFullPath = _directoryManager.GetDirectoryInfo(targetApplicationPath).FullName; _targetApplicationDirectoryFullPath = _directoryManager.GetDirectoryInfo(targetApplicationPath).Parent.FullName; _deploymentManifestEngine = new DeploymentManifestEngine(_testDirectoryManager, _fileManager); }
public async Task GenerateRecommendationsFromCustomRecipesWithManifestFile() { // ARRANGE var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); var webAppWithDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var orchestrator = await GetOrchestrator(webAppWithDockerFilePath); await _commandLineWrapper.Run("git init", tempDirectoryPath); var saveDirectoryPathEcsProject = Path.Combine(tempDirectoryPath, "ECS-CDK"); var saveDirectoryPathEbsProject = Path.Combine(tempDirectoryPath, "EBS-CDK"); var customEcsRecipeName = "Custom ECS Fargate Recipe"; var customEbsRecipeName = "Custom Elastic Beanstalk Recipe"; // select ECS Fargate recipe await Utilities.CreateCDKDeploymentProjectWithRecipeName(webAppWithDockerFilePath, customEcsRecipeName, "1", saveDirectoryPathEcsProject); // select Elastic Beanstalk recipe await Utilities.CreateCDKDeploymentProjectWithRecipeName(webAppWithDockerFilePath, customEbsRecipeName, "3", saveDirectoryPathEbsProject); // Get custom recipe IDs var customEcsRecipeId = await GetCustomRecipeId(Path.Combine(saveDirectoryPathEcsProject, "ECS-CDK.recipe")); var customEbsRecipeId = await GetCustomRecipeId(Path.Combine(saveDirectoryPathEbsProject, "EBS-CDK.recipe")); // ACT var recommendations = await orchestrator.GenerateDeploymentRecommendations(); // ASSERT - Recipes are ordered by priority recommendations.Count.ShouldEqual(5); recommendations[0].Name.ShouldEqual(customEcsRecipeName); // custom recipe recommendations[1].Name.ShouldEqual(customEbsRecipeName); // custom recipe recommendations[2].Name.ShouldEqual("ASP.NET Core App to Amazon ECS using Fargate"); // default recipe recommendations[3].Name.ShouldEqual("ASP.NET Core App to AWS App Runner"); // default recipe recommendations[4].Name.ShouldEqual("ASP.NET Core App to AWS Elastic Beanstalk on Linux"); // default recipe // ASSERT - Recipe paths recommendations[0].Recipe.RecipePath.ShouldEqual(Path.Combine(saveDirectoryPathEcsProject, "ECS-CDK.recipe")); recommendations[1].Recipe.RecipePath.ShouldEqual(Path.Combine(saveDirectoryPathEbsProject, "EBS-CDK.recipe")); // ASSERT - custom recipe IDs recommendations[0].Recipe.Id.ShouldEqual(customEcsRecipeId); recommendations[1].Recipe.Id.ShouldEqual(customEbsRecipeId); File.Exists(Path.Combine(webAppWithDockerFilePath, "aws-deployments.json")).ShouldBeTrue(); }
public ServerModeTests() { var cloudFormationClient = new AmazonCloudFormationClient(Amazon.RegionEndpoint.USWest2); _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); _serviceProvider = serviceCollection.BuildServiceProvider(); _awsRegion = "us-west-2"; _testAppManager = new TestAppManager(); }
public async Task GenerateRecommendationsWithoutCustomRecipes() { // ARRANGE var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); var webAppWithDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var orchestrator = await GetOrchestrator(webAppWithDockerFilePath); await _commandLineWrapper.Run("git init", tempDirectoryPath); // ACT var recommendations = await orchestrator.GenerateDeploymentRecommendations(); // ASSERT recommendations.Count.ShouldEqual(3); recommendations[0].Name.ShouldEqual("ASP.NET Core App to Amazon ECS using Fargate"); // default recipe recommendations[1].Name.ShouldEqual("ASP.NET Core App to AWS App Runner"); // default recipe recommendations[2].Name.ShouldEqual("ASP.NET Core App to AWS Elastic Beanstalk on Linux"); // default recipe }
public async Task DefaultSaveDirectory() { var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); await _commandLineWrapper.Run("git init", tempDirectoryPath); var targetApplicationProjectPath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); await Utilities.CreateCDKDeploymentProject(targetApplicationProjectPath); // Verify a bug fix that the IDictionary for TypeHintData was not getting serialized. var recipeFilePath = Directory.GetFiles(targetApplicationProjectPath + "CDK", "*.recipe", SearchOption.TopDirectoryOnly).FirstOrDefault(); Assert.True(File.Exists(recipeFilePath)); var recipeRoot = JsonConvert.DeserializeObject <RecipeDefinition>(File.ReadAllText(recipeFilePath)); var applicationIAMRoleSetting = recipeRoot.OptionSettings.FirstOrDefault(x => string.Equals(x.Id, "ApplicationIAMRole")); Assert.Equal("ecs-tasks.amazonaws.com", applicationIAMRoleSetting.TypeHintData["ServicePrincipal"]); }
public async Task GenerateRecommendationsFromIncompatibleDeploymentProject() { // ARRANGE var tempDirectoryPath = new TestAppManager().GetProjectPath(string.Empty); var webAppWithDockerFilePath = Path.Combine(tempDirectoryPath, "testapps", "WebAppWithDockerFile"); var blazorAppPath = Path.Combine(tempDirectoryPath, "testapps", "BlazorWasm50"); var orchestrator = await GetOrchestrator(blazorAppPath); await _commandLineWrapper.Run("git init", tempDirectoryPath); var saveDirectoryPathEcsProject = Path.Combine(tempDirectoryPath, "ECS-CDK"); await Utilities.CreateCDKDeploymentProject(webAppWithDockerFilePath, saveDirectoryPathEcsProject); // ACT var recommendations = await orchestrator.GenerateRecommendationsFromSavedDeploymentProject(saveDirectoryPathEcsProject); // ASSERT recommendations.ShouldBeEmpty(); }
public BlazorWasmTests() { _httpHelper = new HttpHelper(); _cloudFormationHelper = new CloudFormationHelper(new AmazonCloudFormationClient()); _cloudFrontHelper = new CloudFrontHelper(new Amazon.CloudFront.AmazonCloudFrontClient()); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); var serviceProvider = serviceCollection.BuildServiceProvider(); _app = serviceProvider.GetService <App>(); Assert.NotNull(_app); _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>(); Assert.NotNull(_interactiveService); _testAppManager = new TestAppManager(); }
public ElasticBeanStalkDeploymentTest() { _httpHelper = new HttpHelper(); var cloudFormationClient = new AmazonCloudFormationClient(); _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); var serviceProvider = serviceCollection.BuildServiceProvider(); _app = serviceProvider.GetService <App>(); Assert.NotNull(_app); _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>(); Assert.NotNull(_interactiveService); _testAppManager = new TestAppManager(); }