public async Task ArcadeChannels_EndToEnd()
        {
            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);

            // Create a new channel
            string testChannelName = $"Test Channel End to End {Environment.MachineName}";

            await using (AsyncDisposableValue <string> channel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false))
            {
                // Get the channel and make sure it's there
                string returnedChannel = await GetTestChannelsAsync().ConfigureAwait(false);

                StringAssert.Contains(testChannelName, returnedChannel, "Channel was not created or could not be retrieved");

                // Delete the channel
                await DeleteTestChannelAsync(testChannelName).ConfigureAwait(false);

                // Get the channel and make sure it was deleted
                string returnedChannel2 = await GetTestChannelsAsync().ConfigureAwait(false);

                StringAssert.DoesNotContain(testChannelName, returnedChannel2, "Channel was not deleted");
            }
        }
        public async Task Darc_GitHubFlow_NonBatched_AllChecksSuccessful()
        {
            TestContext.WriteLine("GitHub Dependency Flow, non-batched, all checks successful");

            using TestParameters parameters = await TestParameters.GetAsync();

            EndToEndFlowLogic testLogic = new EndToEndFlowLogic(parameters);

            await testLogic.NonBatchedGitHubFlowTestBase(
                $"GitHub_NonBatchedTestBranch_AllChecks_{Environment.MachineName}",
                $"GitHub Non-Batched All Checks Channel {Environment.MachineName}",
                source1Assets,
                expectedDependenciesSource1,
                allChecks : true).ConfigureAwait(false);
        }
        public async Task Darc_GitHubFlow_NonBatched()
        {
            TestContext.WriteLine("GitHub Dependency Flow, non-batched");

            using TestParameters parameters = await TestParameters.GetAsync();

            EndToEndFlowLogic testLogic = new EndToEndFlowLogic(parameters);

            await testLogic.NonBatchedUpdatingGitHubFlowTestBase(
                $"GitHub_NonBatchedTestBranch_{Environment.MachineName}",
                $"GitHub Non-Batched Channel {Environment.MachineName}",
                source1Assets,
                source1AssetsUpdated,
                expectedDependenciesSource1,
                expectedDependenciesSource1Updated).ConfigureAwait(false);
        }
        public async Task Darc_GitHubFlow_NonBatched_WithCoherency()
        {
            TestContext.WriteLine("GitHub Dependency Flow, non-batched");

            using TestParameters parameters = await TestParameters.GetAsync();

            EndToEndFlowLogic testLogic = new EndToEndFlowLogic(parameters);

            await testLogic.NonBatchedGitHubFlowTestBase(
                $"GitHub_NonBatchedTestCoherencyBranch_{Environment.MachineName}",
                $"GitHub Non-Batched Coherency Channel {Environment.MachineName}",
                source1Assets,
                expectedCoherencyDependencies,
                isCoherencyTest : true,
                childSourceAssets : childSourceAssets,
                childSourceBuildAssets : childSourceBuildAssets).ConfigureAwait(false);
        }
        public async Task Darc_GitHubFlow_Batched()
        {
            TestContext.WriteLine("Github Dependency Flow, batched");

            using TestParameters parameters = await TestParameters.GetAsync();

            EndToEndFlowLogic       testLogic            = new EndToEndFlowLogic(parameters);
            List <DependencyDetail> expectedDependencies = expectedDependenciesSource1.Concat(expectedDependenciesSource2).ToList();

            await testLogic.DarcBatchedFlowTestBase(
                $"GitHub_BatchedTestBranch_{Environment.MachineName}",
                $"GitHub Batched Channel {Environment.MachineName}",
                source1Assets,
                source2Assets,
                expectedDependencies,
                false).ConfigureAwait(false);
        }
