Skip to content

Add CoreWCF Services Support #5473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions System.ServiceModel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encoding.MessageVersion.Int
EndProject
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}"
EndProject
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}"
EndProject
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}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Infrastructure\Infrastructure.IntegrationTests.csproj", "{719E874A-AEFA-44D5-9530-9C41BD0FA4E8}"
Expand Down Expand Up @@ -209,10 +207,6 @@ Global
{76361777-321D-4588-87F9-38992A758350}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76361777-321D-4588-87F9-38992A758350}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76361777-321D-4588-87F9-38992A758350}.Release|Any CPU.Build.0 = Release|Any CPU
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267}.Release|Any CPU.Build.0 = Release|Any CPU
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8CA16D3-5B1E-4EC0-A817-205A798DC272}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -337,7 +331,6 @@ Global
{48C41A27-631F-45FA-ACD5-7D7EDD4A4931} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{36DD97F6-1F78-4843-A9C0-58C59D367603} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{76361777-321D-4588-87F9-38992A758350} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{ACCCB1B8-5ABE-4F3B-BFEF-9A9C15AA1267} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{C8CA16D3-5B1E-4EC0-A817-205A798DC272} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{719E874A-AEFA-44D5-9530-9C41BD0FA4E8} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
{E878E412-F0AB-4D87-8A7A-3114AAC48CD5} = {D6302510-AB10-4775-BCE9-98FA96FDEB76}
Expand Down
3 changes: 2 additions & 1 deletion azure-pipelines-arcade-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,20 @@ stages:
--projects $(Build.SourcesDirectory)/eng/SendToHelix.proj
$(_TestArgs)
/p:TestJob=Linux
/p:RunWithCoreWcfService=$($Env:_RunWithCoreWcfService)
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: Linux - Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
ServiceHost: $(_serviceUri)
RunAsPublic: $(_RunAsPublic)
RunAsInternal: $(_RunAsInternal)
RunWithCoreWcfService: $(_RunWithCoreWcfService)
IsWindowsBuild: false

# Only build and test MacOS in PR and CI builds.
- ${{ if eq(variables._RunAsPublic, True) }}:
- job: MacOS
condition: ne(variables._RunWithCoreWcfService, True)
timeoutInMinutes: 90
pool:
name: NetCore-Public
Expand Down
60 changes: 51 additions & 9 deletions eng/SendToHelix.proj
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk" DefaultTargets="Test">
<Project Sdk="Microsoft.DotNet.Helix.Sdk" InitialTargets="InstallDotNet;BuildProjects;Test">
<PropertyGroup>
<HelixSource Condition=" '$(RunAsPublic)' == 'true' ">pr/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
<HelixSource Condition=" '$(RunAsInternal)' == 'true' ">official/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
<HelixType>test/product/</HelixType>
<HelixBuild>$(BUILD_BUILDNUMBER)</HelixBuild>
<HelixBuild Condition="'$(HelixBuild)' == ''">123460.01</HelixBuild>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
<DotNetCliVersion>8.0.100</DotNetCliVersion>
<IncludeDotNetCli>true</IncludeDotNetCli>

<!-- Read global.json so we know the version of the dotnet cli we need -->
<GlobalJsonContent>$([System.IO.File]::ReadAllText('$(RepoRoot)global.json'))</GlobalJsonContent>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F&lt;="dotnet": ").*(%3F=")'))</DotNetCliVersion>

<IncludeDotNetCli>true</IncludeDotNetCli>
<EnableAzurePipelinesReporter>true</EnableAzurePipelinesReporter>
<TestRunNamePrefix>$(AGENT_JOBNAME)</TestRunNamePrefix>

<EnableXUnitReporter>true</EnableXUnitReporter>
</PropertyGroup>


<Target Name="InstallDotNet">
<ItemGroup>
<AdditionalDotNetPackage Include="8.0.8">
<PackageType>aspnetcore-runtime</PackageType>
<Channel>Current</Channel>
</AdditionalDotNetPackage>
</ItemGroup>
</Target>

<Target Name="BuildProjects">
<MSBuild Targets="Restore;Publish" Projects="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
</Target>

<ItemGroup>
<XUnitProject Include="..\src\System.Private.ServiceModel\tests\Scenarios\**\*.IntegrationTests.csproj">
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
Expand Down Expand Up @@ -53,19 +68,46 @@
<Creator>$(BUILD_SOURCEVERSIONAUTHOR)</Creator>
<Creator Condition=" '$(Creator)' == ''">anon</Creator>
</PropertyGroup>

<PropertyGroup Condition="!$(HelixTargetQueue.StartsWith('Windows'))">

<PropertyGroup>
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
</PropertyGroup>

