NuGetTransientErrorDetectorTests.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. namespace Microsoft.DotNet.Tools.Tests.Utilities.Tests
  4. {
  5. public class NuGetTransientErrorDetectorTests
  6. {
  7. [Fact]
  8. public void Error1()
  9. {
  10. string input =
  11. "[31;1m Microsoft.NET.ToolPack.Tests.GivenThatWeWantToPackAToolProjectWithPackagedShim.It_contains_shim" +
  12. "(multiTarget: True, targetFramework: \"netcoreapp2.1\") [FAIL]\r\n\u001B[m\u001B[37m Expected command to" +
  13. " pass but it did not.\r\n\u001B[m\u001B[37m File Name: /datadisks/disk1/work/AD2E0974/p/d/dotnet\r\n\u001B[m\u001B[37m" +
  14. " Arguments: msbuild /t:Pack /datadisks/disk1/work/AD2E0974/w/A09F08FB/e/testExecutionDirectory/NupkgOfPackWi---4E69F8CE/" +
  15. "consoledemo.csproj /restore\r\n\u001B[m\u001B[37m Exit Code: 1\r\n\u001B[m\u001B[37m StdOut:\r\n\u001B[m\u001B[37m " +
  16. "Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET\r\n\u001B[m\u001B[37m Copyright (C) Microsoft " +
  17. "Corporation. All rights reserved.\r\n\u001B[m\u001B[37m \r\n\u001B[m\u001B[37m Determining projects to restore...\r\n\u001B" +
  18. "[m\u001B[37m Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/" +
  19. "_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft.netcore.dotnethostpolicy/index.json'.\r\n\u001B[m" +
  20. "\u001B[37m Response status code does not indicate success: 503 (Service Unavailable).\r\n\u001B[m\u001B[37m " +
  21. "Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/" +
  22. "1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft.netcore.dotnethostpolicy/index.json'.\r\n\u001B[m\u001B" +
  23. "[37m Response status code does not indicate success: 503 (Service Unavailable).\r\n\u001B[m\u001B[37m " +
  24. "/datadisks/disk1/work/AD2E0974/p/d/sdk/6.0.100-ci/NuGet.targets(131,5): error : Failed to retrieve information about" +
  25. " 'runtime.osx-x64.Microsoft.NETCore.DotNetHostPolicy' from remote source 'https://pkgs.dev.azure.com/dnceng/" +
  26. "9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft." +
  27. "netcore.dotnethostpolicy/index.json'. [/datadisks/disk1/work/AD2E0974/w/A09F08FB/e/testExecutionDirectory/NupkgOfPackWi---4E69F8CE" +
  28. "/consoledemo.csproj]\r\n\u001B[m\u001B[37m /datadisks/disk1/work/AD2E0974/p/d/sdk/6.0.100-ci/NuGet.targets(131,5): error : " +
  29. "Response status code does not indicate success: 503 (Service Unavailable). [/datadisks/disk1/work/AD2E0974/w/A09F08FB/e/" +
  30. "testExecutionDirectory/NupkgOfPackWi---4E69F8CE/consoledemo.csproj]\r\n\u001B[m\u001B[37m StdErr:\r\n\u001B[m\u001B[37m " +
  31. "\r\n\u001B[m\u001B[37m \r\n\u001B[m\u001B[30;1m Stack Trace:\r\n\u001B[m\u001B[37m at " +
  32. "FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)\r\n\u001B[m\u001B[37m at " +
  33. "FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)\r\n\u001B[m\u001B[37m at " +
  34. "FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)\r\n\u001B[m\u001B[37m at " +
  35. "FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args)\r\n\u001B[m\u001B[37m " +
  36. "/_/test/Microsoft.NET.TestFramework/Assertions/CommandResultAssertions.cs(32,0): at Microsoft.NET.TestFramework.Assertions." +
  37. "CommandResultAssertions.Pass()\r\n\u001B[m\u001B[37m /_/test/Microsoft.NET.ToolPack.Tests/" +
  38. "PackWithShimsAndResultNugetPackageNuGetPackagexFixture.cs(64,0): at Microsoft.NET.ToolPack.Tests.NupkgOfPackWithShimsFixture." +
  39. "SetupNuGetPackage(Boolean multiTarget, String targetFramework)\r\n\u001B[mRunning /datadisks/disk1/work/AD2E0974/p/d/" +
  40. "dotnet msbuild /t:Pack /datadisks/disk1/work/AD2E0974/w/A09F08FB/e/testExecutionDirectory/NupkgOfPackWi---BDB2B0FB/consoledemo.csproj " +
  41. "/restore\r\n\u001B[37m /_/test/Microsoft.NET.ToolPack.Tests/PackWithShimsAndResultNugetPackageNuGetPackagexFixture.cs(47,0): " +
  42. "at Microsoft.NET.ToolPack.Tests.NupkgOfPackWithShimsFixture.GetTestToolPackagePath(Boolean multiTarget, String targetFramework)" +
  43. "\r\n\u001B[m\u001B[37m /_/test/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs(128,0): " +
  44. "at Microsoft.NET.ToolPack.Tests.GivenThatWeWantToPackAToolProjectWithPackagedShim.It_contains_shim(Boolean multiTarget, String " +
  45. "targetFramework)\r\n\u001B[m\u001B[30;1m Output:\r\n\u001B[m\u001B[37m > /datadisks/disk1/work/AD2E0974/p/d/dotnet msbuild " +
  46. "/t:Pack /datadisks/disk1/work/AD2E0974/w/A09F08FB/e/testExecutionDirectory/NupkgOfPackWi---4E69F8CE/consoledemo.csproj /restore" +
  47. "\r\n\u001B[m\u001B[37m Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET\r\n\u001B[m\u001B[37m " +
  48. "Copyright (C) Microsoft Corporation. All rights reserved.\r\n\u001B[m\u001B[37m \r\n\u001B[m\u001B[37m Determining " +
  49. "projects to restore...\r\n\u001B[m\u001B[37m Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/" +
  50. "9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft.netcore." +
  51. "dotnethostpolicy/index.json'.\r\n\u001B[m\u001B[37m Response status code does not indicate success: 503 (Service Unavailable)." +
  52. "\r\n\u001B[m\u001B[37m Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/" +
  53. "9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft.netcore." +
  54. "dotnethostpolicy/index.json'.\r\n\u001B[m\u001B[37m Response status code does not indicate success: 503 (Service Unavailable)" +
  55. ".\r\n\u001B[m\u001B[37m /datadisks/disk1/work/AD2E0974/p/d/sdk/6.0.100-ci/NuGet.targets(131,5): error : Failed to retrieve " +
  56. "information about 'runtime.osx-x64.Microsoft.NETCore.DotNetHostPolicy' from remote source 'https://pkgs.dev.azure.com/dnceng/" +
  57. "9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.osx-x64.microsoft.netcore." +
  58. "dotnethostpolicy/index.json'. [/datadisks/disk1/work/AD2E0974/w/A09F08FB/e/testExecutionDirectory/NupkgOfPackWi---4E69F8CE/" +
  59. "consoledemo.csproj]\r\n\u001B[m\u001B[37m /datadisks/disk1/work/AD2E0974/p/d/sdk/6.0.100-ci/NuGet.targets(131,5): error : " +
  60. "Response status code does not indicate success: 503 (Service Unavailable). [/datadisks/disk1/work/AD2E0974/w/A09F08FB/e/" +
  61. "testExecutionDirectory/NupkgOfPackWi---4E69F8CE/consoledemo.csproj]\r\n\u001B[m\u001B[37m Exit Code: 1";
  62. NuGetTransientErrorDetector.IsTransientError(input).Should().BeTrue();
  63. }
  64. [Fact]
  65. public void Error2()
  66. {
  67. string input =
  68. "C:\\h\\w\\BA6F09CC\\t\\dotnetSdkTests\\raba4db1.z5b\\compose_depen---2E9E4DDB\\FluentAssertion.xml\" (Restore target) (1) ->\r\n " +
  69. "(Restore target) -> \r\n C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\Common7\\IDE\\CommonExtensions\\Microsoft" +
  70. "\\NuGet\\NuGet.targets(131,5): error : Failed to retrieve information about 'runtime.win.System.Console' from remote source " +
  71. "'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3" +
  72. "/flat2/runtime.win.system.console/index.json'. [C:\\h\\w\\BA6F09CC\\t\\dotnetSdkTests\\raba4db1.z5b\\compose_depen---2E9E4DDB\\" +
  73. "FluentAssertion.xml]\r\n C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\Common7\\IDE\\CommonExtensions\\" +
  74. "Microsoft\\NuGet\\NuGet.targets(131,5): error : An error occurred while sending the request. [C:\\h\\w\\BA6F09CC\\t\\dotnetSdkTests" +
  75. "\\raba4db1.z5b\\compose_depen---2E9E4DDB\\FluentAssertion.xml]\r\n C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\" +
  76. "Preview\\Common7\\IDE\\CommonExtensions\\Microsoft\\NuGet\\NuGet.targets(131,5): error : " +
  77. "The request was aborted: The request was canceled. [C:\\h\\w\\BA6F09CC\\t\\dotnetSdkTests\\raba4db1.z5b\\compose_depen---2E9E4DDB" +
  78. "\\FluentAssertion.xml]\r\n";
  79. NuGetTransientErrorDetector.IsTransientError(input).Should().BeTrue();
  80. }
  81. [Fact]
  82. public void Error3()
  83. {
  84. string input =
  85. @"Determining projects to restore...
  86. Failed to download package 'runtime.win-x64.Microsoft.NETCore.DotNetHostResolver.2.1.24' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/runtime.win-x64.microsoft.netcore.dotnethostresolver/2.1.24/runtime.win-x64.microsoft.netcore.dotnethostresolver.2.1.24.nupkg'.
  87. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (k0ivsblobprodcus356.vsblob.vsassets.io:443)
  88. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  89. Failed to download package 'runtime.win-x64.Microsoft.NETCore.DotNetHostResolver.2.1.24' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/runtime.win-x64.microsoft.netcore.dotnethostresolver/2.1.24/runtime.win-x64.microsoft.netcore.dotnethostresolver.2.1.24.nupkg'.
  90. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (k0ivsblobprodcus356.vsblob.vsassets.io:443)
  91. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  92. drive\NuGet.targets(131,5): error : Failed to download package 'runtime.win-x64.Microsoft.NETCore.DotNetHostResolver.2.1.24' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/runtime.win-x64.microsoft.netcore.dotnethostresolver/2.1.24/runtime.win-x64.microsoft.netcore.dotnethostresolver.2.1.24.nupkg'. [C:\h\w\B79F0A31\t\dotnetSdkTests\zvrozon1.u4m\RunFromOutput---802469DB\RunFromOutputFolderWithRID_netcoreapp2.1\RunFromOutputFolderWithRID_netcoreapp2.1.csproj]
  93. drive\NuGet.targets(131,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (k0ivsblobprodcus356.vsblob.vsassets.io:443) [C:\h\w\B79F0A31\t\dotnetSdkTests\zvrozon1.u4m\RunFromOutput---802469DB\RunFromOutputFolderWithRID_netcoreapp2.1\RunFromOutputFolderWithRID_netcoreapp2.1.csproj]
  94. drive\NuGet.targets(131,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [C:\h\w\B79F0A31\t\dotnetSdkTests\zvrozon1.u4m\RunFromOutput---802469DB\RunFromOutputFolderWithRID_netcoreapp2.1\RunFromOutputFolderWithRID_netcoreapp2.1.csproj]
  95. drive\NuGet.targets(131,5): error : The feed 'dotnet-public [https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json]' lists package 'runtime.win-x64.Microsoft.NETCore.DotNetHostResolver.2.1.24' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again. [C:\h\w\B79F0A31\t\dotnetSdkTests\zvrozon1.u4m\RunFromOutput---802469DB\RunFromOutputFolderWithRID_netcoreapp2.1\RunFromOutputFolderWithRID_netcoreapp2.1.csproj]
  96. drive\NuGet.targets(131,5): error : Unable to find package 'runtime.win-x64.Microsoft.NETCore.DotNetHostResolver.2.1.24'. [C:\h\w\B79F0A31\t\dotnetSdkTests\zvrozon1.u4m\RunFromOutput---802469DB\RunFromOutputFolderWithRID_netcoreapp2.1\RunFromOutputFolderWithRID_netcoreapp2.1.csproj]";
  97. NuGetTransientErrorDetector.IsTransientError(input).Should().BeTrue();
  98. }
  99. [Fact]
  100. public void NoTransientError()
  101. {
  102. string input =
  103. @"
  104. info : Adding PackageReference for package 'Newtonsoft.Json' into project 'console/console.csproj'.
  105. info : Restoring packages for console/console.csproj...
  106. info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'console/console.csproj'.
  107. info : Committing restore...
  108. info : Generating MSBuild file console/obj/console.csproj.nuget.g.props.
  109. info : Generating MSBuild file console/obj/console.csproj.nuget.g.targets.
  110. info : Writing assets file to disk. Path: console/obj/project.assets.json
  111. log : Restored console/console.csproj (in 120 ms).
  112. Build started 3/10/2021 1:53:51 PM.
  113. 1>Project on node 1 (Restore target(s)).
  114. 1>_GetAllRestoreProjectPathItems:
  115. Determining projects to restore...
  116. Restore:
  117. Restoring packages for console/console.csproj...
  118. Committing restore...
  119. Generating MSBuild file console/obj/console.csproj.nuget.g.props.
  120. Generating MSBuild file console/obj/console.csproj.nuget.g.targets.
  121. Writing assets file to disk. Path: console/obj/project.assets.json
  122. Restored console/console.csproj (in 131 ms).
  123. NuGet Config files used:
  124. /.nuget/NuGet/NuGet.Config
  125. Feeds used:
  126. https://api.nuget.org/v3/index.json";
  127. NuGetTransientErrorDetector.IsTransientError(input).Should().BeFalse();
  128. }
  129. }
  130. }