diff --git a/.vault-config/product-construction-prod.yaml b/.vault-config/product-construction-prod.yaml index b61c5f2a86..7a41820e10 100644 --- a/.vault-config/product-construction-prod.yaml +++ b/.vault-config/product-construction-prod.yaml @@ -19,3 +19,19 @@ secrets: hasPrivateKey: true hasWebhookSecret: false hasOAuthSecret: true + + dotnet-bot-arcade-services-content-rw: + type: github-access-token + parameters: + gitHubBotAccountSecret: + location: engkeyvault + name: BotAccount-dotnet-bot + gitHubBotAccountName: dotnet-bot + + dotnet-bot-maestro-auth-test-content-rw: + type: github-access-token + parameters: + gitHubBotAccountSecret: + location: engkeyvault + name: BotAccount-dotnet-bot + gitHubBotAccountName: dotnet-bot diff --git a/azure-pipelines-product-construction-service.yml b/azure-pipelines-product-construction-service.yml index 12bffc0d32..8bdc12edf8 100644 --- a/azure-pipelines-product-construction-service.yml +++ b/azure-pipelines-product-construction-service.yml @@ -12,6 +12,7 @@ pr: variables: # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=189 +# Required for MaestroAppClientId, MaestroStagingAppClientId - group: Publish-Build-Assets - name: resourceGroupName value: product-construction-service diff --git a/docs/DevGuide.md b/docs/DevGuide.md index 5f638014d0..fcb62541f9 100644 --- a/docs/DevGuide.md +++ b/docs/DevGuide.md @@ -82,7 +82,7 @@ You can deploy your branch to the staging environment where E2E tests can be run If you want to run the C# scenario tests (make sure that you followed the getting started steps before), you will need to set some environment variables: - 1. GITHUB_TOKEN : Get a github PAT from https://github.com/settings/tokens + 1. GITHUB_TOKEN : See [instructions](#generating-github-pat-for-local-scenario-test-runs) below 1. DARC_PACKAGE_SOURCE : Get the path to the darc nuget package (which would be in `arcade-services\artifacts\packages\Debug\NonShipping\`, see below for getting this built) 1. MAESTRO_BASEURIS : Run ngrok and get the https url @@ -173,3 +173,14 @@ You can disable the DNS Service by deleting `DnsService` from the add-on feature ] ``` If you change any settings in `ClusterManifestTemplate.json` run `Reset Local Cluster` from Service Fabric Local Cluster Manager to recreate the cluster configuration using the new settings + +## Generating GitHub PAT for local scenario test runs + +The GitHub scenario tests are ran against a dedicated organization - [`maestro-auth-tests`](https://github.com/maestro-auth-test). As such, a PAT with adequate permissions is required to run them locally. + +To generate one, navigate to https://github.com/settings/tokens and select the `Fine-grained tokens` sub-menu on the navigation bar. The token should be generated with the following settings: + - Resource owner: `maestro-auth-test` (if this option is not available in the resource settings please ask the team to add you to the test organization) + - Repository access: `All repositories` + - Repository permissions: `Contents` - `Access: Read and Write` + +This configuration will allow the tests to read and write to the test repos without any additional access to the org or the account itself. diff --git a/eng/templates/jobs/e2e-pcs-tests.yml b/eng/templates/jobs/e2e-pcs-tests.yml index fbda672064..87d3d625e4 100644 --- a/eng/templates/jobs/e2e-pcs-tests.yml +++ b/eng/templates/jobs/e2e-pcs-tests.yml @@ -17,6 +17,9 @@ jobs: # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=20&path=Publish-Build-Assets # Required for MaestroAppClientId, MaestroStagingAppClientId - group: Publish-Build-Assets + # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=202&path=Arcade-Services-Scenario-Tests + # Required for dotnet-bot-maestro-auth-test-content-rw + - group: Arcade-Services-Scenario-Tests - ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/heads/production'), startsWith(variables['Build.SourceBranch'], 'refs/heads/production-'), eq(variables['Build.SourceBranch'], 'refs/heads/production'))) }}: - group: MaestroInt KeyVault - name: PcsTestEndpoint @@ -106,7 +109,7 @@ jobs: env: PCS_BASEURI: ${{ variables.PcsTestEndpoint }} PCS_TOKEN: $(GetAuthInfo.Token) - GITHUB_TOKEN: $(maestro-scenario-test-github-token) + GITHUB_TOKEN: $(dotnet-bot-maestro-auth-test-content-rw) AZDO_TOKEN: $(AzdoToken) DARC_PACKAGE_SOURCE: $(Pipeline.Workspace)\PackageArtifacts DARC_DIR: $(Build.SourcesDirectory)\darc diff --git a/eng/templates/jobs/e2e-tests.yml b/eng/templates/jobs/e2e-tests.yml index e5e2fea754..b25b285731 100644 --- a/eng/templates/jobs/e2e-tests.yml +++ b/eng/templates/jobs/e2e-tests.yml @@ -19,8 +19,10 @@ jobs: # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=20&path=Publish-Build-Assets # Required for MaestroAppClientId, MaestroStagingAppClientId - group: Publish-Build-Assets + # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=202&path=Arcade-Services-Scenario-Tests + # Required for dotnet-bot-maestro-auth-test-content-rw + - group: Arcade-Services-Scenario-Tests - ${{ if parameters.isProd }}: - - group: MaestroProd KeyVault - name: MaestroTestEndpoints value: https://maestro-prod.westus2.cloudapp.azure.com,https://maestro.dot.net - name: ScenarioTestSubscription @@ -28,7 +30,6 @@ jobs: - name: MaestroAppId value: $(MaestroAppClientId) - ${{ else }}: - - group: MaestroInt KeyVault - name: MaestroTestEndpoints value: https://maestro-int.westus2.cloudapp.azure.com,https://maestro.int-dot.net - name: ScenarioTestSubscription @@ -119,7 +120,7 @@ jobs: env: MAESTRO_BASEURIS: ${{ variables.MaestroTestEndpoints }} MAESTRO_TOKEN: $(GetAuthInfo.Token) - GITHUB_TOKEN: $(maestro-scenario-test-github-token) + GITHUB_TOKEN: $(dotnet-bot-maestro-auth-test-content-rw) AZDO_TOKEN: $(AzdoToken) DARC_PACKAGE_SOURCE: $(Pipeline.Workspace)\PackageArtifacts DARC_DIR: $(Build.SourcesDirectory)\darc diff --git a/eng/templates/stages/deploy.yaml b/eng/templates/stages/deploy.yaml index 311812c1c8..6840c2bdd6 100644 --- a/eng/templates/stages/deploy.yaml +++ b/eng/templates/stages/deploy.yaml @@ -2,9 +2,6 @@ parameters: - name: isProd type: boolean -# --- Secret Variable group requirements --- -# maestro-scenario-test-github-token - stages: - template: /eng/templates/stages/secret-validation.yml@self parameters: @@ -35,7 +32,9 @@ stages: variables: - ${{ if parameters.isProd }}: - - group: MaestroProd KeyVault + # https://dev.azure.com/dnceng/internal/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=202&path=Arcade-Services-Scenario-Tests + # Required for dotnet-bot-arcade-services-content-write + - group: Arcade-Services-Release - name: PublishProfile value: Prod - name: Subscription @@ -45,7 +44,6 @@ stages: - name: BarMigrationSubscription value: BarMigrationProd - ${{ else }}: - - group: MaestroInt KeyVault - name: PublishProfile value: Int - name: Subscription @@ -131,7 +129,7 @@ stages: --repo dotnet/arcade-services displayName: Create GitHub release env: - GH_TOKEN: $(BotAccount-dotnet-bot-repo-PAT) + GH_TOKEN: $(dotnet-bot-arcade-services-content-write) continueOnError: true - stage: validateDeployment diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor index a3e136e1eb..9f3a48276f 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor @@ -17,8 +17,8 @@ @context.CommitShort - - + + @context.BuildNumber diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor index 49d83ea49e..0b3c853c98 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor @@ -5,7 +5,7 @@ - Maestro++ + Maestro++ diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor index ae5a911967..b250515b1c 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor @@ -6,6 +6,8 @@ @using ProductConstructionService.BarViz.Components; @inject IProductConstructionServiceApi PcsApi +@Channel + @if (_build == null) { @@ -13,6 +15,9 @@ else { + + @Channel + @@ -44,6 +49,8 @@ else private string? Repo { get; set; } + private string? Channel { get; set; } + private ProductConstructionService.Client.Models.Build? _build; protected override async Task OnParametersSetAsync() @@ -51,6 +58,7 @@ else _build = null; Repo = RepoUrlConverter.SlugToRepoUrl(RepoSlug); + Channel = (await PcsApi.Channels.GetChannelAsync(ChannelId)).Name; if (BuildId == "latest") { @@ -61,5 +69,4 @@ else _build = await PcsApi.Builds.GetBuildAsync(int.Parse(BuildId!)); } } - } diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/DeploymentOperation.cs b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/DeploymentOperation.cs index 07b5c64d71..96be626e87 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/DeploymentOperation.cs +++ b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/DeploymentOperation.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Azure; -using Azure.Core; -using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Resources; @@ -95,10 +93,17 @@ public async Task RunAsync() // Wait for the new app revision to become active var newRevisionActive = await WaitForRevisionToBecomeActive(newRevisionName); - // If the new revision is active, the rollout succeeded, assign a label, and transfer all traffic to it + // If the new revision is active, the rollout succeeded, assign a label, transfer all traffic to it, + // and deactivate the previously running revision if (newRevisionActive) { await AssignLabelAndTransferTraffic(newRevisionName, inactiveRevisionLabel); + + if (!string.IsNullOrEmpty(activeRevisionTrafficWeight.RevisionName)) + { + await RemoveRevisionLabel(activeRevisionTrafficWeight.RevisionName, activeRevisionTrafficWeight.Label); + await DeactivateRevision(activeRevisionTrafficWeight.RevisionName); + } } // If the new revision is not active, deactivate it and get print log link else @@ -121,30 +126,33 @@ public async Task RunAsync() } } + private async Task RemoveRevisionLabel(string revisionName, string label) + { + var result = await InvokeAzCLI( + ["containerapp", "revision", "label", "remove"], + ["--label", label]); + result.ThrowIfFailed($"Failed to remove label {label} from revision {revisionName}."); + } + private async Task CleanupRevisionsAsync(IEnumerable revisionsTrafficWeight) { - // Cleanup all revision labels - foreach (var revisionTrafficWeight in revisionsTrafficWeight) + IEnumerable activeRevisions = _containerApp.GetContainerAppRevisions() + .ToEnumerable() + .Where(revision => revision.Data.IsActive ?? false) + .Where(revision => revision.Data.TrafficWeight != 100); + + var revisionsToDeactivate = activeRevisions + .Select(revision => ( + revision.Data.Name, + revisionsTrafficWeight.FirstOrDefault(trafficWeight => trafficWeight.RevisionName == revision.Data.Name)?.Label)); + + foreach (var revision in revisionsToDeactivate) { - if (!string.IsNullOrEmpty(revisionTrafficWeight.Label)) + if (!string.IsNullOrEmpty(revision.Label)) { - var result = await InvokeAzCLI([ - "containerapp", "revision", "label", "remove", - ], - [ - "--label", revisionTrafficWeight.Label - ]); - result.ThrowIfFailed($"Failed to remove label {revisionTrafficWeight.Label} from revision {revisionTrafficWeight.RevisionName}. Stderr: {result.StandardError}"); + await RemoveRevisionLabel(revision.Name, revision.Label); } - } - - // Now deactivate all revisions in the list - foreach (var revisionTrafficWeight in revisionsTrafficWeight) - { - _containerApp = await _containerApp.GetAsync(); - ContainerAppRevisionResource revision = (await _containerApp.GetContainerAppRevisionAsync(revisionTrafficWeight.RevisionName)).Value; - - await revision.DeactivateRevisionAsync(); + await DeactivateRevision(revision.Name); } } @@ -219,11 +227,16 @@ private async Task AssignLabelAndTransferTraffic(string revisionName, string lab label); } - private async Task DeactivateFailedRevisionAndGetLogs(string revisionName) + private async Task DeactivateRevision(string revisionName) { var revision = (await _containerApp.GetContainerAppRevisionAsync(revisionName)).Value; await revision.DeactivateRevisionAsync(); _logger.LogInformation("Deactivated revision {revisionName}", revisionName); + } + + private async Task DeactivateFailedRevisionAndGetLogs(string revisionName) + { + await DeactivateRevision(revisionName); _logger.LogInformation("Check revision logs too see failure reason: {logsUri}", GetLogsUri(revisionName)); } diff --git a/src/ProductConstructionService/Readme.md b/src/ProductConstructionService/Readme.md index 6c0fde4ca4..cff2d31bfb 100644 --- a/src/ProductConstructionService/Readme.md +++ b/src/ProductConstructionService/Readme.md @@ -88,7 +88,7 @@ To run the Product Construction Service locally: In order to debug the Blazor project, you need to run the server (the `ProductConstructionService.AppHost` project) and the front-end separately. The front-end will be served from a different port but will still be able to communicate with the local server. - Start Docker -- Run the `ProductConstructionService.AppHost` project (without debugging) +- Run the `ProductConstructionService.AppHost` project (without debugging or using `dotnet run` from `src\ProductConstructionService\ProductConstructionService.AppHost`) - Debug the `ProductConstructionService.BarViz` project It is also recommended to turn on the API redirection (in `src\ProductConstructionService\ProductConstructionService.Api\appsettings.Development.json`) to point to the production so that the front-end has data to work with: diff --git a/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs b/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs index d4b89e1e07..1570c09426 100644 --- a/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs +++ b/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs @@ -38,7 +38,7 @@ public async Task DarcBatchedFlowTestBase( var targetRepoUri = isAzDoTest ? GetAzDoRepoUrl(targetRepoName) : GetGitHubRepoUrl(targetRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); TestContext.WriteLine($"Adding a subscription from {source1RepoName} to {targetRepoName}"); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionAsync(testChannelName, source1RepoName, targetRepoName, targetBranch, @@ -104,7 +104,7 @@ public async Task NonBatchedGitHubFlowTestBase(string targetBranch, string chann var targetRepoUri = GetGitHubRepoUrl(targetRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionForEndToEndTests( testChannelName, sourceRepoName, targetRepoName, targetBranch, allChecks, false); @@ -152,7 +152,7 @@ public async Task NonBatchedGitHubFlowCoherencyTestBase(string targetBranch, str var childSourceRepoUri = GetGitHubRepoUrl(childRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionForEndToEndTests( testChannelName, sourceRepoName, targetRepoName, targetBranch, allChecks, false); @@ -207,7 +207,7 @@ public async Task NonBatchedGitHubFlowCoherencyOnlyTestBase(string targetBranch, var childSourceRepoUri = GetGitHubRepoUrl(childRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionAsync( testChannelName, @@ -285,7 +285,7 @@ public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, stri var targetRepoUri = GetGitHubRepoUrl(targetRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionForEndToEndTests( testChannelName, sourceRepoName, targetRepoName, targetBranch, allChecks, false); @@ -353,7 +353,7 @@ public async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, string var targetRepoUri = GetAzDoRepoUrl(targetRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionForEndToEndTests( testChannelName, sourceRepoName, targetRepoName, targetBranch, false, true); @@ -417,7 +417,7 @@ public async Task NonBatchedAzDoFlowTestBase(string targetBranch, string channel var targetRepoUri = GetAzDoRepoUrl(targetRepoName); TestContext.WriteLine($"Creating test channel {testChannelName}"); - await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await using AsyncDisposableValue testChannel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue subscription1Id = await CreateSubscriptionForEndToEndTests( testChannelName, sourceRepoName, targetRepoName, targetBranch, allChecks, true); diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs index d781a8d2c9..8a7ea1293a 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs @@ -24,6 +24,8 @@ namespace ProductConstructionService.ScenarioTests; internal abstract class ScenarioTestBase { + private string _packageNameSalt = null!; + private TestParameters _parameters = null!; private List _baseDarcRunArgs = []; // We need this for tests where we have multiple updates @@ -35,6 +37,12 @@ internal abstract class ScenarioTestBase protected AzureDevOpsClient AzDoClient => _parameters.AzDoClient; + [SetUp] + public void BaseSetup() + { + _packageNameSalt = Guid.NewGuid().ToString().Substring(0, 8); + } + public void SetTestParameters(TestParameters parameters) { _parameters = parameters; @@ -846,26 +854,31 @@ protected static AssetData GetAssetDataWithLocations( string? assetLocation2 = null, LocationType assetLocationType2 = LocationType.None) { - var locationsListBuilder = ImmutableList.CreateBuilder(); - - var location1 = new AssetLocationData(assetLocationType1) - { Location = assetLocation1 }; - locationsListBuilder.Add(location1); - - if (assetLocation2 != null && assetLocationType2 != LocationType.None) - { - var location2 = new AssetLocationData(assetLocationType2) - { Location = assetLocation2 }; - locationsListBuilder.Add(location2); - } - var asset = new AssetData(false) { Name = assetName, Version = assetVersion, - Locations = locationsListBuilder.ToImmutable() + Locations = + [ + new AssetLocationData(assetLocationType1) + { + Location = assetLocation1 + } + ] }; + if (assetLocation2 != null && assetLocationType2 != LocationType.None) + { + asset.Locations = + [ + ..asset.Locations, + new AssetLocationData(assetLocationType2) + { + Location = assetLocation2 + } + ]; + } + return asset; } @@ -959,4 +972,9 @@ protected static string GetTestBranchName([CallerMemberName] string testName = " { return $"b{testName}_{Guid.NewGuid().ToString().Substring(0, 16)}"; } + + protected string GetUniqueAssetName(string packageName) + { + return $"{packageName}.{_packageNameSalt}"; + } } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_AzDoFlow.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs similarity index 58% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_AzDoFlow.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs index e89ecf5a5e..970d0e5214 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_AzDoFlow.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs @@ -14,18 +14,19 @@ namespace ProductConstructionService.ScenarioTests; [NonParallelizable] internal class ScenarioTests_AzDoFlow : ScenarioTestBase { - private readonly IImmutableList _source1Assets; - private readonly IImmutableList _source2Assets; - private readonly IImmutableList _source1AssetsUpdated; - private readonly List _expectedAzDoDependenciesSource1; - private readonly List _expectedAzDoDependenciesSource2; - private readonly List _expectedAzDoDependenciesSource1Updated; - - public ScenarioTests_AzDoFlow() + private IImmutableList _source1Assets = null; + private IImmutableList _source2Assets = null; + private IImmutableList _source1AssetsUpdated = null; + private List _expectedAzDoDependenciesSource1 = null; + private List _expectedAzDoDependenciesSource2 = null; + private List _expectedAzDoDependenciesSource1Updated = null; + + [SetUp] + public void SetUp() { - _source1Assets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); - _source2Assets = GetAssetData("Pizza", "3.1.0", "Hamburger", "4.1.0"); - _source1AssetsUpdated = GetAssetData("Foo", "1.17.0", "Bar", "2.17.0"); + _source1Assets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + _source2Assets = GetAssetData(GetUniqueAssetName("Pizza"), "3.1.0", GetUniqueAssetName("Hamburger"), "4.1.0"); + _source1AssetsUpdated = GetAssetData(GetUniqueAssetName("Foo"), "1.17.0", GetUniqueAssetName("Bar"), "2.17.0"); var sourceRepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name); var source2RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo3Name); @@ -34,7 +35,7 @@ public ScenarioTests_AzDoFlow() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -43,7 +44,7 @@ public ScenarioTests_AzDoFlow() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -56,7 +57,7 @@ public ScenarioTests_AzDoFlow() [ new DependencyDetail { - Name = "Pizza", + Name = GetUniqueAssetName("Pizza"), Version = "3.1.0", RepoUri = source2RepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -65,7 +66,7 @@ public ScenarioTests_AzDoFlow() }, new DependencyDetail { - Name = "Hamburger", + Name = GetUniqueAssetName("Hamburger"), Version = "4.1.0", RepoUri = source2RepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -78,7 +79,7 @@ public ScenarioTests_AzDoFlow() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -87,7 +88,7 @@ public ScenarioTests_AzDoFlow() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -148,7 +149,7 @@ await testLogic.NonBatchedUpdatingAzDoFlowTestBase( _source1Assets, _source1AssetsUpdated, _expectedAzDoDependenciesSource1, - _expectedAzDoDependenciesSource1Updated).ConfigureAwait(false); + _expectedAzDoDependenciesSource1Updated); } [Test] @@ -158,42 +159,21 @@ public async Task Darc_AzDoFlow_FeedFlow() // Feed flow test strings var proxyFeed = "https://some-proxy.azurewebsites.net/container/some-container/sig/somesig/se/2020-02-02/darc-int-maestro-test1-bababababab-1/index.json"; - var azdoFeed1 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-aaabaababababe-1/nuget/v3/index.json"; - var azdoFeed2 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-bbbbaababababd-1/nuget/v3/index.json"; - var azdoFeed3 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-cccbaababababf-1/nuget/v3/index.json"; + var azdoFeed1 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-aaaaaaaaaaaaaa-1/nuget/v3/index.json"; + var azdoFeed2 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-bbbbbbbbbbbbbb-1/nuget/v3/index.json"; + var azdoFeed3 = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-cccccccccccccc-1/nuget/v3/index.json"; var regularFeed = "https://dotnetfeed.blob.core.windows.net/maestro-test1/index.json"; var buildContainer = "https://dev.azure.com/dnceng/internal/_apis/build/builds/9999999/artifacts"; string[] expectedFeeds = [proxyFeed, azdoFeed1, azdoFeed3]; string[] notExpectedFeeds = [regularFeed, azdoFeed2, buildContainer]; - IImmutableList feedFlowSourceAssets = ImmutableList.Create( - GetAssetDataWithLocations( - "Foo", - "1.1.0", - proxyFeed, - LocationType.NugetFeed - ), - GetAssetDataWithLocations( - "Bar", - "2.1.0", - azdoFeed1, - LocationType.NugetFeed), - GetAssetDataWithLocations( - "Pizza", - "3.1.0", - azdoFeed2, - LocationType.NugetFeed, - regularFeed, - LocationType.NugetFeed - ), - GetAssetDataWithLocations( - "Hamburger", - "4.1.0", - azdoFeed3, - LocationType.NugetFeed, - buildContainer, - LocationType.Container) - ); + IImmutableList feedFlowSourceAssets = + [ + GetAssetDataWithLocations(GetUniqueAssetName("Foo"), "1.1.0", proxyFeed, LocationType.NugetFeed), + GetAssetDataWithLocations(GetUniqueAssetName("Bar"), "2.1.0", azdoFeed1, LocationType.NugetFeed), + GetAssetDataWithLocations(GetUniqueAssetName("Pizza"), "3.1.0", azdoFeed2, LocationType.NugetFeed, regularFeed, LocationType.NugetFeed), + GetAssetDataWithLocations(GetUniqueAssetName("Hamburger"), "4.1.0", azdoFeed3, LocationType.NugetFeed, buildContainer, LocationType.Container), + ]; TestContext.WriteLine("Azure DevOps Internal feed flow"); TestParameters parameters = await TestParameters.GetAsync(); @@ -201,55 +181,53 @@ public async Task Darc_AzDoFlow_FeedFlow() var testLogic = new EndToEndFlowLogic(parameters); - var expectedAzDoFeedFlowDependencies = new List(); + List expectedAzDoFeedFlowDependencies = + [ + new DependencyDetail + { + Name = GetUniqueAssetName("Foo"), + Version = "1.1.0", + RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), + Commit = TestRepository.CoherencyTestRepo1Commit, + Type = DependencyType.Product, + Pinned = false, + Locations = [proxyFeed], + }, - var feedFoo = new DependencyDetail - { - Name = "Foo", - Version = "1.1.0", - RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), - Commit = TestRepository.CoherencyTestRepo1Commit, - Type = DependencyType.Product, - Pinned = false, - Locations = new List { proxyFeed } - }; - expectedAzDoFeedFlowDependencies.Add(feedFoo); + new DependencyDetail + { + Name = GetUniqueAssetName("Bar"), + Version = "2.1.0", + RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), + Commit = TestRepository.CoherencyTestRepo1Commit, + Type = DependencyType.Product, + Pinned = false, + Locations = [azdoFeed1], + }, - var feedBar = new DependencyDetail - { - Name = "Bar", - Version = "2.1.0", - RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), - Commit = TestRepository.CoherencyTestRepo1Commit, - Type = DependencyType.Product, - Pinned = false, - Locations = new List { azdoFeed1 } - }; - expectedAzDoFeedFlowDependencies.Add(feedBar); + new DependencyDetail + { + Name = GetUniqueAssetName("Pizza"), + Version = "3.1.0", + RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), + Commit = TestRepository.CoherencyTestRepo1Commit, + Type = DependencyType.Product, + Pinned = false, + Locations = [azdoFeed2, regularFeed], + }, - var feedPizza = new DependencyDetail - { - Name = "Pizza", - Version = "3.1.0", - RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), - Commit = TestRepository.CoherencyTestRepo1Commit, - Type = DependencyType.Product, - Pinned = false, - Locations = new List { azdoFeed2, regularFeed } - }; - expectedAzDoFeedFlowDependencies.Add(feedPizza); + new DependencyDetail + { + Name = GetUniqueAssetName("Hamburger"), + Version = "4.1.0", + RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), + Commit = TestRepository.CoherencyTestRepo1Commit, + Type = DependencyType.Product, + Pinned = false, + Locations = [azdoFeed3, buildContainer], + }, + ]; - var feedHamburger = new DependencyDetail - { - Name = "Hamburger", - Version = "4.1.0", - RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name), - Commit = TestRepository.CoherencyTestRepo1Commit, - Type = DependencyType.Product, - Pinned = false, - Locations = new List { azdoFeed3, buildContainer } - }; - expectedAzDoFeedFlowDependencies.Add(feedHamburger); await testLogic.NonBatchedAzDoFlowTestBase( GetTestBranchName(), GetTestChannelName(), @@ -257,6 +235,6 @@ await testLogic.NonBatchedAzDoFlowTestBase( expectedAzDoFeedFlowDependencies, isFeedTest: true, expectedFeeds: expectedFeeds, - notExpectedFeeds: notExpectedFeeds).ConfigureAwait(false); + notExpectedFeeds: notExpectedFeeds); } } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Builds.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs similarity index 81% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_Builds.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs index f9e26d37a3..ef6aca0d0e 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Builds.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs @@ -20,17 +20,15 @@ internal class ScenarioTests_Builds : ScenarioTestBase private const string SourceCommit = "123456"; private const string SourceBranch = "master"; - private readonly IImmutableList _sourceAssets; + private IImmutableList _sourceAssets; private TestParameters _parameters; - public ScenarioTests_Builds() - { - _sourceAssets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); - } - [SetUp] public async Task InitializeAsync() { + _sourceAssets = GetAssetData( + GetUniqueAssetName("Foo"), "1.1.0", + GetUniqueAssetName("Bar"), "2.1.0"); _parameters = await TestParameters.GetAsync(); SetTestParameters(_parameters); } @@ -69,8 +67,8 @@ public async Task ArcadeBuilds_EndToEnd() gatherDropOutput = await GatherDrop(build.Id, gatherWithReleasedDir, true, string.Empty); gatherDropOutput.Should().Contain($"Gathering drop for build {SourceBuildNumber}", "Gather with released 1"); - gatherDropOutput.Should().Contain("Downloading asset Bar@2.1.0", "Gather with released 1"); - gatherDropOutput.Should().Contain("Downloading asset Foo@1.1.0", "Gather with released 1"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Bar")}@2.1.0", "Gather with released 1"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Foo")}@1.1.0", "Gather with released 1"); gatherDropOutput.Should().NotContain("always-download assets in build", "Gather with released 1"); // Gather with release excluded (default behavior). Gather-drop should throw an error. @@ -89,18 +87,18 @@ public async Task ArcadeBuilds_EndToEnd() gatherDropOutput = await GatherDrop(build.Id, gatherWithNoReleased2Dir, false, string.Empty); gatherDropOutput.Should().Contain($"Gathering drop for build {SourceBuildNumber}", "Gather unreleased with release excluded"); - gatherDropOutput.Should().Contain("Downloading asset Bar@2.1.0", "Gather unreleased with release excluded"); - gatherDropOutput.Should().Contain("Downloading asset Foo@1.1.0", "Gather unreleased with release excluded"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Bar")}@2.1.0", "Gather unreleased with release excluded"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Foo")}@1.1.0", "Gather unreleased with release excluded"); gatherDropOutput.Should().NotContain("always-download assets in build", "Gather unreleased with release excluded"); // Gather with release excluded again, but specify --always-download-asset-filters var gatherWithNoReleased3Dir = Path.Combine(scenarioDirectory, "gather-no-released-3"); TestContext.WriteLine("Starting 'Gather unreleased with release excluded' using folder " + gatherWithNoReleased3Dir); - gatherDropOutput = await GatherDrop(build.Id, gatherWithNoReleased3Dir, false, $"B.*r$"); + gatherDropOutput = await GatherDrop(build.Id, gatherWithNoReleased3Dir, false, GetUniqueAssetName("Bar").Replace(".", "\\.") + "$"); gatherDropOutput.Should().Contain($"Gathering drop for build {SourceBuildNumber}", "Gather unreleased with release excluded"); - gatherDropOutput.Should().Contain("Downloading asset Bar@2.1.0", "Gather unreleased with release excluded"); - gatherDropOutput.Should().Contain("Downloading asset Foo@1.1.0", "Gather unreleased with release excluded"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Bar")}@2.1.0", "Gather unreleased with release excluded"); + gatherDropOutput.Should().Contain($"Downloading asset {GetUniqueAssetName("Foo")}@1.1.0", "Gather unreleased with release excluded"); gatherDropOutput.Should().Contain("Found 1 always-download asset(s) in build", "Gather unreleased with release excluded"); } } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Channels.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Channels.cs similarity index 79% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_Channels.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Channels.cs index f8110292e3..951c06d993 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Channels.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Channels.cs @@ -29,17 +29,17 @@ public async Task ArcadeChannels_EndToEnd() // Create a new channel var testChannelName = GetTestChannelName(); - await using (AsyncDisposableValue channel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false)) + await using (AsyncDisposableValue channel = await CreateTestChannelAsync(testChannelName)) { // Get the channel and make sure it's there - var returnedChannel = await GetTestChannelsAsync().ConfigureAwait(false); + var returnedChannel = await GetTestChannelsAsync(); returnedChannel.Should().Contain(testChannelName, "Channel was not created or could not be retrieved"); // Delete the channel - await DeleteTestChannelAsync(testChannelName).ConfigureAwait(false); + await DeleteTestChannelAsync(testChannelName); // Get the channel and make sure it was deleted - var returnedChannel2 = await GetTestChannelsAsync().ConfigureAwait(false); + var returnedChannel2 = await GetTestChannelsAsync(); returnedChannel2.Should().NotContain(testChannelName, "Channel was not deleted"); } } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Clone.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Clone.cs similarity index 100% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_Clone.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Clone.cs diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_DefaultChannels.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_DefaultChannels.cs similarity index 100% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_DefaultChannels.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_DefaultChannels.cs diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Dependencies.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs similarity index 91% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_Dependencies.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs index 6ee38738e9..2bf93f0537 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Dependencies.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs @@ -45,9 +45,9 @@ public async Task ArcadeDependencies_EndToEnd() var targetBranch = GetTestBranchName(); var testChannelName = GetTestChannelName(); - IImmutableList source1Assets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); - IImmutableList source2Assets = GetAssetData("Pizza", "3.1.0", "Hamburger", "4.1.0"); - IImmutableList targetAssets = GetAssetData("Source1", "3.1.0", "Source2", "4.1.0"); + IImmutableList source1Assets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + IImmutableList source2Assets = GetAssetData(GetUniqueAssetName("Pizza"), "3.1.0", GetUniqueAssetName("Hamburger"), "4.1.0"); + IImmutableList targetAssets = GetAssetData(GetUniqueAssetName("Source1"), "3.1.0", GetUniqueAssetName("Source2"), "4.1.0"); var source1RepoUri = GetGitHubRepoUrl(source1RepoName); var source2RepoUri = GetGitHubRepoUrl(source2RepoName); var targetRepoUri = GetGitHubRepoUrl(targetRepoName); diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_GitHubFlow.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs similarity index 74% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_GitHubFlow.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs index 3966f2f2fb..53ff27ab9f 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_GitHubFlow.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs @@ -15,21 +15,22 @@ namespace ProductConstructionService.ScenarioTests; [Parallelizable] internal class ScenarioTests_GitHubFlow : ScenarioTestBase { - private readonly IImmutableList _source1Assets; - private readonly IImmutableList _source2Assets; - private readonly IImmutableList _source1AssetsUpdated; - private readonly List _expectedDependenciesSource1; - private readonly List _expectedDependenciesSource2; - private readonly List _expectedDependenciesSource1Updated; + private IImmutableList _source1Assets = null; + private IImmutableList _source2Assets = null; + private IImmutableList _source1AssetsUpdated = null; + private List _expectedDependenciesSource1 = null; + private List _expectedDependenciesSource2 = null; + private List _expectedDependenciesSource1Updated = null; - public ScenarioTests_GitHubFlow() + [SetUp] + public void SetUp() { using TestParameters parameters = TestParameters.GetAsync().Result; SetTestParameters(parameters); - _source1Assets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); - _source2Assets = GetAssetData("Pizza", "3.1.0", "Hamburger", "4.1.0"); - _source1AssetsUpdated = GetAssetData("Foo", "1.17.0", "Bar", "2.17.0"); + _source1Assets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + _source2Assets = GetAssetData(GetUniqueAssetName("Pizza"), "3.1.0", GetUniqueAssetName("Hamburger"), "4.1.0"); + _source1AssetsUpdated = GetAssetData(GetUniqueAssetName("Foo"), "1.17.0", GetUniqueAssetName("Bar"), "2.17.0"); var sourceRepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name); var source2RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo3Name); @@ -38,7 +39,7 @@ public ScenarioTests_GitHubFlow() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -47,7 +48,7 @@ public ScenarioTests_GitHubFlow() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -60,7 +61,7 @@ public ScenarioTests_GitHubFlow() [ new DependencyDetail { - Name = "Pizza", + Name = GetUniqueAssetName("Pizza"), Version = "3.1.0", RepoUri = source2RepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -69,7 +70,7 @@ public ScenarioTests_GitHubFlow() }, new DependencyDetail { - Name = "Hamburger", + Name = GetUniqueAssetName("Hamburger"), Version = "4.1.0", RepoUri = source2RepoUri, Commit = TestRepository.CoherencyTestRepo1Commit, @@ -82,7 +83,7 @@ public ScenarioTests_GitHubFlow() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.17.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo2Commit, @@ -91,7 +92,7 @@ public ScenarioTests_GitHubFlow() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.17.0", RepoUri = sourceRepoUri, Commit = TestRepository.CoherencyTestRepo2Commit, @@ -116,7 +117,7 @@ await testLogic.DarcBatchedFlowTestBase( _source1Assets, _source2Assets, expectedDependencies, - false).ConfigureAwait(false); + false); } [Test] @@ -133,7 +134,7 @@ await testLogic.NonBatchedUpdatingGitHubFlowTestBase( _source1Assets, _source1AssetsUpdated, _expectedDependenciesSource1, - _expectedDependenciesSource1Updated).ConfigureAwait(false); + _expectedDependenciesSource1Updated); } [Test] @@ -148,7 +149,7 @@ public async Task Darc_GitHubFlow_NonBatched_StrictCoherency() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -157,7 +158,7 @@ public async Task Darc_GitHubFlow_NonBatched_StrictCoherency() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -166,14 +167,14 @@ public async Task Darc_GitHubFlow_NonBatched_StrictCoherency() } ]; - IImmutableList sourceAssets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); + IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); await testLogic.NonBatchedGitHubFlowTestBase( GetTestBranchName(), GetTestChannelName(), sourceAssets, expectedCoherencyDependencies, - allChecks: true).ConfigureAwait(false); + allChecks: true); } [Test] @@ -186,7 +187,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherencyUpdate() [ new DependencyDetail { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -195,7 +196,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherencyUpdate() }, new DependencyDetail { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -204,26 +205,26 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherencyUpdate() }, new DependencyDetail { - Name = "Fzz", - Version = "", + Name = GetUniqueAssetName("Fzz"), + Version = string.Empty, RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), - Commit = "", + Commit = string.Empty, Type = DependencyType.Product, - CoherentParentDependencyName = "Foo" + CoherentParentDependencyName = GetUniqueAssetName("Foo") }, new DependencyDetail { - Name = "ASD", - Version = "", + Name = GetUniqueAssetName("ASD"), + Version = string.Empty, RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), - Commit = "", + Commit = string.Empty, Type = DependencyType.Product, - CoherentParentDependencyName = "Foo" + CoherentParentDependencyName = GetUniqueAssetName("Foo") }, ]; - IImmutableList sourceAssets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0"); - IImmutableList childSourceAssets = GetAssetData("Fzz", "1.1.0", "ASD", "1.1.1"); + IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + IImmutableList childSourceAssets = GetAssetData(GetUniqueAssetName("Fzz"), "1.1.0", GetUniqueAssetName("ASD"), "1.1.1"); await testLogic.NonBatchedGitHubFlowCoherencyTestBase( GetTestBranchName(), @@ -231,8 +232,8 @@ await testLogic.NonBatchedGitHubFlowCoherencyTestBase( sourceAssets, childSourceAssets, expectedCoherencyDependencies, - coherentParent: "Foo", - allChecks: false).ConfigureAwait(false); + coherentParent: GetUniqueAssetName("Foo"), + allChecks: false); } [Test] @@ -245,7 +246,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() [ new DependencyDetail { - Name = "A1", + Name = GetUniqueAssetName("A1"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -254,7 +255,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() }, new DependencyDetail { - Name = "A2", + Name = GetUniqueAssetName("A2"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -267,7 +268,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() [ new DependencyDetail { - Name = "A1", + Name = GetUniqueAssetName("A1"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -276,7 +277,7 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() }, new DependencyDetail { - Name = "A2", + Name = GetUniqueAssetName("A2"), Version = "1.1.0", RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo2Name), Commit = TestRepository.CoherencyTestRepo1Commit, @@ -285,26 +286,26 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() }, new DependencyDetail { - Name = "B1", - Version = "", + Name = GetUniqueAssetName("B1"), + Version = string.Empty, RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), - Commit = "", + Commit = string.Empty, Type = DependencyType.Product, - CoherentParentDependencyName = "A1" + CoherentParentDependencyName = GetUniqueAssetName("A1") }, new DependencyDetail { - Name = "B2", - Version = "", + Name = GetUniqueAssetName("B2"), + Version = string.Empty, RepoUri = GetGitHubRepoUrl(TestRepository.TestRepo1Name), - Commit = "", + Commit = string.Empty, Type = DependencyType.Product, - CoherentParentDependencyName = "A1" + CoherentParentDependencyName = GetUniqueAssetName("A1") }, ]; - IImmutableList sourceAssets = GetAssetData("A1", "1.1.0", "A2", "1.1.0"); - IImmutableList childSourceAssets = GetAssetData("B1", "2.1.0", "B2", "2.1.0"); + IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("A1"), "1.1.0", GetUniqueAssetName("A2"), "1.1.0"); + IImmutableList childSourceAssets = GetAssetData(GetUniqueAssetName("B1"), "2.1.0", GetUniqueAssetName("B2"), "2.1.0"); await testLogic.NonBatchedGitHubFlowCoherencyOnlyTestBase( GetTestBranchName(), @@ -313,6 +314,6 @@ await testLogic.NonBatchedGitHubFlowCoherencyOnlyTestBase( childSourceAssets, expectedNonCoherencyDependencies, expectedCoherencyDependencies, - coherentParent: "A1").ConfigureAwait(false); + coherentParent: GetUniqueAssetName("A1")); } } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_MergePolicies.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs similarity index 89% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_MergePolicies.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs index 6751f23a6c..17138fbfe7 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_MergePolicies.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs @@ -37,7 +37,7 @@ private string GetTestChannelName() return "Test Channel " + _random.Next(int.MaxValue); } - private string GetTargetBranch() + private static string GetTargetBranch() { return Guid.NewGuid().ToString(); } @@ -85,17 +85,19 @@ public async Task AutoMergeFlowTestBase(string targetRepo, string sourceRepo, st var sourceBranch = "dependencyflow-tests"; var sourceCommit = "0b36b99e29b1751403e23cfad0a7dff585818051"; var sourceBuildNumber = _random.Next(int.MaxValue).ToString(); - ImmutableList sourceAssets = ImmutableList.Create() - .Add(new AssetData(true) + ImmutableList sourceAssets = + [ + new AssetData(true) { - Name = "Foo", + Name = GetUniqueAssetName("Foo"), Version = "1.1.0", - }) - .Add(new AssetData(true) + }, + new AssetData(true) { - Name = "Bar", + Name = GetUniqueAssetName("Bar"), Version = "2.1.0", - }); + }, + ]; TestContext.WriteLine($"Creating test channel {testChannelName}"); await using AsyncDisposableValue channel = await CreateTestChannelAsync(testChannelName); @@ -113,8 +115,8 @@ public async Task AutoMergeFlowTestBase(string targetRepo, string sourceRepo, st { await RunGitAsync("checkout", "-b", targetBranch); TestContext.WriteLine("Adding dependencies to target repo"); - await AddDependenciesToLocalRepo(repo.Directory, "Foo", sourceRepoUri); - await AddDependenciesToLocalRepo(repo.Directory, "Bar", sourceRepoUri); + await AddDependenciesToLocalRepo(repo.Directory, sourceAssets.First().Name, sourceRepoUri); + await AddDependenciesToLocalRepo(repo.Directory, sourceAssets.Last().Name, sourceRepoUri); TestContext.WriteLine("Pushing branch to remote"); await RunGitAsync("commit", "-am", "Add dependencies."); diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_RepoPolicies.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_RepoPolicies.cs similarity index 100% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_RepoPolicies.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_RepoPolicies.cs diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_SdkUpdate.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs similarity index 97% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_SdkUpdate.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs index 6c52aa514c..c684561181 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_SdkUpdate.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs @@ -52,7 +52,7 @@ public async Task ArcadeSdkUpdate_E2E(bool targetAzDO) var targetBranch = "test/" + _random.Next(int.MaxValue).ToString(); await using AsyncDisposableValue channel = - await CreateTestChannelAsync(testChannelName).ConfigureAwait(false); + await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue sub = await CreateSubscriptionAsync(testChannelName, sourceRepo, targetRepo, targetBranch, "none", sourceOrg: sourceOrg, targetIsAzDo: targetAzDO); Build build = @@ -66,7 +66,7 @@ public async Task ArcadeSdkUpdate_E2E(bool targetAzDO) using (ChangeDirectory(repo.Directory)) { - await RunGitAsync("checkout", "-b", targetBranch).ConfigureAwait(false); + await RunGitAsync("checkout", "-b", targetBranch); await RunDarcAsync("add-dependency", "--name", DependencyFileManager.ArcadeSdkPackageName, "--type", "toolset", diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Subscriptions.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Subscriptions.cs similarity index 99% rename from test/ProductConstructionService.ScenarioTests/ScenarioTests_Subscriptions.cs rename to test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Subscriptions.cs index 24f8a670bd..6c04dc5610 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests_Subscriptions.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Subscriptions.cs @@ -43,9 +43,9 @@ public async Task Subscriptions_EndToEnd() var targetBranch = GetTestBranchName(); TestContext.WriteLine($"Creating channels {channel1Name} and {channel2Name}"); - await using (AsyncDisposableValue channel1 = await CreateTestChannelAsync(channel1Name).ConfigureAwait(false)) + await using (AsyncDisposableValue channel1 = await CreateTestChannelAsync(channel1Name)) { - await using (AsyncDisposableValue channel2 = await CreateTestChannelAsync(channel2Name).ConfigureAwait(false)) + await using (AsyncDisposableValue channel2 = await CreateTestChannelAsync(channel2Name)) { TestContext.WriteLine("Testing various command line parameters of add-subscription");