Skip to content

Commit 3f6dad8

Browse files
committed
update
1 parent 7fa1dad commit 3f6dad8

File tree

3 files changed

+119
-72
lines changed

3 files changed

+119
-72
lines changed

eng/SendToHelix.proj

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,74 +24,75 @@
2424
</ItemGroup>
2525
</Target>
2626

27-
<Target Name="RunTests" DependsOnTargets="InstallDotNet">
28-
<ItemGroup>
29-
<ProjectsToBuild Include="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
30-
</ItemGroup>
27+
<ItemGroup>
28+
<ProjectsToBuild Include="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
29+
</ItemGroup>
3130

32-
<ItemGroup>
33-
<XUnitProject Include="..\src\System.Private.ServiceModel\tests\Scenarios\**\*.IntegrationTests.csproj">
34-
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
35-
</XUnitProject>
36-
<XUnitProject Include="..\src\System.ServiceModel.*\tests\*.Tests.csproj">
37-
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
38-
</XUnitProject>
39-
</ItemGroup>
31+
<ItemGroup>
32+
<XUnitProject Include="..\src\System.Private.ServiceModel\tests\Scenarios\**\*.IntegrationTests.csproj">
33+
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
34+
</XUnitProject>
35+
<XUnitProject Include="..\src\System.ServiceModel.*\tests\*.Tests.csproj">
36+
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
37+
</XUnitProject>
38+
</ItemGroup>
4039

41-
<ItemGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunAsPublic)' == 'true'" >
42-
<HelixTargetQueue Include="windows.11.amd64.client.open" />
43-
<HelixTargetQueue Include="windows.amd64.server2022.open" />
44-
</ItemGroup>
40+
<ItemGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunAsPublic)' == 'true'" >
41+
<HelixTargetQueue Include="windows.11.amd64.client.open" />
42+
<HelixTargetQueue Include="windows.amd64.server2022.open" />
43+
</ItemGroup>
4544

46-
<ItemGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunAsInternal)'" >
47-
<HelixTargetQueue Include="windows.11.amd64.client" />
48-
<HelixTargetQueue Include="(Debian.11.Amd64)[email protected]/dotnet-buildtools/prereqs:debian-11-helix-amd64" />
49-
<HelixTargetQueue Include="(Mariner.2.0.Amd64)[email protected]/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64" />
50-
</ItemGroup>
45+
<ItemGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunAsInternal)'" >
46+
<HelixTargetQueue Include="windows.11.amd64.client" />
47+
<HelixTargetQueue Include="(Debian.11.Amd64)[email protected]/dotnet-buildtools/prereqs:debian-11-helix-amd64" />
48+
<HelixTargetQueue Include="(Mariner.2.0.Amd64)[email protected]/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64" />
49+
</ItemGroup>
5150

52-
<ItemGroup Condition="'$(TestJob)' == 'Linux'" >
53-
<HelixTargetQueue Include="SLES.15.Amd64.Open" />
54-
<HelixTargetQueue Include="(Fedora.38.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:fedora-38-helix" />
55-
<HelixTargetQueue Include="Ubuntu.2204.Amd64.Open" />
56-
<HelixTargetQueue Include="(Debian.11.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:debian-11-helix-amd64" />
57-
<HelixTargetQueue Include="(Mariner.2.0.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64" />
58-
<HelixTargetQueue Include="(openSUSE.15.2.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:opensuse-15.2-helix-amd64" />
59-
</ItemGroup>
51+
<ItemGroup Condition="'$(TestJob)' == 'Linux'" >
52+
<HelixTargetQueue Include="SLES.15.Amd64.Open" />
53+
<HelixTargetQueue Include="(Fedora.38.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:fedora-38-helix" />
54+
<HelixTargetQueue Include="Ubuntu.2204.Amd64.Open" />
55+
<HelixTargetQueue Include="(Debian.11.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:debian-11-helix-amd64" />
56+
<HelixTargetQueue Include="(Mariner.2.0.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64" />
57+
<HelixTargetQueue Include="(openSUSE.15.2.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:opensuse-15.2-helix-amd64" />
58+
</ItemGroup>
6059

