Skip to content

Commit 47b64d5

Browse files
committed
Integrate CoreWCF services for WCF tests. Add Selfhosted CoreWCF Service for test hosts. Refactor project for CoreWCF compatibility and updates.
This commit includes significant updates to transition the codebase from traditional WCF to CoreWCF, enhancing compatibility with .NET Core. Key changes include: - Updates to Azure pipeline configurations to support new environment variables and MacOS build conditions. - Introduction of new methods in `ConditionalTestDetectors.cs` for checking CoreWCF service status. - Improvements in error handling within `ServiceUtilHelper.cs` for HTTP requests. - Fixes to endpoint address formatting in `Endpoints.cs`. - Implementation of digest authentication in new `DigestAuthentication` classes. - Enhancements to certificate handling in `CertificateGenerator` and `CertificateManager`. - Updates to various test classes to improve reliability when running with CoreWCF. - Overall project structure and dependency updates to reflect the new architecture using CoreWCF and .NET Core compatibility.
1 parent 70e593d commit 47b64d5

File tree

242 files changed

+3002
-4482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+3002
-4482
lines changed

System.ServiceModel.sln

-7
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encoding.MessageVersion.Int
4949
EndProject
5050
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensibility.MessageEncoder.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Extensibility\MessageEncoder\Extensibility.MessageEncoder.IntegrationTests.csproj", "{76361777-321D-4588-87F9-38992A758350}"
5151
EndProject
52-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensibility.MessageInterceptor.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Extensibility\MessageInterceptor\Extensibility.MessageInterceptor.IntegrationTests.csproj", "{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}"
53-
EndProject
5452
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensibility.WebSockets.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Extensibility\WebSockets\Extensibility.WebSockets.IntegrationTests.csproj", "{C8CA16D3-5B1E-4EC0-A817-205A798DC272}"
5553
EndProject
5654
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Infrastructure\Infrastructure.IntegrationTests.csproj", "{719E874A-AEFA-44D5-9530-9C41BD0FA4E8}"
@@ -209,10 +207,6 @@ Global
209207
{76361777-321D-4588-87F9-38992A758350}.Debug|Any CPU.Build.0 = Debug|Any CPU
210208
{76361777-321D-4588-87F9-38992A758350}.Release|Any CPU.ActiveCfg = Release|Any CPU
211209
{76361777-321D-4588-87F9-38992A758350}.Release|Any CPU.Build.0 = Release|Any CPU
212-
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
213-
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Debug|Any CPU.Build.0 = Debug|Any CPU
214-
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Release|Any CPU.ActiveCfg = Release|Any CPU
215-
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Release|Any CPU.Build.0 = Release|Any CPU
216210
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
217211
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Debug|Any CPU.Build.0 = Debug|Any CPU
218212
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -337,7 +331,6 @@ Global
337331
{48C41A27-631F-45FA-ACD5-7D7EDD4A4931} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
338332
{36DD97F6-1F78-4843-A9C0-58C59D367603} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
339333
{76361777-321D-4588-87F9-38992A758350} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
340-
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
341334
{C8CA16D3-5B1E-4EC0-A817-205A798DC272} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
342335
{719E874A-AEFA-44D5-9530-9C41BD0FA4E8} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
343336
{E878E412-F0AB-4D87-8A7A-3114AAC48CD5} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}

azure-pipelines-arcade-PR.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,20 @@ stages:
200200
--projects $(Build.SourcesDirectory)/eng/SendToHelix.proj
201201
$(_TestArgs)
202202
/p:TestJob=Linux
203-
/p:RunWithCoreWcfService=$($Env:_RunWithCoreWcfService)
204203
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
205204
displayName: Linux - Run Helix Tests
206205
env:
207206
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
208207
ServiceHost: $(_serviceUri)
209208
RunAsPublic: $(_RunAsPublic)
210209
RunAsInternal: $(_RunAsInternal)
210+
RunWithCoreWcfService: $(_RunWithCoreWcfService)
211211
IsWindowsBuild: false
212212

213213
# Only build and test MacOS in PR and CI builds.
214214
- ${{ if eq(variables._RunAsPublic, True) }}:
215215
- job: MacOS
216+
condition: ne(variables._RunWithCoreWcfService, True)
216217
timeoutInMinutes: 90
217218
pool:
218219
name: NetCore-Public

eng/SendToHelix.proj

+51-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
<Project Sdk="Microsoft.DotNet.Helix.Sdk" DefaultTargets="Test">
1+
<Project Sdk="Microsoft.DotNet.Helix.Sdk" InitialTargets="InstallDotNet;BuildProjects;Test">
22
<PropertyGroup>
33
<HelixSource Condition=" '$(RunAsPublic)' == 'true' ">pr/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
44
<HelixSource Condition=" '$(RunAsInternal)' == 'true' ">official/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
55
<HelixType>test/product/</HelixType>
66
<HelixBuild>$(BUILD_BUILDNUMBER)</HelixBuild>
77
<HelixBuild Condition="'$(HelixBuild)' == ''">123460.01</HelixBuild>
8-
<DotNetCliPackageType>sdk</DotNetCliPackageType>
9-
<DotNetCliVersion>8.0.100</DotNetCliVersion>
10-
<IncludeDotNetCli>true</IncludeDotNetCli>
118