Beispiel #6
0
        public async Task Darc_AzDoFlow_Batched()
        {
            TestContext.WriteLine("Azure DevOps Dependency Flow, batched");

            TestParameters parameters = await TestParameters.GetAsync();

            SetTestParameters(parameters);
            EndToEndFlowLogic       testLogic            = new EndToEndFlowLogic(parameters);
            List <DependencyDetail> expectedDependencies = expectedAzDoDependenciesSource1.Concat(expectedAzDoDependenciesSource2).ToList();

            await testLogic.DarcBatchedFlowTestBase(
                $"AzDo_BatchedTestBranch_{Environment.MachineName}",
                $"AzDo Batched Channel {Environment.MachineName}",
                source1Assets,
                source2Assets,
                expectedDependencies,
                true);
        }
        public async Task ArcadeRepoPolicies_EndToEnd()
        {
            TestContext.WriteLine("Repository merge policy handling");
            TestContext.WriteLine("Running tests...");

            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);

            string repoUrl = GetRepoUrl(repoName);

            TestContext.WriteLine("Setting repository merge policy to empty");
            await SetRepositoryPolicies(repoUrl, branchName);

            string emptyPolicies = await GetRepositoryPolicies(repoUrl, branchName);

            string expectedEmpty = $"{repoUrl} @ {branchName}\r\n- Merge Policies: []\r\n";

            StringAssert.AreEqualIgnoringCase(expectedEmpty, emptyPolicies, "Repository merge policy is not empty");

            TestContext.WriteLine("Setting repository merge policy to standard");
            await SetRepositoryPolicies(repoUrl, branchName, new string[] { "--standard-automerge" });

            string standardPolicies = await GetRepositoryPolicies(repoUrl, branchName);

            string expectedStandard = $"{repoUrl} @ {branchName}\r\n- Merge Policies:\r\n  Standard\r\n";

            StringAssert.AreEqualIgnoringCase(expectedStandard, standardPolicies, "Repository policy not set to standard");

            TestContext.WriteLine("Setting repository merge policy to all checks successful");
            await SetRepositoryPolicies(repoUrl, branchName, new string[] { "--all-checks-passed", "--ignore-checks", "A,B" });

            string allChecksPolicies = await GetRepositoryPolicies(repoUrl, branchName);

            string expectedAllChecksPolicies = $"{repoUrl} @ {branchName}\r\n- Merge Policies:\r\n  AllChecksSuccessful\r\n    ignoreChecks = \r\n" +
                                               "                   [\r\n" +
                                               "                     \"A\",\r\n" +
                                               "                     \"B\"\r\n" +
                                               "                   ]\r\n";

            StringAssert.AreEqualIgnoringCase(expectedAllChecksPolicies, allChecksPolicies, "Repository policy is incorrect for all checks successful case");
        }
        public async Task InitializeAsync()
        {
            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);
        }
