Skip to content

Commit ca2c629

Browse files
authored
[Tests] Replace azurestorage with a github repo. (#7524)
Our `https://xamjenkinsartifact.azureedge.net` site for some of the unit test data seems to have disappeared. So lets use a github repo to store this data instead. The unit tests can download the raw files directly from github. The repo will be public as well so there won't be any need for authorization. Update `DeleteBinObjTest` to use `7z`
1 parent 6573c37 commit ca2c629

File tree

5 files changed

+65
-13
lines changed

5 files changed

+65
-13
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/FilterAssembliesTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public void TearDown ()
3030
Directory.Delete (tempDirectory, recursive: true);
3131
}
3232

33-
Task<string> DownloadFromNuGet (string url) =>
34-
Task.Factory.StartNew (() => new DownloadedCache ().GetAsFile (url));
33+
Task<string> DownloadFromNuGet (string url, string filename = "") =>
34+
Task.Factory.StartNew (() => new DownloadedCache ().GetAsFile (url, filename));
3535

36-
async Task<string []> GetAssembliesFromNuGet (string url, string path)
36+
async Task<string []> GetAssembliesFromNuGet (string url, string filename, string path)
3737
{
3838
var assemblies = new List<string> ();
39-
var nuget = await DownloadFromNuGet (url);
39+
var nuget = await DownloadFromNuGet (url, filename);
4040
using (var zip = ZipArchive.Open (nuget, FileMode.Open)) {
4141
foreach (var entry in zip) {
4242
if (entry.FullName.StartsWith (path, StringComparison.OrdinalIgnoreCase) &&
@@ -67,6 +67,7 @@ public async Task CircleImageView ()
6767
{
6868
var assemblies = await GetAssembliesFromNuGet (
6969
"https://www.nuget.org/api/v2/package/Refractored.Controls.CircleImageView/1.0.1",
70+
"Refractored.Controls.CircleImageView.1.0.1.nupkg",
7071
"lib/MonoAndroid10/");
7172
var actual = Run (assemblies);
7273
var expected = new [] { "Refractored.Controls.CircleImageView.dll" };
@@ -78,6 +79,7 @@ public async Task XamarinForms ()
7879
{
7980
var assemblies = await GetAssembliesFromNuGet (
8081
"https://www.nuget.org/api/v2/package/Xamarin.Forms/3.6.0.220655",
82+
"Xamarin.Forms.3.6.0.220655.nupkg",
8183
"lib/MonoAndroid90/");
8284
var actual = Run (assemblies);
8385
var expected = new [] {
@@ -93,6 +95,7 @@ public async Task GuavaListenableFuture ()
9395
{
9496
var assemblies = await GetAssembliesFromNuGet (
9597
"https://www.nuget.org/api/v2/package/Xamarin.Google.Guava.ListenableFuture/1.0.0",
98+
"Xamarin.Google.Guava.ListenableFuture.1.0.0.nupkg",
9699
"lib/MonoAndroid50/");
97100
var actual = Run (assemblies);
98101
var expected = new [] { "Xamarin.Google.Guava.ListenableFuture.dll" };

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/BuildItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ public string WebContent {
133133
}
134134

135135
/// <summary>
136-
/// NOTE: downloads a file from our https://xamjenkinsartifact.azureedge.net/ Azure Storage Account
136+
/// NOTE: downloads a file from our https://github.com/dellis1972/xamarin-android-unittest-files repo
137137
/// </summary>
138138
public string WebContentFileNameFromAzure {
139139
get { throw new NotSupportedException (); }
140-
set { WebContent = $"https://xamjenkinsartifact.azureedge.net/mono-jenkins/xamarin-android-test/{value}"; }
140+
set { WebContent = $"https://github.com/dellis1972/xamarin-android-unittest-files/blob/main/{value}?raw=true"; }
141141
}
142142

143143
public string MetadataValues {

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public DownloadedCache (string cacheDirectory)
2424

2525
public string CacheDirectory { get; private set; }
2626

27-
public string GetAsFile (string url)
27+
public string GetAsFile (string url, string filename = "")
2828
{
2929
Directory.CreateDirectory (CacheDirectory);
3030

31-
var filename = Path.Combine (CacheDirectory, Path.GetFileName (new Uri (url).LocalPath));
31+
filename = Path.Combine (CacheDirectory, string.IsNullOrEmpty (filename) ? Path.GetFileName (new Uri (url).LocalPath) : filename);
3232
lock (locks.GetOrAdd (filename, _ => new object ())) {
3333
if (File.Exists (filename))
3434
return filename;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.IO;
3+
using System.Diagnostics;
4+
5+
namespace Xamarin.ProjectTools {
6+
public class SevenZipHelper : IDisposable {
7+
public string ArchivePath { get; private set; }
8+
9+
public SevenZipHelper (string archivePath)
10+
{
11+
ArchivePath = archivePath;
12+
}
13+
14+
public bool ExtractAll (string destinationDir)
15+
{
16+
using (var p = new Process ()) {
17+
p.StartInfo.FileName = Path.Combine ("7z");
18+
p.StartInfo.Arguments = $"x {ArchivePath} -o{destinationDir}";
19+
p.StartInfo.CreateNoWindow = true;
20+
p.StartInfo.UseShellExecute = false;
21+
p.StartInfo.RedirectStandardOutput = true;
22+
p.StartInfo.RedirectStandardError = true;
23+
p.ErrorDataReceived += (sender, e) => {
24+
if (e.Data != null) {
25+
Console.WriteLine (e.Data);
26+
}
27+
};
28+
p.ErrorDataReceived += (sender, e) => {
29+
if (e.Data != null) {
30+
Console.WriteLine (e.Data);
31+
}
32+
};
33+
34+
p.Start ();
35+
p.BeginOutputReadLine ();
36+
p.BeginErrorReadLine ();
37+
bool completed = p.WaitForExit ((int) new TimeSpan (0, 15, 0).TotalMilliseconds);
38+
return completed && p.ExitCode == 0;
39+
}
40+
}
41+
42+
public void Dispose ()
43+
{
44+
}
45+
46+
public static SevenZipHelper Open (string path, FileMode fileMode)
47+
{
48+
return new SevenZipHelper (path);
49+
}
50+
}
51+
}

tests/MSBuildDeviceIntegration/Tests/DeleteBinObjTest.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using Xamarin.ProjectTools;
5-
using Xamarin.Tools.Zip;
65

76
namespace Xamarin.Android.Build.Tests
87
{
98
[TestFixture]
109
[Category ("DotNetIgnore"), Category ("Node-1")] // .csproj files are legacy projects that won't build under dotnet
1110
public class DeleteBinObjTest : DeviceTest
1211
{
13-
const string BaseUrl = "https://xamjenkinsartifact.azureedge.net/mono-jenkins/xamarin-android-test/";
12+
const string BaseUrl = "https://github.com/dellis1972/xamarin-android-unittest-files/blob/main/";
1413
readonly DownloadedCache Cache = new DownloadedCache ();
1514

1615
string HostOS => IsWindows ? "Windows" : "Darwin";
17-
1816
void RunTest (string name, string sln, string csproj, string version, string revision, string packageName, string javaPackageName, bool isRelease)
1917
{
2018
var configuration = isRelease ? "Release" : "Debug";
21-
var zipPath = Cache.GetAsFile ($"{BaseUrl}{name}-{version}-{HostOS}-{revision}.zip");
19+
var zipPath = Cache.GetAsFile ($"{BaseUrl}{name}-{version}-{HostOS}-{revision}.7z?raw=true");
2220
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName)))
23-
using (var zip = ZipArchive.Open (zipPath, FileMode.Open)) {
21+
using (var zip = SevenZipHelper.Open (zipPath, FileMode.Open)) {
2422
builder.AutomaticNuGetRestore = false;
2523

2624
if (!builder.TargetFrameworkExists ("v9.0")) {

0 commit comments

Comments
 (0)