using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
using System.Net;
using HttpStress;
.ToArray(),
};
- Console.WriteLine(" .NET Core: " + Path.GetFileName(Path.GetDirectoryName(typeof(object).Assembly.Location)));
- Console.WriteLine(" ASP.NET Core: " + Path.GetFileName(Path.GetDirectoryName(typeof(WebHost).Assembly.Location)));
- Console.WriteLine(" System.Net.Http: " + GetSysNetHttpAssemblyInfo());
+ string GetAssemblyInfo(Assembly assembly) => $"{assembly.Location}, modified {new FileInfo(assembly.Location).LastWriteTime}";
+
+ Console.WriteLine(" .NET Core: " + GetAssemblyInfo(typeof(object).Assembly));
+ Console.WriteLine(" ASP.NET Core: " + GetAssemblyInfo(typeof(WebHost).Assembly));
+ Console.WriteLine(" System.Net.Http: " + GetAssemblyInfo(typeof(System.Net.Http.HttpClient).Assembly));
Console.WriteLine(" Server: " + (config.UseHttpSys ? "http.sys" : "Kestrel"));
Console.WriteLine(" Server URL: " + config.ServerUri);
Console.WriteLine(" Tracing: " + (config.LogPath == null ? (object)false : config.LogPath.Length == 0 ? (object)true : config.LogPath));
{
return value is null ? null : new S?(mapper(value.Value));
}
-
- private static string GetSysNetHttpAssemblyInfo()
- {
- string location = typeof(System.Net.Http.HttpClient).Assembly.Location;
- return $"{location}, last modified {new FileInfo(location).LastWriteTime}";
- }
}
--- /dev/null
+## HttpStress
+
+Provides stress testing scenaria for System.Net.HttpClient, with emphasis on the HTTP/2 implementation of SocketsHttpHandler.
+
+### Running the suite locally
+
+Using the command line,
+
+```bash
+$ dotnet run -- <stress suite args>
+```
+
+To get the full list of available parameters:
+
+```bash
+$ dotnet run -- -help
+```
+
+### Running with local corefx builds
+
+Note that the stress suite will test the sdk build available in the available,
+that is to say it will not necessarily test the implementation of the local corefx repo.
+To achieve this, you will need to point your environment to the [`testhost` build of corefx](https://github.com/dotnet/coreclr/blob/master/Documentation/building/testing-with-corefx.md).
+
+Using powershell on windows:
+
+```powershell
+# Build corefx from source
+PS> .\build.sh -c Release
+# Load the testhost sdk in the current environment, must match build configuration
+PS> . .\src\System.Net.Http\tests\StressTests\HttpStress\load-corefx-testhost.ps1 -c Release
+# run the stress suite with the new bits
+PS> cd .\src\System.Net.Http\tests\StressTests\HttpStress ; dotnet run --runtime win10-x64
+```
+
+Note that the `--runtime` argument is necessary because `testhost`
+does not bundle the required aspnetcore runtime dependencies.
+This will force the sdk to install the relevant native bits from nuget.
+
+Equivalently using bash on linux:
+
+```bash
+# Build corefx from source
+$ ./build.sh -c Release
+# Load the testhost sdk in the current environment, must match build configuration
+$ source src/System.Net.Http/tests/StressTests/HttpStress/load-corefx-testhost.sh -c Release
+# run the stress suite with the new bits
+$ cd src/System.Net.Http/tests/StressTests/HttpStress && dotnet run -r linux-x64
+```
\ No newline at end of file
--- /dev/null
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+# Helper script used for pointing the current powershell environment
+# to the testhost sdk built by the corefx build script.
+
+[CmdletBinding(PositionalBinding=$false)]
+Param(
+ [string][Alias('f')]$framework = "netcoreapp",
+ [string][Alias('c')]$configuration = "Debug",
+ [string][Alias('a')]$arch = "x64",
+ [string][Alias('o')]$os = ""
+)
+
+# script needs to be sourced, detect if running standalone
+if ($MyInvocation.InvocationName -ne ".")
+{
+ write-output "Script must be sourced"
+ write-output "USAGE: . $($MyInvocation.InvocationName) <args>"
+ exit
+}
+
+# find corefx root, assuming script lives in the git repo
+$SOURCE_DIR="$(split-path -Parent $MyInvocation.MyCommand.Definition)"
+$COREFX_ROOT_DIR=$(git -C "$SOURCE_DIR" rev-parse --show-toplevel)
+
+function Find-Os()
+{
+ if (!$(test-path variable:IsWindows) -or $IsWindows)
+ {
+ return "Windows_NT"
+ }
+ else
+ {
+ switch -Wildcard ($(uname -s))
+ {
+ "Linux*" { return "Linux" }
+ "Darwin*" { return "MacOS" }
+ "*" { return "Unix" }
+ }
+ }
+}
+
+if ($os -eq "")
+{
+ $os=$(Find-Os)
+}
+
+function Set-Sdk-Environment()
+{
+ $candidate_path=$([IO.Path]::Combine($COREFX_ROOT_DIR, 'artifacts', 'bin', 'testhost', "$FRAMEWORK-$OS-$CONFIGURATION-$ARCH"))
+
+ if (!$(test-path -PathType container $candidate_path))
+ {
+ write-output "Could not locate testhost sdk path $candidate_path"
+ return
+ }
+ elseif (!$(test-path -PathType leaf $([IO.Path]::Combine($candidate_path, "dotnet"))) -and
+ !$(test-path -PathType leaf $([IO.Path]::Combine($candidate_path, "dotnet.exe"))))
+ {
+ write-output "Could not find dotnet executable in testhost sdk path $candidate_path"
+ return
+ }
+
+ $pathSeparator=if($os -eq "Windows_NT") { ";" } else { ":" }
+
+ $env:DOTNET_ROOT=$candidate_path
+ $env:DOTNET_CLI_HOME=$candidate_path
+ $env:PATH=($candidate_path + $pathSeparator + $env:PATH)
+ $env:DOTNET_MULTILEVEL_LOOKUP=0
+ $env:DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2
+}
+
+Set-Sdk-Environment
--- /dev/null
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+# Helper script used for pointing the current bash environment
+# to the testhost sdk built by the corefx build script.
+
+# script needs to be sourced, detect if running standalone
+if [[ $0 = $_ ]]; then
+ echo "Script needs to be sourced"
+ echo "USAGE: . $0 <args>"
+ exit 1
+fi
+
+# find corefx root, assuming script lives in the git repo
+SOURCE_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+COREFX_ROOT_DIR=$(git -C "$SOURCE_DIR" rev-parse --show-toplevel)
+
+usage()
+{
+ echo "Usage:"
+ echo " -f <moniker> Target framework: defaults to netcoreapp"
+ echo " -c <config> Build configuration: defaults to Debug"
+ echo " -a <arch> Build architecture: defaults to netcoreapp"
+ echo " -o <os> Operating system"
+}
+
+detect_os()
+{
+ case $(uname -s) in
+ Linux*) echo Linux;;
+ Darwin*) echo MacOS;;
+ CYGWIN*) echo Windows_NT;;
+ MINGW*) echo Windows_NT;;
+ *) echo Unix;;
+ esac
+}
+
+# parse command line args
+OS=$(detect_os)
+ARCH=x64
+FRAMEWORK=netcoreapp
+CONFIGURATION=Debug
+
+OPTIND=1
+while getopts "hf:c:a:o:" opt; do
+ case $opt in
+ f) FRAMEWORK=$OPTARG ;;
+ c) CONFIGURATION=$OPTARG ;;
+ a) ARCH=$OPTARG ;;
+ o) OS=$OPTARG ;;
+ h) usage ; return 0 ;;
+ *) usage ; return 1 ;;
+ esac
+done
+
+apply_to_environment()
+{
+ candidate_path="$COREFX_ROOT_DIR/artifacts/bin/testhost/$FRAMEWORK-$OS-$CONFIGURATION-$ARCH"
+
+ if [ ! -d $candidate_path ]; then
+ echo "Could not locate testhost sdk path $candidate_path"
+ return 1
+ elif [ ! -f $candidate_path/dotnet -a ! -f $candidate_path/dotnet.exe ]; then
+ echo "Could not find dotnet executable in testhost sdk path $candidate_path"
+ return 1
+ fi
+
+ export DOTNET_ROOT=$candidate_path
+ export DOTNET_CLI_HOME=$candidate_path
+ export DOTNET_MULTILEVEL_LOOKUP=0
+ export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2
+
+ if which cygpath > /dev/null 2>&1; then
+ # cygwin & mingw compat: PATH values must be unix style
+ export PATH=$(cygpath -u $candidate_path):$PATH
+ else
+ export PATH=$candidate_path:$PATH
+ fi
+}
+
+apply_to_environment