61-
<ItemGroup Condition="'$(TestJob)' == 'MacOS'" >
62-
<HelixTargetQueue Include="OSX.1200.Amd64.Open" />
63-
<HelixTargetQueue Include="OSX.1200.Arm64.Open" />
64-
</ItemGroup>
60+
<ItemGroup Condition="'$(TestJob)' == 'MacOS'" >
61+
<HelixTargetQueue Include="OSX.1200.Amd64.Open" />
62+
<HelixTargetQueue Include="OSX.1200.Arm64.Open" />
63+
</ItemGroup>
6564

66-
<PropertyGroup Condition=" '$(RunAsPublic)' == 'true' ">
67-
<IsExternal>true</IsExternal>
68-
<Creator>$(BUILD_SOURCEVERSIONAUTHOR)</Creator>
69-
<Creator Condition=" '$(Creator)' == ''">anon</Creator>
70-
</PropertyGroup>
65+
<PropertyGroup Condition=" '$(RunAsPublic)' == 'true' ">
66+
<IsExternal>true</IsExternal>
67+
<Creator>$(BUILD_SOURCEVERSIONAUTHOR)</Creator>
68+
<Creator Condition=" '$(Creator)' == ''">anon</Creator>
69+
</PropertyGroup>
7170

72-
<!--<PropertyGroup Condition=" '$(RunWithCoreWcfService)' == 'true' AND '$(TestJob)' == 'Linux'" >
71+
<!--<PropertyGroup Condition=" '$(RunWithCoreWcfService)' == 'true' AND '$(TestJob)' == 'Linux'" >
7372
<HelixPreCommands>$(HelixPreCommands);$HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
7473
</PropertyGroup>-->
7574

76-
<PropertyGroup Condition="'$(TestJob)' == 'Windows'">
77-
<HelixPreCommands>$(HelixPreCommands);dir C:\ /s /b /o:gn | find "SelfHostedCoreWCFService"</HelixPreCommands>
78-
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\Release\net6.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
79-
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net6.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
80-
</PropertyGroup>
81-
82-
<PropertyGroup Condition="'$(TestJob)' != 'Windows'">
83-
<HelixPreCommands>$(HelixPreCommands);find / -type d -name 'SelfHostedCoreWCFService'</HelixPreCommands>
84-
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
85-
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
86-
<HelixPreCommands>$(HelixPreCommands);$HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/Release/net6.0/SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
87-
<HelixPreCommands>$(HelixPreCommands);$HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/$(Configuration)/net6.0/SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
88-
</PropertyGroup>
89-
</Target>
75+
<PropertyGroup Condition="'$(TestJob)' == 'Windows'">
76+
<HelixPreCommands>$(HelixPreCommands);dir C:\ /s /b /o:gn | find "SelfHostedCoreWCFService"</HelixPreCommands>
77+
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\Release\net6.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
78+
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net6.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
79+
</PropertyGroup>
80+
81+
<PropertyGroup Condition="'$(TestJob)' != 'Windows'">
82+
<HelixPreCommands>$(HelixPreCommands);find / -type d -name 'SelfHostedCoreWCFService'</HelixPreCommands>
83+
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
84+
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
85+
<HelixPreCommands>$(HelixPreCommands);$HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/Release/net6.0/SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
86+
<HelixPreCommands>$(HelixPreCommands);$HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/$(Configuration)/net6.0/SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
87+
</PropertyGroup>
88+
89+
<!--<Target Name="RunTests" DependsOnTargets="InstallDotNet">
90+
</Target>-->
9091

9192
<Target Name="Pack"/>
9293

9394
<Target Name="BuildProjects">
94-
<MSBuild Projects="@(ProjectsToBuild)" Properties="Configuration=Release;PublishDir='$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'" Targets="Publish" />
95+
<MSBuild Targets="Publish" Projects="@(ProjectsToBuild)" Properties="Configuration=Release;PublishDir='$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'" />
9596
</Target>
9697

9798
<ItemGroup>
@@ -103,7 +104,7 @@
103104
<!--<HelixContent Include="$(RepoRoot)src\Project\**" LinkBase="$(MSBuildThisFileDirectory)\myassets"/>-->
104105

