Build HttpStress and SslStress with live-built runtime using current TFM (#61689)

This PR changes both local (non-containerized) and containerized stress builds to build against the live-built runtime with the help of targetingpacks.targets.
This commit is contained in:
Anton Firszov 2021-11-30 18:16:30 +01:00 committed by GitHub
parent 439ffd2434
commit 85642f8147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 492 additions and 197 deletions

4
.gitignore vendored
View File

@ -354,3 +354,7 @@ src/coreclr/System.Private.CoreLib/common
!src/coreclr/inc/obj/
!src/coreclr/vm/.vscode/
!src/coreclr/vm/.vscode/c_cpp_properties.json
# Temporary artifacts from local libraries stress builds
.dotnet-daily/
run-stress-*

View File

@ -6,21 +6,16 @@
Param(
[string][Alias('t')]$imageName = "dotnet-sdk-libs-current",
[string][Alias('c')]$configuration = "Release",
[switch][Alias('w')]$buildWindowsContainers,
[switch][Alias('pa')]$privateAspNetCore
[switch][Alias('w')]$buildWindowsContainers
)
$dotNetVersion="7.0"
$ErrorActionPreference = "Stop"
$REPO_ROOT_DIR=$(git -C "$PSScriptRoot" rev-parse --show-toplevel)
$dockerFilePrefix="$PSScriptRoot/libraries-sdk"
if ($privateAspNetCore)
{
$dockerFilePrefix="$PSScriptRoot/libraries-sdk-aspnetcore"
}
if ($buildWindowsContainers)
{
# Due to size concerns, we don't currently do docker builds on windows.
@ -35,11 +30,38 @@ if ($buildWindowsContainers)
$dockerFile="$dockerFilePrefix.windows.Dockerfile"
# Collect the following artifacts to folder, that will be used as build context for the container,
# so projects can build and test against the live-built runtime:
# 1. Reference assembly pack (microsoft.netcore.app.ref)
# 2. Runtime pack (microsoft.netcore.app.runtime.win-x64)
# 3. targetingpacks.targets, so stress test builds can target the live-built runtime instead of the one in the pre-installed SDK
# 4. testhost
$binArtifacts = "$REPO_ROOT_DIR\artifacts\bin"
$dockerContext = "$REPO_ROOT_DIR\artifacts\docker-context"
if (Test-Path $dockerContext) {
Remove-Item -Recurse -Force $dockerContext
}
Copy-Item -Recurse -Path $binArtifacts\microsoft.netcore.app.ref `
-Destination $dockerContext\microsoft.netcore.app.ref
Copy-Item -Recurse -Path $binArtifacts\microsoft.netcore.app.runtime.win-x64 `
-Destination $dockerContext\microsoft.netcore.app.runtime.win-x64
Copy-Item -Recurse -Path $binArtifacts\testhost `
-Destination $dockerContext\testhost
Copy-Item -Recurse -Path $REPO_ROOT_DIR\eng\targetingpacks.targets `
-Destination $dockerContext\targetingpacks.targets
# In case of non-CI builds, testhost may already contain Microsoft.AspNetCore.App (see build-local.ps1 in HttpStress):
$testHostAspNetCorePath="$dockerContext\testhost\net$dotNetVersion-windows-$configuration-x64/shared/Microsoft.AspNetCore.App"
if (Test-Path $testHostAspNetCorePath) {
Remove-Item -Recurse -Force $testHostAspNetCorePath
}
docker build --tag $imageName `
--build-arg CONFIGURATION=$configuration `
--build-arg TESTHOST_LOCATION=. `
--file $dockerFile `
"$REPO_ROOT_DIR/artifacts/bin/testhost"
$dockerContext
}
else
{

View File

@ -23,7 +23,6 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
imagename="dotnet-sdk-libs-current"
configuration="Release"
privateaspnetcore=0
while [[ $# > 0 ]]; do
opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")"
@ -36,10 +35,6 @@ while [[ $# > 0 ]]; do
configuration=$2
shift 2
;;
-privateaspnetcore|-pa)
privateaspnetcore=1
shift 1
;;
*)
shift 1
;;
@ -49,10 +44,6 @@ done
repo_root=$(git rev-parse --show-toplevel)
docker_file="$scriptroot/libraries-sdk.linux.Dockerfile"
if [[ $privateaspnetcore -eq 1 ]]; then
docker_file="$scriptroot/libraries-sdk-aspnetcore.linux.Dockerfile"
fi
docker build --tag $imagename \
--build-arg CONFIGURATION=$configuration \
--file $docker_file \

View File

@ -1,36 +0,0 @@
# Builds and copies library artifacts into target dotnet sdk image
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-f39df28-20191023143754
ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-bullseye-slim
FROM $BUILD_BASE_IMAGE as corefxbuild
WORKDIR /repo
COPY . .
ARG CONFIGURATION=Release
RUN ./src/coreclr/build.sh -release -skiptests -clang9 && \
./libraries.sh -c $CONFIGURATION -runtimeconfiguration release
FROM $SDK_BASE_IMAGE as target
ARG TESTHOST_LOCATION=/repo/artifacts/bin/testhost
ARG TFM=net7.0
ARG OS=Linux
ARG ARCH=x64
ARG CONFIGURATION=Release
ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
ARG ASPNETCORE_SHARED_NAME=Microsoft.AspNetCore.App
ARG SOURCE_COREFX_VERSION=7.0.0
ARG TARGET_SHARED_FRAMEWORK=/usr/share/dotnet/shared
ARG TARGET_COREFX_VERSION=$DOTNET_VERSION
COPY --from=corefxbuild \
$TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/* \
$TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$TARGET_COREFX_VERSION/
COPY --from=corefxbuild \
$TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/* \
$TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/
COPY --from=corefxbuild \
$TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$ASPNETCORE_SHARED_NAME/$SOURCE_COREFX_VERSION/* \
$TARGET_SHARED_FRAMEWORK/$ASPNETCORE_SHARED_NAME/$TARGET_COREFX_VERSION/

View File

@ -1,26 +0,0 @@
# escape=`
# Simple Dockerfile which copies library build artifacts into target dotnet sdk image
ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-nanoserver-1809
FROM $SDK_BASE_IMAGE as target
ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost"
ARG TFM=net7.0
ARG OS=windows
ARG ARCH=x64
ARG CONFIGURATION=Release
ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
ARG ASPNETCORE_SHARED_NAME=Microsoft.AspNetCore.App
ARG SOURCE_COREFX_VERSION=7.0.0
ARG TARGET_SHARED_FRAMEWORK="C:\\Program Files\\dotnet\\shared"
ARG TARGET_COREFX_VERSION=$DOTNET_VERSION
COPY `
$TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\ `
$TARGET_SHARED_FRAMEWORK\$COREFX_SHARED_FRAMEWORK_NAME\$TARGET_COREFX_VERSION\
COPY `
$TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\ `
$TARGET_SHARED_FRAMEWORK\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\
COPY `
$TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$ASPNETCORE_SHARED_NAME\$SOURCE_COREFX_VERSION\ `
$TARGET_SHARED_FRAMEWORK\$ASPNETCORE_SHARED_NAME\$TARGET_COREFX_VERSION\

View File

@ -4,25 +4,47 @@ ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-bullseye-slim
FROM $BUILD_BASE_IMAGE as corefxbuild
ARG CONFIGURATION=Release
WORKDIR /repo
COPY . .
ARG CONFIGURATION=Release
RUN ./build.sh -ci -subset clr+libs -runtimeconfiguration release -c $CONFIGURATION
RUN ./build.sh clr+libs -runtimeconfiguration Release -configuration $CONFIGURATION -ci
FROM $SDK_BASE_IMAGE as target
ARG TESTHOST_LOCATION=/repo/artifacts/bin/testhost
ARG TFM=net7.0
ARG OS=Linux
ARG ARCH=x64
ARG VERSION=7.0
ARG CONFIGURATION=Release
ENV _DOTNET_INSTALL_CHANNEL="$VERSION.1xx"
ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
ARG SOURCE_COREFX_VERSION=7.0.0
ARG TARGET_SHARED_FRAMEWORK=/usr/share/dotnet/shared
ARG TARGET_COREFX_VERSION=$DOTNET_VERSION
# Install latest daily SDK:
RUN wget https://dot.net/v1/dotnet-install.sh
RUN bash ./dotnet-install.sh --channel $_DOTNET_INSTALL_CHANNEL --quality daily --install-dir /usr/share/dotnet
# Collect the following artifacts under /live-runtime-artifacts,
# so projects can build and test against the live-built runtime:
# 1. Reference assembly pack (microsoft.netcore.app.ref)
# 2. Runtime pack (microsoft.netcore.app.runtime.linux-x64)
# 3. targetingpacks.targets, so stress test builds can target the live-built runtime instead of the one in the pre-installed SDK
# 4. testhost
COPY --from=corefxbuild \
$TESTHOST_LOCATION/$TFM-$OS-$CONFIGURATION-$ARCH/shared/$COREFX_SHARED_FRAMEWORK_NAME/$SOURCE_COREFX_VERSION/* \
$TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$TARGET_COREFX_VERSION/
/repo/artifacts/bin/microsoft.netcore.app.ref \
/live-runtime-artifacts/microsoft.netcore.app.ref
COPY --from=corefxbuild \
/repo/artifacts/bin/microsoft.netcore.app.runtime.linux-x64 \
/live-runtime-artifacts/microsoft.netcore.app.runtime.linux-x64
COPY --from=corefxbuild \
/repo/eng/targetingpacks.targets \
/live-runtime-artifacts/targetingpacks.targets
COPY --from=corefxbuild \
/repo/artifacts/bin/testhost \
/live-runtime-artifacts/testhost
# Add AspNetCore bits to testhost:
ENV _ASPNETCORE_SOURCE="/usr/share/dotnet/shared/Microsoft.AspNetCore.App/$VERSION*"
ENV _ASPNETCORE_DEST="/live-runtime-artifacts/testhost/net$VERSION-Linux-$CONFIGURATION-x64/shared/Microsoft.AspNetCore.App"
RUN mkdir -p $_ASPNETCORE_DEST
RUN cp -r $_ASPNETCORE_SOURCE $_ASPNETCORE_DEST

View File

@ -3,17 +3,23 @@
ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-nanoserver-1809
FROM $SDK_BASE_IMAGE as target
ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost"
ARG TFM=net7.0
ARG OS=windows
ARG ARCH=x64
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG VERSION=7.0
ENV _DOTNET_INSTALL_CHANNEL="$VERSION.1xx"
ARG CONFIGURATION=Release
ARG COREFX_SHARED_FRAMEWORK_NAME=Microsoft.NETCore.App
ARG SOURCE_COREFX_VERSION=7.0.0
ARG TARGET_SHARED_FRAMEWORK="C:\\Program Files\\dotnet\\shared"
ARG TARGET_COREFX_VERSION=$DOTNET_VERSION
USER ContainerAdministrator
COPY `
$TESTHOST_LOCATION\$TFM-$OS-$CONFIGURATION-$ARCH\shared\$COREFX_SHARED_FRAMEWORK_NAME\$SOURCE_COREFX_VERSION\ `
$TARGET_SHARED_FRAMEWORK\$COREFX_SHARED_FRAMEWORK_NAME\$TARGET_COREFX_VERSION\
RUN Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile .\dotnet-install.ps1
RUN & .\dotnet-install.ps1 -Channel $env:_DOTNET_INSTALL_CHANNEL -Quality daily -InstallDir 'C:/Program Files/dotnet'
USER ContainerUser
COPY . /live-runtime-artifacts
# Add AspNetCore bits to testhost:
ENV _ASPNETCORE_SOURCE="C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App/$VERSION*"
ENV _ASPNETCORE_DEST="C:/live-runtime-artifacts/testhost/net$VERSION-windows-$CONFIGURATION-x64/shared/Microsoft.AspNetCore.App"
RUN & New-Item -ItemType Directory -Path $env:_ASPNETCORE_DEST
RUN Copy-Item -Recurse -Path $env:_ASPNETCORE_SOURCE -Destination $env:_ASPNETCORE_DEST

View File

@ -57,6 +57,7 @@ jobs:
export HTTPSTRESS_CLIENT_ARGS="$HTTPSTRESS_CLIENT_ARGS -http 3.0"
export HTTPSTRESS_SERVER_ARGS="$HTTPSTRESS_SERVER_ARGS -http 3.0"
docker-compose up --abort-on-container-exit --no-color
timeoutInMinutes: 35 # In case the HTTP/3.0 run hangs, we timeout shortly after the expected 30 minute run
displayName: Run HttpStress - HTTP 3.0
condition: and(eq(variables['buildRuntime.succeeded'], 'true'), eq(variables['buildStress.succeeded'], 'true'))

View File

@ -1 +1,17 @@
<Project/>
<Project>
<PropertyGroup>
<PackageRid>linux-x64</PackageRid>
<PackageRid Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64</PackageRid>
<!-- Stress projects have their own global.json, the directory above that also has it is the repository root. -->
<RepositoryRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)../, global.json))/</RepositoryRoot>
<TargetingPacksTargetsLocation Condition="'$(TargetingPacksTargetsLocation)' == ''">$(RepositoryRoot)eng/targetingpacks.targets</TargetingPacksTargetsLocation>
<ProductVersion>7.0.0</ProductVersion>
<NetCoreAppCurrent>net7.0</NetCoreAppCurrent>
<NetCoreAppCurrentVersion>7.0</NetCoreAppCurrentVersion>
<MicrosoftNetCoreAppFrameworkName>Microsoft.NETCore.App</MicrosoftNetCoreAppFrameworkName>
<MicrosoftNetCoreAppRefPackDir Condition="'$(MicrosoftNetCoreAppRefPackDir)' == ''" >$(RepositoryRoot)artifacts/bin/microsoft.netcore.app.ref/</MicrosoftNetCoreAppRefPackDir>
<MicrosoftNetCoreAppRuntimePackDir Condition="'$(MicrosoftNetCoreAppRuntimePackDir)' == ''">$(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(PackageRid)/$(Configuration)/</MicrosoftNetCoreAppRuntimePackDir>
</PropertyGroup>
</Project>

View File

@ -1 +1,11 @@
<Project/>
<Project>
<Import Project="$(TargetingPacksTargetsLocation)" />
<PropertyGroup>
<!--
Define this here because the SDK resets it
unconditionally in Microsoft.NETCoreSdk.BundledVersions.props.
-->
<NETCoreAppMaximumVersion>7.0</NETCoreAppMaximumVersion>
</PropertyGroup>
</Project>

View File

@ -1,9 +1,6 @@
ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-bullseye-slim
FROM $SDK_BASE_IMAGE
RUN echo "DOTNET_SDK_VERSION="$DOTNET_SDK_VERSION
RUN echo "DOTNET_VERSION="$DOTNET_VERSION
WORKDIR /app
COPY . .
@ -19,8 +16,13 @@ RUN unzip $PACKAGES_DIR.zip
RUN dpkg -i $PACKAGES_DIR/$MSQUIC_PACKAGE
RUN rm -rf $PACKAGES_DIR*
ARG VERSION=7.0
ARG CONFIGURATION=Release
RUN dotnet build -c $CONFIGURATION
RUN dotnet build -c $CONFIGURATION \
-p:TargetingPacksTargetsLocation=/live-runtime-artifacts/targetingpacks.targets \
-p:MicrosoftNetCoreAppRefPackDir=/live-runtime-artifacts/microsoft.netcore.app.ref/ \
-p:MicrosoftNetCoreAppRuntimePackDir=/live-runtime-artifacts/microsoft.netcore.app.runtime.linux-x64/$CONFIGURATION/
# Enable dump collection
ENV COMPlus_DbgEnableMiniDump=1
@ -29,6 +31,8 @@ ENV COMPlus_DbgMiniDumpName="/share/coredump.%p"
EXPOSE 5001
ENV VERSION=$VERSION
ENV CONFIGURATION=$CONFIGURATION
ENV HTTPSTRESS_ARGS=''
CMD dotnet run --no-build -c $CONFIGURATION -- $HTTPSTRESS_ARGS
CMD /live-runtime-artifacts/testhost/net$VERSION-Linux-$CONFIGURATION-x64/dotnet exec \
./bin/$CONFIGURATION/net$VERSION/HttpStress.dll $HTTPSTRESS_ARGS

View File

@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
@ -22,4 +21,16 @@
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Quic" Version="6.0.0-preview.5.21301.17" />
</ItemGroup>
<PropertyGroup>
<!-- These may lead to duplicate generated classes with local (non-docker) Linux builds. -->
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
</Project>

View File

@ -1,39 +1,47 @@
## HttpStress
Provides stress testing scenaria for System.Net.Http.HttpClient, with emphasis on the HTTP/2 implementation of SocketsHttpHandler.
Provides stress testing scenaria for System.Net.Http.HttpClient and the underlying SocketsHttpHandler.
### Running the suite locally
Using the command line,
Prerequisite: the runtime and the libraries should be [live-built](https://github.com/dotnet/runtime/tree/main/docs/workflow/building/libraries) with `build.cmd`/`build.sh`.
Use the script `build-local.sh` / `build-local.ps1` to build the stress project against the live-built runtime. This will acquire the latest daily SDK, which is TFM-compatible with the live-built runtime.
```bash
$ dotnet run -- <stress suite args>
$ build-local.sh [StressConfiguration] [LibrariesConfiguration]
```
The build script will also generate the runscript that runs the stress suite using the locally built testhost in the form of `run-stress-<StressConfiguration>-<LirariesConfiguration>.sh`. To run the tests with the script, assuming that both the stress project and the libraries have been built against Release configuration:
```bash
$ run-stress-Release-Release.sh [stress suite args]
```
To get the full list of available parameters:
```bash
$ dotnet run -- -help
$ run-stress-Release-Release.sh -help
```
### Running with local runtime builds
### Building and running with Docker
Note that the stress suite will test the sdk available in the environment,
that is to say it will not necessarily test the implementation of the local runtime repo.
To achieve this, we will first need to build a new sdk from source. This can be done [using docker](https://github.com/dotnet/runtime/blob/main/eng/docker/Readme.md).
A docker image containing the live-built runtime bits and the latest daily SDK is created with the [`build-docker-sdk.sh/ps1` scripts](https://github.com/dotnet/runtime/blob/main/eng/docker/Readme.md).
### Running using docker-compose
It's possible to manually `docker build` a docker image containing the stress project based on the docker image created with `build-docker-sdk.sh/ps1`, however the preferred way is to use docker-compose, which can be used to target both linux and windows containers.
The preferred way of running the stress suite is using docker-compose,
which can be used to target both linux and windows containers.
Docker and compose-compose are required for this step (both included in [docker for windows](https://docs.docker.com/docker-for-windows/)).
#### Using Linux containers
From the stress folder on powershell:
From the stress folder:
```powershell
PS> .\run-docker-compose.ps1 -b
PS> .\run-docker-compose.ps1
```
```bash
$ ./run-docker-compose.sh
```
This will build libraries and stress suite to a linux docker image and initialize a stress run using docker-compose.
@ -46,7 +54,7 @@ on how windows containers can be enabled on your machine.
Once ready, simply run:
```powershell
PS> .\run-docker-compose.ps1 -b -w
PS> .\run-docker-compose.ps1 -w
```
For more details on how the `run-docker-compose.ps1` script can be used:
@ -54,3 +62,15 @@ For more details on how the `run-docker-compose.ps1` script can be used:
```powershell
Get-Help .\run-docker-compose.ps1
```
#### Passing arguments to HttpStress
The following will run the stress client and server containers passing the argument `-http 2.0` to both:
```bash
./run-docker-compose.sh -clientstressargs "-http 2.0" -serverstressargs "-http 2.0"
```
```powershell
./run-docker-compose.sh -w -clientStressArgs "-http 2.0" -serverStressArgs "-http 2.0"
```

View File

@ -41,6 +41,8 @@ namespace HttpStress
public StressServer(Configuration configuration)
{
WorkaroundAssemblyResolutionIssues();
ServerUri = configuration.ServerUri;
(string scheme, string hostname, int port) = ParseServerUri(configuration.ServerUri);
IWebHostBuilder host = WebHost.CreateDefaultBuilder();
@ -315,6 +317,13 @@ namespace HttpStress
});
}
private static void WorkaroundAssemblyResolutionIssues()
{
// For some reason, System.Security.Cryptography.Encoding.dll fails to resolve when being loaded on-demand by AspNetCore.
// Enforce early-loading to workaround this issue.
_ = new Oid();
}
private static void AppendChecksumHeader(IHeaderDictionary headers, ulong checksum)
{
headers.Add("crc32", checksum.ToString());

View File

@ -0,0 +1,63 @@
## This is a helper script for non-containerized local build and test execution.
## It downloads and uses the daily SDK which contains the compatible AspNetCore bits.
## Usage:
## ./build-local.ps1 [StressConfiguration] [LibrariesConfiguration]
$Version="7.0"
$RepoRoot="$(git rev-parse --show-toplevel)"
$DailyDotnetRoot= "./.dotnet-daily"
$StressConfiguration = "Release"
if (-not ([string]::IsNullOrEmpty($args[0]))) {
$StressConfiguration = $args[0]
}
$LibrariesConfiguration = "Release"
if (-not ([string]::IsNullOrEmpty($args[1]))) {
$LibrariesConfiguration = $args[0]
}
$TestHostRoot="$RepoRoot/artifacts/bin/testhost/net$Version-windows-$LibrariesConfiguration-x64"
Write-Host "StressConfiguration: $StressConfiguration, LibrariesConfiguration: $LibrariesConfiguration, testhost: $TestHostRoot"
if (-not (Test-Path -Path $TestHostRoot)) {
Write-Host "Cannot find testhost in: $TestHostRoot"
Write-Host "Make sure libraries with the requested configuration are built!"
Write-Host "Usage:"
Write-Host "./build-local.sh [StressConfiguration] [LibrariesConfiguration]"
Write-Host "StressConfiguration and LibrariesConfiguration default to Release!"
exit 1
}
if (-not (Test-Path -Path $DailyDotnetRoot)) {
Write-Host "Downloading daily SDK to: $DailyDotnetRoot"
New-Item -ItemType Directory -Path $DailyDotnetRoot
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile "$DailyDotnetRoot\dotnet-install.ps1"
& "$DailyDotnetRoot\dotnet-install.ps1" -NoPath -Channel "$Version.1xx" -Quality daily -InstallDir $DailyDotnetRoot
} else {
Write-Host "Daily SDK found in $DailyDotnetRoot"
}
$env:DOTNET_ROOT=$DailyDotnetRoot
$env:PATH="$DailyDotnetRoot;$env:PATH"
$env:DOTNET_MULTILEVEL_LOOKUP=0
if (-not (Test-Path -Path "$TestHostRoot/shared/Microsoft.AspNetCore.App")) {
Write-Host "Copying Microsoft.AspNetCore.App bits from daily SDK to testhost: $TestHostRoot"
Copy-Item -Recurse -Path "$DailyDotnetRoot/shared/Microsoft.AspNetCore.App" -Destination "$TestHostRoot/shared"
} else {
Write-Host "Microsoft.AspNetCore.App found in testhost: $TestHostRoot"
}
Write-Host "Building solution."
dotnet build -c $StressConfiguration
$Runscript=".\run-stress-$LibrariesConfiguration-$StressConfiguration.ps1"
if (-not (Test-Path $Runscript)) {
Write-Host "Generating Runscript."
Add-Content -Path $Runscript -Value "& '$TestHostRoot/dotnet' exec ./bin/$StressConfiguration/net$Version/HttpStress.dll `$args"
}
Write-Host "To run tests type:"
Write-Host "$Runscript [stress test args]"

View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
## This is a helper script for non-containerized local build and test execution.
## It downloads and uses the daily SDK which contains the compatible AspNetCore bits.
## Usage:
## ./build-local.sh [StressConfiguration] [LibrariesConfiguration]
version=7.0
repo_root=$(git rev-parse --show-toplevel)
daily_dotnet_root=./.dotnet-daily
stress_configuration="Release"
if [ "$1" != "" ]; then
stress_configuration=${1,,} # Lowercase all characters in $1
stress_configuration=${stress_configuration^} # Uppercase first character
fi
libraries_configuration="Release"
if [ "$2" != "" ]; then
libraries_configuration=${2,,} # Lowercase all characters in $1
libraries_configuration=${libraries_configuration^} # Uppercase first character
fi
testhost_root=$repo_root/artifacts/bin/testhost/net$version-Linux-$libraries_configuration-x64
echo "StressConfiguration: $stress_configuration, LibrariesConfiguration: $libraries_configuration, testhost: $testhost_root"
if [[ ! -d $testhost_root ]]; then
echo "Cannot find testhost in: $testhost_root"
echo "Make sure libraries with the requested configuration are built!"
echo "Usage:"
echo "./build-local.sh [StressConfiguration] [LibrariesConfiguration]"
echo "StressConfiguration and LibrariesConfiguration default to Release!"
exit 1
fi
if [[ ! -d $daily_dotnet_root ]]; then
echo "Downloading daily SDK to $daily_dotnet_root"
mkdir $daily_dotnet_root
wget https://dot.net/v1/dotnet-install.sh -O $daily_dotnet_root/dotnet-install.sh
bash $daily_dotnet_root/dotnet-install.sh --no-path --channel $version.1xx --quality daily --install-dir $daily_dotnet_root
else
echo "Daily SDK found in $daily_dotnet_root"
fi
export DOTNET_ROOT=$daily_dotnet_root
export PATH=$DOTNET_ROOT:$PATH
export DOTNET_MULTILEVEL_LOOKUP=0
if [[ ! -d "$testhost_root/shared/Microsoft.AspNetCore.App" ]]; then
echo "Copying Microsoft.AspNetCore.App bits from daily SDK to testhost: $testhost_root"
cp -r $daily_dotnet_root/shared/Microsoft.AspNetCore.App $testhost_root/shared/Microsoft.AspNetCore.App
else
echo "Microsoft.AspNetCore.App found in testhost: $testhost_root"
fi
echo "Building solution."
dotnet build -c $stress_configuration
runscript=./run-stress-${stress_configuration,,}-${libraries_configuration,,}.sh
if [[ ! -f $runscript ]]; then
echo "Generating runscript."
echo "$testhost_root/dotnet exec ./bin/$stress_configuration/net$version/HttpStress.dll \$@" > $runscript
chmod +x $runscript
fi
echo "To run tests type:"
echo "$runscript [stress test args]"

View File

@ -22,7 +22,6 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
imagename="dotnet-sdk-libs-current"
configuration="Release"
privateaspnetcore=0
buildcurrentlibraries=0
buildonly=0
clientstressargs=""
@ -39,10 +38,6 @@ while [[ $# > 0 ]]; do
configuration=$2
shift 2
;;
-privateaspnetcore|-pa)
privateaspnetcore=1
shift 1
;;
-buildcurrentlibraries|-b)
buildcurrentlibraries=1
shift 1
@ -69,17 +64,10 @@ repo_root=$(git rev-parse --show-toplevel)
if [[ buildcurrentlibraries -eq 1 ]]; then
libraries_args=" -t $imagename -c $configuration"
if [[ $privateaspnetcore -eq 1 ]]; then
libraries_args="$libraries_args -pa"
fi
if ! $repo_root/eng/docker/build-docker-sdk.sh $libraries_args; then
exit 1
fi
elif [[ $privateaspnetcore -eq 1 ]]; then
echo "Using a private Asp.Net Core package (-pa) requires using privately built libraries. Please, enable it with -b switch."
exit 1
fi
build_args=""

View File

@ -5,14 +5,16 @@ FROM $SDK_BASE_IMAGE
# Use powershell as the default shell
SHELL ["pwsh", "-Command"]
RUN echo "DOTNET_SDK_VERSION="$env:DOTNET_SDK_VERSION
RUN echo "DOTNET_VERSION="$env:DOTNET_VERSION
WORKDIR /app
COPY . .
ARG VERSION=7.0
ARG CONFIGURATION=Release
RUN dotnet build -c $env:CONFIGURATION
RUN dotnet build -c $env:CONFIGURATION `
-p:TargetingPacksTargetsLocation=C:/live-runtime-artifacts/targetingpacks.targets `
-p:MicrosoftNetCoreAppRefPackDir=C:/live-runtime-artifacts/microsoft.netcore.app.ref/ `
-p:MicrosoftNetCoreAppRuntimePackDir=C:/live-runtime-artifacts/microsoft.netcore.app.runtime.win-x64/$env:CONFIGURATION/
# Enable dump collection
ENV COMPlus_DbgEnableMiniDump=1
@ -21,6 +23,9 @@ ENV COMPlus_DbgMiniDumpName="C:/share/coredump.%p"
EXPOSE 5001
ENV VERSION=$VERSION
ENV CONFIGURATION=$CONFIGURATION
ENV HTTPSTRESS_ARGS=""
CMD dotnet run --no-build -c $env:CONFIGURATION -- $env:HTTPSTRESS_ARGS.Split()
CMD & C:/live-runtime-artifacts/testhost/net$env:VERSION-windows-$env:CONFIGURATION-x64/dotnet.exe exec `
./bin/$env:CONFIGURATION/net$env:VERSION/HttpStress.dll $env:HTTPSTRESS_ARGS.Split()

View File

@ -0,0 +1,47 @@
## This is a helper script for non-containerized local build and test execution.
## It downloads and uses the daily SDK which contains the compatible AspNetCore bits.
## Usage:
## ./build-local.ps1 [StressConfiguration] [LibrariesConfiguration]
# Note that this script does much less than it's counterpart in HttpStress.
# In SslStress it's a thin utility to generate a runscript for running the app with the live-built testhost.
# The main reason to use an equivalent solution in SslStress is consistency with HttpStress.
$Version="7.0"
$RepoRoot="$(git rev-parse --show-toplevel)"
$DailyDotnetRoot= "./.dotnet-daily"
$StressConfiguration = "Release"
if (-not ([string]::IsNullOrEmpty($args[0]))) {
$StressConfiguration = $args[0]
}
$LibrariesConfiguration = "Release"
if (-not ([string]::IsNullOrEmpty($args[1]))) {
$LibrariesConfiguration = $args[0]
}
$TestHostRoot="$RepoRoot/artifacts/bin/testhost/net$Version-windows-$LibrariesConfiguration-x64"
Write-Host "StressConfiguration: $StressConfiguration, LibrariesConfiguration: $LibrariesConfiguration, testhost: $TestHostRoot"
if (-not (Test-Path -Path $TestHostRoot)) {
Write-Host "Cannot find testhost in: $TestHostRoot"
Write-Host "Make sure libraries with the requested configuration are built!"
Write-Host "Usage:"
Write-Host "./build-local.sh [StressConfiguration] [LibrariesConfiguration]"
Write-Host "StressConfiguration and LibrariesConfiguration default to Release!"
exit 1
}
Write-Host "Building solution."
dotnet build -c $StressConfiguration
$Runscript=".\run-stress-$LibrariesConfiguration-$StressConfiguration.ps1"
if (-not (Test-Path $Runscript)) {
Write-Host "Generating Runscript."
Add-Content -Path $Runscript -Value "& '$TestHostRoot/dotnet' exec ./bin/$StressConfiguration/net$Version/SslStress.dll `$args"
}
Write-Host "To run tests type:"
Write-Host "$Runscript [stress test args]"

View File

@ -1 +1,17 @@
<Project/>
<Project>
<PropertyGroup>
<PackageRid>linux-x64</PackageRid>
<PackageRid Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64</PackageRid>
<!-- Stress projects have their own global.json, the directory above that also has it is the repository root. -->
<RepositoryRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)../, global.json))/</RepositoryRoot>
<TargetingPacksTargetsLocation Condition="'$(TargetingPacksTargetsLocation)' == ''">$(RepositoryRoot)eng/targetingpacks.targets</TargetingPacksTargetsLocation>
<ProductVersion>7.0.0</ProductVersion>
<NetCoreAppCurrent>net7.0</NetCoreAppCurrent>
<NetCoreAppCurrentVersion>7.0</NetCoreAppCurrentVersion>
<MicrosoftNetCoreAppFrameworkName>Microsoft.NETCore.App</MicrosoftNetCoreAppFrameworkName>
<MicrosoftNetCoreAppRefPackDir Condition="'$(MicrosoftNetCoreAppRefPackDir)' == ''" >$(RepositoryRoot)artifacts/bin/microsoft.netcore.app.ref/</MicrosoftNetCoreAppRefPackDir>
<MicrosoftNetCoreAppRuntimePackDir Condition="'$(MicrosoftNetCoreAppRuntimePackDir)' == ''">$(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(PackageRid)/$(Configuration)/</MicrosoftNetCoreAppRuntimePackDir>
</PropertyGroup>
</Project>

View File

@ -1 +1,11 @@
<Project/>
<Project>
<Import Project="$(TargetingPacksTargetsLocation)" />
<PropertyGroup>
<!--
Define this here because the SDK resets it
unconditionally in Microsoft.NETCoreSdk.BundledVersions.props.
-->
<NETCoreAppMaximumVersion>7.0</NETCoreAppMaximumVersion>
</PropertyGroup>
</Project>

View File

@ -1,18 +1,23 @@
ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:6.0-bullseye-slim
FROM $SDK_BASE_IMAGE
RUN echo "DOTNET_SDK_VERSION="$DOTNET_SDK_VERSION
RUN echo "DOTNET_VERSION="$DOTNET_VERSION
WORKDIR /app
COPY . .
WORKDIR /app/System.Net.Security/tests/StressTests/SslStress
ARG VERSION=7.0
ARG CONFIGURATION=Release
RUN dotnet build -c $CONFIGURATION
RUN dotnet build -c $CONFIGURATION \
-p:TargetingPacksTargetsLocation=/live-runtime-artifacts/targetingpacks.targets \
-p:MicrosoftNetCoreAppRefPackDir=/live-runtime-artifacts/microsoft.netcore.app.ref/ \
-p:MicrosoftNetCoreAppRuntimePackDir=/live-runtime-artifacts/microsoft.netcore.app.runtime.linux-x64/$CONFIGURATION/
EXPOSE 5001
ENV VERSION=$VERSION
ENV CONFIGURATION=$CONFIGURATION
ENV SSLSTRESS_ARGS=''
CMD dotnet run --no-build -c $CONFIGURATION -- $SSLSTRESS_ARGS
CMD /live-runtime-artifacts/testhost/net$VERSION-Linux-$CONFIGURATION-x64/dotnet exec \
./bin/$CONFIGURATION/net$VERSION/SslStress.dll $SSLSTRESS_ARGS

View File

@ -4,39 +4,47 @@ Provides stress testing scenaria for System.Net.Security.SslStream.
### Running the suite locally
Using the command line,
Prerequisite: the runtime and the libraries should be [live-built](https://github.com/dotnet/runtime/tree/main/docs/workflow/building/libraries) with `build.cmd`/`build.sh`.
Use the script `build-local.sh` / `Build-Local.ps1` to build the stress project against the live-built runtime.
```bash
$ dotnet run -- <stress suite args>
$ build-local.sh [StressConfiguration] [LibrariesConfiguration]
```
The build script will also generate the runscript that runs the stress suite using the locally built testhost in the form of `run-stress-<StressConfiguration>-<LirariesConfiguration>.sh`. To run the tests with the script, assuming that both the stress project and the libraries have been built against Release configuration:
```bash
$ run-stress-Release-Release.sh [stress suite args]
```
To get the full list of available parameters:
```bash
$ dotnet run -- -help
$ run-stress-Release-Release.sh.sh -help
```
### Running with local runtime builds
### Building and running with Docker
Note that the stress suite will test the sdk available in the environment,
that is to say it will not necessarily test the implementation of the local runtime repo.
To achieve this, we will first need to build a new sdk from source. This can be done [using docker](https://github.com/dotnet/runtime/blob/main/eng/docker/Readme.md).
A docker image containing the live-built runtime bits and the latest daily SDK is created with the [`build-docker-sdk.sh/ps1` scripts](https://github.com/dotnet/runtime/blob/main/eng/docker/Readme.md).
### Running using docker-compose
It's possible to manually `docker build` a docker image containing the stress project based on the docker image created with `build-docker-sdk.sh/ps1`, however the preferred way is to use docker-compose, which can be used to target both linux and windows containers.
The preferred way of running the stress suite is using docker-compose,
which can be used to target both linux and windows containers.
Docker and compose-compose are required for this step (both included in [docker for windows](https://docs.docker.com/docker-for-windows/)).
#### Using Linux containers
From the stress folder on powershell:
From the stress folder:
```powershell
PS> .\run-docker-compose.ps1 -b
```
This will build the libraries and stress suite to a linux docker image and initialize a stress run using docker-compose.
```bash
$ ./run-docker-compose.sh -b
```
This will build libraries and stress suite to a linux docker image and initialize a stress run using docker-compose.
#### Using Windows containers

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
## This is a helper script for non-containerized local build and test execution.
## Usage:
## ./build-local.sh [Configuration]
# Note that this script does much less than it's counterpart in HttpStress.
# In SslStress it's a thin utility to generate a runscript for running the app with the live-built testhost.
# The main reason to use an equivalent solution in SslStress is consistency with HttpStress.
version=7.0
repo_root=$(git rev-parse --show-toplevel)
stress_configuration="Release"
if [ "$1" != "" ]; then
stress_configuration=${1,,} # Lowercase all characters in $1
stress_configuration=${stress_configuration^} # Uppercase first character
fi
libraries_configuration="Release"
if [ "$2" != "" ]; then
libraries_configuration=${2,,} # Lowercase all characters in $1
libraries_configuration=${libraries_configuration^} # Uppercase first character
fi
testhost_root=$repo_root/artifacts/bin/testhost/net$version-Linux-$libraries_configuration-x64
echo "StressConfiguration: $stress_configuration, LibrariesConfiguration: $libraries_configuration, testhost: $testhost_root"
if [[ ! -d $testhost_root ]]; then
echo "Cannot find testhost in: $testhost_root"
echo "Make sure libraries with the requested configuration are built!"
echo "Usage:"
echo "./build-local.sh [StressConfiguration] [LibrariesConfiguration]"
echo "StressConfiguration and LibrariesConfiguration default to Release!"
exit 1
fi
echo "Building solution."
dotnet build -c $stress_configuration
runscript=./run-stress-${stress_configuration,,}-${libraries_configuration,,}.sh
if [[ ! -f $runscript ]]; then
echo "Generating runscript."
echo "$testhost_root/dotnet exec ./bin/$stress_configuration/net$version/SslStress.dll \$@" > $runscript
chmod +x $runscript
fi
echo "To run tests type:"
echo "$runscript [stress test args]"

View File

@ -6,7 +6,6 @@ Param(
[string][Alias('c')]$configuration = "Release", # Build configuration for libraries and stress suite
[switch][Alias('w')]$useWindowsContainers, # Use windows containers, if available
[switch][Alias('b')]$buildCurrentLibraries, # Drives the stress test using libraries built from current source
[switch][Alias('pa')]$privateAspNetCore, # Drive the stress test using a private Asp.Net Core package, requires -b to be set
[switch][Alias('o')]$buildOnly, # Build, but do not run the stress app
[string][Alias('t')]$sdkImageName, # Name of the sdk image name, if built from source.
[string]$clientStressArgs = "",
@ -30,20 +29,11 @@ if ($buildCurrentLibraries)
{
$LIBRARIES_BUILD_ARGS += " -w"
}
if($privateAspNetCore)
{
$LIBRARIES_BUILD_ARGS += " -p"
}
Invoke-Expression "& $REPO_ROOT_DIR/eng/docker/build-docker-sdk.ps1 $LIBRARIES_BUILD_ARGS"
if (!$?) { exit 1 }
}
elseif ($privateAspNetCore) {
write-output "Using a private Asp.Net Core package (-pa) requires using privately built libraries. Please, enable it with -b switch."
write-output "USAGE: . $($MyInvocation.InvocationName) -b -pa <args>"
exit 1
}
# Dockerize the stress app using docker-compose

View File

@ -22,7 +22,6 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
imagename="dotnet-sdk-libs-current"
configuration="Release"
privateaspnetcore=0
buildcurrentlibraries=0
buildonly=0
clientstressargs=""
@ -39,10 +38,6 @@ while [[ $# > 0 ]]; do
configuration=$2
shift 2
;;
-privateaspnetcore|-pa)
privateaspnetcore=1
shift 1
;;
-buildcurrentlibraries|-b)
buildcurrentlibraries=1
shift 1
@ -69,17 +64,10 @@ repo_root=$(git rev-parse --show-toplevel)
if [[ buildcurrentlibraries -eq 1 ]]; then
libraries_args=" -t $imagename -c $configuration"
if [[ $privateaspnetcore -eq 1 ]]; then
libraries_args="$libraries_args -pa"
fi
if ! $repo_root/eng/docker/build-docker-sdk.sh $libraries_args; then
exit 1
fi
elif [[ $privateaspnetcore -eq 1 ]]; then
echo "Using a private Asp.Net Core package (-pa) requires using privately built libraries. Please, enable it with -b switch."
exit 1
fi
build_args=""

View File

@ -5,18 +5,23 @@ FROM $SDK_BASE_IMAGE
# Use powershell as the default shell
SHELL ["pwsh", "-Command"]
RUN echo "DOTNET_SDK_VERSION="$env:DOTNET_SDK_VERSION
RUN echo "DOTNET_VERSION="$env:DOTNET_VERSION
WORKDIR /app
COPY . .
WORKDIR /app/System.Net.Security/tests/StressTests/SslStress
ARG VERSION=7.0
ARG CONFIGURATION=Release
RUN dotnet build -c $env:CONFIGURATION
RUN dotnet build -c $env:CONFIGURATION `
-p:TargetingPacksTargetsLocation=C:/live-runtime-artifacts/targetingpacks.targets `
-p:MicrosoftNetCoreAppRefPackDir=C:/live-runtime-artifacts/microsoft.netcore.app.ref/ `
-p:MicrosoftNetCoreAppRuntimePackDir=C:/live-runtime-artifacts/microsoft.netcore.app.runtime.win-x64/$env:CONFIGURATION/
EXPOSE 5001
ENV VERSION=$VERSION
ENV CONFIGURATION=$CONFIGURATION
ENV SSLSTRESS_ARGS=""
CMD dotnet run --no-build -c $env:CONFIGURATION -- $env:SSLSTRESS_ARGS.Split()
CMD & C:/live-runtime-artifacts/testhost/net$env:VERSION-windows-$env:CONFIGURATION-x64/dotnet.exe exec `
./bin/$env:CONFIGURATION/net$env:VERSION/SslStress.dll $env:SSLSTRESS_ARGS.Split()