<PropertyGroup Condition="'$(TestJob)' != 'Windows'" >
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
</PropertyGroup>

<Target Name="Pack"/>
<PropertyGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
<HelixPreCommands>$(HelixPreCommands);set PATH=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli%3B%PATH%</HelixPreCommands>
<!-- %3B is an escaped ; -->
<HelixPreCommands>$(HelixPreCommands);set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli;set DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set DOTNET_CLI_HOME=%HELIX_WORKITEM_ROOT%\.dotnet</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set NUGET_PACKAGES=%HELIX_WORKITEM_ROOT%\.nuget</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set ServiceUri=localhost</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set RunWithCoreWCF=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net8.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
</PropertyGroup>

<PropertyGroup Condition="'$(TestJob)' != 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
<HelixPreCommands>$(HelixPreCommands);export PATH=$HELIX_CORRELATION_PAYLOAD/dotnet-cli:$PATH</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/dotnet-cli;export DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export DOTNET_CLI_HOME=$HELIX_WORKITEM_ROOT/.dotnet</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export NUGET_PACKAGES=$HELIX_WORKITEM_ROOT/.nuget</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export ServiceUri=localhost</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export RunWithCoreWCF=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);dotnet exec --roll-forward Major $HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/$(Configuration)/net8.0/SelfHostedCoreWCFService.dll bootstrap:true</HelixPreCommands>
</PropertyGroup>

<ItemGroup>
<!-- Directory that is zipped up and sent as a correlation payload to Helix -->
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\src\System.Private.ServiceModel\tools\scripts'))" >
<PayloadDirectory>%(Identity)</PayloadDirectory>
</HelixCorrelationPayload>

<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'))" >
<Destination>SelfHostedCoreWCFService</Destination>
</HelixCorrelationPayload>
</ItemGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,17 @@ public static bool IsWindows()
return OSID.AnyWindows.MatchesCurrent();
}

public static bool IsWindowsOrSelfHosted()
// Returns 'true' if the server is running with CoreWCF Service
public static bool IsRunWithCoreWCFService()
{
if (IsWindows())
{
return true;
}
else if (!IsIISHosted())
string runWithCoreWCFService = TestProperties.GetProperty(TestProperties.RunWithCoreWCF_PropertyName);

if (String.IsNullOrWhiteSpace(runWithCoreWCFService))
{
return true;
return false;
}

return false;
return true;
}

// Returns 'true' if the server is running as localhost.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static bool Windows_Authentication_Available()
// Temporarily use the simple heuristic that if we are running the services locally, it is.
// Refactor this after integration to address https://github.com/dotnet/wcf/issues/1024
return GetConditionValue(nameof(Windows_Authentication_Available),
Server_Is_LocalHost);
Server_Is_LocalHost) && Is_Windows();
}

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

public static bool WindowsOrSelfHosted()
{
return GetConditionValue(nameof(WindowsOrSelfHosted), ConditionalTestDetectors.IsWindowsOrSelfHosted);
}

// Returns the Domain if available.
// TestProperties takes precedence, but if it has not been specified
// and this is a Windows client, we infer it.
Expand Down Expand Up @@ -387,5 +382,13 @@ public static string GetSPN()
{
return ConditionalTestDetectors.GetSPN();
}

// Returns 'false' if run with CoreWCF Service,
// skip failed test
public static bool Skip_CoreWCFService_FailedTest()
{
return !GetConditionValue(nameof(Skip_CoreWCFService_FailedTest),
ConditionalTestDetectors.IsRunWithCoreWCFService);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ public static string GetEndpointAddress(string endpoint, string protocol = "http

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

public static string GetResourceFromServiceAsString(string resource)
Expand All @@ -542,7 +542,14 @@ public static string GetResourceFromServiceAsString(string resource)
using (HttpClient httpClient = new HttpClient())
{
HttpResponseMessage response = httpClient.GetAsync(requestUri).GetAwaiter().GetResult();
return response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
}
else
{
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
}
}
}

Expand All @@ -554,7 +561,14 @@ public static byte[] GetResourceFromServiceAsByteArray(string resource)
using (HttpClient httpClient = new HttpClient())
{
HttpResponseMessage response = httpClient.GetAsync(requestUri).GetAwaiter().GetResult();
return response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
}
else
{
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
}
}
}

Expand All @@ -566,7 +580,14 @@ public static async Task<byte[]> GetResourceFromServiceAsByteArrayAsync(string r
using (HttpClient httpClient = new HttpClient())
{
HttpResponseMessage response = await httpClient.GetAsync(requestUri);
return await response.Content.ReadAsByteArrayAsync();
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsByteArrayAsync();
}
else
{
throw new Exception($"Got Status code {response.StatusCode} from {requestUri}.");
}
}
}
}
Loading