6
6
using System . IO ;
7
7
using System . Linq ;
8
8
using System . Text ;
9
+ using System . Text . Json ;
9
10
using System . Threading . Tasks ;
10
11
using Microsoft . DotNet . MsiInstallerTests . Framework ;
11
12
using Microsoft . NET . Sdk . WorkloadManifestReader ;
@@ -17,8 +18,24 @@ public class WorkloadSetTests : VMTestBase
17
18
{
18
19
readonly string SdkTestingDirectory = @"C:\SdkTesting" ;
19
20
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
+
20
27
public WorkloadSetTests ( ITestOutputHelper log ) : base ( log )
21
28
{
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
+ } ) ;
22
39
}
23
40
24
41
[ Fact ]
@@ -91,7 +108,7 @@ public void UpdateWithWorkloadSets()
91
108
92
109
newRollback . ManifestVersions . Should ( ) . NotBeEquivalentTo ( rollbackAfterUpdate . ManifestVersions ) ;
93
110
94
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24217.2" ) ;
111
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion2 ) ;
95
112
}
96
113
97
114
[ Fact ]
@@ -113,10 +130,19 @@ public void UpdateInWorkloadSetModeWithNoAvailableWorkloadSet()
113
130
GetWorkloadVersion ( ) . Should ( ) . Be ( updatedWorkloadVersion ) ;
114
131
}
115
132
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 )
120
146
{
121
147
InstallSdk ( ) ;
122
148
@@ -148,7 +174,7 @@ public void UpdateToSpecificWorkloadSetVersion(string versionToInstall)
148
174
. Should ( )
149
175
. Pass ( ) ;
150
176
151
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24217.2" ) ;
177
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion2 ) ;
152
178
}
153
179
154
180
[ Fact ]
@@ -207,7 +233,7 @@ public void UpdateToWorkloadSetVersionWithManifestsNotAvailable()
207
233
208
234
var workloadVersionBeforeUpdate = GetWorkloadVersion ( ) ;
209
235
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" )
211
237
. Execute ( )
212
238
. Should ( )
213
239
. Fail ( ) ;
@@ -225,7 +251,7 @@ void SetupWorkloadSetInGlobalJson(out WorkloadSet originalRollback)
225
251
{
226
252
InstallSdk ( ) ;
227
253
228
- var versionToUpdateTo = "8.0.300-preview.0.24217.2" ;
254
+ var versionToUpdateTo = WorkloadSetVersion2 ;
229
255
230
256
string originalVersion = GetWorkloadVersion ( ) ;
231
257
@@ -286,7 +312,7 @@ public void InstallWithVersionAndSkipManifestUpdate()
286
312
{
287
313
InstallSdk ( ) ;
288
314
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 )
290
316
. Execute ( ) . Should ( ) . Fail ( )
291
317
. And . HaveStdErrContaining ( "--skip-manifest-update" )
292
318
. And . HaveStdErrContaining ( "--sdk-version" ) ;
@@ -300,17 +326,17 @@ public void InstallWithVersionWhenPinned()
300
326
AddNuGetSource ( @"c:\SdkTesting\WorkloadSets" ) ;
301
327
302
328
string originalVersion = GetWorkloadVersion ( ) ;
303
- originalVersion . Should ( ) . NotBe ( "8.0.300-preview.0.24178.1" ) ;
329
+ originalVersion . Should ( ) . NotBe ( WorkloadSetVersion1 ) ;
304
330
305
- VM . CreateRunCommand ( "dotnet" , "workload" , "update" , "--version" , "8.0.300-preview.0.24178.1" )
331
+ VM . CreateRunCommand ( "dotnet" , "workload" , "update" , "--version" , WorkloadSetVersion1 )
306
332
. Execute ( ) . Should ( ) . Pass ( ) ;
307
333
308
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24178.1" ) ;
334
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion1 ) ;
309
335
310
- VM . CreateRunCommand ( "dotnet" , "workload" , "install" , "aspire" , "--version" , "8.0.300-preview.0.24217.2" )
336
+ VM . CreateRunCommand ( "dotnet" , "workload" , "install" , "aspire" , "--version" , WorkloadSetVersion2 )
311
337
. Execute ( ) . Should ( ) . Pass ( ) ;
312
338
313
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24217.2" ) ;
339
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion2 ) ;
314
340
}
315
341
316
342
[ Fact ]
@@ -321,18 +347,18 @@ public void InstallWithGlobalJsonWhenPinned()
321
347
//AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
322
348
323
349
string originalVersion = GetWorkloadVersion ( ) ;
324
- originalVersion . Should ( ) . NotBe ( "8.0.300-preview.0.24178.1" ) ;
350
+ originalVersion . Should ( ) . NotBe ( WorkloadSetVersion1 ) ;
325
351
326
- VM . CreateRunCommand ( "dotnet" , "workload" , "update" , "--version" , "8.0.300-preview.0.24178.1" )
352
+ VM . CreateRunCommand ( "dotnet" , "workload" , "update" , "--version" , WorkloadSetVersion1 )
327
353
. Execute ( ) . Should ( ) . Pass ( ) ;
328
354
329
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24178.1" ) ;
355
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion1 ) ;
330
356
331
357
VM . CreateRunCommand ( "dotnet" , "workload" , "install" , "aspire" )
332
358
. WithWorkingDirectory ( SdkTestingDirectory )
333
359
. Execute ( ) . Should ( ) . Pass ( ) ;
334
360
335
- GetWorkloadVersion ( SdkTestingDirectory ) . Should ( ) . Be ( "8.0.300-preview.0.24217.2" ) ;
361
+ GetWorkloadVersion ( SdkTestingDirectory ) . Should ( ) . Be ( WorkloadSetVersion2 ) ;
336
362
337
363
GetRollback ( SdkTestingDirectory ) . Should ( ) . NotBe ( originalRollback ) ;
338
364
@@ -346,22 +372,28 @@ public void UpdateShouldNotPinWorkloadSet()
346
372
347
373
AddNuGetSource ( @"c:\SdkTesting\WorkloadSets" ) ;
348
374
375
+ var packageVersion = WorkloadSet . WorkloadSetVersionToWorkloadSetPackageVersion ( WorkloadSetVersion2 , out var sdkFeatureBand ) ;
376
+
349
377
// 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") )
351
381
. Execute ( ) . Should ( ) . Pass ( ) ;
352
382
353
383
VM . CreateRunCommand ( "dotnet" , "workload" , "update" )
354
384
. Execute ( ) . Should ( ) . Pass ( ) ;
355
385
356
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24178.1" ) ;
386
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion1 ) ;
357
387
358
388
// 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") )
360
392
. Execute ( ) . Should ( ) . Pass ( ) ;
361
393
362
394
InstallWorkload ( "aspire" , skipManifestUpdate : false ) ;
363
395
364
- GetWorkloadVersion ( ) . Should ( ) . Be ( "8.0.300-preview.0.24217.2" ) ;
396
+ GetWorkloadVersion ( ) . Should ( ) . Be ( WorkloadSetVersion2 ) ;
365
397
}
366
398
367
399
[ Fact ]
0 commit comments