Beispiel #9
0
        public async Task Subscriptions_EndToEnd()
        {
            TestContext.WriteLine("Subscription management tests...");
            string repo1Name    = TestRepository.TestRepo1Name;
            string repo2Name    = TestRepository.TestRepo2Name;
            string channel1Name = $"SubscriptionEndToEnd_TestChannel1_{Environment.MachineName}";
            string channel2Name = $"SubscriptionEndToEnd_TestChannel2_{Environment.MachineName}";

            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);

            string repo1Uri     = GetRepoUrl(repo1Name);
            string repo2Uri     = GetRepoUrl(repo2Name);
            string repo1AzDoUri = GetAzDoRepoUrl(repo1Name);
            string targetBranch = $"SubscriptionEndToEnd_TargetBranch_{Environment.MachineName}";

            TestContext.WriteLine($"Creating channels {channel1Name} and {channel2Name}");
            await using (AsyncDisposableValue <string> channel1 = await CreateTestChannelAsync(channel1Name).ConfigureAwait(false))
            {
                await using (AsyncDisposableValue <string> channel2 = await CreateTestChannelAsync(channel2Name).ConfigureAwait(false))
                {
                    TestContext.WriteLine("Testing various command line parameters of add-subscription");
                    await using AsyncDisposableValue <string> subscription1Id = await CreateSubscriptionAsync(
                                    channel1Name, repo1Name, repo2Name, targetBranch, "everyWeek", "maestro-auth-test");

                    Subscription expectedSubscription1 = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo2Uri,
                        targetBranch,
                        channel1Name,
                        subscription1Id.Value,
                        UpdateFrequency.EveryWeek,
                        false);

                    string expectedSubscription1Info = UxHelpers.GetTextSubscriptionDescription(expectedSubscription1, null);

                    await ValidateSubscriptionInfo(subscription1Id.Value, expectedSubscription1Info);

                    await using AsyncDisposableValue <string> subscription2Id = await CreateSubscriptionAsync(
                                    channel1Name, repo1Name, repo1Name, targetBranch, "none", "maestro-auth-test",
                                    new List <string>
                                    { "--all-checks-passed", "--no-extra-commits", "--no-requested-changes", "--ignore-checks", "WIP,license/cla" }, targetIsAzDo : true);

                    Subscription expectedSubscription2 = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo1AzDoUri,
                        targetBranch,
                        channel1Name,
                        subscription2Id.Value,
                        UpdateFrequency.None,
                        false,
                        new List <string> {
                        MergePolicyConstants.NoExtraCommitsMergePolicyName, MergePolicyConstants.AllCheckSuccessfulMergePolicyName, MergePolicyConstants.NoRequestedChangesMergePolicyName
                    },
                        new List <string> {
                        "WIP", "license/cla"
                    });

                    string expectedSubscription2Info = UxHelpers.GetTextSubscriptionDescription(expectedSubscription2, null);

                    await ValidateSubscriptionInfo(subscription2Id.Value, expectedSubscription2Info);

                    await using AsyncDisposableValue <string> subscription3Id = await CreateSubscriptionAsync(
                                    channel2Name, repo1Name, repo2Name, targetBranch, "none", "maestro-auth-test",
                                    new List <string>
                                    { "--all-checks-passed", "--no-extra-commits", "--no-requested-changes", "--ignore-checks", "WIP,license/cla" });

                    Subscription expectedSubscription3 = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo2Uri,
                        targetBranch,
                        channel2Name,
                        subscription3Id.Value,
                        UpdateFrequency.None,
                        false,
                        new List <string> {
                        MergePolicyConstants.NoExtraCommitsMergePolicyName, MergePolicyConstants.AllCheckSuccessfulMergePolicyName, MergePolicyConstants.NoRequestedChangesMergePolicyName
                    },
                        new List <string> {
                        "WIP", "license/cla"
                    });

                    string expectedSubscription3Info = UxHelpers.GetTextSubscriptionDescription(expectedSubscription3, null);

                    await ValidateSubscriptionInfo(subscription3Id.Value, expectedSubscription3Info);

                    // Disable the first two subscriptions, but not the third.
                    TestContext.WriteLine("Disable the subscriptions for test channel 1");
                    await SetSubscriptionStatus(false, channelName : channel1Name);

                    // Disable one by id (classic usage) to make sure that works
                    TestContext.WriteLine("Disable the third subscription by id");
                    await SetSubscriptionStatus(false, subscriptionId : subscription3Id.Value);

                    // Re-enable
                    TestContext.WriteLine("Enable the third subscription by id");
                    await SetSubscriptionStatus(true, subscriptionId : subscription3Id.Value);

                    StringAssert.Contains("Enabled: True", await GetSubscriptionInfo(subscription3Id.Value), $"Expected subscription {subscription3Id} to be enabled");

                    // Mass delete the subscriptions. Delete the first two but not the third.
                    TestContext.WriteLine("Delete the subscriptions for test channel 1");
                    string message = await DeleteSubscriptionsForChannel(channel1Name);

                    // Check that there are no subscriptions against channel1 now
                    TestContext.WriteLine("Verify that there are no subscriptions in test channel 1");
                    Assert.ThrowsAsync <MaestroTestException>(async() => await GetSubscriptions(channel1Name), "Subscriptions for channel 1 were not deleted.");

                    // Validate the third subscription, which should still exist
                    TestContext.WriteLine("Verify that the third subscription still exists, then delete it");
                    await ValidateSubscriptionInfo(subscription3Id.Value, expectedSubscription3Info);

                    string message2 = await DeleteSubscriptionById(subscription3Id.Value);

                    // Attempt to create a batchable subscription with merge policies.
                    // Should fail, merge policies are set separately for batched subs
                    TestContext.WriteLine("Attempt to create a batchable subscription with merge policies");
                    Assert.ThrowsAsync <MaestroTestException>(async() =>
                                                              await CreateSubscriptionAsync(channel1Name, repo1Name, repo2Name, targetBranch, "none", additionalOptions: new List <string> {
                        "--standard-automerge", "--batchable"
                    }),
                                                              "Attempt to create a batchable subscription with merge policies");

                    // Create a batchable subscription
                    TestContext.WriteLine("Create a batchable subscription");
                    await using AsyncDisposableValue <string> batchSubscriptionId = await CreateSubscriptionAsync(
                                    channel1Name, repo1Name, repo2Name, targetBranch, "everyWeek", "maestro-auth-test", additionalOptions : new List <string> { "--batchable" });

                    Subscription expectedBatchedSubscription = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo2Uri,
                        targetBranch,
                        channel1Name,
                        batchSubscriptionId.Value,
                        UpdateFrequency.EveryWeek,
                        true);

                    string expectedBatchedSubscriptionInfo = UxHelpers.GetTextSubscriptionDescription(expectedBatchedSubscription, null);

                    await ValidateSubscriptionInfo(batchSubscriptionId.Value, expectedBatchedSubscriptionInfo);
                    await DeleteSubscriptionById(batchSubscriptionId.Value);

                    TestContext.WriteLine("Testing YAML for darc add-subscription");

                    string yamlDefinition = $@"
                    Channel: {channel1Name}
                    Source Repository URL: {repo1Uri}
                    Target Repository URL: {repo2Uri}
                    Target Branch: {targetBranch}
                    Update Frequency: everyWeek
                    Batchable: False
                    Merge Policies:
                    - Name: Standard
                    ";

                    await using AsyncDisposableValue <string> yamlSubscriptionId = await CreateSubscriptionAsync(yamlDefinition);

                    Subscription expectedYamlSubscription = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo2Uri,
                        targetBranch,
                        channel1Name,
                        yamlSubscriptionId.Value,
                        UpdateFrequency.EveryWeek,
                        false,
                        new List <string> {
                        MergePolicyConstants.StandardMergePolicyName
                    });

                    string expectedYamlSubscriptionInfo = UxHelpers.GetTextSubscriptionDescription(expectedYamlSubscription, null);

                    await ValidateSubscriptionInfo(yamlSubscriptionId.Value, expectedYamlSubscriptionInfo);
                    await DeleteSubscriptionById(yamlSubscriptionId.Value);

                    TestContext.WriteLine("Change casing of the various properties. Expecting no changes.");

                    string yamlDefinition2 = $@"
                    Channel: {channel1Name}
                    Source Repository URL: {repo1Uri}
                    Target Repository URL: {repo2Uri}
                    Target Branch: {targetBranch}
                    Update Frequency: everyweek
                    Batchable: False
                    Merge Policies:
                    - Name: standard
                    ";

                    await using AsyncDisposableValue <string> yamlSubscription2Id = await CreateSubscriptionAsync(yamlDefinition2);

                    Subscription expectedYamlSubscription2 = SubscriptionBuilder.BuildSubscription(
                        repo1Uri,
                        repo2Uri,
                        targetBranch,
                        channel1Name,
                        yamlSubscription2Id.Value,
                        UpdateFrequency.EveryWeek, false,
                        new List <string> {
                        MergePolicyConstants.StandardMergePolicyName
                    });

                    string expectedYamlSubscriptionInfo2 = UxHelpers.GetTextSubscriptionDescription(expectedYamlSubscription2, null);

                    await ValidateSubscriptionInfo(yamlSubscription2Id.Value, expectedYamlSubscriptionInfo2);
                    await DeleteSubscriptionById(yamlSubscription2Id.Value);

                    TestContext.WriteLine("Attempt to add multiple of the same merge policy checks. Should fail.");

                    string yamlDefinition3 = $@"
                    Channel: {channel1Name}
                    Source Repository URL: {repo1Uri}
                    Target Repository URL: {repo2Uri}
                    Target Branch: {targetBranch}
                    Update Frequency: everyweek
                    Batchable: False
                    Merge Policies:
                    - Name: AllChecksSuccessful
                      Properties:
                        ignoreChecks:
                        - WIP
                        - license/cla
                    - Name: AllChecksSuccessful
                      Properties:
                        ignoreChecks:
                        - WIP
                        - MySpecialCheck";

                    Assert.ThrowsAsync <MaestroTestException>(async() =>
                                                              await CreateSubscriptionAsync(yamlDefinition3), "Attempt to create a subscription with multiples of the same merge policy.");

                    TestContext.WriteLine("Testing duplicate subscription handling...");
                    AsyncDisposableValue <string> yamlSubscription3Id = await CreateSubscriptionAsync(channel1Name, repo1Name, repo2Name, targetBranch, "everyWeek", "maestro-auth-test");

                    Assert.ThrowsAsync <MaestroTestException>(async() =>
                                                              await CreateSubscriptionAsync(channel1Name, repo1Name, repo2Name, targetBranch, "everyWeek", "maestro-auth-test"),
                                                              "Attempt to create a subscription with the same values as an existing subscription.");

                    Assert.ThrowsAsync <MaestroTestException>(async() =>
                                                              await CreateSubscriptionAsync(channel1Name, repo1Name, repo2Name, targetBranch, "everyweek", "maestro-auth-test"),
                                                              "Attempt to create a subscription with the same values as an existing subscription (except for the casing of one parameter.");

                    await DeleteSubscriptionById(yamlSubscription3Id.Value);

                    TestContext.WriteLine("End of test case. Starting clean up.");
                }
            }
        }
