From 9b2b9ff0e380656829113d3d124dbc9446b4c60b Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 17 Mar 2023 17:47:35 -0700 Subject: [PATCH 1/9] we use the generated SHA of the assets repo within the tag name that is uploaded. This means that if a set of recordings has already been pushed, we won't attempt to push again and error out --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs index 7c2c8440667..28f37191cc8 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -124,7 +124,20 @@ public async Task Push(string pathToAssetsJson) { } GitHandler.Run($"tag {generatedTagName}", config); - GitHandler.Run($"push origin {generatedTagName}", config); + + var remoteResult = GitHandler.Run($"ls-remote origin --tags {generatedTagName}", config); + + if (remoteResult.ExitCode != 0) + { + if (string.IsNullOrWhiteSpace(remoteResult.StdOut)) + { + GitHandler.Run($"push origin {generatedTagName}", config); + } + else + { + _consoleWrapper.WriteLine("Not attempting to push new tag, as we have found it already within the assets repo"); + } + } } catch(GitProcessException e) { From ef4c84e0790edc2f5791682d5a389a917bc1cc94 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:15:18 -0700 Subject: [PATCH 2/9] Update tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs Co-authored-by: Ben Broderick Phillips --- tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs index 28f37191cc8..0f093fce932 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -135,7 +135,7 @@ public async Task Push(string pathToAssetsJson) { } else { - _consoleWrapper.WriteLine("Not attempting to push new tag, as we have found it already within the assets repo"); + _consoleWrapper.WriteLine($"Not attempting to push tag '{generatedTagName}', as it already exists within the assets repo"); } } } From 528521d04fb3a7321eae60f9c3577211fce132aa Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:51:41 -0700 Subject: [PATCH 3/9] identify the error with my push logic --- .../Azure.Sdk.Tools.TestProxy/RecordingHandler.cs | 4 ++-- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index eb2871238d8..af8a23ca1c2 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -564,10 +564,10 @@ public static string GetAssetsJsonLocation(string pathToAssetsJson, string conte if (!Path.IsPathFullyQualified(pathToAssetsJson)) { - path = Path.Join(contextDirectory, pathToAssetsJson.Replace("\\", "/")); + path = Path.Join(contextDirectory, pathToAssetsJson); } - return path; + return path.Replace("\\", "/"); } public async Task Restore(string pathToAssetsJson) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs index 0f093fce932..bfebebbb48c 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -127,16 +127,13 @@ public async Task Push(string pathToAssetsJson) { var remoteResult = GitHandler.Run($"ls-remote origin --tags {generatedTagName}", config); - if (remoteResult.ExitCode != 0) + if (string.IsNullOrWhiteSpace(remoteResult.StdOut)) { - if (string.IsNullOrWhiteSpace(remoteResult.StdOut)) - { - GitHandler.Run($"push origin {generatedTagName}", config); - } - else - { - _consoleWrapper.WriteLine($"Not attempting to push tag '{generatedTagName}', as it already exists within the assets repo"); - } + GitHandler.Run($"push origin {generatedTagName}", config); + } + else + { + _consoleWrapper.WriteLine($"Not attempting to push tag '{generatedTagName}', as it already exists within the assets repo"); } } catch(GitProcessException e) From ccb0b9693a11783f0e1737d97e6e7fcefb76b069 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:00:30 -0700 Subject: [PATCH 4/9] update integration tests? --- .../test-scripts/CLIIntegration.Tests.ps1 | 67 +++++++++++++++++++ .../test-scripts/assets.Tests.Helpers.ps1 | 4 +- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 index 86ee688428f..c4caa11951f 100644 --- a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 +++ b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 @@ -426,6 +426,73 @@ Describe "AssetsModuleTests" { $exists | Should -Be $true } } + It "Should handle pushing an identical SHA twice, and properly update to the necessary tag without error state." { + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $testGuid = [Guid]::NewGuid() + $created_tag_prefix = "duplicate_push_test_$testGuid" + $creationPath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "tests" "recordings" + $file1 = Join-Path $creationPath "file1.txt" + $file2 = Join-Path $creationPath "file2.txt" + $file3 = Join-Path $creationPath "file3.txt" + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "" + AssetsRepoId = "" + TagPrefix = $created_tag_prefix + Tag = "" + } + + $assetsJsonRelativePath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "assets.json" + + $files = @( + $assetsJsonRelativePath + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false + + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + + $localAssetsFilePath = Join-Path $testFolder ".assets" + $assetsFolder = $(Get-ChildItem $localAssetsFilePath -Directory)[0].FullName + mkdir -p $(Join-Path $assetsFolder $creationPath) + + # Create new files. These are in a predictable location with predicatable content so we can generate the same SHA twice in a row. + Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 + + # Push the changes + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + + # now, let's describe an _entirely different_ assets folder, attempt the same push. + # this should result in the SAME tag twice in the assets repo, and we should properly NOT do the full push action + $newTestFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false + $newAssetsFile = Join-Path $newTestFolder $assetsJsonRelativePath + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + + # same file updates. we should have an identical sha! + Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 + + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder + $LASTEXITCODE | Should -Be 0 + + $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $newAssetsFile + + $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + $exists | Should -Be $true + } + } AfterEach { Remove-Test-Folder $testFolder Remove-Integration-Tag $updatedAssets diff --git a/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 b/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 index ec6d0e7e495..cc90cf84086 100644 --- a/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 +++ b/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 @@ -212,7 +212,7 @@ Function Describe-TestFolder { chmod 777 $testPath } - return $testPath + return $testPath.Replace("`\", "/") } # Cleanup the test folder used for testing. The DISABLE_INTEGRATION_BRANCH_CLEANUP @@ -243,7 +243,7 @@ Function Invoke-ProxyCommand { ) if ($TestProxyExe.Trim().ToLower() -eq "test-proxy") { - $CommandArgs += " --storage-location=`"$MountDirectory`"" + $CommandArgs += " --storage-location=$MountDirectory" Write-Host "$TestProxyExe $CommandArgs" # Need to cast the output into an array otherwise it'll be one long string with no newlines if ($WriteOutput) { From d04b0c6c0050240adcfa7de60b26fb7742fc1849 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:59:55 -0700 Subject: [PATCH 5/9] commit test fix --- .../test-scripts/CLIIntegration.Tests.ps1 | 126 ++++++++++-------- 1 file changed, 67 insertions(+), 59 deletions(-) diff --git a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 index c4caa11951f..356a8a9ed99 100644 --- a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 +++ b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 @@ -431,66 +431,74 @@ Describe "AssetsModuleTests" { Set-ItResult -Skipped } else { - $testGuid = [Guid]::NewGuid() - $created_tag_prefix = "duplicate_push_test_$testGuid" - $creationPath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "tests" "recordings" - $file1 = Join-Path $creationPath "file1.txt" - $file2 = Join-Path $creationPath "file2.txt" - $file3 = Join-Path $creationPath "file3.txt" - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "" - AssetsRepoId = "" - TagPrefix = $created_tag_prefix - Tag = "" + $newTestFolder = "" + try { + $testGuid = [Guid]::NewGuid() + $created_tag_prefix = "duplicate_push_test_$testGuid" + $creationPath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "tests" "recordings" + $file1 = Join-Path $creationPath "file1.txt" + $file2 = Join-Path $creationPath "file2.txt" + $file3 = Join-Path $creationPath "file3.txt" + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "" + AssetsRepoId = "" + TagPrefix = $created_tag_prefix + Tag = "" + } + + $assetsJsonRelativePath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "assets.json" + + $files = @( + $assetsJsonRelativePath + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false + + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + + $localAssetsFilePath = Join-Path $testFolder ".assets" + $assetsFolder = $(Get-ChildItem $localAssetsFilePath -Directory)[0].FullName + mkdir -p $(Join-Path $assetsFolder $creationPath) + + # Create new files. These are in a predictable location with predicatable content so we can generate the same SHA twice in a row. + Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 + + # Push the changes + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + + # now, let's describe an _entirely different_ assets folder, attempt the same push. + # this should result in the SAME tag twice in the assets repo, and we should properly NOT do the full push action + $newTestFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false + $newAssetsFile = Join-Path $newTestFolder $assetsJsonRelativePath + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder + $LASTEXITCODE | Should -Be 0 + + # same file updates. we should have an identical sha! + Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 + Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 + + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder + $LASTEXITCODE | Should -Be 0 + + $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $newAssetsFile + + $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + $exists | Should -Be $true + } + finally { + if ($newTestFolder) { + Remove-Test-Folder $newTestFolder + } } - - $assetsJsonRelativePath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "assets.json" - - $files = @( - $assetsJsonRelativePath - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false - - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - - $localAssetsFilePath = Join-Path $testFolder ".assets" - $assetsFolder = $(Get-ChildItem $localAssetsFilePath -Directory)[0].FullName - mkdir -p $(Join-Path $assetsFolder $creationPath) - - # Create new files. These are in a predictable location with predicatable content so we can generate the same SHA twice in a row. - Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 - - # Push the changes - $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - - # now, let's describe an _entirely different_ assets folder, attempt the same push. - # this should result in the SAME tag twice in the assets repo, and we should properly NOT do the full push action - $newTestFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false - $newAssetsFile = Join-Path $newTestFolder $assetsJsonRelativePath - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - - # same file updates. we should have an identical sha! - Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 - - $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder - $LASTEXITCODE | Should -Be 0 - - $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $newAssetsFile - - $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - $exists | Should -Be $true } } AfterEach { From 34f20b6fbb270f6f650908ed5319a5a81253771f Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 13 Apr 2023 18:53:12 -0700 Subject: [PATCH 6/9] progress for the night this is entirely broken --- .../GitStoreIntegrationPushTests.cs | 171 ++-- .../TestHelpers.cs | 4 +- .../test-scripts/CLIIntegration.Tests.ps1 | 795 +++++++++--------- .../test-scripts/assets.Tests.Helpers.ps1 | 2 +- 4 files changed, 494 insertions(+), 478 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs index fefa9cb0e10..f1f0b44f91f 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs @@ -105,6 +105,7 @@ public async Task Scenario1(string inputJson) finally { DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); TestHelpers.CleanupIntegrationTestTag(updatedAssets); } } @@ -187,6 +188,7 @@ public async Task Scenario2(string inputJson) finally { DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); TestHelpers.CleanupIntegrationTestTag(updatedAssets); } } @@ -280,6 +282,7 @@ public async Task Scenario3(string inputJson) finally { DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); TestHelpers.CleanupIntegrationTestTag(updatedAssets); } } @@ -362,6 +365,7 @@ public async Task Scenario4(string inputJson) finally { DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); TestHelpers.CleanupIntegrationTestTag(updatedAssets); } } @@ -384,7 +388,7 @@ public async Task Scenario4(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""language/tables"", - ""Tag"": ""language/tables_9e81fb"" + ""Tag"": ""python/tables_9e81fb"" }")] [Trait("Category", "Integration")] public async Task Scenario5(string inputJson) @@ -401,14 +405,15 @@ public async Task Scenario5(string inputJson) // The first restore needs to be done with isPushTest set to true so it creates the branch var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); // The second restore needs to use the assets that was updated in the first restore so it - // restores from the branch we're going to push to + // restores from the tag we're going to push to var testFolder2 = TestHelpers.DescribeTestFolder(assets, folderStructure); try { // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); + assets = TestHelpers.LoadAssetsFromFile(jsonFileLocation); var parsedConfiguration = await _defaultStore.ParseConfigurationFile(jsonFileLocation); await _defaultStore.Restore(jsonFileLocation); @@ -474,10 +479,11 @@ public async Task Scenario5(string inputJson) // Ensure that the targeted tag is present on the repo TestHelpers.CheckExistenceOfTag(updatedAssets, localFilePath); - + // Update the second assets file and do another restore TestHelpers.UpdateAssetsFile(updatedAssets, jsonFileLocation2); await defaultStore2.Restore(jsonFileLocation2); + updatedAssets = TestHelpers.LoadAssetsFromFile(jsonFileLocation2); // Verify the files pushes in another directory are restored correctly here Assert.Equal(3, System.IO.Directory.EnumerateFiles(localFilePath2).Count()); @@ -485,90 +491,95 @@ public async Task Scenario5(string inputJson) Assert.True(TestHelpers.VerifyFileVersion(localFilePath2, "file2.txt", 3)); Assert.True(TestHelpers.VerifyFileVersion(localFilePath2, "file6.txt", 1)); await TestHelpers.CheckBreadcrumbAgainstAssetsJsons(new string[] { jsonFileLocation }); - - } - finally - { - DirectoryHelper.DeleteGitDirectory(testFolder); - TestHelpers.CleanupIntegrationTestTag(updatedAssets); - DirectoryHelper.DeleteGitDirectory(testFolder2); } - } - - /// - /// 1. Restore from a tag that has minimal existing files and a long destination path - /// 2. Add a _bunch_ of files - /// 3. Push - /// 4. Verify local files are what is expected - /// 5. Verify assets.json was updated with the new commit Tag - /// - /// - /// - [EnvironmentConditionalSkipTheory] - [InlineData(1000, 0.15)] // 1000 0.15MB files - [InlineData(150, 0.25)] // 150 0.25MB files - [InlineData(100, 0.50)] // 100 0.5MB files - [InlineData(10, 90)] // 10 90MB files - [Trait("Category", "Integration")] - public async Task LargePushPerformance(int numberOfFiles, double fileSize) - { - var folderStructure = new string[] - { - GitStoretests.AssetsJson - }; - Assets assets = JsonSerializer.Deserialize(@"{ - ""AssetsRepo"": ""Azure/azure-sdk-assets-integration"", - ""AssetsRepoPrefixPath"": ""python"", - ""TagPrefix"": ""python/tables"", - ""Tag"": ""python/tables4f724f0c"" - }"); - Assets updatedAssets = null; - List testFiles = new List(); - string originalTagPrefix = assets.TagPrefix; - string originalTag = assets.Tag; - var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); - - try + catch(Exception) { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); - - var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); - - var parsedConfiguration = await _defaultStore.ParseConfigurationFile(jsonFileLocation); - await _defaultStore.Restore(jsonFileLocation); - - var assetRepoRoot = await _defaultStore.GetPath(jsonFileLocation); - var deepPath = Path.Join(assetRepoRoot, "sdk", "tables", "azure-data-tables", "tests", "recordings"); - - // generate a bunch of files - for (var i = 0; i < numberOfFiles; i++) - { - testFiles.Add(TestHelpers.GenerateRandomFile(fileSize, deepPath)); - } - - await _defaultStore.Push(jsonFileLocation); - - // Verify that after the push the directory still contains our updated files - Assert.Equal(3 + testFiles.Count, System.IO.Directory.EnumerateFiles(deepPath).Count()); - foreach (var path in testFiles) - { - Assert.True(File.Exists(path)); - } - - // Ensure that the config was updated with the new Tag as part of the push - updatedAssets = TestHelpers.LoadAssetsFromFile(jsonFileLocation); - Assert.NotEqual(originalTag, updatedAssets.Tag); - - // Ensure that the targeted tag is present on the repo - TestHelpers.CheckExistenceOfTag(updatedAssets, assetRepoRoot); - await TestHelpers.CheckBreadcrumbAgainstAssetsJsons(new string[] { jsonFileLocation }); + throw; } finally { DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); TestHelpers.CleanupIntegrationTestTag(updatedAssets); + DirectoryHelper.DeleteGitDirectory(testFolder2); } } + + ///// + ///// 1. Restore from a tag that has minimal existing files and a long destination path + ///// 2. Add a _bunch_ of files + ///// 3. Push + ///// 4. Verify local files are what is expected + ///// 5. Verify assets.json was updated with the new commit Tag + ///// + ///// + ///// + //[EnvironmentConditionalSkipTheory] + //[InlineData(1000, 0.15)] // 1000 0.15MB files + //[InlineData(150, 0.25)] // 150 0.25MB files + //[InlineData(100, 0.50)] // 100 0.5MB files + //[InlineData(10, 90)] // 10 90MB files + //[Trait("Category", "Integration")] + //public async Task LargePushPerformance(int numberOfFiles, double fileSize) + //{ + // var folderStructure = new string[] + // { + // GitStoretests.AssetsJson + // }; + // Assets assets = JsonSerializer.Deserialize(@"{ + // ""AssetsRepo"": ""Azure/azure-sdk-assets-integration"", + // ""AssetsRepoPrefixPath"": ""python"", + // ""TagPrefix"": ""python/tables"", + // ""Tag"": ""python/tables4f724f0c"" + // }"); + // Assets updatedAssets = null; + // List testFiles = new List(); + // string originalTagPrefix = assets.TagPrefix; + // string originalTag = assets.Tag; + // var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); + + // try + // { + // // Ensure that the TagPrefix was updated + // Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + + // var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); + + // var parsedConfiguration = await _defaultStore.ParseConfigurationFile(jsonFileLocation); + // await _defaultStore.Restore(jsonFileLocation); + + // var assetRepoRoot = await _defaultStore.GetPath(jsonFileLocation); + // var deepPath = Path.Join(assetRepoRoot, "sdk", "tables", "azure-data-tables", "tests", "recordings"); + + // // generate a bunch of files + // for (var i = 0; i < numberOfFiles; i++) + // { + // testFiles.Add(TestHelpers.GenerateRandomFile(fileSize, deepPath)); + // } + + // await _defaultStore.Push(jsonFileLocation); + + // // Verify that after the push the directory still contains our updated files + // Assert.Equal(3 + testFiles.Count, System.IO.Directory.EnumerateFiles(deepPath).Count()); + // foreach (var path in testFiles) + // { + // Assert.True(File.Exists(path)); + // } + + // // Ensure that the config was updated with the new Tag as part of the push + // updatedAssets = TestHelpers.LoadAssetsFromFile(jsonFileLocation); + // Assert.NotEqual(originalTag, updatedAssets.Tag); + + // // Ensure that the targeted tag is present on the repo + // TestHelpers.CheckExistenceOfTag(updatedAssets, assetRepoRoot); + // await TestHelpers.CheckBreadcrumbAgainstAssetsJsons(new string[] { jsonFileLocation }); + // } + // finally + // { + // DirectoryHelper.DeleteGitDirectory(testFolder); + // TestHelpers.CleanupIntegrationTestTag(assets); + // TestHelpers.CleanupIntegrationTestTag(updatedAssets); + // } + //} } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs index 2daf91a0fb6..60d45f4ca56 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs @@ -181,7 +181,7 @@ public static string DescribeTestFolder(Assets assets, string[] sampleFiles, str InitIntegrationTag(assets, adjustedAssetsRepoTag); // set the TagPrefix to the adjusted test branch - assets.TagPrefix = adjustedAssetsRepoTag; + assets.Tag = adjustedAssetsRepoTag; localAssetsJsonContent = JsonSerializer.Serialize(assets); } @@ -473,7 +473,7 @@ public static void CleanupIntegrationTestTag(Assets assets) Directory.CreateDirectory(tmpPath); GitProcessHandler GitHandler = new GitProcessHandler(); string gitCloneUrl = GitStore.GetCloneUrl(assets.AssetsRepo, Directory.GetCurrentDirectory()); - GitHandler.Run($"clone {gitCloneUrl} .", tmpPath); + GitHandler.Run($"clone --filter=blob:none {gitCloneUrl} .", tmpPath); GitHandler.Run($"push origin --delete {assets.Tag}", tmpPath); } finally diff --git a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 index 356a8a9ed99..a5a6e61aa7d 100644 --- a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 +++ b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 @@ -20,412 +20,412 @@ BeforeAll { } Describe "AssetsModuleTests" { - Context "RestoreAssetsRepoTests" -Tag "Integration" { - BeforeEach { - $testFolder = $null - } - It "Should restore from original push of assets." { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_fc54d0" - } - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - } - It "Should restore from second push of assets." { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_9e81fb" - } + # Context "RestoreAssetsRepoTests" -Tag "Integration" { + # BeforeEach { + # $testFolder = $null + # } + # It "Should restore from original push of assets." { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_fc54d0" + # } + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - } - It "Should restore from third push of files." { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_bb2223" - } + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - } - AfterEach { - Remove-Test-Folder $testFolder - } - } - Context "ResetAssetsRepoTests" -Tag "Integration" { - BeforeEach { - $testFolder = $null - } - It "It should call Reset without prompt if no files have changed" { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_fc54d0" - } - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - - $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # With no pending changes, the reset should leave everything alone - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - } - It "It should call Reset and prompt Yes to restore files" { - # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. - if ($env:CLI_TEST_WITH_DOCKER) { - Set-ItResult -Skipped - } - else { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_fc54d0" - } - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # } + # It "Should restore from second push of assets." { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_9e81fb" + # } + + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # } + # It "Should restore from third push of files." { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_bb2223" + # } + + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + # } + # AfterEach { + # Remove-Test-Folder $testFolder + # } + # } + # Context "ResetAssetsRepoTests" -Tag "Integration" { + # BeforeEach { + # $testFolder = $null + # } + # It "It should call Reset without prompt if no files have changed" { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_fc54d0" + # } + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + + # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # # With no pending changes, the reset should leave everything alone + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # } + # It "It should call Reset and prompt Yes to restore files" { + # # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. + # if ($env:CLI_TEST_WITH_DOCKER) { + # Set-ItResult -Skipped + # } + # else { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_fc54d0" + # } + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # Create a new file and verify - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Update a file and verify - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # Delete a file - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - Remove-Item -Path $fileToRemove + # # Create a new file and verify + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # # Update a file and verify + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # # Delete a file + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + # Remove-Item -Path $fileToRemove - # Reset answering Y and they should all go back to original restore - $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "Y" - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - } - } - It "It should call Reset and prompt No to restore files" { - # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. - if ($env:CLI_TEST_WITH_DOCKER) { - Set-ItResult -Skipped - } - else { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "main" - Tag = "language/tables_fc54d0" - } - $files = @( - "assets.json" - ) - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # # Reset answering Y and they should all go back to original restore + # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "Y" + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # } + # } + # It "It should call Reset and prompt No to restore files" { + # # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. + # if ($env:CLI_TEST_WITH_DOCKER) { + # Set-ItResult -Skipped + # } + # else { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "main" + # Tag = "language/tables_fc54d0" + # } + # $files = @( + # "assets.json" + # ) + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # Create two new files and verify - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -Version 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - # Update a file and verify - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # Delete a file - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - Remove-Item -Path $fileToRemove + # # Create two new files and verify + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -Version 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + # # Update a file and verify + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # # Delete a file + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + # Remove-Item -Path $fileToRemove - # Reset answering N and they should remain changed as per the previous changes - $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "N" - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - } - } - AfterEach { - Remove-Test-Folder $testFolder - } - } + # # Reset answering N and they should remain changed as per the previous changes + # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "N" + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + # } + # } + # AfterEach { + # Remove-Test-Folder $testFolder + # } + # } Context "PushAssetsRepoTests" -Tag "Integration" { BeforeEach { $updatedAssets = $null $testFolder = $null } - It "Should push new, updated and deleted files, original restore from first push of assets." { - if ($env:CLI_TEST_WITH_DOCKER) { - Set-ItResult -Skipped - } - else { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "language/tables" - Tag = "language/tables_fc54d0" - } - $files = @( - "assets.json" - ) - - $originalTagPrefix = $recordingJson.TagPrefix - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # Ensure that the TagPrefix was updated for testing - $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - - # Create a new file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - # Update the version on an existing file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - # Delete a file - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - Remove-Item -Path $fileToRemove - $assetsFile = Join-Path $testFolder "assets.json" - - # Push the changes - $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # Verify that after the push the directory still contains our updated files - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - - $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - $exists | Should -Be $true - } - } - It "Should push new, updated and deleted files, original restore from second push of assets." { - if ($env:CLI_TEST_WITH_DOCKER) { - Set-ItResult -Skipped - } - else { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "language/tables" - Tag = "language/tables_bb2223" - } + # It "Should push new, updated and deleted files, original restore from first push of assets." { + # if ($env:CLI_TEST_WITH_DOCKER) { + # Set-ItResult -Skipped + # } + # else { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "language/tables" + # Tag = "language/tables_fc54d0" + # } + # $files = @( + # "assets.json" + # ) - $files = @( - "assets.json" - ) - $originalTagPrefix = $recordingJson.TagPrefix - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # Ensure that the TagPrefix was updated for testing - $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - - # The initial restore/verification - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - - # Create a new file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 - # Update the version on an existing file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 - # Delete a file - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file5.txt" - Remove-Item -Path $fileToRemove - $assetsFile = Join-Path $testFolder "assets.json" - - # Push the changes - $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # Verify that after the push the directory still contains our updated files - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 - - $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - $exists | Should -Be $true - } - } - It "Should push new, updated and deleted files, original restore from third push of assets." { - if ($env:CLI_TEST_WITH_DOCKER) { - Set-ItResult -Skipped - } - else { - $recordingJson = [PSCustomObject]@{ - AssetsRepo = "Azure/azure-sdk-assets-integration" - AssetsRepoPrefixPath = "pull/scenarios" - AssetsRepoId = "" - TagPrefix = "language/tables" - Tag = "language/tables_9e81fb" - } + # $originalTagPrefix = $recordingJson.TagPrefix + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # # Ensure that the TagPrefix was updated for testing + # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $files = @( - "assets.json" - ) - $originalTagPrefix = $recordingJson.TagPrefix - $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # Ensure that the TagPrefix was updated for testing - $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - $assetsFile = Join-Path $testFolder "assets.json" - $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - - # The initial restore/verification - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - $LASTEXITCODE | Should -Be 0 - $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - - # Create a new file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 - # Update the version on an existing file - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 - # Delete files 3 & 4 - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file3.txt" - Remove-Item -Path $fileToRemove - $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file4.txt" - Remove-Item -Path $fileToRemove - $assetsFile = Join-Path $testFolder "assets.json" - - # Push the changes - $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # Verify that after the push the directory still contains our updated files - Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 - Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 - - $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - $exists | Should -Be $true - } - } + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + + # # Create a new file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + # # Update the version on an existing file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + # # Delete a file + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + # Remove-Item -Path $fileToRemove + # $assetsFile = Join-Path $testFolder "assets.json" + + # # Push the changes + # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # # Verify that after the push the directory still contains our updated files + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + + # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + # $exists | Should -Be $true + # } + # } + # It "Should push new, updated and deleted files, original restore from second push of assets." { + # if ($env:CLI_TEST_WITH_DOCKER) { + # Set-ItResult -Skipped + # } + # else { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "language/tables" + # Tag = "language/tables_bb2223" + # } + + # $files = @( + # "assets.json" + # ) + # $originalTagPrefix = $recordingJson.TagPrefix + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # # Ensure that the TagPrefix was updated for testing + # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + + # # The initial restore/verification + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + + # # Create a new file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 + # # Update the version on an existing file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 + # # Delete a file + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file5.txt" + # Remove-Item -Path $fileToRemove + # $assetsFile = Join-Path $testFolder "assets.json" + + # # Push the changes + # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # # Verify that after the push the directory still contains our updated files + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 + + # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + # $exists | Should -Be $true + # } + # } + # It "Should push new, updated and deleted files, original restore from third push of assets." { + # if ($env:CLI_TEST_WITH_DOCKER) { + # Set-ItResult -Skipped + # } + # else { + # $recordingJson = [PSCustomObject]@{ + # AssetsRepo = "Azure/azure-sdk-assets-integration" + # AssetsRepoPrefixPath = "pull/scenarios" + # AssetsRepoId = "" + # TagPrefix = "language/tables" + # Tag = "language/tables_9e81fb" + # } + + # $files = @( + # "assets.json" + # ) + # $originalTagPrefix = $recordingJson.TagPrefix + # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # # Ensure that the TagPrefix was updated for testing + # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + # $assetsFile = Join-Path $testFolder "assets.json" + # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + + # # The initial restore/verification + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # $LASTEXITCODE | Should -Be 0 + # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + + # # Create a new file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 + # # Update the version on an existing file + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 + # # Delete files 3 & 4 + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file3.txt" + # Remove-Item -Path $fileToRemove + # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file4.txt" + # Remove-Item -Path $fileToRemove + # $assetsFile = Join-Path $testFolder "assets.json" + + # # Push the changes + # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # # Verify that after the push the directory still contains our updated files + # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 + # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 + + # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + # $exists | Should -Be $true + # } + # } It "Should handle pushing an identical SHA twice, and properly update to the necessary tag without error state." { if ($env:CLI_TEST_WITH_DOCKER) { Set-ItResult -Skipped @@ -434,7 +434,7 @@ Describe "AssetsModuleTests" { $newTestFolder = "" try { $testGuid = [Guid]::NewGuid() - $created_tag_prefix = "duplicate_push_test_$testGuid" + $created_tag_prefix = "test_$testGuid" $creationPath = Join-Path "sdk" "keyvault" "azure-keyvault-keys" "tests" "recordings" $file1 = Join-Path $creationPath "file1.txt" $file2 = Join-Path $creationPath "file2.txt" @@ -479,7 +479,12 @@ Describe "AssetsModuleTests" { $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder $LASTEXITCODE | Should -Be 0 - + + Write-Host $newTestFolder + write-Host $testFolder + + Read-Host "after second restore" + # same file updates. we should have an identical sha! Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 diff --git a/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 b/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 index cc90cf84086..83339919c11 100644 --- a/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 +++ b/tools/test-proxy/scripts/test-scripts/assets.Tests.Helpers.ps1 @@ -124,7 +124,7 @@ Function Remove-Integration-Tag { try { Push-Location $tempPath $gitCloneUrl = Get-CloneUrl $Assets.AssetsRepo - Write-Host "git clone $($gitCloneUrl) ." + Write-Host "git clone --filter=blob:none $($gitCloneUrl) ." git clone $($gitCloneUrl) . Write-Host "git push origin --delete $($Assets.Tag)" git push origin --delete $($Assets.Tag) From 7f381378b1101de1dd54e061f1fe3e423cd65581 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 14 Apr 2023 16:13:47 -0700 Subject: [PATCH 7/9] Reducing missing cleanup items --- .../GitStoreIntegrationPushTests.cs | 152 +++++++++--------- .../TestHelpers.cs | 21 ++- 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs index f1f0b44f91f..9205269069b 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs @@ -505,81 +505,81 @@ public async Task Scenario5(string inputJson) } } - ///// - ///// 1. Restore from a tag that has minimal existing files and a long destination path - ///// 2. Add a _bunch_ of files - ///// 3. Push - ///// 4. Verify local files are what is expected - ///// 5. Verify assets.json was updated with the new commit Tag - ///// - ///// - ///// - //[EnvironmentConditionalSkipTheory] - //[InlineData(1000, 0.15)] // 1000 0.15MB files - //[InlineData(150, 0.25)] // 150 0.25MB files - //[InlineData(100, 0.50)] // 100 0.5MB files - //[InlineData(10, 90)] // 10 90MB files - //[Trait("Category", "Integration")] - //public async Task LargePushPerformance(int numberOfFiles, double fileSize) - //{ - // var folderStructure = new string[] - // { - // GitStoretests.AssetsJson - // }; - // Assets assets = JsonSerializer.Deserialize(@"{ - // ""AssetsRepo"": ""Azure/azure-sdk-assets-integration"", - // ""AssetsRepoPrefixPath"": ""python"", - // ""TagPrefix"": ""python/tables"", - // ""Tag"": ""python/tables4f724f0c"" - // }"); - // Assets updatedAssets = null; - // List testFiles = new List(); - // string originalTagPrefix = assets.TagPrefix; - // string originalTag = assets.Tag; - // var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); - - // try - // { - // // Ensure that the TagPrefix was updated - // Assert.NotEqual(originalTagPrefix, assets.TagPrefix); - - // var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); - - // var parsedConfiguration = await _defaultStore.ParseConfigurationFile(jsonFileLocation); - // await _defaultStore.Restore(jsonFileLocation); - - // var assetRepoRoot = await _defaultStore.GetPath(jsonFileLocation); - // var deepPath = Path.Join(assetRepoRoot, "sdk", "tables", "azure-data-tables", "tests", "recordings"); - - // // generate a bunch of files - // for (var i = 0; i < numberOfFiles; i++) - // { - // testFiles.Add(TestHelpers.GenerateRandomFile(fileSize, deepPath)); - // } - - // await _defaultStore.Push(jsonFileLocation); - - // // Verify that after the push the directory still contains our updated files - // Assert.Equal(3 + testFiles.Count, System.IO.Directory.EnumerateFiles(deepPath).Count()); - // foreach (var path in testFiles) - // { - // Assert.True(File.Exists(path)); - // } - - // // Ensure that the config was updated with the new Tag as part of the push - // updatedAssets = TestHelpers.LoadAssetsFromFile(jsonFileLocation); - // Assert.NotEqual(originalTag, updatedAssets.Tag); - - // // Ensure that the targeted tag is present on the repo - // TestHelpers.CheckExistenceOfTag(updatedAssets, assetRepoRoot); - // await TestHelpers.CheckBreadcrumbAgainstAssetsJsons(new string[] { jsonFileLocation }); - // } - // finally - // { - // DirectoryHelper.DeleteGitDirectory(testFolder); - // TestHelpers.CleanupIntegrationTestTag(assets); - // TestHelpers.CleanupIntegrationTestTag(updatedAssets); - // } - //} + /// + /// 1. Restore from a tag that has minimal existing files and a long destination path + /// 2. Add a _bunch_ of files + /// 3. Push + /// 4. Verify local files are what is expected + /// 5. Verify assets.json was updated with the new commit Tag + /// + /// + /// + [EnvironmentConditionalSkipTheory] + [InlineData(1000, 0.15)] // 1000 0.15MB files + [InlineData(150, 0.25)] // 150 0.25MB files + [InlineData(100, 0.50)] // 100 0.5MB files + [InlineData(10, 90)] // 10 90MB files + [Trait("Category", "Integration")] + public async Task LargePushPerformance(int numberOfFiles, double fileSize) + { + var folderStructure = new string[] + { + GitStoretests.AssetsJson + }; + Assets assets = JsonSerializer.Deserialize(@"{ + ""AssetsRepo"": ""Azure/azure-sdk-assets-integration"", + ""AssetsRepoPrefixPath"": ""python"", + ""TagPrefix"": ""python/tables"", + ""Tag"": ""python/tables4f724f0c"" + }"); + Assets updatedAssets = null; + List testFiles = new List(); + string originalTagPrefix = assets.TagPrefix; + string originalTag = assets.Tag; + var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); + + try + { + // Ensure that the TagPrefix was updated + Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + + var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); + + var parsedConfiguration = await _defaultStore.ParseConfigurationFile(jsonFileLocation); + await _defaultStore.Restore(jsonFileLocation); + + var assetRepoRoot = await _defaultStore.GetPath(jsonFileLocation); + var deepPath = Path.Join(assetRepoRoot, "sdk", "tables", "azure-data-tables", "tests", "recordings"); + + // generate a bunch of files + for (var i = 0; i < numberOfFiles; i++) + { + testFiles.Add(TestHelpers.GenerateRandomFile(fileSize, deepPath)); + } + + await _defaultStore.Push(jsonFileLocation); + + // Verify that after the push the directory still contains our updated files + Assert.Equal(3 + testFiles.Count, System.IO.Directory.EnumerateFiles(deepPath).Count()); + foreach (var path in testFiles) + { + Assert.True(File.Exists(path)); + } + + // Ensure that the config was updated with the new Tag as part of the push + updatedAssets = TestHelpers.LoadAssetsFromFile(jsonFileLocation); + Assert.NotEqual(originalTag, updatedAssets.Tag); + + // Ensure that the targeted tag is present on the repo + TestHelpers.CheckExistenceOfTag(updatedAssets, assetRepoRoot); + await TestHelpers.CheckBreadcrumbAgainstAssetsJsons(new string[] { jsonFileLocation }); + } + finally + { + DirectoryHelper.DeleteGitDirectory(testFolder); + TestHelpers.CleanupIntegrationTestTag(assets); + TestHelpers.CleanupIntegrationTestTag(updatedAssets); + } + } } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs index 60d45f4ca56..30347f3bf23 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/TestHelpers.cs @@ -402,8 +402,8 @@ public static async Task CheckBreadcrumbAgainstAssetsJsons(IEnumerable j /// This function is only used by the Push scenarios. It'll clone the assets repository /// /// - /// - public static void InitIntegrationTag(Assets assets, string adjustedAssetsRepoBranch) + /// + public static void InitIntegrationTag(Assets assets, string adjustedAssetsRepoTag) { // generate a test folder root string tmpPath = Path.Join(Path.GetTempPath(), Guid.NewGuid().ToString()); @@ -419,10 +419,10 @@ public static void InitIntegrationTag(Assets assets, string adjustedAssetsRepoBr var gitCloneUrl = GitStore.GetCloneUrl(assets.AssetsRepo, tmpPath); // Clone the original assets repo - GitHandler.Run($"clone {gitCloneUrl} .", tmpPath); + GitHandler.Run($"clone --filter=blob:none {gitCloneUrl} .", tmpPath); - // Check to see if there's already a branch - CommandResult commandResult = GitHandler.Run($"ls-remote --tags {gitCloneUrl} {assets.TagPrefix}", tmpPath); + // Check to see if the tag already exists + CommandResult commandResult = GitHandler.Run($"ls-remote --tags {gitCloneUrl} {assets.Tag}", tmpPath); // If the commandResult response is empty, there's nothing to do and we can return if (!String.IsNullOrWhiteSpace(commandResult.StdOut)) @@ -430,15 +430,14 @@ public static void InitIntegrationTag(Assets assets, string adjustedAssetsRepoBr // If the commandResult response is not empty, the command result will have something // similar to the following: // e4a4949a2b6cc2ff75afd0fe0d97cbcabf7b67b7 refs/heads/scenario_clean_push - GitHandler.Run($"checkout {assets.TagPrefix}", tmpPath); - + GitHandler.Run($"checkout {assets.Tag}", tmpPath); } - // Create the adjustedAssetsRepoBranch from the original branch. The reason being is that pushing + // Create the adjustedAssetsRepoTag from the original branch. The reason being is that pushing // to a branch of a branch is automatic - GitHandler.Run($"tag {adjustedAssetsRepoBranch}", tmpPath); - // Push the contents of the TagPrefix into the adjustedAssetsRepoBranch - GitHandler.Run($"push origin {adjustedAssetsRepoBranch}", tmpPath); + GitHandler.Run($"tag {adjustedAssetsRepoTag}", tmpPath); + // Push the contents of the TagPrefix into the adjustedAssetsRepoTag + GitHandler.Run($"push origin {adjustedAssetsRepoTag}", tmpPath); } finally { From 8b8b7850e1dee1fa47ba9b69bc06691a7bc859f1 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 14 Apr 2023 17:09:52 -0700 Subject: [PATCH 8/9] repair cli integration tests --- .../test-scripts/CLIIntegration.Tests.ps1 | 810 +++++++++--------- 1 file changed, 405 insertions(+), 405 deletions(-) diff --git a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 index a5a6e61aa7d..6a730c902f2 100644 --- a/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 +++ b/tools/test-proxy/scripts/test-scripts/CLIIntegration.Tests.ps1 @@ -20,412 +20,412 @@ BeforeAll { } Describe "AssetsModuleTests" { - # Context "RestoreAssetsRepoTests" -Tag "Integration" { - # BeforeEach { - # $testFolder = $null - # } - # It "Should restore from original push of assets." { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_fc54d0" - # } - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # } - # It "Should restore from second push of assets." { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_9e81fb" - # } - - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # } - # It "Should restore from third push of files." { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_bb2223" - # } - - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - # } - # AfterEach { - # Remove-Test-Folder $testFolder - # } - # } - # Context "ResetAssetsRepoTests" -Tag "Integration" { - # BeforeEach { - # $testFolder = $null - # } - # It "It should call Reset without prompt if no files have changed" { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_fc54d0" - # } - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - - # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # # With no pending changes, the reset should leave everything alone - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # } - # It "It should call Reset and prompt Yes to restore files" { - # # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. - # if ($env:CLI_TEST_WITH_DOCKER) { - # Set-ItResult -Skipped - # } - # else { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_fc54d0" - # } - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + Context "RestoreAssetsRepoTests" -Tag "Integration" { + BeforeEach { + $testFolder = $null + } + It "Should restore from original push of assets." { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "python/tables_fc54d0" + } + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + } + It "Should restore from second push of assets." { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "python/tables_9e81fb" + } + + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + } + It "Should restore from third push of files." { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "language/tables_bb2223" + } + + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + } + AfterEach { + Remove-Test-Folder $testFolder + } + } + Context "ResetAssetsRepoTests" -Tag "Integration" { + BeforeEach { + $testFolder = $null + } + It "It should call Reset without prompt if no files have changed" { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "python/tables_fc54d0" + } + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + + $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + # With no pending changes, the reset should leave everything alone + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + } + It "It should call Reset and prompt Yes to restore files" { + # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "python/tables_fc54d0" + } + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # # Create a new file and verify - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # # Update a file and verify - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # # Delete a file - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - # Remove-Item -Path $fileToRemove + # Create a new file and verify + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + # Update a file and verify + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # Delete a file + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + Remove-Item -Path $fileToRemove - # # Reset answering Y and they should all go back to original restore - # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "Y" - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # } - # } - # It "It should call Reset and prompt No to restore files" { - # # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. - # if ($env:CLI_TEST_WITH_DOCKER) { - # Set-ItResult -Skipped - # } - # else { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "main" - # Tag = "language/tables_fc54d0" - # } - # $files = @( - # "assets.json" - # ) - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + # Reset answering Y and they should all go back to original restore + $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "Y" + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + } + } + It "It should call Reset and prompt No to restore files" { + # Write-Output doesn't cooperate with the docker run. Need to find a different method. Covered in #4374. + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "main" + Tag = "python/tables_fc54d0" + } + $files = @( + "assets.json" + ) + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # # Create two new files and verify - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -Version 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - # # Update a file and verify - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # # Delete a file - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - # Remove-Item -Path $fileToRemove + # Create two new files and verify + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -Version 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + # Update a file and verify + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + # Delete a file + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + Remove-Item -Path $fileToRemove - # # Reset answering N and they should remain changed as per the previous changes - # $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "N" - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - # } - # } - # AfterEach { - # Remove-Test-Folder $testFolder - # } - # } + # Reset answering N and they should remain changed as per the previous changes + $CommandArgs = "reset --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder -WriteOutput "N" + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + } + } + AfterEach { + Remove-Test-Folder $testFolder + } + } Context "PushAssetsRepoTests" -Tag "Integration" { BeforeEach { $updatedAssets = $null $testFolder = $null } - # It "Should push new, updated and deleted files, original restore from first push of assets." { - # if ($env:CLI_TEST_WITH_DOCKER) { - # Set-ItResult -Skipped - # } - # else { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "language/tables" - # Tag = "language/tables_fc54d0" - # } - # $files = @( - # "assets.json" - # ) - - # $originalTagPrefix = $recordingJson.TagPrefix - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # # Ensure that the TagPrefix was updated for testing - # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - - # # Create a new file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 - # # Update the version on an existing file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - # # Delete a file - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" - # Remove-Item -Path $fileToRemove - # $assetsFile = Join-Path $testFolder "assets.json" - - # # Push the changes - # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # # Verify that after the push the directory still contains our updated files - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - - # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - # $exists | Should -Be $true - # } - # } - # It "Should push new, updated and deleted files, original restore from second push of assets." { - # if ($env:CLI_TEST_WITH_DOCKER) { - # Set-ItResult -Skipped - # } - # else { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "language/tables" - # Tag = "language/tables_bb2223" - # } - - # $files = @( - # "assets.json" - # ) - # $originalTagPrefix = $recordingJson.TagPrefix - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # # Ensure that the TagPrefix was updated for testing - # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - - # # The initial restore/verification - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 - - # # Create a new file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 - # # Update the version on an existing file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 - # # Delete a file - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file5.txt" - # Remove-Item -Path $fileToRemove - # $assetsFile = Join-Path $testFolder "assets.json" - - # # Push the changes - # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # # Verify that after the push the directory still contains our updated files - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 - - # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - # $exists | Should -Be $true - # } - # } - # It "Should push new, updated and deleted files, original restore from third push of assets." { - # if ($env:CLI_TEST_WITH_DOCKER) { - # Set-ItResult -Skipped - # } - # else { - # $recordingJson = [PSCustomObject]@{ - # AssetsRepo = "Azure/azure-sdk-assets-integration" - # AssetsRepoPrefixPath = "pull/scenarios" - # AssetsRepoId = "" - # TagPrefix = "language/tables" - # Tag = "language/tables_9e81fb" - # } - - # $files = @( - # "assets.json" - # ) - # $originalTagPrefix = $recordingJson.TagPrefix - # $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true - # # Ensure that the TagPrefix was updated for testing - # $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix - # $assetsFile = Join-Path $testFolder "assets.json" - # $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) - # $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" - - # # The initial restore/verification - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - # $LASTEXITCODE | Should -Be 0 - # $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 - - # # Create a new file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 - # # Update the version on an existing file - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 - # Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 - # # Delete files 3 & 4 - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file3.txt" - # Remove-Item -Path $fileToRemove - # $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file4.txt" - # Remove-Item -Path $fileToRemove - # $assetsFile = Join-Path $testFolder "assets.json" - - # # Push the changes - # $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" - # Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder - - # # Verify that after the push the directory still contains our updated files - # Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 - # Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 - - # $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile - # Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" - # $updatedAssets.Tag | Should -not -Be $recordingJson.Tag - - # $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath - # $exists | Should -Be $true - # } - # } + It "Should push new, updated and deleted files, original restore from first push of assets." { + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "language/tables" + Tag = "python/tables_fc54d0" + } + $files = @( + "assets.json" + ) + + $originalTagPrefix = $recordingJson.TagPrefix + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # Ensure that the TagPrefix was updated for testing + $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + + # Create a new file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -Version 1 + # Update the version on an existing file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + # Delete a file + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file2.txt" + Remove-Item -Path $fileToRemove + $assetsFile = Join-Path $testFolder "assets.json" + + # Push the changes + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # Verify that after the push the directory still contains our updated files + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + + $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + $exists | Should -Be $true + } + } + It "Should push new, updated and deleted files, original restore from second push of assets." { + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "language/tables" + Tag = "language/tables_bb2223" + } + + $files = @( + "assets.json" + ) + $originalTagPrefix = $recordingJson.TagPrefix + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # Ensure that the TagPrefix was updated for testing + $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + + # The initial restore/verification + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file5.txt" -ExpectedVersion 1 + + # Create a new file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 + # Update the version on an existing file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 + # Delete a file + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file5.txt" + Remove-Item -Path $fileToRemove + $assetsFile = Join-Path $testFolder "assets.json" + + # Push the changes + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # Verify that after the push the directory still contains our updated files + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 + + $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + $exists | Should -Be $true + } + } + It "Should push new, updated and deleted files, original restore from third push of assets." { + if ($env:CLI_TEST_WITH_DOCKER) { + Set-ItResult -Skipped + } + else { + $recordingJson = [PSCustomObject]@{ + AssetsRepo = "Azure/azure-sdk-assets-integration" + AssetsRepoPrefixPath = "pull/scenarios" + AssetsRepoId = "" + TagPrefix = "language/tables" + Tag = "python/tables_9e81fb" + } + + $files = @( + "assets.json" + ) + $originalTagPrefix = $recordingJson.TagPrefix + $testFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $true + # Ensure that the TagPrefix was updated for testing + $originalTagPrefix | Should -not -Be $recordingJson.TagPrefix + $assetsFile = Join-Path $testFolder "assets.json" + $assetsJsonRelativePath = [System.IO.Path]::GetRelativePath($testFolder, $assetsFile) + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" + + # The initial restore/verification + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + $LASTEXITCODE | Should -Be 0 + $localAssetsFilePath = Get-AssetsFilePath -AssetsJsonContent $recordingJson -AssetsJsonFile $assetsFile + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 4 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 1 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file3.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file4.txt" -ExpectedVersion 1 + + # Create a new file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -Version 1 + # Update the version on an existing file + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -Version 2 + Edit-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -Version 3 + # Delete files 3 & 4 + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file3.txt" + Remove-Item -Path $fileToRemove + $fileToRemove = Join-Path -Path $localAssetsFilePath -ChildPath "file4.txt" + Remove-Item -Path $fileToRemove + $assetsFile = Join-Path $testFolder "assets.json" + + # Push the changes + $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" + Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder + + # Verify that after the push the directory still contains our updated files + Test-DirectoryFileCount -Directory $localAssetsFilePath -ExpectedNumberOfFiles 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file1.txt" -ExpectedVersion 2 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file2.txt" -ExpectedVersion 3 + Test-FileVersion -FilePath $localAssetsFilePath -FileName "file6.txt" -ExpectedVersion 1 + + $updatedAssets = Update-AssetsFromFile -AssetsJsonContent $assetsFile + Write-Host "updatedAssets.Tag=$($updatedAssets.Tag), originalAssets.Tag=$($recordingJson.Tag)" + $updatedAssets.Tag | Should -not -Be $recordingJson.Tag + + $exists = Test-TagExists -AssetsJsonContent $updatedAssets -WorkingDirectory $localAssetsFilePath + $exists | Should -Be $true + } + } It "Should handle pushing an identical SHA twice, and properly update to the necessary tag without error state." { if ($env:CLI_TEST_WITH_DOCKER) { Set-ItResult -Skipped @@ -471,24 +471,24 @@ Describe "AssetsModuleTests" { $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $testFolder $LASTEXITCODE | Should -Be 0 - + # now, let's describe an _entirely different_ assets folder, attempt the same push. # this should result in the SAME tag twice in the assets repo, and we should properly NOT do the full push action $newTestFolder = Describe-TestFolder -AssetsJsonContent $recordingJson -Files $files -IsPushTest $false $newAssetsFile = Join-Path $newTestFolder $assetsJsonRelativePath + $CommandArgs = "restore --assets-json-path $assetsJsonRelativePath" Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder $LASTEXITCODE | Should -Be 0 - Write-Host $newTestFolder - write-Host $testFolder - - Read-Host "after second restore" + $newlocalAssetsFilePath = Join-Path $newTestFolder ".assets" + $newAssetsFolder = $(Get-ChildItem $newlocalAssetsFilePath -Directory)[0].FullName + mkdir -p $(Join-Path $newAssetsFolder $creationPath) # same file updates. we should have an identical sha! - Edit-FileVersion -FilePath $assetsFolder -FileName $file1 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file2 -Version 1 - Edit-FileVersion -FilePath $assetsFolder -FileName $file3 -Version 1 + Edit-FileVersion -FilePath $newAssetsFolder -FileName $file1 -Version 1 + Edit-FileVersion -FilePath $newAssetsFolder -FileName $file2 -Version 1 + Edit-FileVersion -FilePath $newAssetsFolder -FileName $file3 -Version 1 $CommandArgs = "push --assets-json-path $assetsJsonRelativePath" Invoke-ProxyCommand -TestProxyExe $TestProxyExe -CommandArgs $CommandArgs -MountDirectory $newTestFolder From d29c27022b7d09a77a3c9a7e1abde6dffc63c3ae Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 17 Apr 2023 11:18:26 -0700 Subject: [PATCH 9/9] repair the tests to account for the newly updated test helpers --- .../GitStoreIntegrationPushTests.cs | 26 +++++++++---------- .../GitStoreIntegrationResetTests.cs | 18 ++++++------- .../GitStoreIntegrationRestoreTests.cs | 8 +++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs index 9205269069b..c829abf5e2f 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationPushTests.cs @@ -42,7 +42,7 @@ public GitStoreIntegrationPushTests() ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""language/tables"", - ""Tag"": ""language/tables_fc54d0"" + ""Tag"": ""python/tables_fc54d0"" }")] [Trait("Category", "Integration")] public async Task Scenario1(string inputJson) @@ -59,8 +59,8 @@ public async Task Scenario1(string inputJson) var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest:true); try { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + // Ensure that the Tag was updated + Assert.NotEqual(originalTag, assets.TagPrefix); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); @@ -142,8 +142,8 @@ public async Task Scenario2(string inputJson) var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); try { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + // Ensure that the Tag was updated + Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); @@ -209,7 +209,7 @@ public async Task Scenario2(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""language/tables"", - ""Tag"": ""language/tables_9e81fb"" + ""Tag"": ""python/tables_9e81fb"" }")] [Trait("Category", "Integration")] public async Task Scenario3(string inputJson) @@ -225,8 +225,8 @@ public async Task Scenario3(string inputJson) var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); try { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + // Ensure that the Tag was updated + Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); @@ -319,8 +319,8 @@ public async Task Scenario4(string inputJson) var testFolder = TestHelpers.DescribeTestFolder(assets, folderStructure, isPushTest: true); try { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + // Ensure that the Tag was updated + Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); @@ -409,7 +409,7 @@ public async Task Scenario5(string inputJson) var testFolder2 = TestHelpers.DescribeTestFolder(assets, folderStructure); try { - // Ensure that the TagPrefix was updated + // Ensure that the Tag was updated Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); @@ -540,8 +540,8 @@ public async Task LargePushPerformance(int numberOfFiles, double fileSize) try { - // Ensure that the TagPrefix was updated - Assert.NotEqual(originalTagPrefix, assets.TagPrefix); + // Ensure that the Tag was updated + Assert.NotEqual(originalTag, assets.Tag); var jsonFileLocation = Path.Join(testFolder, GitStoretests.AssetsJson); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationResetTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationResetTests.cs index 7aee6f2ef2b..799fc2ea575 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationResetTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationResetTests.cs @@ -37,7 +37,7 @@ public GitStoreIntegrationResetTests() } // Scenario 1 - Changes to existing files only are detected and overridden with Reset response Y - // 1. Restore from Tag language/tables_fc54d0 + // 1. Restore from Tag python/tables_fc54d0 // 2. Expect: 3 files with versions they were checked in with // 3. Update one or more files, incrementing their version // 4. Expect: files updated should be at version 2 @@ -50,7 +50,7 @@ public GitStoreIntegrationResetTests() ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_fc54d0"" + ""Tag"": ""python/tables_fc54d0"" }")] [Trait("Category", "Integration")] public async Task Scenario1(string inputJson) @@ -101,7 +101,7 @@ public async Task Scenario1(string inputJson) } // Scenario 2 - Changes to existing files only are detected and retained with Reset response N - // 1. Restore from Tag language/tables_fc54d0 + // 1. Restore from Tag python/tables_fc54d0 // 2. Expect: 3 files with versions they were checked in with // 3. Update one or more files, incrementing their version // 4. Expect: files updated should be at version 2 @@ -114,7 +114,7 @@ public async Task Scenario1(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_fc54d0"" + ""Tag"": ""python/tables_fc54d0"" }")] [Trait("Category", "Integration")] public async Task Scenario2(string inputJson) @@ -168,7 +168,7 @@ public async Task Scenario2(string inputJson) } // Scenario 3 - Restore from Tag, add and remove files, Reset response Y - // 1. Restore from Tag language/tables_9e81fb + // 1. Restore from Tag python/tables_9e81fb // 2. Expect: 4 files with versions they were checked in with // 3. Update add/remove files // 4. Expect: Untouched files are the same versions as step 2, added files are version 1, removed files are gone @@ -181,7 +181,7 @@ public async Task Scenario2(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_9e81fb"" + ""Tag"": ""python/tables_9e81fb"" }")] [Trait("Category", "Integration")] public async Task Scenario3(string inputJson) @@ -244,7 +244,7 @@ public async Task Scenario3(string inputJson) } // Scenario 4 - Restore from Tag, add and remove files, Reset response N - // 1. Restore from Tag language/tables_9e81fb + // 1. Restore from Tag python/tables_9e81fb // 2. Expect: 4 files with versions they were checked in with // 3. Update add/remove files // 4. Expect: Untouched files are the same versions as step 2, added files are version 1, removed files are gone @@ -257,7 +257,7 @@ public async Task Scenario3(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_9e81fb"" + ""Tag"": ""python/tables_9e81fb"" }")] [Trait("Category", "Integration")] public async Task Scenario4(string inputJson) @@ -319,7 +319,7 @@ public async Task Scenario4(string inputJson) } // Scenario 5 - Restore from Tag, add and remove files, Reset response N, then Reset response Y - // 1. Restore from Tag language/tables_9e81fb + // 1. Restore from Tag python/tables_9e81fb // 2. Expect: 3 files with versions they were checked in with // 3. Update add/remove files // 4. Expect: Untouched files are the same versions as step 2, added files are version 1, removed files are gone diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationRestoreTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationRestoreTests.cs index fd54cbcadba..b274977abce 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationRestoreTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/IntegrationTests/GitStoreIntegrationRestoreTests.cs @@ -34,7 +34,7 @@ public GitStoreIntegrationRestoreTests() private GitStore _defaultStore = new GitStore(); // Scenario1 - // Tag language/tables_fc54d0 + // Tag python/tables_fc54d0 // This was the initial push of the test files: // Added file1.txt // Added file2.txt @@ -47,7 +47,7 @@ public GitStoreIntegrationRestoreTests() ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_fc54d0"" + ""Tag"": ""python/tables_fc54d0"" }")] [Trait("Category", "Integration")] public async Task Scenario1(string inputJson) @@ -85,7 +85,7 @@ public async Task Scenario1(string inputJson) // Scenario2 - // Tag language/tables_9e81fb + // Tag python/tables_9e81fb // This was the second push of the test files. // Unchanged file1.txt // Updated file2.txt @@ -102,7 +102,7 @@ public async Task Scenario1(string inputJson) ""AssetsRepoPrefixPath"": ""pull/scenarios"", ""AssetsRepoId"": """", ""TagPrefix"": ""main"", - ""Tag"": ""language/tables_9e81fb"" + ""Tag"": ""python/tables_9e81fb"" }")] [Trait("Category", "Integration")] public async Task Scenario2(string inputJson)