public async Task FeedConfigParserTests4Async() { var buildEngine = new MockBuildEngine(); var task = new PublishArtifactsInManifestV2 { TargetFeedConfig = new Microsoft.Build.Utilities.TaskItem[] { new Microsoft.Build.Utilities.TaskItem(TargetFeedContentType.BinaryLayout.ToString(), new Dictionary <string, string> { { "TargetUrl", BlobFeedUrl }, { "Token", RandomToken }, // Use different casing here to make sure that parsing // ignores case. { "Type", "AZURESTORAGEFEED" }, { "AssetSelection", "SHIPPINGONLY" }, { "Internal", "false" } }), }, BuildEngine = buildEngine }; await task.ParseTargetFeedConfigAsync(); // This will have set the feed configs. Assert.Collection(task.FeedConfigs, configList => { Assert.Equal(TargetFeedContentType.BinaryLayout, configList.Key); Assert.Collection(configList.Value, config => { Assert.Equal(RandomToken, config.Token); Assert.Equal(BlobFeedUrl, config.TargetURL); Assert.Equal(FeedType.AzureStorageFeed, config.Type); Assert.Equal(AssetSelection.ShippingOnly, config.AssetSelection); }); }); }
public async Task PushNugetPackageTestsAsync(int pushAttemptsBeforeSuccess, bool packageAlreadyOnFeed, bool localPackageMatchesFeed, bool expectedFailure = false) { // Setup var buildEngine = new MockBuildEngine(); // May as well check that the exe is plumbed through from the task. string fakeNugetExeName = $"{Path.GetRandomFileName()}.exe"; int timesNugetExeCalled = 0; // Functionality is the same as this is in the base class, create a v2 object to test. var task = new PublishArtifactsInManifestV2 { InternalBuild = true, BuildEngine = buildEngine, NugetPath = fakeNugetExeName, MaxRetryCount = 5, // In case the default changes, lock to 5 so the test data works RetryDelayMilliseconds = 10 // retry faster in test }; TargetFeedConfig config = new TargetFeedConfig(TargetFeedContentType.Package, "testUrl", FeedType.AzDoNugetFeed, "tokenValue"); Func <string, string, HttpClient, MsBuildUtils.TaskLoggingHelper, Task <PackageFeedStatus> > testCompareLocalPackage = async(string localPackageFullPath, string packageContentUrl, HttpClient client, MsBuildUtils.TaskLoggingHelper log) => { await(Task.Delay(10)); // To make this actually async Debug.WriteLine($"Called mocked CompareLocalPackageToFeedPackage() : localPackageFullPath = {localPackageFullPath}, packageContentUrl = {packageContentUrl}"); if (packageAlreadyOnFeed) { return(localPackageMatchesFeed ? PackageFeedStatus.ExistsAndIdenticalToLocal : PackageFeedStatus.ExistsAndDifferent); } else { return(PackageFeedStatus.DoesNotExist); } }; Func <string, string, Task <ProcessExecutionResult> > testRunAndLogProcess = (string fakeExePath, string fakeExeArgs) => { Debug.WriteLine($"Called mocked RunProcessAndGetOutputs() : ExePath = {fakeExePath}, ExeArgs = {fakeExeArgs}"); fakeNugetExeName.Should().Be(fakeExePath); ProcessExecutionResult result = new ProcessExecutionResult() { StandardError = "fake stderr", StandardOut = "fake stdout" }; timesNugetExeCalled++; if (timesNugetExeCalled >= pushAttemptsBeforeSuccess) { result.ExitCode = 0; } else { result.ExitCode = 1; } return(Task.FromResult(result)); }; await task.PushNugetPackageAsync( config, null, "localPackageLocation", "1234", "version", "feedaccount", "feedvisibility", "feedname", testCompareLocalPackage, testRunAndLogProcess); if (!expectedFailure && localPackageMatchesFeed) { // Successful retry scenario; make sure we ran the # of retries we thought. timesNugetExeCalled.Should().BeLessOrEqualTo(task.MaxRetryCount); } expectedFailure.Should().Be(task.Log.HasLoggedErrors); }
public void StableFeeds(bool publishInstallersAndChecksums, bool isInternalBuild) { var expectedFeeds = new List <TargetFeedConfig>(); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, StablePackageFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, latestLinkShortUrlPrefix: $"{LatestLinkShortUrlPrefix}/{BuildQuality}", assetSelection: AssetSelection.ShippingOnly, isolated: true, @internal: isInternalBuild, allowOverwrite: false, symbolTargetType: symbolTargetType, filenamesToExclude: FilesToExclude)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Symbols, StableSymbolsFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, latestLinkShortUrlPrefix: $"{LatestLinkShortUrlPrefix}/{BuildQuality}", assetSelection: AssetSelection.All, isolated: true, @internal: isInternalBuild, allowOverwrite: false, symbolTargetType: symbolTargetType, filenamesToExclude: FilesToExclude)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, PublishingConstants.FeedDotNet5Transport, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, latestLinkShortUrlPrefix: $"{LatestLinkShortUrlPrefix}/{BuildQuality}", assetSelection: AssetSelection.NonShippingOnly, isolated: false, @internal: isInternalBuild, allowOverwrite: false, symbolTargetType: symbolTargetType, filenamesToExclude: FilesToExclude)); if (publishInstallersAndChecksums) { foreach (var contentType in InstallersAndSymbols) { if (contentType == TargetFeedContentType.Symbols) { continue; } expectedFeeds.Add( new TargetFeedConfig( contentType, PublishingConstants.FeedForInstallers, FeedType.AzureStorageFeed, InstallersTargetStaticFeedKey, latestLinkShortUrlPrefix: $"{LatestLinkShortUrlPrefix}/{BuildQuality}", assetSelection: AssetSelection.All, isolated: false, @internal: isInternalBuild, allowOverwrite: false, symbolTargetType: symbolTargetType, filenamesToExclude: FilesToExclude)); } expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Checksum, PublishingConstants.FeedForChecksums, FeedType.AzureStorageFeed, ChecksumsTargetStaticFeedKey, latestLinkShortUrlPrefix: $"{LatestLinkShortUrlPrefix}/{BuildQuality}", assetSelection: AssetSelection.All, isolated: false, @internal: isInternalBuild, allowOverwrite: false, symbolTargetType: symbolTargetType, filenamesToExclude: FilesToExclude)); } var buildEngine = new MockBuildEngine(); var channelConfig = PublishingConstants.ChannelInfos.First(c => c.Id == 131); var config = new SetupTargetFeedConfigV3( channelConfig, isInternalBuild, true, repositoryName: "test-repo", commitSha: "c0c0c0c0", publishInstallersAndChecksums, FeedKeys, Array.Empty <ITaskItem>(), Array.Empty <ITaskItem>(), $"{LatestLinkShortUrlPrefix}/{BuildQuality}", buildEngine, symbolTargetType, StablePackageFeed, StableSymbolsFeed, filesToExclude: FilesToExclude ); var actualFeeds = config.Setup(); actualFeeds.Should().BeEquivalentTo(expectedFeeds); }
public void StableFeeds(bool publishInstallersAndChecksums, bool isInternalBuild) { var expectedFeeds = new List <TargetFeedConfig>(); if (publishInstallersAndChecksums) { expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Checksum, ChecksumsTargetStaticFeed, FeedType.AzureStorageFeed, ChecksumsTargetStaticFeedKey, string.Empty, AssetSelection.All, isolated: true, @internal: false, allowOverwrite: true)); foreach (var contentType in Installers) { expectedFeeds.Add( new TargetFeedConfig( contentType, InstallersTargetStaticFeed, FeedType.AzureStorageFeed, InstallersTargetStaticFeedKey, string.Empty, AssetSelection.All, isolated: true, @internal: false, allowOverwrite: true)); } } expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, StablePackageFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, string.Empty, AssetSelection.ShippingOnly, isolated: true, @internal: false, allowOverwrite: false)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Symbols, StableSymbolsFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, string.Empty, AssetSelection.All, isolated: true, @internal: false, allowOverwrite: false)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, AzureDevOpsStaticTransportFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, string.Empty, AssetSelection.NonShippingOnly, isolated: false, @internal: false, allowOverwrite: false)); var buildEngine = new MockBuildEngine(); var config = new SetupTargetFeedConfigV3( isInternalBuild, isStableBuild: true, repositoryName: "test-repo", commitSha: "c0c0c0c0", publishInstallersAndChecksums, InstallersTargetStaticFeed, InstallersTargetStaticFeedKey, ChecksumsTargetStaticFeed, ChecksumsTargetStaticFeedKey, AzureDevOpsStaticShippingFeed, AzureDevOpsStaticTransportFeed, AzureDevOpsStaticSymbolsFeed, LatestLinkShortUrlPrefix, AzureDevOpsFeedsKey, buildEngine, StablePackageFeed, StableSymbolsFeed ); var actualFeeds = config.Setup(); Assert.True(AreEquivalent(expectedFeeds, actualFeeds)); }
public void NonStableAndPublic(bool publishInstallersAndChecksums) { var expectedFeeds = new List <TargetFeedConfig>(); if (publishInstallersAndChecksums) { expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Checksum, ChecksumsTargetStaticFeed, FeedType.AzureStorageFeed, ChecksumsTargetStaticFeedKey, $"{LatestLinkShortUrlPrefix}/{BuildQuality}", AssetSelection.All, isolated: false, @internal: false, allowOverwrite: false, symbolTargetType, filenamesToExclude: FilesToExclude)); foreach (var contentType in Installers) { expectedFeeds.Add( new TargetFeedConfig( contentType, InstallersTargetStaticFeed, FeedType.AzureStorageFeed, InstallersTargetStaticFeedKey, $"{LatestLinkShortUrlPrefix}/{BuildQuality}", AssetSelection.All, isolated: false, @internal: false, allowOverwrite: false, symbolTargetType, filenamesToExclude: FilesToExclude)); } } expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Symbols, PublishingConstants.LegacyDotNetBlobFeedURL, FeedType.AzureStorageFeed, AzureStorageTargetFeedPAT, string.Empty, AssetSelection.All, isolated: false, @internal: false, allowOverwrite: false, symbolTargetType, filenamesToExclude: FilesToExclude)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, AzureDevOpsStaticShippingFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, string.Empty, AssetSelection.ShippingOnly, isolated: false, @internal: false, allowOverwrite: false, symbolTargetType, filenamesToExclude: FilesToExclude)); expectedFeeds.Add( new TargetFeedConfig( TargetFeedContentType.Package, AzureDevOpsStaticTransportFeed, FeedType.AzDoNugetFeed, AzureDevOpsFeedsKey, string.Empty, AssetSelection.NonShippingOnly, isolated: false, @internal: false, allowOverwrite: false, symbolTargetType, filenamesToExclude: FilesToExclude)); var buildEngine = new MockBuildEngine(); var config = new SetupTargetFeedConfigV3( isInternalBuild: false, isStableBuild: false, repositoryName: "test-repo", commitSha: "c0c0c0c0", AzureStorageTargetFeedPAT, publishInstallersAndChecksums, InstallersTargetStaticFeed, InstallersTargetStaticFeedKey, ChecksumsTargetStaticFeed, ChecksumsTargetStaticFeedKey, AzureDevOpsStaticShippingFeed, AzureDevOpsStaticTransportFeed, AzureDevOpsStaticSymbolsFeed, $"{LatestLinkShortUrlPrefix}/{BuildQuality}", AzureDevOpsFeedsKey, buildEngine: buildEngine, symbolTargetType, filesToExclude: FilesToExclude ); var actualFeeds = config.Setup(); actualFeeds.Should().BeEquivalentTo(expectedFeeds); }
public BuildManifestUtilTests() { _buildEngine = new MockBuildEngine(); _stubTask = new StubTask(_buildEngine); _taskLoggingHelper = new TaskLoggingHelper(_stubTask); }