Skip to content

Commit cf31e96

Browse files
committed
Load test workload set versions from file on VM
1 parent 6ac1637 commit cf31e96

File tree

1 file changed

+57
-22
lines changed

1 file changed

+57
-22
lines changed

src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using System.Text;
9+
using System.Text.Json;
910
using System.Threading.Tasks;
1011
using Microsoft.DotNet.MsiInstallerTests.Framework;
1112
using Microsoft.NET.Sdk.WorkloadManifestReader;
@@ -17,8 +18,24 @@ public class WorkloadSetTests : VMTestBase
1718
{
1819
readonly string SdkTestingDirectory = @"C:\SdkTesting";
1920

21+
22+
Lazy<Dictionary<string, string>> _testWorkloadSetVersions;
23+
string WorkloadSetVersion1 => _testWorkloadSetVersions.Value.GetValueOrDefault("version1", "8.0.300-preview.0.24178.1");
24+
string WorkloadSetVersion2 => _testWorkloadSetVersions.Value.GetValueOrDefault("version2", "8.0.300-preview.0.24217.2");
25+
string WorkloadSetPreviousBandVersion => _testWorkloadSetVersions.Value.GetValueOrDefault("previousbandversion", "8.0.204");
26+
2027
public WorkloadSetTests(ITestOutputHelper log) : base(log)
2128
{
29+
_testWorkloadSetVersions = new Lazy<Dictionary<string, string>>(() =>
30+
{
31+
var versionsFile = VM.GetRemoteFile(@"c:\SdkTesting\workloadsets\testworkloadsetversions.json");
32+
if (!versionsFile.Exists)
33+
{
34+
return new Dictionary<string, string>();
35+
}
36+
37+
return JsonSerializer.Deserialize<Dictionary<string, string>>(versionsFile.ReadAllText());
38+
});
2239
}
2340

2441
[Fact]
@@ -91,7 +108,7 @@ public void UpdateWithWorkloadSets()
91108

92109
newRollback.ManifestVersions.Should().NotBeEquivalentTo(rollbackAfterUpdate.ManifestVersions);
93110

94-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
111+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
95112
}
96113

97114
[Fact]
@@ -113,10 +130,19 @@ public void UpdateInWorkloadSetModeWithNoAvailableWorkloadSet()
113130
GetWorkloadVersion().Should().Be(updatedWorkloadVersion);
114131
}
115132

116-
[Theory]
117-
[InlineData("8.0.300-preview.0.24178.1")]
118-
[InlineData("8.0.204")]
119-
public void UpdateToSpecificWorkloadSetVersion(string versionToInstall)
133+
[Fact]
134+
public void UpdateToSpecificWorkloadSetVersion()
135+
{
136+
UpdateToWorkloadSetVersion(WorkloadSetVersion1);
137+
}
138+
139+
[Fact]
140+
public void UpdateToPreviousBandWorkloadSetVersion()
141+
{
142+
UpdateToWorkloadSetVersion(WorkloadSetPreviousBandVersion);
143+
}
144+
145+
private void UpdateToWorkloadSetVersion(string versionToInstall)
120146
{
121147
InstallSdk();
122148

@@ -148,7 +174,7 @@ public void UpdateToSpecificWorkloadSetVersion(string versionToInstall)
148174
.Should()
149175
.Pass();
150176

151-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
177+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
152178
}
153179

154180
[Fact]
@@ -207,7 +233,7 @@ public void UpdateToWorkloadSetVersionWithManifestsNotAvailable()
207233

208234
var workloadVersionBeforeUpdate = GetWorkloadVersion();
209235

210-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", @"8.0.300-preview.0.24217.2", "--source", @"c:\SdkTesting\workloadsets")
236+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion2, "--source", @"c:\SdkTesting\workloadsets")
211237
.Execute()
212238
.Should()
213239
.Fail();
@@ -225,7 +251,7 @@ void SetupWorkloadSetInGlobalJson(out WorkloadSet originalRollback)
225251
{
226252
InstallSdk();
227253

228-
var versionToUpdateTo = "8.0.300-preview.0.24217.2";
254+
var versionToUpdateTo = WorkloadSetVersion2;
229255

230256
string originalVersion = GetWorkloadVersion();
231257

@@ -286,7 +312,7 @@ public void InstallWithVersionAndSkipManifestUpdate()
286312
{
287313
InstallSdk();
288314

289-
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--skip-manifest-update", "--version", "8.0.300-preview.0.24178.1")
315+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--skip-manifest-update", "--version", WorkloadSetVersion1)
290316
.Execute().Should().Fail()
291317
.And.HaveStdErrContaining("--skip-manifest-update")
292318
.And.HaveStdErrContaining("--sdk-version");
@@ -300,17 +326,17 @@ public void InstallWithVersionWhenPinned()
300326
AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
301327

302328
string originalVersion = GetWorkloadVersion();
303-
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
329+
originalVersion.Should().NotBe(WorkloadSetVersion1);
304330

305-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
331+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion1)
306332
.Execute().Should().Pass();
307333

308-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
334+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
309335

310-
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--version", "8.0.300-preview.0.24217.2")
336+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--version", WorkloadSetVersion2)
311337
.Execute().Should().Pass();
312338

313-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
339+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
314340
}
315341

316342
[Fact]
@@ -321,18 +347,18 @@ public void InstallWithGlobalJsonWhenPinned()
321347
//AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
322348

323349
string originalVersion = GetWorkloadVersion();
324-
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
350+
originalVersion.Should().NotBe(WorkloadSetVersion1);
325351

326-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
352+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion1)
327353
.Execute().Should().Pass();
328354

329-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
355+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
330356

331357
VM.CreateRunCommand("dotnet", "workload", "install", "aspire")
332358
.WithWorkingDirectory(SdkTestingDirectory)
333359
.Execute().Should().Pass();
334360

335-
GetWorkloadVersion(SdkTestingDirectory).Should().Be("8.0.300-preview.0.24217.2");
361+
GetWorkloadVersion(SdkTestingDirectory).Should().Be(WorkloadSetVersion2);
336362

337363
GetRollback(SdkTestingDirectory).Should().NotBe(originalRollback);
338364

@@ -346,22 +372,31 @@ public void UpdateShouldNotPinWorkloadSet()
346372

347373
AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
348374

375+
var packageVersion = WorkloadSet.WorkloadSetVersionToWorkloadSetPackageVersion(WorkloadSetVersion2, out var sdkFeatureBand);
376+
349377
// Rename latest workload set so it won't be installed
350-
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.nupkg", $"Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.bak")
378+
VM.CreateActionGroup($"Disable {WorkloadSetVersion2}",
379+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.nupkg", $"Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.bak"),
380+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.nupkg", $"Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.bak"))
351381
.Execute().Should().Pass();
352382

353383
VM.CreateRunCommand("dotnet", "workload", "update")
354384
.Execute().Should().Pass();
355385

356-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
386+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
357387

358388
// Bring latest workload set version back, so installing workload should update to it
359-
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.bak", $"Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.nupkg")
389+
VM.CreateActionGroup($"Enable {WorkloadSetVersion2}",
390+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.bak", $"Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.nupkg"),
391+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.bak", $"Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.nupkg"))
360392
.Execute().Should().Pass();
361393

394+
//VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.bak", $"Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.nupkg")
395+
// .Execute().Should().Pass();
396+
362397
InstallWorkload("aspire", skipManifestUpdate: false);
363398

364-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
399+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
365400
}
366401

367402
[Fact]

0 commit comments

Comments
 (0)