From 6e1b3e30204d7f86b259711b8d22f994680f1442 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 08:20:58 -0800 Subject: [PATCH 01/23] Going to just do a full migrate command for the multipart repo --- .../BbsToGithub.cs | 31 ++++++++++++++++++- .../TestHelper.cs | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index dc54136d0..fac8b848b 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -141,6 +141,35 @@ await _targetHelper.RunBbsCliMigration( // TODO: Assert migration logs are downloaded } + [Fact] + public async Task MigrateRepo_MultipartUpload() + { + var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; + var bbsProjectKey = $"IN"; + var bbsRepo = "100_cli"; + var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; + var targetRepo = $"{bbsProjectKey}-e2e-{Guid.NewGuid()}"; + var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; + var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); + await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); + + + var retryPolicy = new RetryPolicy(null); + await retryPolicy.Retry(async () => + { + await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + }); + + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo}{archiveDownloadOptions} --use-github-storage"; + + await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); + + _targetHelper.AssertNoErrorInLogs(_startTime); + + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); + } + private string GetSshKeyName(string bbsServer) { var bbsVersion = Regex.Match(bbsServer, @"e2e-bbs-(\d{1,2}-\d{1,2}-\d{1,2})").Groups[1].Value.Replace('-', '_'); @@ -153,4 +182,4 @@ public void Dispose() _targetGithubHttpClient?.Dispose(); _versionClient?.Dispose(); } -} +} \ No newline at end of file diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index 040b2ee72..5776a7627 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -547,6 +547,8 @@ public async Task RunPowershellScript(string script, IDictionary public async Task RunCliCommand(string command, string cliName, IDictionary tokens) => await RunShellCommand(command, cliName, GetOsDistPath(), tokens); + public async Task RunBbsMigrateRepoCommand(string migrateRepoCommand, IDictionary tokens) => + await RunCliMigration(migrateRepoCommand, "bbs2gh", tokens); private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary environmentVariables = null) { var startInfo = new ProcessStartInfo From ccf741dc9212ca1b5e21a21276039eba0918a614 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 08:31:03 -0800 Subject: [PATCH 02/23] testing only my one integration test --- .../AdoBasicToGithub.cs | 138 +++++++++--------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs index aef851c4d..eca627e95 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs @@ -1,78 +1,78 @@ -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; +// using System.Threading.Tasks; +// using Xunit; +// using Xunit.Abstractions; -namespace OctoshiftCLI.IntegrationTests -{ - [Collection("Integration Tests")] - public class AdoBasicToGithub : AdoToGithub - { - public AdoBasicToGithub(ITestOutputHelper output) : base(output) - { - } +// namespace OctoshiftCLI.IntegrationTests +// { +// [Collection("Integration Tests")] +// public class AdoBasicToGithub : AdoToGithub +// { +// public AdoBasicToGithub(ITestOutputHelper output) : base(output) +// { +// } - [Fact] - public async Task Basic() - { - var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; - var githubOrg = $"octoshift-e2e-ado-basic-{TestHelper.GetOsName()}-2"; - var teamProject1 = "gei-e2e-1"; - var teamProject2 = "gei-e2e-2"; - var adoRepo1 = teamProject1; - var adoRepo2 = teamProject2; - var pipeline1 = "pipeline1"; - var pipeline2 = "pipeline2"; +// [Fact] +// public async Task Basic() +// { +// var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; +// var githubOrg = $"octoshift-e2e-ado-basic-{TestHelper.GetOsName()}-2"; +// var teamProject1 = "gei-e2e-1"; +// var teamProject2 = "gei-e2e-2"; +// var adoRepo1 = teamProject1; +// var adoRepo2 = teamProject2; +// var pipeline1 = "pipeline1"; +// var pipeline2 = "pipeline2"; - var retryPolicy = new RetryPolicy(null); +// var retryPolicy = new RetryPolicy(null); - await retryPolicy.Retry(async () => - { - await Helper.ResetAdoTestEnvironment(adoOrg); - await Helper.ResetGithubTestEnvironment(githubOrg); +// await retryPolicy.Retry(async () => +// { +// await Helper.ResetAdoTestEnvironment(adoOrg); +// await Helper.ResetGithubTestEnvironment(githubOrg); - await Helper.CreateTeamProject(adoOrg, teamProject1); - var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); - await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); +// await Helper.CreateTeamProject(adoOrg, teamProject1); +// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); +// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); - await Helper.CreateTeamProject(adoOrg, teamProject2); - commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); - await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); - }); +// await Helper.CreateTeamProject(adoOrg, teamProject2); +// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); +// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); +// }); - await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all", Tokens); +// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all", Tokens); - Helper.AssertNoErrorInLogs(StartTime); +// Helper.AssertNoErrorInLogs(StartTime); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); - await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); - await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); - await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); - await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); - await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); - await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); - await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); - await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); - await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); - } - } -} +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); +// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); +// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); +// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); +// await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); +// await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); +// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); +// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); +// await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); +// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// } +// } +// } From b17afbc6894b8ea16d7af8e0fa27fed8afcce36b Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 08:31:38 -0800 Subject: [PATCH 03/23] testing only my one integration test --- .../AdoCsvToGithub.cs | 140 +++++----- .../AdoServerToGithub.cs | 116 ++++----- .../AdoToGithub.cs | 120 ++++----- .../BbsToGithub.cs | 148 +++++------ .../GhesToGithub.cs | 246 +++++++++--------- .../GithubToGithub.cs | 190 +++++++------- 6 files changed, 480 insertions(+), 480 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs index d389fec2e..e795e1f9d 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs @@ -1,79 +1,79 @@ -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; +// using System.Threading.Tasks; +// using Xunit; +// using Xunit.Abstractions; -namespace OctoshiftCLI.IntegrationTests -{ - [Collection("Integration Tests")] - public class AdoCsvToGithub : AdoToGithub - { - public AdoCsvToGithub(ITestOutputHelper output) : base(output) - { - } +// namespace OctoshiftCLI.IntegrationTests +// { +// [Collection("Integration Tests")] +// public class AdoCsvToGithub : AdoToGithub +// { +// public AdoCsvToGithub(ITestOutputHelper output) : base(output) +// { +// } - [Fact] - public async Task With_Inventory_Report_Csv() - { - var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; - var githubOrg = $"octoshift-e2e-ado-csv-{TestHelper.GetOsName()}"; - var teamProject1 = "gei-e2e-1"; - var teamProject2 = "gei-e2e-2"; - var adoRepo1 = teamProject1; - var adoRepo2 = teamProject2; - var pipeline1 = "pipeline1"; - var pipeline2 = "pipeline2"; +// [Fact] +// public async Task With_Inventory_Report_Csv() +// { +// var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; +// var githubOrg = $"octoshift-e2e-ado-csv-{TestHelper.GetOsName()}"; +// var teamProject1 = "gei-e2e-1"; +// var teamProject2 = "gei-e2e-2"; +// var adoRepo1 = teamProject1; +// var adoRepo2 = teamProject2; +// var pipeline1 = "pipeline1"; +// var pipeline2 = "pipeline2"; - var retryPolicy = new RetryPolicy(null); +// var retryPolicy = new RetryPolicy(null); - await retryPolicy.Retry(async () => - { - await Helper.ResetAdoTestEnvironment(adoOrg); - await Helper.ResetGithubTestEnvironment(githubOrg); +// await retryPolicy.Retry(async () => +// { +// await Helper.ResetAdoTestEnvironment(adoOrg); +// await Helper.ResetGithubTestEnvironment(githubOrg); - await Helper.CreateTeamProject(adoOrg, teamProject1); - var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); - await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); +// await Helper.CreateTeamProject(adoOrg, teamProject1); +// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); +// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); - await Helper.CreateTeamProject(adoOrg, teamProject2); - commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); - await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); - }); +// await Helper.CreateTeamProject(adoOrg, teamProject2); +// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); +// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); +// }); - await Helper.RunCliCommand($"ado2gh inventory-report --ado-org {adoOrg}", "gh", Tokens); - await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all --repo-list repos.csv", Tokens); +// await Helper.RunCliCommand($"ado2gh inventory-report --ado-org {adoOrg}", "gh", Tokens); +// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all --repo-list repos.csv", Tokens); - Helper.AssertNoErrorInLogs(StartTime); +// Helper.AssertNoErrorInLogs(StartTime); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); - await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); - await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); - await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); - await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); - await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); - await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); - await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); - await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); - await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); - } - } -} +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); +// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); +// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); +// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); +// await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); +// await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); +// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); +// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); +// await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); +// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// } +// } +// } diff --git a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs index c57689a91..2aa70ed1a 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs @@ -1,68 +1,68 @@ -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; +// using System.Threading.Tasks; +// using Xunit; +// using Xunit.Abstractions; -namespace OctoshiftCLI.IntegrationTests -{ - [Collection("Integration Tests")] - public class AdoServerToGithub : AdoToGithub - { - private const string ADO_SERVER_URL = "http://octoshift-ado-server-2022.eastus.cloudapp.azure.com/"; +// namespace OctoshiftCLI.IntegrationTests +// { +// [Collection("Integration Tests")] +// public class AdoServerToGithub : AdoToGithub +// { +// private const string ADO_SERVER_URL = "http://octoshift-ado-server-2022.eastus.cloudapp.azure.com/"; - public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL, "ADO_SERVER_PAT") - { - } +// public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL, "ADO_SERVER_PAT") +// { +// } - [Fact(Skip = "ADO Server is not a supported feature in GEI")] - public async Task Basic() - { - var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; - var githubOrg = $"octoshift-e2e-ado-server-{TestHelper.GetOsName()}"; - var teamProject1 = "gei-e2e-1"; - var teamProject2 = "gei-e2e-2"; - var adoRepo1 = teamProject1; - var adoRepo2 = teamProject2; - var pipeline1 = "pipeline1"; - var pipeline2 = "pipeline2"; +// [Fact(Skip = "ADO Server is not a supported feature in GEI")] +// public async Task Basic() +// { +// var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; +// var githubOrg = $"octoshift-e2e-ado-server-{TestHelper.GetOsName()}"; +// var teamProject1 = "gei-e2e-1"; +// var teamProject2 = "gei-e2e-2"; +// var adoRepo1 = teamProject1; +// var adoRepo2 = teamProject2; +// var pipeline1 = "pipeline1"; +// var pipeline2 = "pipeline2"; - var retryPolicy = new RetryPolicy(null); +// var retryPolicy = new RetryPolicy(null); - await retryPolicy.Retry(async () => - { - await Helper.ResetAdoTestEnvironment(adoOrg, ADO_SERVER_URL); - await Helper.ResetGithubTestEnvironment(githubOrg); +// await retryPolicy.Retry(async () => +// { +// await Helper.ResetAdoTestEnvironment(adoOrg, ADO_SERVER_URL); +// await Helper.ResetGithubTestEnvironment(githubOrg); - await Helper.CreateTeamProject(adoOrg, teamProject1, ADO_SERVER_URL); - var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1, ADO_SERVER_URL); - await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId, ADO_SERVER_URL); +// await Helper.CreateTeamProject(adoOrg, teamProject1, ADO_SERVER_URL); +// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1, ADO_SERVER_URL); +// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId, ADO_SERVER_URL); - await Helper.CreateTeamProject(adoOrg, teamProject2, ADO_SERVER_URL); - commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2, ADO_SERVER_URL); - await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId, ADO_SERVER_URL); - }); +// await Helper.CreateTeamProject(adoOrg, teamProject2, ADO_SERVER_URL); +// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2, ADO_SERVER_URL); +// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId, ADO_SERVER_URL); +// }); - await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --ado-server-url {ADO_SERVER_URL} --download-migration-logs --create-teams --link-idp-groups", Tokens); +// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --ado-server-url {ADO_SERVER_URL} --download-migration-logs --create-teams --link-idp-groups", Tokens); - Helper.AssertNoErrorInLogs(StartTime); +// Helper.AssertNoErrorInLogs(StartTime); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); - await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); - await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); - await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); - Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); - } - } -} +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); +// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); +// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); +// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); +// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); +// } +// } +// } diff --git a/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs index 09743b34f..512e52c6c 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using OctoshiftCLI.Services; -using Xunit.Abstractions; +// using System; +// using System.Collections.Generic; +// using System.Net.Http; +// using OctoshiftCLI.Services; +// using Xunit.Abstractions; -namespace OctoshiftCLI.IntegrationTests -{ - public abstract class AdoToGithub : IDisposable - { - private readonly ITestOutputHelper _output; - private readonly HttpClient _adoHttpClient; - private readonly HttpClient _githubHttpClient; - private readonly HttpClient _versionClient; - private bool disposedValue; +// namespace OctoshiftCLI.IntegrationTests +// { +// public abstract class AdoToGithub : IDisposable +// { +// private readonly ITestOutputHelper _output; +// private readonly HttpClient _adoHttpClient; +// private readonly HttpClient _githubHttpClient; +// private readonly HttpClient _versionClient; +// private bool disposedValue; - protected TestHelper Helper { get; } - protected Dictionary Tokens { get; } - protected DateTime StartTime { get; } +// protected TestHelper Helper { get; } +// protected Dictionary Tokens { get; } +// protected DateTime StartTime { get; } - protected AdoToGithub(ITestOutputHelper output, string adoServerUrl = "https://dev.azure.com", string adoPatEnvVar = "ADO_PAT") - { - StartTime = DateTime.Now; - _output = output; +// protected AdoToGithub(ITestOutputHelper output, string adoServerUrl = "https://dev.azure.com", string adoPatEnvVar = "ADO_PAT") +// { +// StartTime = DateTime.Now; +// _output = output; - var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); +// var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); - _versionClient = new HttpClient(); - var adoToken = Environment.GetEnvironmentVariable(adoPatEnvVar); - _adoHttpClient = new HttpClient(); - var retryPolicy = new RetryPolicy(logger); - var adoClient = new AdoClient(logger, _adoHttpClient, new VersionChecker(_versionClient, logger), retryPolicy, adoToken); - var adoApi = new AdoApi(adoClient, adoServerUrl, logger); +// _versionClient = new HttpClient(); +// var adoToken = Environment.GetEnvironmentVariable(adoPatEnvVar); +// _adoHttpClient = new HttpClient(); +// var retryPolicy = new RetryPolicy(logger); +// var adoClient = new AdoClient(logger, _adoHttpClient, new VersionChecker(_versionClient, logger), retryPolicy, adoToken); +// var adoApi = new AdoApi(adoClient, adoServerUrl, logger); - var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); - _githubHttpClient = new HttpClient(); - var githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); - var githubApi = new GithubApi(githubClient, "https://api.github.com", new RetryPolicy(logger), null); +// var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); +// _githubHttpClient = new HttpClient(); +// var githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); +// var githubApi = new GithubApi(githubClient, "https://api.github.com", new RetryPolicy(logger), null); - Tokens = new Dictionary - { - ["GH_PAT"] = githubToken, - ["ADO_PAT"] = adoToken - }; +// Tokens = new Dictionary +// { +// ["GH_PAT"] = githubToken, +// ["ADO_PAT"] = adoToken +// }; - Helper = new TestHelper(_output, adoApi, githubApi, adoClient, githubClient); - } +// Helper = new TestHelper(_output, adoApi, githubApi, adoClient, githubClient); +// } - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - _adoHttpClient.Dispose(); - _githubHttpClient.Dispose(); - _versionClient.Dispose(); - } +// protected virtual void Dispose(bool disposing) +// { +// if (!disposedValue) +// { +// if (disposing) +// { +// _adoHttpClient.Dispose(); +// _githubHttpClient.Dispose(); +// _versionClient.Dispose(); +// } - disposedValue = true; - } - } +// disposedValue = true; +// } +// } - public void Dispose() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - } -} +// public void Dispose() +// { +// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method +// Dispose(disposing: true); +// GC.SuppressFinalize(this); +// } +// } +// } diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index fac8b848b..44135f54e 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -67,79 +67,79 @@ public BbsToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - [Theory] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] - [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] - public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) - { - var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; - var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; - var repo1 = $"{bbsProjectKey}-repo-1"; - var repo2 = $"{bbsProjectKey}-repo-2"; - var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1"; - var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2"; - - var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger); - var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer); - - var retryPolicy = new RetryPolicy(null); - - await retryPolicy.Retry(async () => - { - await _targetHelper.ResetBlobContainers(); - await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey); - await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - - await sourceHelper.CreateBbsProject(bbsProjectKey); - await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1); - await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1); - await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2); - await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2); - }); - - var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; - if (useSshForArchiveDownload) - { - var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); - await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); - } - else - { - archiveDownloadOptions = " --smb-user octoshift"; - _tokens.Add("SMB_PASSWORD", Environment.GetEnvironmentVariable("SMB_PASSWORD")); - } - - var archiveUploadOptions = ""; - if (uploadOption == ArchiveUploadOption.AzureStorage) - { - _tokens.Add("AZURE_STORAGE_CONNECTION_STRING", _azureStorageConnectionString); - } - else if (uploadOption == ArchiveUploadOption.AwsS3) - { - _tokens.Add("AWS_ACCESS_KEY_ID", Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID")); - _tokens.Add("AWS_SECRET_ACCESS_KEY", Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY")); - var awsBucketName = Environment.GetEnvironmentVariable("AWS_BUCKET_NAME"); - archiveUploadOptions = $" --aws-bucket-name {awsBucketName} --aws-region {AWS_REGION}"; - } - else if (uploadOption == ArchiveUploadOption.GithubStorage) - { - archiveUploadOptions = " --use-github-storage"; - } - - await _targetHelper.RunBbsCliMigration( - $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey}{archiveDownloadOptions}{archiveUploadOptions}", _tokens); - - _targetHelper.AssertNoErrorInLogs(_startTime); - - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); - - // TODO: Assert migration logs are downloaded - } + // [Theory] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] + // [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] + // public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) + // { + // var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; + // var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; + // var repo1 = $"{bbsProjectKey}-repo-1"; + // var repo2 = $"{bbsProjectKey}-repo-2"; + // var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1"; + // var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2"; + + // var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger); + // var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer); + + // var retryPolicy = new RetryPolicy(null); + + // await retryPolicy.Retry(async () => + // { + // await _targetHelper.ResetBlobContainers(); + // await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey); + // await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + + // await sourceHelper.CreateBbsProject(bbsProjectKey); + // await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1); + // await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1); + // await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2); + // await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2); + // }); + + // var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; + // if (useSshForArchiveDownload) + // { + // var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); + // await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); + // } + // else + // { + // archiveDownloadOptions = " --smb-user octoshift"; + // _tokens.Add("SMB_PASSWORD", Environment.GetEnvironmentVariable("SMB_PASSWORD")); + // } + + // var archiveUploadOptions = ""; + // if (uploadOption == ArchiveUploadOption.AzureStorage) + // { + // _tokens.Add("AZURE_STORAGE_CONNECTION_STRING", _azureStorageConnectionString); + // } + // else if (uploadOption == ArchiveUploadOption.AwsS3) + // { + // _tokens.Add("AWS_ACCESS_KEY_ID", Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID")); + // _tokens.Add("AWS_SECRET_ACCESS_KEY", Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY")); + // var awsBucketName = Environment.GetEnvironmentVariable("AWS_BUCKET_NAME"); + // archiveUploadOptions = $" --aws-bucket-name {awsBucketName} --aws-region {AWS_REGION}"; + // } + // else if (uploadOption == ArchiveUploadOption.GithubStorage) + // { + // archiveUploadOptions = " --use-github-storage"; + // } + + // await _targetHelper.RunBbsCliMigration( + // $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey}{archiveDownloadOptions}{archiveUploadOptions}", _tokens); + + // _targetHelper.AssertNoErrorInLogs(_startTime); + + // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); + // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); + // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); + // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); + + // // TODO: Assert migration logs are downloaded + // } [Fact] public async Task MigrateRepo_MultipartUpload() @@ -182,4 +182,4 @@ public void Dispose() _targetGithubHttpClient?.Dispose(); _versionClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs index 948fa83da..75686d320 100644 --- a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs @@ -1,123 +1,123 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Azure.Storage.Blobs; -using OctoshiftCLI.Services; -using Xunit; -using Xunit.Abstractions; - -namespace OctoshiftCLI.IntegrationTests; - -[Collection("Integration Tests")] -public sealed class GhesToGithub : IDisposable -{ - private const string GHES_API_URL = "https://octoshift-ghe.westus2.cloudapp.azure.com/api/v3"; - - private readonly ITestOutputHelper _output; - private readonly TestHelper _targetHelper; - private readonly TestHelper _sourceHelper; - private readonly HttpClient _versionClient; - private readonly HttpClient _targetGithubHttpClient; - private readonly GithubClient _targetGithubClient; - private readonly GithubApi _targetGithubApi; - private readonly HttpClient _sourceGithubHttpClient; - private readonly GithubClient _sourceGithubClient; - private readonly GithubApi _sourceGithubApi; - private readonly BlobServiceClient _blobServiceClient; - private readonly Dictionary _tokens; - private readonly DateTime _startTime; - private readonly ArchiveUploader _archiveUploader; - private readonly string _azureStorageConnectionString; - - public GhesToGithub(ITestOutputHelper output) - { - _startTime = DateTime.Now; - _output = output; - - var logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { }); - - var sourceGithubToken = Environment.GetEnvironmentVariable("GHES_PAT"); - var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); - _azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_GHES_{TestHelper.GetOsName().ToUpper()}"); - _tokens = new Dictionary - { - ["GH_SOURCE_PAT"] = sourceGithubToken, - ["GH_PAT"] = targetGithubToken, - }; - - _versionClient = new HttpClient(); - _archiveUploader = new ArchiveUploader(_targetGithubClient, logger); - - _sourceGithubHttpClient = new HttpClient(); - _sourceGithubClient = new GithubClient(logger, _sourceGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), sourceGithubToken); - _sourceGithubApi = new GithubApi(_sourceGithubClient, GHES_API_URL, new RetryPolicy(logger), _archiveUploader); - - _targetGithubHttpClient = new HttpClient(); - _targetGithubClient = new GithubClient(logger, _targetGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), targetGithubToken); - _targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(logger), _archiveUploader); - - _blobServiceClient = new BlobServiceClient(_azureStorageConnectionString); - - _sourceHelper = new TestHelper(_output, _sourceGithubApi, _sourceGithubClient) { GithubApiBaseUrl = GHES_API_URL }; - _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); - } - - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task Basic(bool useGithubStorage) - { - var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; - var githubTargetOrg = $"octoshift-e2e-ghes-{TestHelper.GetOsName()}"; - const string repo1 = "repo-1"; - const string repo2 = "repo-2"; - - var retryPolicy = new RetryPolicy(null); - - if (!useGithubStorage) - { - _tokens["AZURE_STORAGE_CONNECTION_STRING"] = _azureStorageConnectionString; - } - - await retryPolicy.Retry(async () => - { - if (!useGithubStorage) - { - await _targetHelper.ResetBlobContainers(); - } - - await _sourceHelper.ResetGithubTestEnvironment(githubSourceOrg); - await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - - await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo1); - await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo2); - }); - - // Build the command with conditional option - var command = $"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --ghes-api-url {GHES_API_URL} --download-migration-logs"; - if (useGithubStorage) - { - command += " --use-github-storage"; - } - - await _targetHelper.RunGeiCliMigration(command, _tokens); - - _targetHelper.AssertNoErrorInLogs(_startTime); - - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo1); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo2); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo1); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo2); - - _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo1); - _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo2); - } - - public void Dispose() - { - _sourceGithubHttpClient?.Dispose(); - _targetGithubHttpClient?.Dispose(); - _versionClient?.Dispose(); - } -} +// using System; +// using System.Collections.Generic; +// using System.Net.Http; +// using System.Threading.Tasks; +// using Azure.Storage.Blobs; +// using OctoshiftCLI.Services; +// using Xunit; +// using Xunit.Abstractions; + +// namespace OctoshiftCLI.IntegrationTests; + +// [Collection("Integration Tests")] +// public sealed class GhesToGithub : IDisposable +// { +// private const string GHES_API_URL = "https://octoshift-ghe.westus2.cloudapp.azure.com/api/v3"; + +// private readonly ITestOutputHelper _output; +// private readonly TestHelper _targetHelper; +// private readonly TestHelper _sourceHelper; +// private readonly HttpClient _versionClient; +// private readonly HttpClient _targetGithubHttpClient; +// private readonly GithubClient _targetGithubClient; +// private readonly GithubApi _targetGithubApi; +// private readonly HttpClient _sourceGithubHttpClient; +// private readonly GithubClient _sourceGithubClient; +// private readonly GithubApi _sourceGithubApi; +// private readonly BlobServiceClient _blobServiceClient; +// private readonly Dictionary _tokens; +// private readonly DateTime _startTime; +// private readonly ArchiveUploader _archiveUploader; +// private readonly string _azureStorageConnectionString; + +// public GhesToGithub(ITestOutputHelper output) +// { +// _startTime = DateTime.Now; +// _output = output; + +// var logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { }); + +// var sourceGithubToken = Environment.GetEnvironmentVariable("GHES_PAT"); +// var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); +// _azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_GHES_{TestHelper.GetOsName().ToUpper()}"); +// _tokens = new Dictionary +// { +// ["GH_SOURCE_PAT"] = sourceGithubToken, +// ["GH_PAT"] = targetGithubToken, +// }; + +// _versionClient = new HttpClient(); +// _archiveUploader = new ArchiveUploader(_targetGithubClient, logger); + +// _sourceGithubHttpClient = new HttpClient(); +// _sourceGithubClient = new GithubClient(logger, _sourceGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), sourceGithubToken); +// _sourceGithubApi = new GithubApi(_sourceGithubClient, GHES_API_URL, new RetryPolicy(logger), _archiveUploader); + +// _targetGithubHttpClient = new HttpClient(); +// _targetGithubClient = new GithubClient(logger, _targetGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), targetGithubToken); +// _targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(logger), _archiveUploader); + +// _blobServiceClient = new BlobServiceClient(_azureStorageConnectionString); + +// _sourceHelper = new TestHelper(_output, _sourceGithubApi, _sourceGithubClient) { GithubApiBaseUrl = GHES_API_URL }; +// _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); +// } + +// [Theory] +// [InlineData(false)] +// [InlineData(true)] +// public async Task Basic(bool useGithubStorage) +// { +// var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; +// var githubTargetOrg = $"octoshift-e2e-ghes-{TestHelper.GetOsName()}"; +// const string repo1 = "repo-1"; +// const string repo2 = "repo-2"; + +// var retryPolicy = new RetryPolicy(null); + +// if (!useGithubStorage) +// { +// _tokens["AZURE_STORAGE_CONNECTION_STRING"] = _azureStorageConnectionString; +// } + +// await retryPolicy.Retry(async () => +// { +// if (!useGithubStorage) +// { +// await _targetHelper.ResetBlobContainers(); +// } + +// await _sourceHelper.ResetGithubTestEnvironment(githubSourceOrg); +// await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + +// await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo1); +// await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo2); +// }); + +// // Build the command with conditional option +// var command = $"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --ghes-api-url {GHES_API_URL} --download-migration-logs"; +// if (useGithubStorage) +// { +// command += " --use-github-storage"; +// } + +// await _targetHelper.RunGeiCliMigration(command, _tokens); + +// _targetHelper.AssertNoErrorInLogs(_startTime); + +// await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo1); +// await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo2); +// await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo1); +// await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo2); + +// _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo1); +// _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo2); +// } + +// public void Dispose() +// { +// _sourceGithubHttpClient?.Dispose(); +// _targetGithubHttpClient?.Dispose(); +// _versionClient?.Dispose(); +// } +// } diff --git a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs index ef22f4cc6..351a2aa95 100644 --- a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using OctoshiftCLI.Services; -using Xunit; -using Xunit.Abstractions; - -namespace OctoshiftCLI.IntegrationTests -{ - [Collection("Integration Tests")] - public class GithubToGithub : IDisposable - { - private readonly ITestOutputHelper _output; - private readonly GithubApi _githubApi; - private readonly TestHelper _helper; - - private readonly HttpClient _githubHttpClient; - private readonly HttpClient _versionClient; - private readonly GithubClient _githubClient; - private bool disposedValue; - private readonly Dictionary _tokens; - private readonly DateTime _startTime; - public GithubToGithub(ITestOutputHelper output) - { - _startTime = DateTime.Now; - _output = output; - - var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); - - var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); - _tokens = new Dictionary { ["GH_PAT"] = githubToken }; - - _githubHttpClient = new HttpClient(); - _versionClient = new HttpClient(); - _githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); - _githubApi = new GithubApi(_githubClient, "https://api.github.com", new RetryPolicy(logger), null); - - _helper = new TestHelper(_output, _githubApi, _githubClient); - } - - [Fact] - public async Task Basic() - { - var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; - var githubTargetOrg = $"octoshift-e2e-ghec-{TestHelper.GetOsName()}"; - var repo1 = "repo-1"; - var repo2 = "repo-2"; - - var retryPolicy = new RetryPolicy(null); - - await retryPolicy.Retry(async () => - { - await _helper.ResetGithubTestEnvironment(githubSourceOrg); - await _helper.ResetGithubTestEnvironment(githubTargetOrg); - - await _helper.CreateGithubRepo(githubSourceOrg, repo1); - await _helper.CreateGithubRepo(githubSourceOrg, repo2); - }); - - await _helper.RunGeiCliMigration($"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --download-migration-logs", _tokens); - - _helper.AssertNoErrorInLogs(_startTime); - - await _helper.AssertGithubRepoExists(githubTargetOrg, repo1); - await _helper.AssertGithubRepoExists(githubTargetOrg, repo2); - await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo1); - await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo2); - - _helper.AssertMigrationLogFileExists(githubTargetOrg, repo1); - _helper.AssertMigrationLogFileExists(githubTargetOrg, repo2); - } - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - _githubHttpClient.Dispose(); - _versionClient.Dispose(); - } - - disposedValue = true; - } - } - - public void Dispose() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - } -} +// using System; +// using System.Collections.Generic; +// using System.Net.Http; +// using System.Threading.Tasks; +// using OctoshiftCLI.Services; +// using Xunit; +// using Xunit.Abstractions; + +// namespace OctoshiftCLI.IntegrationTests +// { +// [Collection("Integration Tests")] +// public class GithubToGithub : IDisposable +// { +// private readonly ITestOutputHelper _output; +// private readonly GithubApi _githubApi; +// private readonly TestHelper _helper; + +// private readonly HttpClient _githubHttpClient; +// private readonly HttpClient _versionClient; +// private readonly GithubClient _githubClient; +// private bool disposedValue; +// private readonly Dictionary _tokens; +// private readonly DateTime _startTime; +// public GithubToGithub(ITestOutputHelper output) +// { +// _startTime = DateTime.Now; +// _output = output; + +// var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); + +// var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); +// _tokens = new Dictionary { ["GH_PAT"] = githubToken }; + +// _githubHttpClient = new HttpClient(); +// _versionClient = new HttpClient(); +// _githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); +// _githubApi = new GithubApi(_githubClient, "https://api.github.com", new RetryPolicy(logger), null); + +// _helper = new TestHelper(_output, _githubApi, _githubClient); +// } + +// [Fact] +// public async Task Basic() +// { +// var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; +// var githubTargetOrg = $"octoshift-e2e-ghec-{TestHelper.GetOsName()}"; +// var repo1 = "repo-1"; +// var repo2 = "repo-2"; + +// var retryPolicy = new RetryPolicy(null); + +// await retryPolicy.Retry(async () => +// { +// await _helper.ResetGithubTestEnvironment(githubSourceOrg); +// await _helper.ResetGithubTestEnvironment(githubTargetOrg); + +// await _helper.CreateGithubRepo(githubSourceOrg, repo1); +// await _helper.CreateGithubRepo(githubSourceOrg, repo2); +// }); + +// await _helper.RunGeiCliMigration($"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --download-migration-logs", _tokens); + +// _helper.AssertNoErrorInLogs(_startTime); + +// await _helper.AssertGithubRepoExists(githubTargetOrg, repo1); +// await _helper.AssertGithubRepoExists(githubTargetOrg, repo2); +// await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo1); +// await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo2); + +// _helper.AssertMigrationLogFileExists(githubTargetOrg, repo1); +// _helper.AssertMigrationLogFileExists(githubTargetOrg, repo2); +// } + +// protected virtual void Dispose(bool disposing) +// { +// if (!disposedValue) +// { +// if (disposing) +// { +// _githubHttpClient.Dispose(); +// _versionClient.Dispose(); +// } + +// disposedValue = true; +// } +// } + +// public void Dispose() +// { +// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method +// Dispose(disposing: true); +// GC.SuppressFinalize(this); +// } +// } +// } From b09ce56b0173d9581a450be77ee87822d9d79e30 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 09:19:31 -0800 Subject: [PATCH 04/23] Add other tests back in --- .../AdoBasicToGithub.cs | 138 +++++----- .../AdoCsvToGithub.cs | 140 +++++----- .../AdoServerToGithub.cs | 116 ++++----- .../AdoToGithub.cs | 120 ++++----- .../BbsToGithub.cs | 148 +++++------ .../GhesToGithub.cs | 246 +++++++++--------- .../GithubToGithub.cs | 190 +++++++------- .../TestHelper.cs | 3 +- 8 files changed, 551 insertions(+), 550 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs index eca627e95..aef851c4d 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs @@ -1,78 +1,78 @@ -// using System.Threading.Tasks; -// using Xunit; -// using Xunit.Abstractions; +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; -// namespace OctoshiftCLI.IntegrationTests -// { -// [Collection("Integration Tests")] -// public class AdoBasicToGithub : AdoToGithub -// { -// public AdoBasicToGithub(ITestOutputHelper output) : base(output) -// { -// } +namespace OctoshiftCLI.IntegrationTests +{ + [Collection("Integration Tests")] + public class AdoBasicToGithub : AdoToGithub + { + public AdoBasicToGithub(ITestOutputHelper output) : base(output) + { + } -// [Fact] -// public async Task Basic() -// { -// var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; -// var githubOrg = $"octoshift-e2e-ado-basic-{TestHelper.GetOsName()}-2"; -// var teamProject1 = "gei-e2e-1"; -// var teamProject2 = "gei-e2e-2"; -// var adoRepo1 = teamProject1; -// var adoRepo2 = teamProject2; -// var pipeline1 = "pipeline1"; -// var pipeline2 = "pipeline2"; + [Fact] + public async Task Basic() + { + var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; + var githubOrg = $"octoshift-e2e-ado-basic-{TestHelper.GetOsName()}-2"; + var teamProject1 = "gei-e2e-1"; + var teamProject2 = "gei-e2e-2"; + var adoRepo1 = teamProject1; + var adoRepo2 = teamProject2; + var pipeline1 = "pipeline1"; + var pipeline2 = "pipeline2"; -// var retryPolicy = new RetryPolicy(null); + var retryPolicy = new RetryPolicy(null); -// await retryPolicy.Retry(async () => -// { -// await Helper.ResetAdoTestEnvironment(adoOrg); -// await Helper.ResetGithubTestEnvironment(githubOrg); + await retryPolicy.Retry(async () => + { + await Helper.ResetAdoTestEnvironment(adoOrg); + await Helper.ResetGithubTestEnvironment(githubOrg); -// await Helper.CreateTeamProject(adoOrg, teamProject1); -// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); -// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); + await Helper.CreateTeamProject(adoOrg, teamProject1); + var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); + await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); -// await Helper.CreateTeamProject(adoOrg, teamProject2); -// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); -// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); -// }); + await Helper.CreateTeamProject(adoOrg, teamProject2); + commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); + await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); + }); -// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all", Tokens); + await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all", Tokens); -// Helper.AssertNoErrorInLogs(StartTime); + Helper.AssertNoErrorInLogs(StartTime); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); -// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); -// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); -// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); -// await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); -// await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); -// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); -// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); -// await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); -// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// } -// } -// } + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); + await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); + await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); + await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); + await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); + await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); + await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); + await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); + await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); + await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); + } + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs index e795e1f9d..d389fec2e 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs @@ -1,79 +1,79 @@ -// using System.Threading.Tasks; -// using Xunit; -// using Xunit.Abstractions; +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; -// namespace OctoshiftCLI.IntegrationTests -// { -// [Collection("Integration Tests")] -// public class AdoCsvToGithub : AdoToGithub -// { -// public AdoCsvToGithub(ITestOutputHelper output) : base(output) -// { -// } +namespace OctoshiftCLI.IntegrationTests +{ + [Collection("Integration Tests")] + public class AdoCsvToGithub : AdoToGithub + { + public AdoCsvToGithub(ITestOutputHelper output) : base(output) + { + } -// [Fact] -// public async Task With_Inventory_Report_Csv() -// { -// var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; -// var githubOrg = $"octoshift-e2e-ado-csv-{TestHelper.GetOsName()}"; -// var teamProject1 = "gei-e2e-1"; -// var teamProject2 = "gei-e2e-2"; -// var adoRepo1 = teamProject1; -// var adoRepo2 = teamProject2; -// var pipeline1 = "pipeline1"; -// var pipeline2 = "pipeline2"; + [Fact] + public async Task With_Inventory_Report_Csv() + { + var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; + var githubOrg = $"octoshift-e2e-ado-csv-{TestHelper.GetOsName()}"; + var teamProject1 = "gei-e2e-1"; + var teamProject2 = "gei-e2e-2"; + var adoRepo1 = teamProject1; + var adoRepo2 = teamProject2; + var pipeline1 = "pipeline1"; + var pipeline2 = "pipeline2"; -// var retryPolicy = new RetryPolicy(null); + var retryPolicy = new RetryPolicy(null); -// await retryPolicy.Retry(async () => -// { -// await Helper.ResetAdoTestEnvironment(adoOrg); -// await Helper.ResetGithubTestEnvironment(githubOrg); + await retryPolicy.Retry(async () => + { + await Helper.ResetAdoTestEnvironment(adoOrg); + await Helper.ResetGithubTestEnvironment(githubOrg); -// await Helper.CreateTeamProject(adoOrg, teamProject1); -// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); -// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); + await Helper.CreateTeamProject(adoOrg, teamProject1); + var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1); + await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId); -// await Helper.CreateTeamProject(adoOrg, teamProject2); -// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); -// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); -// }); + await Helper.CreateTeamProject(adoOrg, teamProject2); + commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2); + await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId); + }); -// await Helper.RunCliCommand($"ado2gh inventory-report --ado-org {adoOrg}", "gh", Tokens); -// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all --repo-list repos.csv", Tokens); + await Helper.RunCliCommand($"ado2gh inventory-report --ado-org {adoOrg}", "gh", Tokens); + await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --all --repo-list repos.csv", Tokens); -// Helper.AssertNoErrorInLogs(StartTime); + Helper.AssertNoErrorInLogs(StartTime); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); -// await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); -// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); -// await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); -// await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); -// await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); -// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); -// await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); -// await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); -// await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// } -// } -// } + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject1}-{teamProject1}", $"https://dev.azure.com/{adoOrg}/{teamProject1}/_workitems/edit//"); + await Helper.AssertAutolinkConfigured(githubOrg, $"{teamProject2}-{teamProject2}", $"https://dev.azure.com/{adoOrg}/{teamProject2}/_workitems/edit//"); + await Helper.AssertAdoRepoDisabled(adoOrg, teamProject1, adoRepo1); + await Helper.AssertAdoRepoDisabled(adoOrg, teamProject2, adoRepo2); + await Helper.AssertAdoRepoLocked(adoOrg, teamProject1, adoRepo1); + await Helper.AssertAdoRepoLocked(adoOrg, teamProject2, adoRepo2); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); + await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject1); + await Helper.AssertServiceConnectionWasShared(adoOrg, teamProject2); + await Helper.AssertPipelineRewired(adoOrg, teamProject1, pipeline1, githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertPipelineRewired(adoOrg, teamProject2, pipeline2, githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject1); + await Helper.AssertBoardsIntegrationConfigured(adoOrg, teamProject2); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); + } + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs index 2aa70ed1a..c57689a91 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs @@ -1,68 +1,68 @@ -// using System.Threading.Tasks; -// using Xunit; -// using Xunit.Abstractions; +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; -// namespace OctoshiftCLI.IntegrationTests -// { -// [Collection("Integration Tests")] -// public class AdoServerToGithub : AdoToGithub -// { -// private const string ADO_SERVER_URL = "http://octoshift-ado-server-2022.eastus.cloudapp.azure.com/"; +namespace OctoshiftCLI.IntegrationTests +{ + [Collection("Integration Tests")] + public class AdoServerToGithub : AdoToGithub + { + private const string ADO_SERVER_URL = "http://octoshift-ado-server-2022.eastus.cloudapp.azure.com/"; -// public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL, "ADO_SERVER_PAT") -// { -// } + public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL, "ADO_SERVER_PAT") + { + } -// [Fact(Skip = "ADO Server is not a supported feature in GEI")] -// public async Task Basic() -// { -// var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; -// var githubOrg = $"octoshift-e2e-ado-server-{TestHelper.GetOsName()}"; -// var teamProject1 = "gei-e2e-1"; -// var teamProject2 = "gei-e2e-2"; -// var adoRepo1 = teamProject1; -// var adoRepo2 = teamProject2; -// var pipeline1 = "pipeline1"; -// var pipeline2 = "pipeline2"; + [Fact(Skip = "ADO Server is not a supported feature in GEI")] + public async Task Basic() + { + var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; + var githubOrg = $"octoshift-e2e-ado-server-{TestHelper.GetOsName()}"; + var teamProject1 = "gei-e2e-1"; + var teamProject2 = "gei-e2e-2"; + var adoRepo1 = teamProject1; + var adoRepo2 = teamProject2; + var pipeline1 = "pipeline1"; + var pipeline2 = "pipeline2"; -// var retryPolicy = new RetryPolicy(null); + var retryPolicy = new RetryPolicy(null); -// await retryPolicy.Retry(async () => -// { -// await Helper.ResetAdoTestEnvironment(adoOrg, ADO_SERVER_URL); -// await Helper.ResetGithubTestEnvironment(githubOrg); + await retryPolicy.Retry(async () => + { + await Helper.ResetAdoTestEnvironment(adoOrg, ADO_SERVER_URL); + await Helper.ResetGithubTestEnvironment(githubOrg); -// await Helper.CreateTeamProject(adoOrg, teamProject1, ADO_SERVER_URL); -// var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1, ADO_SERVER_URL); -// await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId, ADO_SERVER_URL); + await Helper.CreateTeamProject(adoOrg, teamProject1, ADO_SERVER_URL); + var commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject1, adoRepo1, ADO_SERVER_URL); + await Helper.CreatePipeline(adoOrg, teamProject1, adoRepo1, pipeline1, commitId, ADO_SERVER_URL); -// await Helper.CreateTeamProject(adoOrg, teamProject2, ADO_SERVER_URL); -// commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2, ADO_SERVER_URL); -// await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId, ADO_SERVER_URL); -// }); + await Helper.CreateTeamProject(adoOrg, teamProject2, ADO_SERVER_URL); + commitId = await Helper.InitializeAdoRepo(adoOrg, teamProject2, adoRepo2, ADO_SERVER_URL); + await Helper.CreatePipeline(adoOrg, teamProject2, adoRepo2, pipeline2, commitId, ADO_SERVER_URL); + }); -// await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --ado-server-url {ADO_SERVER_URL} --download-migration-logs --create-teams --link-idp-groups", Tokens); + await Helper.RunAdoToGithubCliMigration($"generate-script --github-org {githubOrg} --ado-org {adoOrg} --ado-server-url {ADO_SERVER_URL} --download-migration-logs --create-teams --link-idp-groups", Tokens); -// Helper.AssertNoErrorInLogs(StartTime); + Helper.AssertNoErrorInLogs(StartTime); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); -// await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); -// await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); -// await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); -// Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); -// } -// } -// } + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoExists(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject1}-{teamProject1}"); + await Helper.AssertGithubRepoInitialized(githubOrg, $"{teamProject2}-{teamProject2}"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamCreated(githubOrg, $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-Admins"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-Maintainers"); + await Helper.AssertGithubTeamIdpLinked(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-Admins"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Maintainers", $"{teamProject1}-{teamProject1}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject1}-Admins", $"{teamProject1}-{teamProject1}", "admin"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Maintainers", $"{teamProject2}-{teamProject2}", "maintain"); + await Helper.AssertGithubTeamHasRepoRole(githubOrg, $"{teamProject2}-Admins", $"{teamProject2}-{teamProject2}", "admin"); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject1}-{teamProject1}"); + Helper.AssertMigrationLogFileExists(githubOrg, $"{teamProject2}-{teamProject2}"); + } + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs index 512e52c6c..09743b34f 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoToGithub.cs @@ -1,71 +1,71 @@ -// using System; -// using System.Collections.Generic; -// using System.Net.Http; -// using OctoshiftCLI.Services; -// using Xunit.Abstractions; +using System; +using System.Collections.Generic; +using System.Net.Http; +using OctoshiftCLI.Services; +using Xunit.Abstractions; -// namespace OctoshiftCLI.IntegrationTests -// { -// public abstract class AdoToGithub : IDisposable -// { -// private readonly ITestOutputHelper _output; -// private readonly HttpClient _adoHttpClient; -// private readonly HttpClient _githubHttpClient; -// private readonly HttpClient _versionClient; -// private bool disposedValue; +namespace OctoshiftCLI.IntegrationTests +{ + public abstract class AdoToGithub : IDisposable + { + private readonly ITestOutputHelper _output; + private readonly HttpClient _adoHttpClient; + private readonly HttpClient _githubHttpClient; + private readonly HttpClient _versionClient; + private bool disposedValue; -// protected TestHelper Helper { get; } -// protected Dictionary Tokens { get; } -// protected DateTime StartTime { get; } + protected TestHelper Helper { get; } + protected Dictionary Tokens { get; } + protected DateTime StartTime { get; } -// protected AdoToGithub(ITestOutputHelper output, string adoServerUrl = "https://dev.azure.com", string adoPatEnvVar = "ADO_PAT") -// { -// StartTime = DateTime.Now; -// _output = output; + protected AdoToGithub(ITestOutputHelper output, string adoServerUrl = "https://dev.azure.com", string adoPatEnvVar = "ADO_PAT") + { + StartTime = DateTime.Now; + _output = output; -// var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); + var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); -// _versionClient = new HttpClient(); -// var adoToken = Environment.GetEnvironmentVariable(adoPatEnvVar); -// _adoHttpClient = new HttpClient(); -// var retryPolicy = new RetryPolicy(logger); -// var adoClient = new AdoClient(logger, _adoHttpClient, new VersionChecker(_versionClient, logger), retryPolicy, adoToken); -// var adoApi = new AdoApi(adoClient, adoServerUrl, logger); + _versionClient = new HttpClient(); + var adoToken = Environment.GetEnvironmentVariable(adoPatEnvVar); + _adoHttpClient = new HttpClient(); + var retryPolicy = new RetryPolicy(logger); + var adoClient = new AdoClient(logger, _adoHttpClient, new VersionChecker(_versionClient, logger), retryPolicy, adoToken); + var adoApi = new AdoApi(adoClient, adoServerUrl, logger); -// var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); -// _githubHttpClient = new HttpClient(); -// var githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); -// var githubApi = new GithubApi(githubClient, "https://api.github.com", new RetryPolicy(logger), null); + var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); + _githubHttpClient = new HttpClient(); + var githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); + var githubApi = new GithubApi(githubClient, "https://api.github.com", new RetryPolicy(logger), null); -// Tokens = new Dictionary -// { -// ["GH_PAT"] = githubToken, -// ["ADO_PAT"] = adoToken -// }; + Tokens = new Dictionary + { + ["GH_PAT"] = githubToken, + ["ADO_PAT"] = adoToken + }; -// Helper = new TestHelper(_output, adoApi, githubApi, adoClient, githubClient); -// } + Helper = new TestHelper(_output, adoApi, githubApi, adoClient, githubClient); + } -// protected virtual void Dispose(bool disposing) -// { -// if (!disposedValue) -// { -// if (disposing) -// { -// _adoHttpClient.Dispose(); -// _githubHttpClient.Dispose(); -// _versionClient.Dispose(); -// } + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + _adoHttpClient.Dispose(); + _githubHttpClient.Dispose(); + _versionClient.Dispose(); + } -// disposedValue = true; -// } -// } + disposedValue = true; + } + } -// public void Dispose() -// { -// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method -// Dispose(disposing: true); -// GC.SuppressFinalize(this); -// } -// } -// } + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 44135f54e..0047c9d6f 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -67,79 +67,79 @@ public BbsToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - // [Theory] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] - // [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] - // public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) - // { - // var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; - // var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; - // var repo1 = $"{bbsProjectKey}-repo-1"; - // var repo2 = $"{bbsProjectKey}-repo-2"; - // var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1"; - // var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2"; - - // var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger); - // var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer); - - // var retryPolicy = new RetryPolicy(null); - - // await retryPolicy.Retry(async () => - // { - // await _targetHelper.ResetBlobContainers(); - // await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey); - // await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - - // await sourceHelper.CreateBbsProject(bbsProjectKey); - // await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1); - // await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1); - // await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2); - // await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2); - // }); - - // var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; - // if (useSshForArchiveDownload) - // { - // var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); - // await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); - // } - // else - // { - // archiveDownloadOptions = " --smb-user octoshift"; - // _tokens.Add("SMB_PASSWORD", Environment.GetEnvironmentVariable("SMB_PASSWORD")); - // } - - // var archiveUploadOptions = ""; - // if (uploadOption == ArchiveUploadOption.AzureStorage) - // { - // _tokens.Add("AZURE_STORAGE_CONNECTION_STRING", _azureStorageConnectionString); - // } - // else if (uploadOption == ArchiveUploadOption.AwsS3) - // { - // _tokens.Add("AWS_ACCESS_KEY_ID", Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID")); - // _tokens.Add("AWS_SECRET_ACCESS_KEY", Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY")); - // var awsBucketName = Environment.GetEnvironmentVariable("AWS_BUCKET_NAME"); - // archiveUploadOptions = $" --aws-bucket-name {awsBucketName} --aws-region {AWS_REGION}"; - // } - // else if (uploadOption == ArchiveUploadOption.GithubStorage) - // { - // archiveUploadOptions = " --use-github-storage"; - // } - - // await _targetHelper.RunBbsCliMigration( - // $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey}{archiveDownloadOptions}{archiveUploadOptions}", _tokens); - - // _targetHelper.AssertNoErrorInLogs(_startTime); - - // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); - // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); - // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); - // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); - - // // TODO: Assert migration logs are downloaded - // } + [Theory] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] + [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] + public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) + { + var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; + var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; + var repo1 = $"{bbsProjectKey}-repo-1"; + var repo2 = $"{bbsProjectKey}-repo-2"; + var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1"; + var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2"; + + var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger); + var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer); + + var retryPolicy = new RetryPolicy(null); + + await retryPolicy.Retry(async () => + { + await _targetHelper.ResetBlobContainers(); + await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey); + await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + + await sourceHelper.CreateBbsProject(bbsProjectKey); + await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1); + await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1); + await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2); + await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2); + }); + + var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; + if (useSshForArchiveDownload) + { + var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); + await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); + } + else + { + archiveDownloadOptions = " --smb-user octoshift"; + _tokens.Add("SMB_PASSWORD", Environment.GetEnvironmentVariable("SMB_PASSWORD")); + } + + var archiveUploadOptions = ""; + if (uploadOption == ArchiveUploadOption.AzureStorage) + { + _tokens.Add("AZURE_STORAGE_CONNECTION_STRING", _azureStorageConnectionString); + } + else if (uploadOption == ArchiveUploadOption.AwsS3) + { + _tokens.Add("AWS_ACCESS_KEY_ID", Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID")); + _tokens.Add("AWS_SECRET_ACCESS_KEY", Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY")); + var awsBucketName = Environment.GetEnvironmentVariable("AWS_BUCKET_NAME"); + archiveUploadOptions = $" --aws-bucket-name {awsBucketName} --aws-region {AWS_REGION}"; + } + else if (uploadOption == ArchiveUploadOption.GithubStorage) + { + archiveUploadOptions = " --use-github-storage"; + } + + await _targetHelper.RunBbsCliMigration( + $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey}{archiveDownloadOptions}{archiveUploadOptions}", _tokens); + + _targetHelper.AssertNoErrorInLogs(_startTime); + + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); + + // TODO: Assert migration logs are downloaded + } [Fact] public async Task MigrateRepo_MultipartUpload() @@ -148,7 +148,7 @@ public async Task MigrateRepo_MultipartUpload() var bbsProjectKey = $"IN"; var bbsRepo = "100_cli"; var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; - var targetRepo = $"{bbsProjectKey}-e2e-{Guid.NewGuid()}"; + var targetRepo = $"multi-part-{E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); diff --git a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs index 75686d320..948fa83da 100644 --- a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs @@ -1,123 +1,123 @@ -// using System; -// using System.Collections.Generic; -// using System.Net.Http; -// using System.Threading.Tasks; -// using Azure.Storage.Blobs; -// using OctoshiftCLI.Services; -// using Xunit; -// using Xunit.Abstractions; - -// namespace OctoshiftCLI.IntegrationTests; - -// [Collection("Integration Tests")] -// public sealed class GhesToGithub : IDisposable -// { -// private const string GHES_API_URL = "https://octoshift-ghe.westus2.cloudapp.azure.com/api/v3"; - -// private readonly ITestOutputHelper _output; -// private readonly TestHelper _targetHelper; -// private readonly TestHelper _sourceHelper; -// private readonly HttpClient _versionClient; -// private readonly HttpClient _targetGithubHttpClient; -// private readonly GithubClient _targetGithubClient; -// private readonly GithubApi _targetGithubApi; -// private readonly HttpClient _sourceGithubHttpClient; -// private readonly GithubClient _sourceGithubClient; -// private readonly GithubApi _sourceGithubApi; -// private readonly BlobServiceClient _blobServiceClient; -// private readonly Dictionary _tokens; -// private readonly DateTime _startTime; -// private readonly ArchiveUploader _archiveUploader; -// private readonly string _azureStorageConnectionString; - -// public GhesToGithub(ITestOutputHelper output) -// { -// _startTime = DateTime.Now; -// _output = output; - -// var logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { }); - -// var sourceGithubToken = Environment.GetEnvironmentVariable("GHES_PAT"); -// var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); -// _azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_GHES_{TestHelper.GetOsName().ToUpper()}"); -// _tokens = new Dictionary -// { -// ["GH_SOURCE_PAT"] = sourceGithubToken, -// ["GH_PAT"] = targetGithubToken, -// }; - -// _versionClient = new HttpClient(); -// _archiveUploader = new ArchiveUploader(_targetGithubClient, logger); - -// _sourceGithubHttpClient = new HttpClient(); -// _sourceGithubClient = new GithubClient(logger, _sourceGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), sourceGithubToken); -// _sourceGithubApi = new GithubApi(_sourceGithubClient, GHES_API_URL, new RetryPolicy(logger), _archiveUploader); - -// _targetGithubHttpClient = new HttpClient(); -// _targetGithubClient = new GithubClient(logger, _targetGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), targetGithubToken); -// _targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(logger), _archiveUploader); - -// _blobServiceClient = new BlobServiceClient(_azureStorageConnectionString); - -// _sourceHelper = new TestHelper(_output, _sourceGithubApi, _sourceGithubClient) { GithubApiBaseUrl = GHES_API_URL }; -// _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); -// } - -// [Theory] -// [InlineData(false)] -// [InlineData(true)] -// public async Task Basic(bool useGithubStorage) -// { -// var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; -// var githubTargetOrg = $"octoshift-e2e-ghes-{TestHelper.GetOsName()}"; -// const string repo1 = "repo-1"; -// const string repo2 = "repo-2"; - -// var retryPolicy = new RetryPolicy(null); - -// if (!useGithubStorage) -// { -// _tokens["AZURE_STORAGE_CONNECTION_STRING"] = _azureStorageConnectionString; -// } - -// await retryPolicy.Retry(async () => -// { -// if (!useGithubStorage) -// { -// await _targetHelper.ResetBlobContainers(); -// } - -// await _sourceHelper.ResetGithubTestEnvironment(githubSourceOrg); -// await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - -// await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo1); -// await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo2); -// }); - -// // Build the command with conditional option -// var command = $"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --ghes-api-url {GHES_API_URL} --download-migration-logs"; -// if (useGithubStorage) -// { -// command += " --use-github-storage"; -// } - -// await _targetHelper.RunGeiCliMigration(command, _tokens); - -// _targetHelper.AssertNoErrorInLogs(_startTime); - -// await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo1); -// await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo2); -// await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo1); -// await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo2); - -// _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo1); -// _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo2); -// } - -// public void Dispose() -// { -// _sourceGithubHttpClient?.Dispose(); -// _targetGithubHttpClient?.Dispose(); -// _versionClient?.Dispose(); -// } -// } +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Azure.Storage.Blobs; +using OctoshiftCLI.Services; +using Xunit; +using Xunit.Abstractions; + +namespace OctoshiftCLI.IntegrationTests; + +[Collection("Integration Tests")] +public sealed class GhesToGithub : IDisposable +{ + private const string GHES_API_URL = "https://octoshift-ghe.westus2.cloudapp.azure.com/api/v3"; + + private readonly ITestOutputHelper _output; + private readonly TestHelper _targetHelper; + private readonly TestHelper _sourceHelper; + private readonly HttpClient _versionClient; + private readonly HttpClient _targetGithubHttpClient; + private readonly GithubClient _targetGithubClient; + private readonly GithubApi _targetGithubApi; + private readonly HttpClient _sourceGithubHttpClient; + private readonly GithubClient _sourceGithubClient; + private readonly GithubApi _sourceGithubApi; + private readonly BlobServiceClient _blobServiceClient; + private readonly Dictionary _tokens; + private readonly DateTime _startTime; + private readonly ArchiveUploader _archiveUploader; + private readonly string _azureStorageConnectionString; + + public GhesToGithub(ITestOutputHelper output) + { + _startTime = DateTime.Now; + _output = output; + + var logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { }); + + var sourceGithubToken = Environment.GetEnvironmentVariable("GHES_PAT"); + var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); + _azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_GHES_{TestHelper.GetOsName().ToUpper()}"); + _tokens = new Dictionary + { + ["GH_SOURCE_PAT"] = sourceGithubToken, + ["GH_PAT"] = targetGithubToken, + }; + + _versionClient = new HttpClient(); + _archiveUploader = new ArchiveUploader(_targetGithubClient, logger); + + _sourceGithubHttpClient = new HttpClient(); + _sourceGithubClient = new GithubClient(logger, _sourceGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), sourceGithubToken); + _sourceGithubApi = new GithubApi(_sourceGithubClient, GHES_API_URL, new RetryPolicy(logger), _archiveUploader); + + _targetGithubHttpClient = new HttpClient(); + _targetGithubClient = new GithubClient(logger, _targetGithubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), targetGithubToken); + _targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(logger), _archiveUploader); + + _blobServiceClient = new BlobServiceClient(_azureStorageConnectionString); + + _sourceHelper = new TestHelper(_output, _sourceGithubApi, _sourceGithubClient) { GithubApiBaseUrl = GHES_API_URL }; + _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task Basic(bool useGithubStorage) + { + var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; + var githubTargetOrg = $"octoshift-e2e-ghes-{TestHelper.GetOsName()}"; + const string repo1 = "repo-1"; + const string repo2 = "repo-2"; + + var retryPolicy = new RetryPolicy(null); + + if (!useGithubStorage) + { + _tokens["AZURE_STORAGE_CONNECTION_STRING"] = _azureStorageConnectionString; + } + + await retryPolicy.Retry(async () => + { + if (!useGithubStorage) + { + await _targetHelper.ResetBlobContainers(); + } + + await _sourceHelper.ResetGithubTestEnvironment(githubSourceOrg); + await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + + await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo1); + await _sourceHelper.CreateGithubRepo(githubSourceOrg, repo2); + }); + + // Build the command with conditional option + var command = $"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --ghes-api-url {GHES_API_URL} --download-migration-logs"; + if (useGithubStorage) + { + command += " --use-github-storage"; + } + + await _targetHelper.RunGeiCliMigration(command, _tokens); + + _targetHelper.AssertNoErrorInLogs(_startTime); + + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo1); + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, repo2); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo1); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, repo2); + + _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo1); + _targetHelper.AssertMigrationLogFileExists(githubTargetOrg, repo2); + } + + public void Dispose() + { + _sourceGithubHttpClient?.Dispose(); + _targetGithubHttpClient?.Dispose(); + _versionClient?.Dispose(); + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs index 351a2aa95..ef22f4cc6 100644 --- a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs @@ -1,95 +1,95 @@ -// using System; -// using System.Collections.Generic; -// using System.Net.Http; -// using System.Threading.Tasks; -// using OctoshiftCLI.Services; -// using Xunit; -// using Xunit.Abstractions; - -// namespace OctoshiftCLI.IntegrationTests -// { -// [Collection("Integration Tests")] -// public class GithubToGithub : IDisposable -// { -// private readonly ITestOutputHelper _output; -// private readonly GithubApi _githubApi; -// private readonly TestHelper _helper; - -// private readonly HttpClient _githubHttpClient; -// private readonly HttpClient _versionClient; -// private readonly GithubClient _githubClient; -// private bool disposedValue; -// private readonly Dictionary _tokens; -// private readonly DateTime _startTime; -// public GithubToGithub(ITestOutputHelper output) -// { -// _startTime = DateTime.Now; -// _output = output; - -// var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); - -// var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); -// _tokens = new Dictionary { ["GH_PAT"] = githubToken }; - -// _githubHttpClient = new HttpClient(); -// _versionClient = new HttpClient(); -// _githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); -// _githubApi = new GithubApi(_githubClient, "https://api.github.com", new RetryPolicy(logger), null); - -// _helper = new TestHelper(_output, _githubApi, _githubClient); -// } - -// [Fact] -// public async Task Basic() -// { -// var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; -// var githubTargetOrg = $"octoshift-e2e-ghec-{TestHelper.GetOsName()}"; -// var repo1 = "repo-1"; -// var repo2 = "repo-2"; - -// var retryPolicy = new RetryPolicy(null); - -// await retryPolicy.Retry(async () => -// { -// await _helper.ResetGithubTestEnvironment(githubSourceOrg); -// await _helper.ResetGithubTestEnvironment(githubTargetOrg); - -// await _helper.CreateGithubRepo(githubSourceOrg, repo1); -// await _helper.CreateGithubRepo(githubSourceOrg, repo2); -// }); - -// await _helper.RunGeiCliMigration($"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --download-migration-logs", _tokens); - -// _helper.AssertNoErrorInLogs(_startTime); - -// await _helper.AssertGithubRepoExists(githubTargetOrg, repo1); -// await _helper.AssertGithubRepoExists(githubTargetOrg, repo2); -// await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo1); -// await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo2); - -// _helper.AssertMigrationLogFileExists(githubTargetOrg, repo1); -// _helper.AssertMigrationLogFileExists(githubTargetOrg, repo2); -// } - -// protected virtual void Dispose(bool disposing) -// { -// if (!disposedValue) -// { -// if (disposing) -// { -// _githubHttpClient.Dispose(); -// _versionClient.Dispose(); -// } - -// disposedValue = true; -// } -// } - -// public void Dispose() -// { -// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method -// Dispose(disposing: true); -// GC.SuppressFinalize(this); -// } -// } -// } +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using OctoshiftCLI.Services; +using Xunit; +using Xunit.Abstractions; + +namespace OctoshiftCLI.IntegrationTests +{ + [Collection("Integration Tests")] + public class GithubToGithub : IDisposable + { + private readonly ITestOutputHelper _output; + private readonly GithubApi _githubApi; + private readonly TestHelper _helper; + + private readonly HttpClient _githubHttpClient; + private readonly HttpClient _versionClient; + private readonly GithubClient _githubClient; + private bool disposedValue; + private readonly Dictionary _tokens; + private readonly DateTime _startTime; + public GithubToGithub(ITestOutputHelper output) + { + _startTime = DateTime.Now; + _output = output; + + var logger = new OctoLogger(x => { }, x => _output.WriteLine(x), x => { }, x => { }); + + var githubToken = Environment.GetEnvironmentVariable("GHEC_PAT"); + _tokens = new Dictionary { ["GH_PAT"] = githubToken }; + + _githubHttpClient = new HttpClient(); + _versionClient = new HttpClient(); + _githubClient = new GithubClient(logger, _githubHttpClient, new VersionChecker(_versionClient, logger), new RetryPolicy(logger), new DateTimeProvider(), githubToken); + _githubApi = new GithubApi(_githubClient, "https://api.github.com", new RetryPolicy(logger), null); + + _helper = new TestHelper(_output, _githubApi, _githubClient); + } + + [Fact] + public async Task Basic() + { + var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; + var githubTargetOrg = $"octoshift-e2e-ghec-{TestHelper.GetOsName()}"; + var repo1 = "repo-1"; + var repo2 = "repo-2"; + + var retryPolicy = new RetryPolicy(null); + + await retryPolicy.Retry(async () => + { + await _helper.ResetGithubTestEnvironment(githubSourceOrg); + await _helper.ResetGithubTestEnvironment(githubTargetOrg); + + await _helper.CreateGithubRepo(githubSourceOrg, repo1); + await _helper.CreateGithubRepo(githubSourceOrg, repo2); + }); + + await _helper.RunGeiCliMigration($"generate-script --github-source-org {githubSourceOrg} --github-target-org {githubTargetOrg} --download-migration-logs", _tokens); + + _helper.AssertNoErrorInLogs(_startTime); + + await _helper.AssertGithubRepoExists(githubTargetOrg, repo1); + await _helper.AssertGithubRepoExists(githubTargetOrg, repo2); + await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo1); + await _helper.AssertGithubRepoInitialized(githubTargetOrg, repo2); + + _helper.AssertMigrationLogFileExists(githubTargetOrg, repo1); + _helper.AssertMigrationLogFileExists(githubTargetOrg, repo2); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + _githubHttpClient.Dispose(); + _versionClient.Dispose(); + } + + disposedValue = true; + } + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index 5776a7627..c9587e2ae 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -549,6 +549,7 @@ public async Task RunCliCommand(string command, string cliName, IDictionary tokens) => await RunCliMigration(migrateRepoCommand, "bbs2gh", tokens); + private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary environmentVariables = null) { var startInfo = new ProcessStartInfo @@ -573,7 +574,7 @@ private async Task RunShellCommand(string command, string fileName, string worki } } - _output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}"); + // _output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}"); var p = Process.Start(startInfo); await p.WaitForExitAsync(); From 795f341b948bf3d10440cb19853d66d341ff680c Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 09:34:47 -0800 Subject: [PATCH 05/23] bug fix --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 0047c9d6f..2b833c1de 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -148,7 +148,8 @@ public async Task MigrateRepo_MultipartUpload() var bbsProjectKey = $"IN"; var bbsRepo = "100_cli"; var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; - var targetRepo = $"multi-part-{E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; + var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; + var targetRepo = $"multi-part-{targetName}"; var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); From d30d3af5ff1c98f191713df6d210043212f47b9b Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Mon, 18 Nov 2024 10:36:35 -0800 Subject: [PATCH 06/23] Update src/OctoshiftCLI.IntegrationTests/TestHelper.cs Co-authored-by: Arin Ghazarian --- src/OctoshiftCLI.IntegrationTests/TestHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index c9587e2ae..ff8432fbf 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -548,7 +548,7 @@ public async Task RunCliCommand(string command, string cliName, IDictionary tokens) => - await RunCliMigration(migrateRepoCommand, "bbs2gh", tokens); + await RunCliCommand(migrateRepoCommand, "bbs2gh", tokens); private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary environmentVariables = null) { From 01ccf3939c39371c0a408f580e838ddeb3ac991d Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 10:37:39 -0800 Subject: [PATCH 07/23] Add values back in --- src/OctoshiftCLI.IntegrationTests/TestHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index ff8432fbf..dcf9150af 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -574,7 +574,7 @@ private async Task RunShellCommand(string command, string fileName, string worki } } - // _output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}"); + _output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}"); var p = Process.Start(startInfo); await p.WaitForExitAsync(); From a93c4f9996f7e20e5200371b212697f9b77740a4 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 10:43:58 -0800 Subject: [PATCH 08/23] Can we get only my test to run --- src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 10 +++++----- src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs index aef851c4d..79f06f064 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs @@ -11,7 +11,7 @@ public AdoBasicToGithub(ITestOutputHelper output) : base(output) { } - [Fact] + // [Fact] public async Task Basic() { var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs index d389fec2e..d167795df 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs @@ -11,7 +11,7 @@ public AdoCsvToGithub(ITestOutputHelper output) : base(output) { } - [Fact] + // [Fact] public async Task With_Inventory_Report_Csv() { var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs index c57689a91..c54585ff0 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs @@ -13,7 +13,7 @@ public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL { } - [Fact(Skip = "ADO Server is not a supported feature in GEI")] + // [Fact(Skip = "ADO Server is not a supported feature in GEI")] public async Task Basic() { var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 2b833c1de..7285c8552 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -67,11 +67,11 @@ public BbsToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - [Theory] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] - [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] - [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] + // [Theory] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] + // [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] + // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) { var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs index 948fa83da..af5969e9f 100644 --- a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs @@ -63,9 +63,9 @@ public GhesToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - [Theory] - [InlineData(false)] - [InlineData(true)] + // [Theory] + // [InlineData(false)] + // [InlineData(true)] public async Task Basic(bool useGithubStorage) { var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; From ff6f6cca39aa452a94410502879fd9d40e0996de Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Mon, 18 Nov 2024 10:58:02 -0800 Subject: [PATCH 09/23] Update src/OctoshiftCLI.IntegrationTests/TestHelper.cs Co-authored-by: Arin Ghazarian --- src/OctoshiftCLI.IntegrationTests/TestHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index dcf9150af..925c82ac2 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -548,7 +548,7 @@ public async Task RunCliCommand(string command, string cliName, IDictionary tokens) => - await RunCliCommand(migrateRepoCommand, "bbs2gh", tokens); + await RunCliCommand($"bbs2gh {migrateRepoCommand}", "gh", tokens); private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary environmentVariables = null) { From 1ae70afb26fc2968c49afacb48b389fb6273aeb9 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 11:12:41 -0800 Subject: [PATCH 10/23] Add target repo name to command --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 4 ++-- src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 7285c8552..cb3d74bf4 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -150,7 +150,7 @@ public async Task MigrateRepo_MultipartUpload() var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; var targetRepo = $"multi-part-{targetName}"; - var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; + var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --ssh-port 22"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); @@ -161,7 +161,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); diff --git a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs index ef22f4cc6..1ecd0bf21 100644 --- a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs @@ -39,7 +39,7 @@ public GithubToGithub(ITestOutputHelper output) _helper = new TestHelper(_output, _githubApi, _githubClient); } - [Fact] + // [Fact] public async Task Basic() { var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; From aefa44b704b6580311c71bd73248d28d385b39aa Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 11:19:48 -0800 Subject: [PATCH 11/23] Add target repo name to command --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index cb3d74bf4..c0a21a9a0 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -161,7 +161,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}--github-pat{targetGithubToken}{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From 501e67d5ae65c5bbdb2f4842f3d3600b174f35bb Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 11:25:14 -0800 Subject: [PATCH 12/23] Add target repo name to command --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index c0a21a9a0..5e715a27a 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -32,6 +32,8 @@ public sealed class BbsToGithub : IDisposable private readonly DateTime _startTime; private readonly string _azureStorageConnectionString; + private readonly string _targetGithubToken; + public enum ArchiveUploadOption { AzureStorage, AwsS3, GithubStorage } public BbsToGithub(ITestOutputHelper output) @@ -51,6 +53,7 @@ public BbsToGithub(ITestOutputHelper output) ["BBS_PASSWORD"] = sourceBbsPassword, ["GH_PAT"] = targetGithubToken }; + _targetGithubToken = targetGithubToken; _versionClient = new HttpClient(); @@ -161,7 +164,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}--github-pat{targetGithubToken}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo} --github-pat{_targetGithubToken}{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From b1d855f2ab2880f03fba4e5925aa54ff881a30a4 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 11:46:08 -0800 Subject: [PATCH 13/23] Add target repo name to command --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 5e715a27a..efc259d51 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -32,8 +32,6 @@ public sealed class BbsToGithub : IDisposable private readonly DateTime _startTime; private readonly string _azureStorageConnectionString; - private readonly string _targetGithubToken; - public enum ArchiveUploadOption { AzureStorage, AwsS3, GithubStorage } public BbsToGithub(ITestOutputHelper output) @@ -53,7 +51,6 @@ public BbsToGithub(ITestOutputHelper output) ["BBS_PASSWORD"] = sourceBbsPassword, ["GH_PAT"] = targetGithubToken }; - _targetGithubToken = targetGithubToken; _versionClient = new HttpClient(); @@ -164,7 +161,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo} --github-pat{_targetGithubToken}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo} --ssh-port 22{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From 7f099c126355bc00c928bb6377aa623dc5f35120 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 12:04:01 -0800 Subject: [PATCH 14/23] Modifying migrate script --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index efc259d51..310b1be8a 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -150,7 +150,8 @@ public async Task MigrateRepo_MultipartUpload() var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; var targetRepo = $"multi-part-{targetName}"; - var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --ssh-port 22"; + + var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); @@ -161,7 +162,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo} --ssh-port 22{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo}{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From 663cc7e2400c12b1e00d7ae019e1cde0ff1a1f57 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 12:18:31 -0800 Subject: [PATCH 15/23] Modifying migrate script --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 310b1be8a..360a6af29 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -162,7 +162,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}{archiveDownloadOptions} --use-github-storage"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From ef18120e712e731e27596286f2df3d65ccd58928 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 12:40:37 -0800 Subject: [PATCH 16/23] Modifying migrate script --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 360a6af29..755f8efcb 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -151,7 +151,6 @@ public async Task MigrateRepo_MultipartUpload() var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; var targetRepo = $"multi-part-{targetName}"; - var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); @@ -162,7 +161,7 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-repo{targetRepo}{archiveDownloadOptions} --use-github-storage"; + var migrateRepoCommand = $"migrate-repo --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-org {githubTargetOrg} --github-repo{targetRepo} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage --verbose"; await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); From 739368c89aed1e688c133129f4f7a30658286e05 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 12:53:29 -0800 Subject: [PATCH 17/23] Try it by making it a generate script --- .../BbsToGithub.cs | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 755f8efcb..a82200986 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -142,7 +142,7 @@ await _targetHelper.RunBbsCliMigration( } [Fact] - public async Task MigrateRepo_MultipartUpload() + public async Task StartingFromScractch() { var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; var bbsProjectKey = $"IN"; @@ -161,16 +161,47 @@ await retryPolicy.Retry(async () => await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); }); - var migrateRepoCommand = $"migrate-repo --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-org {githubTargetOrg} --github-repo{targetRepo} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage --verbose"; - - await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); + await _targetHelper.RunBbsCliMigration( + $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage", _tokens); _targetHelper.AssertNoErrorInLogs(_startTime); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); } + // [Fact] + // public async Task MigrateRepo_MultipartUpload() + // { + // var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; + // var bbsProjectKey = $"IN"; + // var bbsRepo = "100_cli"; + // var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; + // var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; + // var targetRepo = $"multi-part-{targetName}"; + + // var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); + // await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); + + + // var retryPolicy = new RetryPolicy(null); + // await retryPolicy.Retry(async () => + // { + // await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + // }); + + // var migrateRepoCommand = $"migrate-repo --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-org {githubTargetOrg} --github-repo{targetRepo} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage --verbose"; + + // await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); + + // _targetHelper.AssertNoErrorInLogs(_startTime); + + // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); + // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); + // } + private string GetSshKeyName(string bbsServer) { var bbsVersion = Regex.Match(bbsServer, @"e2e-bbs-(\d{1,2}-\d{1,2}-\d{1,2})").Groups[1].Value.Replace('-', '_'); From 22f7656743401caeca750ccddf3959b0dfb42832 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 12:57:35 -0800 Subject: [PATCH 18/23] Fix build error --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index a82200986..fdde414e9 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -162,14 +162,14 @@ await retryPolicy.Retry(async () => }); await _targetHelper.RunBbsCliMigration( - $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage", _tokens); + $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage", _tokens); _targetHelper.AssertNoErrorInLogs(_startTime); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1); - await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2); + _targetHelper.AssertNoErrorInLogs(_startTime); + + await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); + await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); } // [Fact] From 626fc2a16feb56cb1f17e631ba473bc5d3b817ad Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 13:14:22 -0800 Subject: [PATCH 19/23] Fix target repo name --- .../BbsToGithub.cs | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index fdde414e9..c5b9678c4 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -142,14 +142,12 @@ await _targetHelper.RunBbsCliMigration( } [Fact] - public async Task StartingFromScractch() + public async Task MigrateRepo_MultipartUpload() { var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; var bbsProjectKey = $"IN"; - var bbsRepo = "100_cli"; var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; - var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; - var targetRepo = $"multi-part-{targetName}"; + var targetRepo = $"IN-100_cli"; var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); @@ -172,36 +170,6 @@ await _targetHelper.RunBbsCliMigration( await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); } - // [Fact] - // public async Task MigrateRepo_MultipartUpload() - // { - // var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}"; - // var bbsProjectKey = $"IN"; - // var bbsRepo = "100_cli"; - // var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990"; - // var targetName = $"E2E -{TestHelper.GetOsName().ToUpper()}-e2e-{Guid.NewGuid()}"; - // var targetRepo = $"multi-part-{targetName}"; - - // var sshKey = Environment.GetEnvironmentVariable(GetSshKeyName(bbsServer)); - // await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey); - - - // var retryPolicy = new RetryPolicy(null); - // await retryPolicy.Retry(async () => - // { - // await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - // }); - - // var migrateRepoCommand = $"migrate-repo --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {bbsRepo} --github-org {githubTargetOrg} --github-repo{targetRepo} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage --verbose"; - - // await _targetHelper.RunBbsMigrateRepoCommand(migrateRepoCommand, _tokens); - - // _targetHelper.AssertNoErrorInLogs(_startTime); - - // await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); - // await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); - // } - private string GetSshKeyName(string bbsServer) { var bbsVersion = Regex.Match(bbsServer, @"e2e-bbs-(\d{1,2}-\d{1,2}-\d{1,2})").Groups[1].Value.Replace('-', '_'); From 42dbf06894dc453762314e6810c4d8df0fc51456 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 13:17:30 -0800 Subject: [PATCH 20/23] Add tests back in --- src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs | 2 +- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 10 +++++----- src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs | 6 +++--- src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs index 79f06f064..aef851c4d 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoBasicToGithub.cs @@ -11,7 +11,7 @@ public AdoBasicToGithub(ITestOutputHelper output) : base(output) { } - // [Fact] + [Fact] public async Task Basic() { var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs index d167795df..d389fec2e 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoCsvToGithub.cs @@ -11,7 +11,7 @@ public AdoCsvToGithub(ITestOutputHelper output) : base(output) { } - // [Fact] + [Fact] public async Task With_Inventory_Report_Csv() { var adoOrg = $"gei-e2e-testing-csv-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs index c54585ff0..c57689a91 100644 --- a/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/AdoServerToGithub.cs @@ -13,7 +13,7 @@ public AdoServerToGithub(ITestOutputHelper output) : base(output, ADO_SERVER_URL { } - // [Fact(Skip = "ADO Server is not a supported feature in GEI")] + [Fact(Skip = "ADO Server is not a supported feature in GEI")] public async Task Basic() { var adoOrg = $"gei-e2e-testing-basic-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index c5b9678c4..4a25c98ec 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -67,11 +67,11 @@ public BbsToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - // [Theory] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] - // [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] - // [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] + [Theory] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AzureStorage)] + [InlineData("http://e2e-bbs-7-21-9-win-2019.eastus.cloudapp.azure.com:7990", false, ArchiveUploadOption.AzureStorage)] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.AwsS3)] + [InlineData("http://e2e-bbs-8-5-0-linux-2204.eastus.cloudapp.azure.com:7990", true, ArchiveUploadOption.GithubStorage)] public async Task Basic(string bbsServer, bool useSshForArchiveDownload, ArchiveUploadOption uploadOption) { var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs index af5969e9f..948fa83da 100644 --- a/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GhesToGithub.cs @@ -63,9 +63,9 @@ public GhesToGithub(ITestOutputHelper output) _targetHelper = new TestHelper(_output, _targetGithubApi, _targetGithubClient, _blobServiceClient); } - // [Theory] - // [InlineData(false)] - // [InlineData(true)] + [Theory] + [InlineData(false)] + [InlineData(true)] public async Task Basic(bool useGithubStorage) { var githubSourceOrg = $"e2e-testing-{TestHelper.GetOsName()}"; diff --git a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs index 1ecd0bf21..ef22f4cc6 100644 --- a/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/GithubToGithub.cs @@ -39,7 +39,7 @@ public GithubToGithub(ITestOutputHelper output) _helper = new TestHelper(_output, _githubApi, _githubClient); } - // [Fact] + [Fact] public async Task Basic() { var githubSourceOrg = $"octoshift-e2e-source-{TestHelper.GetOsName()}"; From ca52a114f487b839d03617d465aba59bedb394a1 Mon Sep 17 00:00:00 2001 From: bbsadmin Date: Mon, 18 Nov 2024 13:28:47 -0800 Subject: [PATCH 21/23] remove unncesary method --- src/OctoshiftCLI.IntegrationTests/TestHelper.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs index 925c82ac2..040b2ee72 100644 --- a/src/OctoshiftCLI.IntegrationTests/TestHelper.cs +++ b/src/OctoshiftCLI.IntegrationTests/TestHelper.cs @@ -547,9 +547,6 @@ public async Task RunPowershellScript(string script, IDictionary public async Task RunCliCommand(string command, string cliName, IDictionary tokens) => await RunShellCommand(command, cliName, GetOsDistPath(), tokens); - public async Task RunBbsMigrateRepoCommand(string migrateRepoCommand, IDictionary tokens) => - await RunCliCommand($"bbs2gh {migrateRepoCommand}", "gh", tokens); - private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary environmentVariables = null) { var startInfo = new ProcessStartInfo From 8e8dbbaaed4a07b5c92007672be4ffbe0b150fb1 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Mon, 18 Nov 2024 18:00:08 -0800 Subject: [PATCH 22/23] Update src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs Co-authored-by: Arin Ghazarian --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 4a25c98ec..4feb9c3c6 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -164,8 +164,6 @@ await _targetHelper.RunBbsCliMigration( _targetHelper.AssertNoErrorInLogs(_startTime); - _targetHelper.AssertNoErrorInLogs(_startTime); - await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo); await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo); } From db82dd8d3edf9f89a6e19fd95d8bb4608111cc10 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Mon, 18 Nov 2024 18:00:15 -0800 Subject: [PATCH 23/23] Update src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs Co-authored-by: Arin Ghazarian --- src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs index 4feb9c3c6..17ebc6965 100644 --- a/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs +++ b/src/OctoshiftCLI.IntegrationTests/BbsToGithub.cs @@ -155,9 +155,9 @@ public async Task MigrateRepo_MultipartUpload() var retryPolicy = new RetryPolicy(null); await retryPolicy.Retry(async () => - { - await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); - }); + { + await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg); + }); await _targetHelper.RunBbsCliMigration( $"generate-script --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE} --use-github-storage", _tokens);