9+
<!-- Read global.json so we know the version of the dotnet cli we need -->
10+
<GlobalJsonContent>$([System.IO.File]::ReadAllText('$(RepoRoot)global.json'))</GlobalJsonContent>
11+
<DotNetCliPackageType>sdk</DotNetCliPackageType>
12+
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F&lt;="dotnet": ").*(%3F=")'))</DotNetCliVersion>
13+
14+
<IncludeDotNetCli>true</IncludeDotNetCli>
1215
<EnableAzurePipelinesReporter>true</EnableAzurePipelinesReporter>
1316
<TestRunNamePrefix>$(AGENT_JOBNAME)</TestRunNamePrefix>
14-
1517
<EnableXUnitReporter>true</EnableXUnitReporter>
1618
</PropertyGroup>
17-
19+
20+
<Target Name="InstallDotNet">
21+
<ItemGroup>
22+
<AdditionalDotNetPackage Include="8.0.8">
23+
<PackageType>aspnetcore-runtime</PackageType>
24+
<Channel>Current</Channel>
25+
</AdditionalDotNetPackage>
26+
</ItemGroup>
27+
</Target>
28+
29+
<Target Name="BuildProjects">
30+
<MSBuild Targets="Restore;Publish" Projects="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
31+
</Target>
32+
1833
<ItemGroup>
1934
<XUnitProject Include="..\src\System.Private.ServiceModel\tests\Scenarios\**\*.IntegrationTests.csproj">
2035
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
@@ -53,19 +68,46 @@
5368
<Creator>$(BUILD_SOURCEVERSIONAUTHOR)</Creator>
5469
<Creator Condition=" '$(Creator)' == ''">anon</Creator>
5570
</PropertyGroup>
56-
57-
<PropertyGroup Condition="!$(HelixTargetQueue.StartsWith('Windows'))">
71+
72+
<PropertyGroup>
73+
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
74+
</PropertyGroup>
75+
76+
<PropertyGroup Condition="'$(TestJob)' != 'Windows'" >
5877
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
5978
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
6079
</PropertyGroup>
6180

62-
<Target Name="Pack"/>
81+
<PropertyGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
82+
<HelixPreCommands>$(HelixPreCommands);set PATH=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli%3B%PATH%</HelixPreCommands>
83+
<!-- %3B is an escaped ; -->
84+
<HelixPreCommands>$(HelixPreCommands);set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli;set DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
85+
<HelixPreCommands>$(HelixPreCommands);set DOTNET_CLI_HOME=%HELIX_WORKITEM_ROOT%\.dotnet</HelixPreCommands>
86+
<HelixPreCommands>$(HelixPreCommands);set NUGET_PACKAGES=%HELIX_WORKITEM_ROOT%\.nuget</HelixPreCommands>
87+
<HelixPreCommands>$(HelixPreCommands);set ServiceUri=localhost</HelixPreCommands>
88+
<HelixPreCommands>$(HelixPreCommands);set RunWithCoreWCF=true</HelixPreCommands>
89+
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net8.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
90+
</PropertyGroup>
91+
92+
<PropertyGroup Condition="'$(TestJob)' != 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
93+
<HelixPreCommands>$(HelixPreCommands);export PATH=$HELIX_CORRELATION_PAYLOAD/dotnet-cli:$PATH</HelixPreCommands>
94+
<HelixPreCommands>$(HelixPreCommands);export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/dotnet-cli;export DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
95+
<HelixPreCommands>$(HelixPreCommands);export DOTNET_CLI_HOME=$HELIX_WORKITEM_ROOT/.dotnet</HelixPreCommands>
96+
<HelixPreCommands>$(HelixPreCommands);export NUGET_PACKAGES=$HELIX_WORKITEM_ROOT/.nuget</HelixPreCommands>
97+
<HelixPreCommands>$(HelixPreCommands);export ServiceUri=localhost</HelixPreCommands>
98+
<HelixPreCommands>$(HelixPreCommands);export RunWithCoreWCF=true</HelixPreCommands>
99+
<HelixPreCommands>$(HelixPreCommands);dotnet exec --roll-forward Major $HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/$(Configuration)/net8.0/SelfHostedCoreWCFService.dll bootstrap:true</HelixPreCommands>
100+
</PropertyGroup>
63101

64102
<ItemGroup>
65103
<!-- Directory that is zipped up and sent as a correlation payload to Helix -->
66104
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\src\System.Private.ServiceModel\tools\scripts'))" >
67105
<PayloadDirectory>%(Identity)</PayloadDirectory>
68106
</HelixCorrelationPayload>
107+
108+
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'))" >
109+
<Destination>SelfHostedCoreWCFService</Destination>
110+
</HelixCorrelationPayload>
69111
</ItemGroup>
70112