Beispiel #10
0
        public async Task ArcadeSdkUpdate()
        {
            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);

            string testChannelName   = "Test Channel " + _random.Next(int.MaxValue);
            var    sourceRepo        = "arcade";
            var    sourceRepoUri     = "https://github.com/dotnet/arcade";
            var    sourceBranch      = "dependencyflow-tests";
            var    sourceCommit      = "0b36b99e29b1751403e23cfad0a7dff585818051";
            var    sourceBuildNumber = _random.Next(int.MaxValue).ToString();
            ImmutableList <AssetData> sourceAssets = ImmutableList.Create <AssetData>()
                                                     .Add(new AssetData(true)
            {
                Name    = "Microsoft.DotNet.Arcade.Sdk",
                Version = "2.1.0",
            });
            var targetRepo   = "maestro-test2";
            var targetBranch = _random.Next(int.MaxValue).ToString();

            await using AsyncDisposableValue <string> channel = await CreateTestChannelAsync(testChannelName).ConfigureAwait(false);

            await using AsyncDisposableValue <string> sub = await CreateSubscriptionAsync(testChannelName, sourceRepo, targetRepo, targetBranch, "none");

            Build build = await CreateBuildAsync(GetRepoUrl("dotnet", sourceRepo), sourceBranch, sourceCommit, sourceBuildNumber, sourceAssets);

            await using IAsyncDisposable _ = await AddBuildToChannelAsync(build.Id, testChannelName);

            using TemporaryDirectory repo = await CloneRepositoryAsync(targetRepo);

            using (ChangeDirectory(repo.Directory))
            {
                await RunGitAsync("checkout", "-b", targetBranch).ConfigureAwait(false);
                await RunDarcAsync("add-dependency",
                                   "--name", "Microsoft.DotNet.Arcade.Sdk",
                                   "--type", "toolset",
                                   "--repo", sourceRepoUri);
                await RunGitAsync("commit", "-am", "Add dependencies.");

                await using IAsyncDisposable ___ = await PushGitBranchAsync("origin", targetBranch);
                await TriggerSubscriptionAsync(sub.Value);

                PullRequest pr = await WaitForPullRequestAsync(targetRepo, targetBranch);

                StringAssert.AreEqualIgnoringCase($"[{targetBranch}] Update dependencies from dotnet/arcade", pr.Title);

                await CheckoutRemoteRefAsync(pr.MergeCommitSha);

                string dependencies = await RunDarcAsync("get-dependencies");

                string[] dependencyLines = dependencies.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                Assert.AreEqual(new[]
                {
                    "Name:             Microsoft.DotNet.Arcade.Sdk",
                    "Version:          2.1.0",
                    $"Repo:             {sourceRepoUri}",
                    $"Commit:           {sourceCommit}",
                    "Type:             Toolset",
                    "Pinned:           False",
                }, dependencyLines);

                using TemporaryDirectory arcadeRepo = await CloneRepositoryAsync("dotnet", sourceRepo);

                using (ChangeDirectory(arcadeRepo.Directory))
                {
                    await CheckoutRemoteRefAsync(sourceCommit);
                }

                var arcadeFiles = Directory.EnumerateFileSystemEntries(Path.Join(arcadeRepo.Directory, "eng", "common"),
                                                                       "*", SearchOption.AllDirectories)
                                  .Select(s => s.Substring(arcadeRepo.Directory.Length))
                                  .ToHashSet();
                var repoFiles = Directory.EnumerateFileSystemEntries(Path.Join(repo.Directory, "eng", "common"), "*",
                                                                     SearchOption.AllDirectories)
                                .Select(s => s.Substring(repo.Directory.Length))
                                .ToHashSet();

                Assert.IsEmpty(arcadeFiles.Except(repoFiles));
                Assert.IsEmpty(repoFiles.Except(arcadeFiles));
            }
        }
        public async Task Darc_CloneRepo()
        {
            TestContext.WriteLine("Darc-Clone repo end to end test");

            TestParameters parameters = await TestParameters.GetAsync();

            SetTestParameters(parameters);

            string sourceRepoName    = "core-sdk";
            string sourceRepoVersion = "v3.0.100-preview4-011223";
            string sourceRepoUri     = GetRepoUrl(sourceRepoName);

            // these repos are not currently clonable for us due to auth
            string reposToIgnore = "https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted";

            // these repos have file names that are too long on Windows for the temp folder
            reposToIgnore += ";https://github.com/aspnet/AspNetCore;https://github.com/aspnet/AspNetCore-Tooling;https://github.com/dotnet/core-setup;https://github.com/dotnet/templating;" +
                             "https://github.com/dotnet/sdk;https://github.com/Microsoft/visualfsharp;https://github.com/dotnet/roslyn;https://github.com/NuGet/NuGet.Client;https://github.com/dotnet/corefx";

            Dictionary <string, string> expectedRepos1 = new Dictionary <string, string>
            {
                { "cli.204f425b6f061d0b8a01faf46f762ecf71436f68", "BB7B735A345157E1CB90E4E03340FD202C798B06E5EA089C2F0191562D9DF1B4" },
                { "cliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01", "CCA267C3FB69E8AADFA6CEE474249ACB84829D9CCFE7F9F5D7F17EFA87A26739" },
                { "core-sdk.v3.0.100-preview4-011223", "BBAE24214F40518798126A2F4729C38B6C3B67886DCDE0C2D64BBE203D4ACFBB" },
                { "msbuild.d004974104fde202e633b3c97e0ece3287aa62f9", "FD4F85D3FB60B5EBC105647E290924071A240A0C6FD49E3D44A2BC38A797946C" },
                { "standard.8ef5ada20b5343b0cb9e7fd577341426dab76cd8", "FA876A709FDB0CD3D864431B2887D2BC9ACBFC313E8C452A8636EE7FAE4E5D02" },
                { "toolset.3165b2579582b6b44aef768c01c3cc9ff4f0bc17", "D483493BF79129FD2DADC39C51FACB5FA363CEB03E54ECD180720DE2D95EDED9" },
                { "websdk.b55d4f4cf22bee7ec9a2ca5f49d54ebf6ee67e83", "A51DEB15209039D17FC0D781BFC445F8C5CDC1D51673AC4C0929FBEE8C1E4D21" },
                { "winforms.b1ee29b8b8e14c1200adff02847391dde471d0d2", "1288479D12130F9AEF56137DCC655B5B59277F5153172B30DC419456AF9CA011" },
                { "wpf.d378b1ec6b8555c52b7da1c40ffc0784cb0f5cad", "CFE5E19366FD5A90101A8F369CFC70611F9B1439A0720D435EE34872AF55A40A" }
            };

            string[] expectedMasterRepos1 = new string[]
            {
                "cli",
                "cliCommandLineParser",
                "core-sdk",
                "msbuild",
                "standard",
                "toolset",
                "websdk",
                "winforms",
                "wpf"
            };

            string[] expectedGitDirs1 = new string[]
            {
                "cli.git",
                "cliCommandLineParser.git",
                "core-sdk.git",
                "msbuild.git",
                "standard.git",
                "toolset.git",
                "websdk.git",
                "winforms.git",
                "wpf.git"
            };

            TestContext.WriteLine($"parameters: sourceRepoName={sourceRepoName}, sourceRepoVersion={sourceRepoVersion}, reposToIgnore='{reposToIgnore}'");
            TestContext.WriteLine($"Cloning repo {sourceRepoUri} at {sourceRepoVersion} with depth 2 and include - toolset = false");
            TemporaryDirectory reposFolder = await CloneRepositoryWithDarc(sourceRepoName, sourceRepoVersion, reposToIgnore, false, 2);

            CheckExpectedClonedRepos(expectedRepos1, expectedMasterRepos1, expectedGitDirs1, reposFolder);

            Dictionary <string, string> expectedRepos2 = new Dictionary <string, string>
            {
                { "cli.204f425b6f061d0b8a01faf46f762ecf71436f68", "BB7B735A345157E1CB90E4E03340FD202C798B06E5EA089C2F0191562D9DF1B4" },
                { "cliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01", "CCA267C3FB69E8AADFA6CEE474249ACB84829D9CCFE7F9F5D7F17EFA87A26739" },
                { "core-sdk.v3.0.100-preview4-011223", "BBAE24214F40518798126A2F4729C38B6C3B67886DCDE0C2D64BBE203D4ACFBB" },
                { "coreclr.d833cacabd67150fe3a2405845429a0ba1b72c12", "5A69F61C354C1DE9B839D6922CE866AB0B760BCCBC919EE4C408D44B6A40084C" },
                { "msbuild.d004974104fde202e633b3c97e0ece3287aa62f9", "FD4F85D3FB60B5EBC105647E290924071A240A0C6FD49E3D44A2BC38A797946C" },
                { "standard.8ef5ada20b5343b0cb9e7fd577341426dab76cd8", "FA876A709FDB0CD3D864431B2887D2BC9ACBFC313E8C452A8636EE7FAE4E5D02" },
                { "toolset.3165b2579582b6b44aef768c01c3cc9ff4f0bc17", "D483493BF79129FD2DADC39C51FACB5FA363CEB03E54ECD180720DE2D95EDED9" },
                { "websdk.b55d4f4cf22bee7ec9a2ca5f49d54ebf6ee67e83", "A51DEB15209039D17FC0D781BFC445F8C5CDC1D51673AC4C0929FBEE8C1E4D21" },
                { "winforms.b1ee29b8b8e14c1200adff02847391dde471d0d2", "1288479D12130F9AEF56137DCC655B5B59277F5153172B30DC419456AF9CA011" },
                { "wpf.d378b1ec6b8555c52b7da1c40ffc0784cb0f5cad", "CFE5E19366FD5A90101A8F369CFC70611F9B1439A0720D435EE34872AF55A40A" }
            };

            string[] expectedMasterRepos2 = new string[]
            {
                "cli",
                "cliCommandLineParser",
                "core-sdk",
                "coreclr",
                "msbuild",
                "standard",
                "toolset",
                "websdk",
                "winforms",
                "wpf"
            };

            string[] expectedGitDirs2 = new string[]
            {
                "cli.git",
                "cliCommandLineParser.git",
                "core-sdk.git",
                "coreclr.git",
                "msbuild.git",
                "standard.git",
                "toolset.git",
                "websdk.git",
                "winforms.git",
                "wpf.git"
            };

            reposToIgnore += ";https://github.com/dotnet/arcade";
            TestContext.WriteLine($"Cloning repo {sourceRepoUri} at {sourceRepoVersion} with depth 4 and include-toolset=true");
            reposFolder = await CloneRepositoryWithDarc(sourceRepoName, sourceRepoVersion, reposToIgnore, true, 4);

            CheckExpectedClonedRepos(expectedRepos2, expectedMasterRepos2, expectedGitDirs2, reposFolder);
        }
        public ScenarioTests_GitHubFlow()
        {
            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");
            childSourceBuildAssets = GetAssetData("Baz", "1.3.0", "Bop", "1.0");
            childSourceAssets      = GetSingleAssetData("Baz", "1.3.0");

            expectedDependenciesSource1 = new List <DependencyDetail>();
            string           sourceRepoUri = GetRepoUrl(TestRepository.TestRepo1Name);
            DependencyDetail foo           = new DependencyDetail
            {
                Name    = "Foo",
                Version = "1.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource1.Add(foo);

            DependencyDetail bar = new DependencyDetail
            {
                Name    = "Bar",
                Version = "2.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource1.Add(bar);

            expectedDependenciesSource2 = new List <DependencyDetail>();
            string           source2RepoUri = GetRepoUrl(TestRepository.TestRepo3Name);
            DependencyDetail pizza          = new DependencyDetail
            {
                Name    = "Pizza",
                Version = "3.1.0",
                RepoUri = source2RepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource2.Add(pizza);

            DependencyDetail hamburger = new DependencyDetail
            {
                Name    = "Hamburger",
                Version = "4.1.0",
                RepoUri = source2RepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource2.Add(hamburger);

            expectedDependenciesSource1Updated = new List <DependencyDetail>();
            DependencyDetail fooUpdated = new DependencyDetail
            {
                Name    = "Foo",
                Version = "1.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource1Updated.Add(fooUpdated);

            DependencyDetail barUpdated = new DependencyDetail
            {
                Name    = "Bar",
                Version = "2.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedDependenciesSource1Updated.Add(barUpdated);

            expectedCoherencyDependencies = new List <DependencyDetail>();
            DependencyDetail baz = new DependencyDetail
            {
                Name    = "Baz",
                Version = "1.3.0",
                RepoUri = GetRepoUrl(TestRepository.TestRepo1Name),
                Commit  = TestRepository.CoherencyTestRepo2Commit,
                Type    = DependencyType.Product,
                Pinned  = false,
                CoherentParentDependencyName = "Foo"
            };

            DependencyDetail parentFoo = new DependencyDetail
            {
                Name    = "Foo",
                Version = "1.1.0",
                RepoUri = GetRepoUrl(TestRepository.TestRepo2Name),
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            DependencyDetail parentBar = new DependencyDetail
            {
                Name    = "Bar",
                Version = "2.1.0",
                RepoUri = GetRepoUrl(TestRepository.TestRepo2Name),
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedCoherencyDependencies.Add(parentFoo);
            expectedCoherencyDependencies.Add(parentBar);
            expectedCoherencyDependencies.Add(baz);
        }
Beispiel #13
0
        public async Task Darc_AzDoFlow_FeedFlow()
        {
            TestContext.WriteLine("AzDo Dependency Feed Flow, non-batched");

            // Feed flow test strings
            string proxyFeed      = "https://some-proxy.azurewebsites.net/container/some-container/sig/somesig/se/2020-02-02/darc-int-maestro-test1-bababababab-1/index.json";
            string azdoFeed1      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-aaabaababababe-1/nuget/v3/index.json";
            string azdoFeed2      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-bbbbaababababd-1/nuget/v3/index.json";
            string azdoFeed3      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-cccbaababababf-1/nuget/v3/index.json";
            string regularFeed    = "https://dotnetfeed.blob.core.windows.net/maestro-test1/index.json";
            string buildContainer = "https://dev.azure.com/dnceng/internal/_apis/build/builds/9999999/artifacts";

            string[] expectedFeeds    = { proxyFeed, azdoFeed1, azdoFeed3 };
            string[] notExpectedFeeds = { regularFeed, azdoFeed2, buildContainer };

            IImmutableList <AssetData> 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)
                );

            TestContext.WriteLine("Azure DevOps Internal feed flow");
            TestParameters parameters = await TestParameters.GetAsync();

            SetTestParameters(parameters);

            EndToEndFlowLogic testLogic = new EndToEndFlowLogic(parameters);

            List <DependencyDetail> expectedAzDoFeedFlowDependencies = new List <DependencyDetail>();

            DependencyDetail feedFoo = new DependencyDetail
            {
                Name      = "Foo",
                Version   = "1.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    proxyFeed
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedFoo);

            DependencyDetail feedBar = new DependencyDetail
            {
                Name      = "Bar",
                Version   = "2.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed1
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedBar);

            DependencyDetail feedPizza = new DependencyDetail
            {
                Name      = "Pizza",
                Version   = "3.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed2, regularFeed
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedPizza);

            DependencyDetail feedHamburger = new DependencyDetail
            {
                Name      = "Hamburger",
                Version   = "4.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed3, buildContainer
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedHamburger);
            await testLogic.NonBatchedAzDoFlowTestBase(
                $"AzDo_FeedFlowBranch_{Environment.MachineName}",
                $"AzDo_FeedFlowChannel_{Environment.MachineName}",
                feedFlowSourceAssets,
                expectedAzDoFeedFlowDependencies,
                isFeedTest : true,
                expectedFeeds : expectedFeeds,
                notExpectedFeeds : notExpectedFeeds).ConfigureAwait(false);
        }
Beispiel #14
0
        public async Task ArcadeDependencies_EndToEnd()
        {
            _parameters = await TestParameters.GetAsync();

            SetTestParameters(_parameters);

            string source1RepoName    = TestRepository.TestRepo1Name;
            string source2RepoName    = TestRepository.TestRepo3Name;
            string targetRepoName     = TestRepository.TestRepo2Name;
            string target1BuildNumber = "098765";
            string target2BuildNumber = "987654";
            string sourceBuildNumber  = "654321";
            string sourceCommit       = "SourceCommitVar";
            string targetCommit       = "TargetCommitVar";
            string sourceBranch       = $"DependenciesSourceBranch_{Environment.MachineName}";
            string targetBranch       = $"DependenciesTargetBranch_{Environment.MachineName}";
            string testChannelName    = $"TestChannel_Dependencies_{Environment.MachineName}";

            IImmutableList <AssetData> source1Assets = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0");
            IImmutableList <AssetData> source2Assets = GetAssetData("Pizza", "3.1.0", "Hamburger", "4.1.0");
            IImmutableList <AssetData> targetAssets  = GetAssetData("Source1", "3.1.0", "Source2", "4.1.0");
            string source1RepoUri = GetRepoUrl(source1RepoName);
            string source2RepoUri = GetRepoUrl(source2RepoName);
            string targetRepoUri  = GetRepoUrl(targetRepoName);

            TestContext.WriteLine($"Creating test channel {testChannelName}");
            await CreateTestChannelAsync(testChannelName);

            TestContext.WriteLine("Set up build1 for intake into target repository");
            Build build1 = await CreateBuildAsync(source1RepoUri, sourceBranch, sourceCommit, sourceBuildNumber, source1Assets);

            await AddBuildToChannelAsync(build1.Id, testChannelName);

            TestContext.WriteLine("Set up build2 for intake into target repository");
            Build build2 = await CreateBuildAsync(source2RepoUri, sourceBranch, sourceCommit, sourceBuildNumber, source2Assets);

            await AddBuildToChannelAsync(build2.Id, testChannelName);

            ImmutableList <BuildRef> dependencies = ImmutableList <BuildRef> .Empty;
            BuildRef buildRef1 = new BuildRef(build1.Id, true, 1);

            dependencies = dependencies.Add(buildRef1);
            BuildRef buildRef2 = new BuildRef(build2.Id, true, 2);

            dependencies = dependencies.Add(buildRef2);

            // Add the target build once, should populate the BuildDependencies table and calculate TimeToInclusion
            TestContext.WriteLine("Set up targetBuild in target repository");
            Build targetBuild1 = await CreateBuildAsync(targetRepoUri, targetBranch, targetCommit, target1BuildNumber, targetAssets, dependencies);

            await AddBuildToChannelAsync(targetBuild1.Id, testChannelName);

            Build newTargetBuild1 = new Build(targetBuild1.Id, targetBuild1.DateProduced, targetBuild1.Staleness, targetBuild1.Released,
                                              targetBuild1.Stable, targetBuild1.Commit, targetBuild1.Channels, targetBuild1.Assets, dependencies, incoherencies: null);

            // Add the target build a second time, should populate the BuildDependencies table and use the previous TimeToInclusion
            Build targetBuild2 = await CreateBuildAsync(targetRepoUri, targetBranch, targetCommit, target2BuildNumber, targetAssets, dependencies);

            await AddBuildToChannelAsync(targetBuild2.Id, testChannelName);

            Build newTargetBuild2 = new Build(targetBuild2.Id, targetBuild2.DateProduced, targetBuild2.Staleness, targetBuild2.Released,
                                              targetBuild2.Stable, targetBuild2.Commit, targetBuild2.Channels, targetBuild2.Assets, dependencies, incoherencies: null);

            Build retrievedBuild1 = await MaestroApi.Builds.GetBuildAsync(targetBuild1.Id);

            Build retrievedBuild2 = await MaestroApi.Builds.GetBuildAsync(targetBuild2.Id);

            Assert.AreEqual(newTargetBuild1.Dependencies.Count, retrievedBuild1.Dependencies.Count);
            Assert.AreEqual(newTargetBuild2.Dependencies.Count, retrievedBuild2.Dependencies.Count);

            BuildRefComparer buildRefComparer = new BuildRefComparer();

            CollectionAssert.AreEqual(retrievedBuild1.Dependencies, newTargetBuild1.Dependencies, buildRefComparer);
            CollectionAssert.AreEqual(retrievedBuild2.Dependencies, newTargetBuild2.Dependencies, buildRefComparer);
        }