105106
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'))" >
106-
<Destination>SelfHostedCoreWCFService</Destination>
107+
<Destination>%(Identity)</Destination>
107108
</HelixCorrelationPayload>
108109
</ItemGroup>
109110

src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/TestDefinitionHelper.cs

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// See the LICENSE file in the project root for more information.
44

55
#if NET
6+
using System.Diagnostics;
7+
using System.Net;
68
using System.Security.Claims;
9+
using System.Security.Cryptography.X509Certificates;
710
using CoreWCF.Configuration;
811
using CoreWCF.Description;
912
using idunno.Authentication.Basic;
@@ -26,7 +29,7 @@ internal class TestDefinitionHelper
2629
private const int DefaultWebSocketPort = 8083;
2730
private const int DefaultWebSocketSPort = 8084;
2831

29-
private static IDictionary<ServiceSchema, string> BaseAddresses
32+
internal static IDictionary<ServiceSchema, string> BaseAddresses
3033
{
3134
get
3235
{
@@ -57,10 +60,47 @@ private static IDictionary<ServiceSchema, string> BaseAddresses
5760
}
5861

5962
#if NET
63+
internal class ServiceTestHostOptions
64+
{
65+
public List<Uri> serviceBaseAddresses = new List<Uri>();
66+
public Dictionary<Enum, string> endpointBasePath = new Dictionary<Enum, string>();
67+
}
68+
6069
internal static async Task StartHosts()
6170
{
6271
bool success = true;
63-
var webHost = WebHost.CreateDefaultBuilder()
72+
var serviceTestHostOptionsDict = new Dictionary<string, ServiceTestHostOptions>();
73+
74+
var webHost = new WebHostBuilder()
75+
.UseKestrel(options => {
76+
options.Listen(IPAddress.IPv6Any, new Uri(BaseAddresses[ServiceSchema.HTTP]).Port);
77+
options.Listen(address: IPAddress.IPv6Any, new Uri(BaseAddresses[ServiceSchema.HTTPS]).Port, listenOptions =>
78+
{
79+
listenOptions.UseHttps(httpsOptions =>
80+
{
81+
X509Certificate2 cert = TestHost.CertificateFromFriendlyName(StoreName.My, StoreLocation.LocalMachine, "WCF Bridge - Machine certificate generated by the CertificateManager");
82+
httpsOptions.ServerCertificate = cert;
83+
});
84+
if (Debugger.IsAttached)
85+
{
86+
listenOptions.UseConnectionLogging();
87+
}
88+
});
89+
options.Listen(IPAddress.IPv6Any, new Uri(BaseAddresses[ServiceSchema.WS]).Port);
90+
options.Listen(address: IPAddress.IPv6Any, new Uri(BaseAddresses[ServiceSchema.WSS]).Port, listenOptions =>
91+
{
92+
listenOptions.UseHttps(httpsOptions =>
93+
{
94+
X509Certificate2 cert = TestHost.CertificateFromFriendlyName(StoreName.My, StoreLocation.LocalMachine, "WCF Bridge - Machine certificate generated by the CertificateManager");
95+
httpsOptions.ServerCertificate = cert;
96+
});
97+
if (Debugger.IsAttached)
98+
{
99+
listenOptions.UseConnectionLogging();
100+
}
101+
});
102+
})
103+
//.UseNetTcp(IPAddress.IPv6Any, new Uri(BaseAddresses[ServiceSchema.NETTCP]).Port)
64104
.ConfigureServices(services =>
65105
{
66106
services.AddAuthentication(BasicAuthenticationDefaults.AuthenticationScheme)
@@ -100,8 +140,7 @@ internal static async Task StartHosts()
100140
{
101141
foreach (var serviceTestHost in GetAttributedServiceHostTypes())
102142
{
103-
var serviceBaseAddresses = new List<Uri>();
104-
var endpointBasePath = new Dictionary<Enum, string>();
143+
var serviceTestHostOptions = new ServiceTestHostOptions();
105144
foreach (TestServiceDefinitionAttribute attr in serviceTestHost.GetCustomAttributes(typeof(TestServiceDefinitionAttribute), false))
106145
{
107146
Uri serviceBaseAddress = null;
@@ -111,9 +150,9 @@ internal static async Task StartHosts()
111150
{
112151
if (attr.Schema.HasFlag(schema))
113152
{
114-
endpointBasePath.Add(schema, attr.BasePath);
153+
serviceTestHostOptions.endpointBasePath.Add(schema, attr.BasePath);
115154
serviceBaseAddress = new Uri(BaseAddresses[(ServiceSchema)schema]);
116-
serviceBaseAddresses.Add(serviceBaseAddress);
155+
serviceTestHostOptions.serviceBaseAddresses.Add(serviceBaseAddress);
117156
}
118157
}
119158
}
@@ -132,30 +171,37 @@ internal static async Task StartHosts()
132171
}
133172
}
134173

174+
serviceTestHostOptionsDict.Add(serviceTestHost.Name, serviceTestHostOptions);
135175
try
136176
{
137177
if (success)
138178
{
139-
var serviceHost = (ServiceHost)Activator.CreateInstance(serviceTestHost, serviceBaseAddresses.ToArray());
179+
string serviceHostTypeName = serviceTestHost.Name;
180+
var serviceHost = (ServiceHost)Activator.CreateInstance(serviceTestHost, serviceTestHostOptionsDict[serviceHostTypeName].serviceBaseAddresses.ToArray());
140181
serviceBuilder.AddService(serviceHost.ServiceType, options =>
141182
{
142-
foreach (var baseAddress in serviceBaseAddresses)
183+
var localHostTypeName = serviceHostTypeName;
184+
//options.BaseAddresses.Clear();
185+
foreach (var baseAddress in serviceTestHostOptionsDict[localHostTypeName].serviceBaseAddresses)
143186
{
144187
if (!options.BaseAddresses.Contains(baseAddress))
145188
options.BaseAddresses.Add(baseAddress);
146189
}
190+
191+
foreach (var endpoint in serviceHost.Endpoints)
192+
{
193+
Enum schema = ServiceHostHelper.ToServiceSchema(endpoint.Binding.Scheme);
194+
string basePath = serviceTestHostOptionsDict[localHostTypeName].endpointBasePath[schema];
195+
string endpointAddress = string.Format("{0}/{1}", basePath, endpoint.Address);
196+
serviceBuilder.AddServiceEndpoint(serviceHost.ServiceType, endpoint.ContractType, endpoint.Binding, new Uri(endpointAddress, UriKind.RelativeOrAbsolute), null);
197+
}
147198
});
148-
foreach (var endpoint in serviceHost.Endpoints)
149-
{
150-
Enum schema = ServiceHostHelper.ToServiceSchema(endpoint.Binding.Scheme);
151-
string basePath = endpointBasePath[schema];
152-
string endpointAddress = string.Format("{0}/{1}", basePath, endpoint.Address);
153-
serviceBuilder.AddServiceEndpoint(serviceHost.ServiceType, endpoint.ContractType, endpoint.Binding, new Uri(endpointAddress, UriKind.RelativeOrAbsolute), null);
154-
}
199+
155200
serviceBuilder.ConfigureServiceHostBase(serviceHost.ServiceType, serviceHostBase =>
156201
{
202+
var localHostTypeName = serviceHostTypeName;
157203
var smb = serviceHostBase.Description.Behaviors.Find<ServiceMetadataBehavior>();
158-
if (serviceBaseAddresses.Where(uri => uri.Scheme == Uri.UriSchemeHttps).Any())
204+
if (serviceTestHostOptionsDict[localHostTypeName].serviceBaseAddresses.Where(uri => uri.Scheme == Uri.UriSchemeHttps).Any())
159205
{
160206
smb.HttpsGetEnabled = true;
161207
}

src/System.Private.ServiceModel/tools/SelfHostedCoreWcfService/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static async Task Main(string[] args)
3131
string crlFileLocation = "c:\\WCFTest\\test.crl";
3232

3333
CertificateGeneratorLibrary.SetupCerts(testserverbase, validatePeriod, crlFileLocation);
34-
34+
//System.Diagnostics.Debugger.Launch();
3535
Console.WriteLine("Starting services...");
3636
await TestDefinitionHelper.StartHosts();
3737

0 commit comments

Comments
 (0)