71113
<PropertyGroup>

src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalTestDetectors.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,17 @@ public static bool IsWindows()
142142
return OSID.AnyWindows.MatchesCurrent();
143143
}
144144

145-
public static bool IsWindowsOrSelfHosted()
145+
// Returns 'true' if the server is running with CoreWCF Service
146+
public static bool IsRunWithCoreWCFService()
146147
{
147-
if (IsWindows())
148-
{
149-
return true;
150-
}
151-
else if (!IsIISHosted())
148+
string runWithCoreWCFService = TestProperties.GetProperty(TestProperties.RunWithCoreWCF_PropertyName);
149+
150+
if (String.IsNullOrWhiteSpace(runWithCoreWCFService))
152151
{
153-
return true;
152+
return false;
154153
}
155154

156-
return false;
155+
return true;
157156
}
158157

159158
// Returns 'true' if the server is running as localhost.

src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalWcfTest.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public static bool Windows_Authentication_Available()
328328
// Temporarily use the simple heuristic that if we are running the services locally, it is.
329329
// Refactor this after integration to address https://github.com/dotnet/wcf/issues/1024
330330
return GetConditionValue(nameof(Windows_Authentication_Available),
331-
Server_Is_LocalHost);
331+
Server_Is_LocalHost) && Is_Windows();
332332
}
333333

334334
// Returns true if NTLM is available to use.
@@ -351,11 +351,6 @@ public static bool SSL_Available()
351351
ConditionalTestDetectors.IsWindows);
352352
}
353353

354-
public static bool WindowsOrSelfHosted()
355-
{
356-
return GetConditionValue(nameof(WindowsOrSelfHosted), ConditionalTestDetectors.IsWindowsOrSelfHosted);
357-
}
358-
359354
// Returns the Domain if available.
360355
// TestProperties takes precedence, but if it has not been specified
361356
// and this is a Windows client, we infer it.
@@ -387,5 +382,13 @@ public static string GetSPN()
387382
{
388383
return ConditionalTestDetectors.GetSPN();
389384
}
385+
386+
// Returns 'false' if run with CoreWCF Service,
387+
// skip failed test
388+
public static bool Skip_CoreWCFService_FailedTest()
389+
{
390+
return !GetConditionValue(nameof(Skip_CoreWCFService_FailedTest),
391+
ConditionalTestDetectors.IsRunWithCoreWCFService);
392+
}
390393
}
391394
}

src/System.Private.ServiceModel/tests/Common/Infrastructure/ServiceUtilHelper.cs

+26-5
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ public static string GetEndpointAddress(string endpoint, string protocol = "http
530530

531531
private static string GetResourceAddress(string resource, string protocol = "http")
532532
{
533-
string host = TestProperties.GetProperty(TestProperties.ServiceUri_PropertyName);
534-
return string.Format(@"{0}://{1}/{2}/{3}", protocol, host, TestHostUtilitiesService, resource);
533+
var baseUri = BuildBaseUri(protocol);
534+
return new Uri(baseUri, $"{TestHostUtilitiesService}/{resource}").ToString();
535535
}
536536

537537
public static string GetResourceFromServiceAsString(string resource)
@@ -542,7 +542,14 @@ public static string GetResourceFromServiceAsString(string resource)
542542
using (HttpClient httpClient = new HttpClient())
543543
{
544544
HttpResponseMessage response = httpClient.GetAsync(requestUri).GetAwaiter().GetResult();
545-
return response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
545+
if (response.IsSuccessStatusCode)
546+
{
547+
return response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
548+
}
549+
else
550+
{
551+
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
552+
}
546553
}
547554
}
548555

@@ -554,7 +561,14 @@ public static byte[] GetResourceFromServiceAsByteArray(string resource)
554561
using (HttpClient httpClient = new HttpClient())
555562
{
556563
HttpResponseMessage response = httpClient.GetAsync(requestUri).GetAwaiter().GetResult();
557-
return response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
564+
if (response.IsSuccessStatusCode)
565+
{
566+
return response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
567+
}
568+
else
569+
{
570+
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
571+
}
558572
}
559573
}
560574

@@ -566,7 +580,14 @@ public static async Task<byte[]> GetResourceFromServiceAsByteArrayAsync(string r
566580
using (HttpClient httpClient = new HttpClient())
567581
{
568582
HttpResponseMessage response = await httpClient.GetAsync(requestUri);
569-
return await response.Content.ReadAsByteArrayAsync();
583+
if (response.IsSuccessStatusCode)
584+
{
585+
return await response.Content.ReadAsByteArrayAsync();
586+
}
587+
else
588+
{
589+
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
590+
}
570591
}
571592
}
572593
}

0 commit comments

Comments
 (0)