diff --git a/.dockerignore b/.dockerignore index b1b026d8b31b4d..8bf5252822b1d3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -61,6 +61,7 @@ **/*.obj **/*.pch **/*.pdb +!**/_.pdb **/*.pgc **/*.pgd **/*.rsp diff --git a/eng/docker/build-docker-sdk.ps1 b/eng/docker/build-docker-sdk.ps1 index ed0181887c1480..e3fbaef77d1d36 100755 --- a/eng/docker/build-docker-sdk.ps1 +++ b/eng/docker/build-docker-sdk.ps1 @@ -14,46 +14,42 @@ $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. # Build on the host machine, then simply copy artifacts to the target docker image. # This should result in significantly lower build times, for now. - & "$REPO_ROOT_DIR/build.cmd" -ci -subset clr+libs -runtimeconfiguration release -c $configuration - - # Dockerize the build artifacts - if($privateAspNetCore) - { - docker build --tag $imageName ` - --build-arg CONFIGURATION=$configuration ` - --build-arg TESTHOST_LOCATION=. ` - --file "$PSScriptRoot/libraries-sdk-aspnetcore.windows.Dockerfile" ` - "$REPO_ROOT_DIR/artifacts/bin/testhost" - } - else + & "$REPO_ROOT_DIR/build.cmd" clr+libs -ci -rc release -c $configuration + + if (!$?) { - docker build --tag $imageName ` - --build-arg CONFIGURATION=$configuration ` - --build-arg TESTHOST_LOCATION=. ` - --file "$PSScriptRoot/libraries-sdk.windows.Dockerfile" ` - "$REPO_ROOT_DIR/artifacts/bin/testhost" + exit $LASTEXITCODE } + + $dockerFile="$dockerFilePrefix.windows.Dockerfile" + + docker build --tag $imageName ` + --build-arg CONFIGURATION=$configuration ` + --build-arg TESTHOST_LOCATION=. ` + --file $dockerFile ` + "$REPO_ROOT_DIR/artifacts/bin/testhost" } -else +else { # Docker build libraries and copy to dotnet sdk image - if($privateAspNetCore) - { - docker build --tag $imageName ` - --build-arg CONFIGURATION=$configuration ` - --file "$PSScriptRoot/libraries-sdk-aspnetcore.linux.Dockerfile" ` - $REPO_ROOT_DIR - } - else - { + $dockerFile="$dockerFilePrefix.linux.Dockerfile" + docker build --tag $imageName ` --build-arg CONFIGURATION=$configuration ` - --file "$PSScriptRoot/libraries-sdk.linux.Dockerfile" ` + --file $dockerFile ` $REPO_ROOT_DIR - } } + +exit $LASTEXITCODE diff --git a/eng/docker/build-docker-sdk.sh b/eng/docker/build-docker-sdk.sh new file mode 100755 index 00000000000000..39ddd5ffc460d7 --- /dev/null +++ b/eng/docker/build-docker-sdk.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# Builds libraries and produces a dotnet sdk docker image +# that contains the current bits in its shared framework folder. + +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u + +# Stop script if command returns non-zero exit code. +# Prevents hidden errors caused by missing error code propagation. +set -e + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +imagename="dotnet-sdk-libs-current" +configuration="Release" +privateaspnetcore=0 + +while [[ $# > 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -imagename|-t) + imagename=$2 + shift 2 + ;; + -configuration|-c) + configuration=$2 + shift 2 + ;; + -privateaspnetcore|-pa) + privateaspnetcore=1 + shift 1 + ;; + *) + shift 1 + ;; + esac +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 \ + $repo_root + +exit $? diff --git a/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile index 422e8e19601558..04974370ebac4b 100644 --- a/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile +++ b/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile @@ -1,6 +1,6 @@ # 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/core/sdk:3.0.100-buster +ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:5.0-buster-slim FROM $BUILD_BASE_IMAGE as corefxbuild diff --git a/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile index 81c13817d11d91..32f91f5d8595fd 100644 --- a/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile +++ b/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile @@ -1,6 +1,6 @@ # escape=` # Simple Dockerfile which copies library build artifacts into target dotnet sdk image -ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/core/sdk:3.0.100-nanoserver-1809 +ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:5.0-nanoserver-1809 FROM $SDK_BASE_IMAGE as target ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost" diff --git a/eng/docker/libraries-sdk.linux.Dockerfile b/eng/docker/libraries-sdk.linux.Dockerfile index 8a4abed0b09509..2cc979dba6a07c 100644 --- a/eng/docker/libraries-sdk.linux.Dockerfile +++ b/eng/docker/libraries-sdk.linux.Dockerfile @@ -1,6 +1,6 @@ # 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/core/sdk:3.0.100-buster +ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:5.0-buster-slim FROM $BUILD_BASE_IMAGE as corefxbuild @@ -25,4 +25,4 @@ ARG TARGET_COREFX_VERSION=3.0.0 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/ + $TARGET_SHARED_FRAMEWORK/$COREFX_SHARED_FRAMEWORK_NAME/$TARGET_COREFX_VERSION/ \ No newline at end of file diff --git a/eng/docker/libraries-sdk.windows.Dockerfile b/eng/docker/libraries-sdk.windows.Dockerfile index b6393424aad23a..50c3f357c9b770 100644 --- a/eng/docker/libraries-sdk.windows.Dockerfile +++ b/eng/docker/libraries-sdk.windows.Dockerfile @@ -1,6 +1,6 @@ # escape=` -# Simple Dockerfile which copies library build artifacts into target dotnet sdk image -ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/core/sdk:3.0.100-nanoserver-1809 +# Simple Dockerfile which copies clr and library build artifacts into target dotnet sdk image +ARG SDK_BASE_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:5.0-nanoserver-1809 FROM $SDK_BASE_IMAGE as target ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost" diff --git a/eng/pipelines/libraries/stress/http.yml b/eng/pipelines/libraries/stress/http.yml index 2d7dbb6860b2b4..ddf8a566790339 100644 --- a/eng/pipelines/libraries/stress/http.yml +++ b/eng/pipelines/libraries/stress/http.yml @@ -27,7 +27,8 @@ jobs: displayName: Docker Linux timeoutInMinutes: 120 pool: - name: Hosted Ubuntu 1604 + name: NetCorePublic-Pool + queue: BuildPool.Ubuntu.1604.Amd64.Open steps: - checkout: self @@ -35,11 +36,11 @@ jobs: fetchDepth: 5 - bash: | - $(dockerfilesFolder)/build-docker-sdk.ps1 -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) + $(dockerfilesFolder)/build-docker-sdk.sh -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) displayName: Build CLR and Libraries - bash: | - $(httpStressProject)/run-docker-compose.ps1 -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) + $(httpStressProject)/run-docker-compose.sh -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) displayName: Build HttpStress - bash: | @@ -51,7 +52,8 @@ jobs: displayName: Docker NanoServer timeoutInMinutes: 120 pool: - vmImage: 'windows-latest' + name: NetCorePublic-Pool + queue: BuildPool.Server.Amd64.VS2019.Open steps: - checkout: self @@ -59,15 +61,15 @@ jobs: fetchDepth: 5 lfs: false - - pwsh: | + - powershell: | $(dockerfilesFolder)/build-docker-sdk.ps1 -w -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) displayName: Build CLR and Libraries - - pwsh: | + - powershell: | $(httpStressProject)/run-docker-compose.ps1 -w -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) displayName: Build HttpStress - - pwsh: | + - powershell: | cd '$(httpStressProject)' docker-compose up --abort-on-container-exit --no-color displayName: Run HttpStress diff --git a/eng/pipelines/libraries/stress/ssl.yml b/eng/pipelines/libraries/stress/ssl.yml index 88e20efce027a1..5359ea76e8b280 100644 --- a/eng/pipelines/libraries/stress/ssl.yml +++ b/eng/pipelines/libraries/stress/ssl.yml @@ -28,7 +28,8 @@ jobs: displayName: Docker Linux timeoutInMinutes: 120 pool: - name: Hosted Ubuntu 1604 + name: NetCorePublic-Pool + queue: BuildPool.Ubuntu.1604.Amd64.Open steps: - checkout: self @@ -36,11 +37,11 @@ jobs: fetchDepth: 5 - bash: | - $(dockerfilesFolder)/build-docker-sdk.ps1 -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) + $(dockerfilesFolder)/build-docker-sdk.sh -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) displayName: Build CLR and Libraries - bash: | - $(sslStressProject)/run-docker-compose.ps1 -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) + $(sslStressProject)/run-docker-compose.sh -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) displayName: Build SslStress - bash: | @@ -52,7 +53,8 @@ jobs: displayName: Docker NanoServer timeoutInMinutes: 120 pool: - vmImage: 'windows-latest' + name: NetCorePublic-Pool + queue: BuildPool.Server.Amd64.VS2019.Open steps: - checkout: self @@ -60,15 +62,15 @@ jobs: fetchDepth: 5 lfs: false - - pwsh: | + - powershell: | $(dockerfilesFolder)/build-docker-sdk.ps1 -w -t $(sdkBaseImage) -c $(BUILD_CONFIGURATION) displayName: Build CLR and Libraries - - pwsh: | + - powershell: | $(sslStressProject)/run-docker-compose.ps1 -w -o -c $(BUILD_CONFIGURATION) -t $(sdkBaseImage) displayName: Build SslStress - - pwsh: | + - powershell: | cd '$(sslStressProject)' docker-compose up --abort-on-container-exit --no-color displayName: Run SslStress diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj index 0d8818fb1d0827..b107d5ba1930e6 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 preview enable diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh new file mode 100755 index 00000000000000..bf5955315b188b --- /dev/null +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# Runs the stress test using docker-compose + +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u + +# Stop script if command returns non-zero exit code. +# Prevents hidden errors caused by missing error code propagation. +set -e + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +imagename="dotnet-sdk-libs-current" +configuration="Release" +privateaspnetcore=0 +buildcurrentlibraries=0 +buildonly=0 +clientstressargs="" +serverstressargs="" + +while [[ $# > 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -sdkimagename|-t) + imagename=$2 + shift 2 + ;; + -configuration|-c) + configuration=$2 + shift 2 + ;; + -privateaspnetcore|-pa) + privateaspnetcore=1 + shift 1 + ;; + -buildcurrentlibraries|-b) + buildcurrentlibraries=1 + shift 1 + ;; + -buildonly|-o) + buildonly=1 + shift 1 + ;; + -clientstressargs) + clientstressargs=$2 + shift 2 + ;; + -serverstressargs) + serverstressargs=$2 + shift 2 + ;; + *) + shift 1 + ;; + esac +done + +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="" +if [[ "$imagename" != "" ]]; then + build_args=" --build-arg SDK_BASE_IMAGE=$imagename" +fi + +compose_file="$scriptroot/docker-compose.yml" + +if ! docker-compose --file "$compose_file" build $build_args; then + exit $? +fi + +if [[ $buildonly -eq 0 ]]; then + export HTTPSTRESS_CLIENT_ARGS=$clientstressargs + export HTTPSTRESS_SERVER_ARGS=$serverstressargs + docker-compose --file "$compose_file" up --abort-on-container-exit + exit $? +fi diff --git a/src/libraries/System.Net.Security/tests/StressTests/SslStress/SslStress.csproj b/src/libraries/System.Net.Security/tests/StressTests/SslStress/SslStress.csproj index f383e35086a6e5..3221dd6cd13cb5 100644 --- a/src/libraries/System.Net.Security/tests/StressTests/SslStress/SslStress.csproj +++ b/src/libraries/System.Net.Security/tests/StressTests/SslStress/SslStress.csproj @@ -1,7 +1,7 @@ Exe - netcoreapp3.0 + net5.0 enable diff --git a/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh new file mode 100755 index 00000000000000..ba08e07dfe1342 --- /dev/null +++ b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# Runs the stress test using docker-compose + +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u + +# Stop script if command returns non-zero exit code. +# Prevents hidden errors caused by missing error code propagation. +set -e + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +imagename="dotnet-sdk-libs-current" +configuration="Release" +privateaspnetcore=0 +buildcurrentlibraries=0 +buildonly=0 +clientstressargs="" +serverstressargs="" + +while [[ $# > 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -sdkimagename|-t) + imagename=$2 + shift 2 + ;; + -configuration|-c) + configuration=$2 + shift 2 + ;; + -privateaspnetcore|-pa) + privateaspnetcore=1 + shift 1 + ;; + -buildcurrentlibraries|-b) + buildcurrentlibraries=1 + shift 1 + ;; + -buildonly|-o) + buildonly=1 + shift 1 + ;; + -clientstressargs) + clientstressargs=$2 + shift 2 + ;; + -serverstressargs) + serverstressargs=$2 + shift 2 + ;; + *) + shift 1 + ;; + esac +done + +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="" +if [[ "$imagename" != "" ]]; then + build_args=" --build-arg SDK_BASE_IMAGE=$imagename" +fi + +compose_file="$scriptroot/docker-compose.yml" + +if ! docker-compose --file "$compose_file" build $build_args; then + exit $? +fi + +if [[ $buildonly -eq 0 ]]; then + export SSLSTRESS_CLIENT_ARGS=$clientstressargs + export SSLSTRESS_SERVER_ARGS=$serverstressargs + docker-compose --file "$compose_file" up --abort-on-container-exit + exit $? +fi