Skip to content

Commit f04a2c8

Browse files
vidai-msftisra-fel
andauthored
Testfx target framework upgrade from netcoreapp3.1 to net6.0 (#22484)
* Upgraded target framework for testfx to net6.0 * Fixed test case issues after TestFx target framework upgraded to .NET6 and also improved test execution performance by replacing Start-Sleep with Start-TestSleep * Update test-steps.yml * Fixed test script issue for Compute. * Updated test framework for testcoverage CI --------- Co-authored-by: Yeming Liu <[email protected]>
1 parent a194bc2 commit f04a2c8

File tree

31 files changed

+211
-219
lines changed

31 files changed

+211
-219
lines changed

.azure-pipelines/powershell-core.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
variables:
2-
WindowsName: windows
2+
WindowsName: windows
33
WindowsAgentPoolName: pool-windows-2019
44
WindowsAgentPoolVMImage: ''
55
LinuxName: linux
@@ -8,7 +8,7 @@ variables:
88
MacOSName: macOS
99
MacOSAgentPoolName: 'Azure Pipelines'
1010
MacOSAgentPoolVMImage: macOS-11
11-
TestFramework: netcoreapp3.1
11+
TestFramework: net6.0
1212
TestTarget: Test
1313
Configuration: Debug
1414
DebugLocalBuildTasks: true

.azure-pipelines/test-coverage.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
parameters:
2-
- name: dotnet_sdk_3_1
3-
displayName: .NET Core 3.1
4-
default: 3.1.x
52
- name: dotnet_sdk_6
63
displayName: .NET 6
74
type: string
@@ -13,7 +10,7 @@ parameters:
1310
- name: testFramework
1411
displayName: Test Framework
1512
type: string
16-
default: netcoreapp3.1
13+
default: net6.0
1714
- name: testPoolName
1815
displayName: Test Pool Name
1916
type: string
@@ -64,10 +61,10 @@ jobs:
6461

6562
steps:
6663
- task: UseDotNet@2
67-
displayName: 'Install .NET Core 3.1 SDK'
64+
displayName: 'Install .NET 6.0 SDK'
6865
inputs:
6966
packageType: sdk
70-
version: ${{ parameters.dotnet_sdk_3_1 }}
67+
version: ${{ parameters.dotnet_sdk_6 }}
7168

7269
- task: PowerShell@2
7370
displayName: Initialize Environment

.azure-pipelines/util/test-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ steps:
2626
pwsh: true
2727

2828
- task: UseDotNet@2
29-
displayName: 'Use .NET Core sdk'
29+
displayName: 'Use .NET SDK 6 for tests'
3030
inputs:
3131
packageType: sdk
32-
version: 3.1.x
32+
version: 6.0.x
3333

3434
- task: PowerShell@2
3535
displayName: Remove pre-installed Az modules

.azure-pipelines/windows-powershell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ variables:
22
AgentPoolName: pool-windows-2019
33
WindowsName: windows
44
WindowsImage: windows-2019
5-
TestFramework: netcoreapp3.1
5+
TestFramework: net6.0
66
TestTarget: Test
77
Configuration: Debug
88
DebugLocalBuildTasks: true

src/Accounts/Accounts.Test/AzureRMProfileTests.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
using System.Net.Http;
4343
using System.Runtime.InteropServices;
4444
using System.Runtime.Serialization.Formatters.Binary;
45+
using System.Text.Json;
4546
using System.Threading;
4647
using System.Threading.Tasks;
4748

@@ -1064,20 +1065,10 @@ public void ProfileSerializeDeserializeWorks()
10641065
currentProfile.EnvironmentTable[environment.Name] = environment;
10651066
currentProfile.DefaultContext.TokenCache = new AzureTokenCache { CacheData = new byte[] { 1, 2, 3, 4, 5, 6, 8, 9, 0 } };
10661067

1067-
AzureRmProfile deserializedProfile;
10681068
// Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
1069-
BinaryFormatter bf = new BinaryFormatter();
1070-
using (MemoryStream ms = new MemoryStream())
1071-
{
1072-
// "Save" object state
1073-
bf.Serialize(ms, currentProfile);
1074-
1075-
// Re-use the same stream for de-serialization
1076-
ms.Seek(0, 0);
1077-
1078-
// Replace the original exception with de-serialized one
1079-
deserializedProfile = (AzureRmProfile)bf.Deserialize(ms);
1080-
}
1069+
var serializedProfile = JsonSerializer.Serialize(currentProfile);
1070+
// Replace the original exception with de-serialized one
1071+
var deserializedProfile = JsonSerializer.Deserialize<AzureRmProfile>(serializedProfile);
10811072
Assert.NotNull(deserializedProfile);
10821073
var jCurrentProfile = currentProfile.ToString();
10831074
var jDeserializedProfile = deserializedProfile.ToString();

src/Accounts/Accounts.Test/Mocks/MockDataStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ public X509Certificate2 GetCertificate(string thumbprint)
278278
}
279279
else
280280
{
281-
return new X509Certificate2();
281+
byte[] emptyCertificateData = Array.Empty<byte>();
282+
return new X509Certificate2(emptyCertificateData);
282283
}
283284
}
284285

src/Accounts/Accounts.Test/OnImportTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void UserProfilePathInAccessible()
4343
cmdlt.OnImport();
4444

4545
//Verify
46-
Assert.Equal(AzureSession.Instance.ARMContextSaveMode, ContextSaveMode.Process);
46+
Assert.Equal(ContextSaveMode.Process, AzureSession.Instance.ARMContextSaveMode);
4747
}
4848

4949
[Fact]
@@ -60,7 +60,7 @@ public void PersistenceCheckReturnFalse()
6060
cmdlt.OnImport();
6161

6262
//Verify
63-
Assert.Equal(AzureSession.Instance.ARMContextSaveMode, ContextSaveMode.Process);
63+
Assert.Equal(ContextSaveMode.Process, AzureSession.Instance.ARMContextSaveMode);
6464
}
6565
}
6666
}

src/Accounts/Authentication.Test/Mocks/MockDataStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ public X509Certificate2 GetCertificate(string thumbprint)
272272
}
273273
else
274274
{
275-
return new X509Certificate2();
275+
byte[] emptyCertificateData = Array.Empty<byte>();
276+
return new X509Certificate2(emptyCertificateData);
276277
}
277278
}
278279

src/Accounts/AuthenticationAssemblyLoadContext/AuthenticationAssemblyLoadContext.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />
77

88
<PropertyGroup>
9-
<TargetFramework>netcoreapp3.1</TargetFramework>
9+
<TargetFramework>net6.0</TargetFramework>
1010
<AssemblyName>Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext</AssemblyName>
1111
<RootNamespace>Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext</RootNamespace>
1212
</PropertyGroup>

src/Aks/Aks.Test/MergeKubeConfigTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ConfigFixture
1616

1717
public ConfigFixture()
1818
{
19-
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
19+
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
2020
var merged = ImportAzureRmAksCredential.MergeKubeConfig(File.ReadAllText(dir + "/Fixtures/config.yaml"), File.ReadAllText(dir + "/Fixtures/additional_kube_config.yaml"));
2121
_rootNode = RootNodeFromString(merged);
2222
}

0 commit comments

Comments
 (0)