From b0b1f636f1f3750b1db5ecff4dabb5994b5a1c13 Mon Sep 17 00:00:00 2001 From: Alexander Nikolaev Date: Fri, 20 Mar 2020 14:46:42 +0100 Subject: [PATCH 1/3] Run stress tests on private Asp.Net Core package --- eng/docker/build-docker-sdk.ps1 | 25 +++++++++++-- .../libraries-sdk-aspnetcore.linux.Dockerfile | 36 +++++++++++++++++++ ...ibraries-sdk-aspnetcore.windows.Dockerfile | 26 ++++++++++++++ .../HttpStress/run-docker-compose.ps1 | 15 ++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile create mode 100644 eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile diff --git a/eng/docker/build-docker-sdk.ps1 b/eng/docker/build-docker-sdk.ps1 index 76c1ce7b41407..ab14212da9a21 100755 --- a/eng/docker/build-docker-sdk.ps1 +++ b/eng/docker/build-docker-sdk.ps1 @@ -6,7 +6,8 @@ Param( [string][Alias('t')]$imageName = "dotnet-sdk-libs-current", [string][Alias('c')]$configuration = "Release", - [switch][Alias('w')]$buildWindowsContainers + [switch][Alias('w')]$buildWindowsContainers, + [switch][Alias('pa')]$privateAspNetCore ) $ErrorActionPreference = "Stop" @@ -22,17 +23,37 @@ if ($buildWindowsContainers) & "$REPO_ROOT_DIR/libraries.cmd" -ci -c $configuration -runtimeConfiguration release # Dockerize the build artifacts - docker build --tag $imageName ` + 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" + } + { + docker build --tag $imageName ` --build-arg CONFIGURATION=$configuration ` --build-arg TESTHOST_LOCATION=. ` --file "$PSScriptRoot/libraries-sdk.windows.Dockerfile" ` "$REPO_ROOT_DIR/artifacts/bin/testhost" + } } 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 + { docker build --tag $imageName ` --build-arg CONFIGURATION=$configuration ` --file "$PSScriptRoot/libraries-sdk.linux.Dockerfile" ` $REPO_ROOT_DIR + } } diff --git a/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile new file mode 100644 index 0000000000000..f352d29cac70c --- /dev/null +++ b/eng/docker/libraries-sdk-aspnetcore.linux.Dockerfile @@ -0,0 +1,36 @@ +# 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 + +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=netcoreapp5.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=5.0.0 +ARG TARGET_SHARED_FRAMEWORK=/usr/share/dotnet/shared +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/ +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/ \ No newline at end of file diff --git a/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile b/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile new file mode 100644 index 0000000000000..59aa7f034f71f --- /dev/null +++ b/eng/docker/libraries-sdk-aspnetcore.windows.Dockerfile @@ -0,0 +1,26 @@ +# 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 +FROM $SDK_BASE_IMAGE as target + +ARG TESTHOST_LOCATION=".\\artifacts\\bin\\testhost" +ARG TFM=netcoreapp5.0 +ARG OS=Windows_NT +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=5.0.0 +ARG TARGET_SHARED_FRAMEWORK="C:\\Program Files\\dotnet\\shared" +ARG TARGET_COREFX_VERSION=3.0.0 + +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\ diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.ps1 b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.ps1 index 60dfaa6e252a1..216eb9f5732ef 100755 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.ps1 +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.ps1 @@ -6,6 +6,7 @@ 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 = "", @@ -19,16 +20,30 @@ $COMPOSE_FILE = "$PSScriptRoot/docker-compose.yml" if ($buildCurrentLibraries) { + if ([string]::IsNullOrEmpty($sdkImageName)) + { + $sdkImageName = "dotnet-sdk-libs-current" + } + $LIBRARIES_BUILD_ARGS = " -t $sdkImageName -c $configuration" if($useWindowsContainers) { $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 " + exit 1 +} # Dockerize the stress app using docker-compose From 790f08287c92e0f0dcef722f52347252f565af24 Mon Sep 17 00:00:00 2001 From: Alexander Nikolaev Date: Fri, 20 Mar 2020 15:25:38 +0100 Subject: [PATCH 2/3] -pa switch added to SslStress tests as well --- .../StressTests/SslStress/run-docker-compose.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.ps1 b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.ps1 index 81dd794249911..72e99224c6022 100755 --- a/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.ps1 +++ b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.ps1 @@ -6,6 +6,7 @@ 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 = "", @@ -19,16 +20,30 @@ $COMPOSE_FILE = "$PSScriptRoot/docker-compose.yml" if ($buildCurrentLibraries) { + if ([string]::IsNullOrEmpty($sdkImageName)) + { + $sdkImageName = "dotnet-sdk-libs-current" + } + $LIBRARIES_BUILD_ARGS = " -t $sdkImageName -c $configuration" if($useWindowsContainers) { $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 " + exit 1 +} # Dockerize the stress app using docker-compose From 47f2c10540c85d9947263e49c66a08d900c3d8d1 Mon Sep 17 00:00:00 2001 From: Alexander Nikolaev Date: Tue, 24 Mar 2020 13:44:22 +0100 Subject: [PATCH 3/3] Windows containers build fixed --- eng/docker/build-docker-sdk.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/docker/build-docker-sdk.ps1 b/eng/docker/build-docker-sdk.ps1 index ab14212da9a21..a7c3094077dda 100755 --- a/eng/docker/build-docker-sdk.ps1 +++ b/eng/docker/build-docker-sdk.ps1 @@ -31,6 +31,7 @@ if ($buildWindowsContainers) --file "$PSScriptRoot/libraries-sdk-aspnetcore.windows.Dockerfile" ` "$REPO_ROOT_DIR/artifacts/bin/testhost" } + else { docker build --tag $imageName ` --build-arg CONFIGURATION=$configuration `