Skip to content

Commit eb712b1

Browse files
committed
split up bbs e2e tests
1 parent 094b0f8 commit eb712b1

File tree

6 files changed

+635
-1
lines changed

6 files changed

+635
-1
lines changed

.github/workflows/integration-tests.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,34 @@ jobs:
9191
fail-fast: false
9292
matrix:
9393
runner-os: [windows-latest, ubuntu-latest, macos-latest]
94-
source-vcs: [AdoBasic, AdoCsv, Bbs, Ghes, Github]
94+
source-vcs: [AdoBasic, AdoCsv, Ghes, Github, BbsAzureLinux, BbsAzureWindows, BbsAwsLinux, BbsGithubStorage, BbsGithubMultipart]
95+
exclude:
96+
# Split BBS tests across different runners for parallelization instead of running all on each platform
97+
# BbsAzureLinux runs on ubuntu-latest
98+
- runner-os: windows-latest
99+
source-vcs: BbsAzureLinux
100+
- runner-os: macos-latest
101+
source-vcs: BbsAzureLinux
102+
# BbsAzureWindows runs on windows-latest
103+
- runner-os: ubuntu-latest
104+
source-vcs: BbsAzureWindows
105+
- runner-os: macos-latest
106+
source-vcs: BbsAzureWindows
107+
# BbsAwsLinux runs on macos-latest
108+
- runner-os: windows-latest
109+
source-vcs: BbsAwsLinux
110+
- runner-os: ubuntu-latest
111+
source-vcs: BbsAwsLinux
112+
# BbsGithubStorage runs on ubuntu-latest
113+
- runner-os: windows-latest
114+
source-vcs: BbsGithubStorage
115+
- runner-os: macos-latest
116+
source-vcs: BbsGithubStorage
117+
# BbsGithubMultipart runs on windows-latest
118+
- runner-os: ubuntu-latest
119+
source-vcs: BbsGithubMultipart
120+
- runner-os: macos-latest
121+
source-vcs: BbsGithubMultipart
95122
runs-on: ${{ matrix.runner-os }}
96123
concurrency: integration-test-${{ matrix.source-vcs }}-${{ matrix.runner-os }}
97124
steps:
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Net.Http;
5+
using System.Threading.Tasks;
6+
using Azure.Storage.Blobs;
7+
using OctoshiftCLI.Services;
8+
using Xunit;
9+
using Xunit.Abstractions;
10+
11+
namespace OctoshiftCLI.IntegrationTests;
12+
13+
[Collection("Integration Tests")]
14+
public sealed class BbsAwsLinuxToGithub : IDisposable
15+
{
16+
private const string SSH_KEY_FILE = "ssh_key.pem";
17+
private const string AWS_REGION = "us-east-1";
18+
19+
private readonly ITestOutputHelper _output;
20+
private readonly OctoLogger _logger;
21+
private readonly TestHelper _targetHelper;
22+
private readonly HttpClient _versionClient;
23+
private readonly HttpClient _targetGithubHttpClient;
24+
private readonly GithubClient _targetGithubClient;
25+
private readonly GithubApi _targetGithubApi;
26+
private readonly HttpClient _sourceBbsHttpClient;
27+
private readonly BbsClient _sourceBbsClient;
28+
private readonly BlobServiceClient _blobServiceClient;
29+
private readonly ArchiveUploader _archiveUploader;
30+
private readonly Dictionary<string, string> _tokens;
31+
private readonly DateTime _startTime;
32+
33+
public BbsAwsLinuxToGithub(ITestOutputHelper output)
34+
{
35+
_startTime = DateTime.Now;
36+
_output = output;
37+
38+
_logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { });
39+
40+
var sourceBbsUsername = Environment.GetEnvironmentVariable("BBS_USERNAME");
41+
var sourceBbsPassword = Environment.GetEnvironmentVariable("BBS_PASSWORD");
42+
var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT");
43+
_tokens = new Dictionary<string, string>
44+
{
45+
["GHEC_PAT"] = targetGithubToken,
46+
["BBS_USERNAME"] = sourceBbsUsername,
47+
["BBS_PASSWORD"] = sourceBbsPassword
48+
};
49+
50+
_targetHelper = new TestHelper(_output, targetGithubToken);
51+
52+
_versionClient = new HttpClient();
53+
_targetGithubHttpClient = new HttpClient();
54+
_targetGithubClient = new GithubClient(_logger, _targetGithubHttpClient, new VersionChecker(_versionClient, _logger), new RetryPolicy(_logger), new DateTimeProvider(), targetGithubToken);
55+
var retryPolicy = new RetryPolicy(_logger);
56+
var environmentVariableProvider = new EnvironmentVariableProvider(_logger);
57+
_archiveUploader = new ArchiveUploader(_targetGithubClient, _logger, retryPolicy, environmentVariableProvider);
58+
_targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(_logger), _archiveUploader);
59+
60+
var azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_BBS_{TestHelper.GetOsName().ToUpper()}");
61+
_blobServiceClient = new BlobServiceClient(azureStorageConnectionString);
62+
63+
_sourceBbsHttpClient = new HttpClient();
64+
_sourceBbsClient = new BbsClient(_logger, _sourceBbsHttpClient, new VersionChecker(_versionClient, _logger), new RetryPolicy(_logger), new DateTimeProvider(), sourceBbsUsername, sourceBbsPassword);
65+
}
66+
67+
[Fact]
68+
public async Task MigrateRepo_BbsLinux_AwsS3()
69+
{
70+
var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.westus2.cloudapp.azure.com:7990";
71+
var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}";
72+
var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}";
73+
var repo1 = $"{bbsProjectKey}-repo-1";
74+
var repo2 = $"{bbsProjectKey}-repo-2";
75+
var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1";
76+
var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2";
77+
78+
var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger);
79+
var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer);
80+
81+
var retryPolicy = new RetryPolicy(null);
82+
83+
await retryPolicy.Retry(async () =>
84+
{
85+
await _targetHelper.ResetBlobContainers();
86+
await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey);
87+
await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg);
88+
89+
await sourceHelper.CreateBbsProject(bbsProjectKey);
90+
await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1);
91+
await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1);
92+
await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2);
93+
await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2);
94+
});
95+
96+
// Use SSH for archive download
97+
var sshKey = Environment.GetEnvironmentVariable("SSH_KEY_BBS_8_5_0");
98+
await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey);
99+
var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}";
100+
101+
// Use AWS S3
102+
_tokens.Add("AWS_ACCESS_KEY_ID", Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID"));
103+
_tokens.Add("AWS_SECRET_ACCESS_KEY", Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY"));
104+
var awsBucketName = Environment.GetEnvironmentVariable("AWS_BUCKET_NAME");
105+
var awsOptions = $" --aws-bucket-name {awsBucketName} --aws-region {AWS_REGION}";
106+
107+
await _targetHelper.RunBbsCliMigration(
108+
$"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {repo1} --github-repo {targetRepo1}{archiveDownloadOptions}{awsOptions}", _tokens);
109+
110+
_targetHelper.AssertNoErrorInLogs(_startTime);
111+
112+
await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1);
113+
await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1);
114+
115+
await _targetHelper.RunBbsCliMigration(
116+
$"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {repo2} --github-repo {targetRepo2}{archiveDownloadOptions}{awsOptions}", _tokens);
117+
118+
_targetHelper.AssertNoErrorInLogs(_startTime);
119+
120+
await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2);
121+
await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2);
122+
}
123+
124+
public void Dispose()
125+
{
126+
_sourceBbsHttpClient?.Dispose();
127+
_targetGithubHttpClient?.Dispose();
128+
_versionClient?.Dispose();
129+
}
130+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Net.Http;
5+
using System.Threading.Tasks;
6+
using Azure.Storage.Blobs;
7+
using OctoshiftCLI.Services;
8+
using Xunit;
9+
using Xunit.Abstractions;
10+
11+
namespace OctoshiftCLI.IntegrationTests;
12+
13+
[Collection("Integration Tests")]
14+
public sealed class BbsAzureLinuxToGithub : IDisposable
15+
{
16+
private const string SSH_KEY_FILE = "ssh_key.pem";
17+
18+
private readonly ITestOutputHelper _output;
19+
private readonly OctoLogger _logger;
20+
private readonly TestHelper _targetHelper;
21+
private readonly HttpClient _versionClient;
22+
private readonly HttpClient _targetGithubHttpClient;
23+
private readonly GithubClient _targetGithubClient;
24+
private readonly GithubApi _targetGithubApi;
25+
private readonly HttpClient _sourceBbsHttpClient;
26+
private readonly BbsClient _sourceBbsClient;
27+
private readonly BlobServiceClient _blobServiceClient;
28+
private readonly ArchiveUploader _archiveUploader;
29+
private readonly Dictionary<string, string> _tokens;
30+
private readonly DateTime _startTime;
31+
private readonly string _azureStorageConnectionString;
32+
33+
public BbsAzureLinuxToGithub(ITestOutputHelper output)
34+
{
35+
_startTime = DateTime.Now;
36+
_output = output;
37+
38+
_logger = new OctoLogger(_ => { }, x => _output.WriteLine(x), _ => { }, _ => { });
39+
40+
var sourceBbsUsername = Environment.GetEnvironmentVariable("BBS_USERNAME");
41+
var sourceBbsPassword = Environment.GetEnvironmentVariable("BBS_PASSWORD");
42+
var targetGithubToken = Environment.GetEnvironmentVariable("GHEC_PAT");
43+
_azureStorageConnectionString = Environment.GetEnvironmentVariable($"AZURE_STORAGE_CONNECTION_STRING_BBS_{TestHelper.GetOsName().ToUpper()}");
44+
_tokens = new Dictionary<string, string>
45+
{
46+
["GHEC_PAT"] = targetGithubToken,
47+
["BBS_USERNAME"] = sourceBbsUsername,
48+
["BBS_PASSWORD"] = sourceBbsPassword
49+
};
50+
51+
_targetHelper = new TestHelper(_output, targetGithubToken);
52+
53+
_versionClient = new HttpClient();
54+
_targetGithubHttpClient = new HttpClient();
55+
_targetGithubClient = new GithubClient(_logger, _targetGithubHttpClient, new VersionChecker(_versionClient, _logger), new RetryPolicy(_logger), new DateTimeProvider(), targetGithubToken);
56+
var retryPolicy = new RetryPolicy(_logger);
57+
var environmentVariableProvider = new EnvironmentVariableProvider(_logger);
58+
_archiveUploader = new ArchiveUploader(_targetGithubClient, _logger, retryPolicy, environmentVariableProvider);
59+
_targetGithubApi = new GithubApi(_targetGithubClient, "https://api.github.com", new RetryPolicy(_logger), _archiveUploader);
60+
61+
_blobServiceClient = new BlobServiceClient(_azureStorageConnectionString);
62+
63+
_sourceBbsHttpClient = new HttpClient();
64+
_sourceBbsClient = new BbsClient(_logger, _sourceBbsHttpClient, new VersionChecker(_versionClient, _logger), new RetryPolicy(_logger), new DateTimeProvider(), sourceBbsUsername, sourceBbsPassword);
65+
}
66+
67+
[Fact]
68+
public async Task MigrateRepo_BbsLinux_AzureStorage()
69+
{
70+
var bbsServer = "http://e2e-bbs-8-5-0-linux-2204.westus2.cloudapp.azure.com:7990";
71+
var bbsProjectKey = $"E2E-{TestHelper.GetOsName().ToUpper()}";
72+
var githubTargetOrg = $"octoshift-e2e-bbs-{TestHelper.GetOsName()}";
73+
var repo1 = $"{bbsProjectKey}-repo-1";
74+
var repo2 = $"{bbsProjectKey}-repo-2";
75+
var targetRepo1 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-1";
76+
var targetRepo2 = $"{bbsProjectKey}-e2e-{TestHelper.GetOsName().ToLower()}-repo-2";
77+
78+
var sourceBbsApi = new BbsApi(_sourceBbsClient, bbsServer, _logger);
79+
var sourceHelper = new TestHelper(_output, sourceBbsApi, _sourceBbsClient, bbsServer);
80+
81+
var retryPolicy = new RetryPolicy(null);
82+
83+
await retryPolicy.Retry(async () =>
84+
{
85+
await _targetHelper.ResetBlobContainers();
86+
await sourceHelper.ResetBbsTestEnvironment(bbsProjectKey);
87+
await _targetHelper.ResetGithubTestEnvironment(githubTargetOrg);
88+
89+
await sourceHelper.CreateBbsProject(bbsProjectKey);
90+
await sourceHelper.CreateBbsRepo(bbsProjectKey, repo1);
91+
await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo1);
92+
await sourceHelper.CreateBbsRepo(bbsProjectKey, repo2);
93+
await sourceHelper.InitializeBbsRepo(bbsProjectKey, repo2);
94+
});
95+
96+
// Use SSH for archive download
97+
var sshKey = Environment.GetEnvironmentVariable("SSH_KEY_BBS_8_5_0");
98+
await File.WriteAllTextAsync(Path.Join(TestHelper.GetOsDistPath(), SSH_KEY_FILE), sshKey);
99+
var archiveDownloadOptions = $" --ssh-user octoshift --ssh-private-key {SSH_KEY_FILE}";
100+
101+
// Use Azure Storage
102+
_tokens.Add("AZURE_STORAGE_CONNECTION_STRING", _azureStorageConnectionString);
103+
104+
await _targetHelper.RunBbsCliMigration(
105+
$"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {repo1} --github-repo {targetRepo1}{archiveDownloadOptions}", _tokens);
106+
107+
_targetHelper.AssertNoErrorInLogs(_startTime);
108+
109+
await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo1);
110+
await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo1);
111+
112+
await _targetHelper.RunBbsCliMigration(
113+
$"migrate-repo --github-org {githubTargetOrg} --bbs-server-url {bbsServer} --bbs-project {bbsProjectKey} --bbs-repo {repo2} --github-repo {targetRepo2}{archiveDownloadOptions}", _tokens);
114+
115+
_targetHelper.AssertNoErrorInLogs(_startTime);
116+
117+
await _targetHelper.AssertGithubRepoExists(githubTargetOrg, targetRepo2);
118+
await _targetHelper.AssertGithubRepoInitialized(githubTargetOrg, targetRepo2);
119+
}
120+
121+
public void Dispose()
122+
{
123+
_sourceBbsHttpClient?.Dispose();
124+
_targetGithubHttpClient?.Dispose();
125+
_versionClient?.Dispose();
126+
}
127+
}

0 commit comments

Comments
 (0)