diff --git a/.github/workflows/all_solutions.yml b/.github/workflows/all_solutions.yml index edd887e965..b323d79f49 100644 --- a/.github/workflows/all_solutions.yml +++ b/.github/workflows/all_solutions.yml @@ -52,7 +52,8 @@ jobs: Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\*.*" -Force -ErrorAction SilentlyContinue Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\x64-Release" -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\x86-Release" -Recurse -Force -ErrorAction SilentlyContinue - Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-release" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-x64-release" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-arm64-release" -Recurse -Force -ErrorAction SilentlyContinue shell: powershell - name: Build x64 @@ -76,9 +77,9 @@ jobs: path: ${{ github.workspace }}\src\Agent\_profilerBuild\**\* if-no-files-found: error - build-linux-profiler: + build-linux-x64-profiler: needs: cancel-previous-workflow-runs - name: Build Linux Profiler + name: Build Linux x64 Profiler runs-on: ubuntu-18.04 env: @@ -93,10 +94,11 @@ jobs: - name: Clean out _profilerBuild directory run: | - rm -f ${{ github.workspace }}/src/Agent/_profilerBuild/*.* - rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-release - rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x64-Release - rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x86-Release + rm -f ${{ github.workspace }}/src/Agent/_profilerBuild/*.* || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x64-Release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x86-Release || true shell: bash - name: Build Linux Profler @@ -108,8 +110,73 @@ jobs: - name: Move Profiler to staging folder run: | - mkdir --parents ${{ github.workspace }}/src/Agent/_profilerBuild/linux-release/ - mv -f ${{ env.profiler_path }}/libNewRelicProfiler.so ${{ github.workspace }}/src/Agent/_profilerBuild/linux-release/libNewRelicProfiler.so + mkdir --parents ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release/ + mv -f ${{ env.profiler_path }}/libNewRelicProfiler.so ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release/libNewRelicProfiler.so + shell: bash + + - name: Archive Artifacts + uses: actions/upload-artifact@v2 + with: + name: profiler + path: ${{ github.workspace }}/src/Agent/_profilerBuild/ + if-no-files-found: error + + build-linux-arm64-profiler: + needs: cancel-previous-workflow-runs + name: Build Linux ARM64 Profiler + runs-on: ubuntu-18.04 + + env: + profiler_path: ${{ github.workspace }}/src/Agent/NewRelic/Profiler + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Clean out _profilerBuild directory + run: | + rm -f ${{ github.workspace }}/src/Agent/_profilerBuild/*.* || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x64-Release || true + rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x86-Release || true + shell: bash + + - uses: uraimo/run-on-arch-action@v2.0.5 + name: Run commands + id: runcmd + with: + arch: aarch64 + distro: ubuntu18.04 + githubToken: ${{ github.token }} + install: | + apt-get update -q -y + apt-get install -q -y wget curl git dos2unix software-properties-common make binutils libc++-dev clang-3.9 lldb-3.9 build-essential + echo "deb https://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" | tee /etc/apt/sources.list.d/llvm.list + wget --no-cache --no-cookies -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + mkdir /root/git + cd /root/git + git clone --branch release/3.0 https://github.com/dotnet/coreclr.git + curl -sSL https://virtuoso-testing.s3.us-west-2.amazonaws.com/cmake-3.9.0-rc3-aarch64.tar.gz | tar -xzC ~ + chmod 777 ~/cmake-3.9.0-rc3-aarch64/bin/cmake + ln -s ~/cmake-3.9.0-rc3-aarch64/bin/cmake /usr/bin/cmake || true + rm /usr/bin/cc || true + ln -s /usr/bin/clang-3.9 /usr/bin/cc + rm /usr/bin/c++ || true + ln -s /usr/bin/clang++-3.9 /usr/bin/c++ + dockerRunArgs: | + --volume "${{ env.profiler_path }}:/profiler" + run: | + cd /profiler + chmod 777 ./linux/build_profiler.sh + ./linux/build_profiler.sh + + - name: Move Profiler to staging folder + run: | + mkdir --parents ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release/ + mv -f ${{ env.profiler_path }}/libNewRelicProfiler.so ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release/libNewRelicProfiler.so shell: bash - name: Archive Artifacts @@ -121,7 +188,7 @@ jobs: # This builds both FullAgent and MSIInstaller since MSIInstaller requires FullAgent artifacts. build-test-fullagent-msi: - needs: [ build-windows-profiler, build-linux-profiler ] + needs: [ build-windows-profiler, build-linux-x64-profiler, build-linux-arm64-profiler ] name: Build and Test FullAgent and MSIInstaller runs-on: windows-2019 @@ -146,7 +213,8 @@ jobs: Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\*.*" -Force -ErrorAction SilentlyContinue Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\x64-Release" -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\x86-Release" -Recurse -Force -ErrorAction SilentlyContinue - Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-release" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-x64-release" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-arm64-release" -Recurse -Force -ErrorAction SilentlyContinue shell: powershell - name: Download Profiler Artifacts Before Agent Build @@ -199,6 +267,7 @@ jobs: ${{ github.workspace }}\src\Agent\newrelichome_x64 ${{ github.workspace }}\src\Agent\newrelichome_x64_coreclr ${{ github.workspace }}\src\Agent\newrelichome_x64_coreclr_linux + ${{ github.workspace }}\src\Agent\newrelichome_arm64_coreclr_linux ${{ github.workspace }}\src\Agent\newrelichome_x86 ${{ github.workspace }}\src\Agent\newrelichome_x86_coreclr if-no-files-found: error @@ -552,6 +621,73 @@ jobs: path: C:\IntegrationTestWorkingDirectory\TestResults\**\*TestResults.xml if-no-files-found: error + run-integration-tests-linux-arm64: + needs: build-test-fullagent-msi + name: Run IntegrationTests linux-arm64 + runs-on: ubuntu-18.04 + if: false + + env: + test_path: ${{ github.workspace }}/tests/Agent/IntegrationTests/IntegrationTests/TestResults + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Agent Home Folders + uses: actions/download-artifact@v2 + with: + name: homefolders + path: src/Agent + + - name: Run test commands + uses: uraimo/run-on-arch-action@v2.0.5 + with: + arch: aarch64 + distro: ubuntu18.04 + githubToken: ${{ github.token }} + + env: | + test_secrets: '${{ secrets.TEST_SECRETS }}' + NR_DOTNET_TEST_SAVE_WORKING_DIRECTORY: 1 + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 + + install: | + apt-get update -q -y && apt-get install -q -y curl + export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 + mkdir -p /usr/share/dotnet + curl -sSL https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.818/dotnet-sdk-2.1.818-linux-arm64.tar.gz | tar -xzC /usr/share/dotnet + curl -sSL https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.414/dotnet-sdk-3.1.414-linux-arm64.tar.gz | tar -xzC /usr/share/dotnet + curl -sSL https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.401/dotnet-sdk-5.0.401-linux-arm64.tar.gz | tar -xzC /usr/share/dotnet + ln -sf /usr/share/dotnet/dotnet /usr/bin/dotnet + dotnet help + + dockerRunArgs: | + --volume "${{ env.test_path }}:/tmp/IntegrationTestWorkingDirectory" + + run: | + cd tests/Agent/IntegrationTests/IntegrationTests + echo $test_secrets | dotnet user-secrets set --project "../Shared" + dotnet test -f netcoreapp3.1 -c Release -l "trx" --filter "FullyQualifiedName~ApiCallsTestsCore|FullyQualifiedName~InfiniteTracingNetCoreLatestTests" + + - name: Archive IntegrationTestWorkingDirectory on Failure + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: integration-test-artifacts-linux-arm64 + path: ${{ env.test_path }}/**/* + if-no-files-found: error + + - name: Archive Test Artifacts + uses: actions/upload-artifact@v2 + if: ${{ always() }} + with: + name: integration-test-artifacts-linux-arm64 + path: ${{ env.test_path }}/*.trx + if-no-files-found: error + run-unbounded-tests: needs: [build-unbounded-tests] name: Run Unbounded Tests diff --git a/build/ArtifactBuilder/Artifacts/Artifact.cs b/build/ArtifactBuilder/Artifacts/Artifact.cs index 2146981878..665a884580 100644 --- a/build/ArtifactBuilder/Artifacts/Artifact.cs +++ b/build/ArtifactBuilder/Artifacts/Artifact.cs @@ -24,9 +24,12 @@ public Artifact(string name) protected string PackageDirectory; protected string OutputDirectory; - public void Build() + public void Build(bool clearOutput = true) { - FileHelpers.DeleteDirectories(StagingDirectory, OutputDirectory); + FileHelpers.DeleteDirectories(StagingDirectory); + if (clearOutput) + FileHelpers.DeleteDirectories(OutputDirectory); + InternalBuild(); } diff --git a/build/ArtifactBuilder/Artifacts/DownloadSiteArtifact.cs b/build/ArtifactBuilder/Artifacts/DownloadSiteArtifact.cs index dc994d76f0..d99348e642 100644 --- a/build/ArtifactBuilder/Artifacts/DownloadSiteArtifact.cs +++ b/build/ArtifactBuilder/Artifacts/DownloadSiteArtifact.cs @@ -58,9 +58,9 @@ protected override void InternalBuild() } //Linux packages - CopyFileAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxDeb", "*.deb", OutputDirectory); - CopyFileAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxRpm", "*.rpm", OutputDirectory); - CopyFileAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxTar", "*.tar.gz", OutputDirectory); + CopyAllFilesAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxDeb", "*.deb", OutputDirectory); + CopyAllFilesAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxRpm", "*.rpm", OutputDirectory); + CopyAllFilesAndChecksum($@"{RepoRootDirectory}\build\BuildArtifacts\LinuxTar", "*.tar.gz", OutputDirectory); //Copying Readme.txt file FileHelpers.CopyFile($@"{PackageDirectory}\Readme.txt", $@"{OutputDirectory}"); @@ -83,6 +83,19 @@ private void CopyFileAndChecksum(string sourceDirectory, string sourceFileSearch File.Copy($@"{sourceDirectory}\{SourceShaFileName}", $@"{ShaDirectory}\{destinationFileName}{ShaFileExtension}"); } + private void CopyAllFilesAndChecksum(string sourceDirectory, string sourceFileSearchPattern, string destinationDirectory) + { + var files = Directory.GetFiles(sourceDirectory, sourceFileSearchPattern); + + foreach (var filePath in files) + { + var fileName = Path.GetFileName(filePath); + + File.Copy(filePath, $@"{destinationDirectory}\{fileName}"); + File.Copy($"{filePath}.sha256", $@"{ShaDirectory}\{fileName}.sha256"); + } + } + private void CreateSHAValuesTableMarkdownFile(string shaDirectory, string outputFilename) { var outputLines = new List() { { "### Checksums" }, { "| File | SHA - 256 Hash |" }, { "| ---| ---|" } }; diff --git a/build/ArtifactBuilder/Artifacts/LinuxPackage.cs b/build/ArtifactBuilder/Artifacts/LinuxPackage.cs index 4f2d511331..fc51cbf7ba 100644 --- a/build/ArtifactBuilder/Artifacts/LinuxPackage.cs +++ b/build/ArtifactBuilder/Artifacts/LinuxPackage.cs @@ -37,7 +37,7 @@ protected override void InternalBuild() //Generate the checksum file based on the Linux standards for the checksum contents: // is either a ' ' for text mode or '*' for binary mode. - File.WriteAllText($@"{OutputDirectory}\checksum.sha256", $"{FileHelpers.GetSha256Checksum(packagePath)} *{fileInfo.Name}"); + File.WriteAllText($@"{OutputDirectory}\{fileInfo.Name}.sha256", $"{FileHelpers.GetSha256Checksum(packagePath)} *{fileInfo.Name}"); } } } diff --git a/build/ArtifactBuilder/Program.cs b/build/ArtifactBuilder/Program.cs index c335d2d7b0..781db30def 100644 --- a/build/ArtifactBuilder/Program.cs +++ b/build/ArtifactBuilder/Program.cs @@ -76,8 +76,10 @@ static int Main(string[] args) private static void BuildLinuxPackages() { new LinuxPackage("LinuxDeb", "_amd64", "deb").Build(); + new LinuxPackage("LinuxDeb", "_arm64", "deb").Build(clearOutput: false); new LinuxPackage("LinuxRpm", ".x86_64", "rpm").Build(); new LinuxPackage("LinuxTar", "_amd64", "tar.gz").Build(); + new LinuxPackage("LinuxTar", "_arm64", "tar.gz").Build(clearOutput: false); } private static void BuildDownloadSite(string[] args) diff --git a/build/Linux/build/deb/build.sh b/build/Linux/build/deb/build.sh index 007859f5d1..72cbf1c695 100644 --- a/build/Linux/build/deb/build.sh +++ b/build/Linux/build/deb/build.sh @@ -1,7 +1,13 @@ #!/bin/bash -PACKAGE_NAME='newrelic-netcore20-agent' +ARCH='amd64' AGENT_HOMEDIR='newrelichome_x64_coreclr_linux' +PACKAGE_NAME='newrelic-netcore20-agent' + +if [ "$1" = "arm64" ]; then + ARCH="arm64" + AGENT_HOMEDIR='newrelichome_arm64_coreclr_linux' +fi if [ -z "$AGENT_VERSION" ]; then # Get version from agent core dll @@ -15,11 +21,10 @@ if [ -z "$AGENT_VERSION" ]; then fi echo "AGENT_VERSION=${AGENT_VERSION}" -INSTALL_ROOT=/tmp/${PACKAGE_NAME} -ARCH='amd64' +INSTALL_ROOT=/tmp/${ARCH}/${PACKAGE_NAME} PACKAGE_FILE_BASENAME="${PACKAGE_NAME}_${AGENT_VERSION}_$ARCH" -mkdir ${INSTALL_ROOT} && mkdir ${INSTALL_ROOT}/DEBIAN +mkdir /tmp/${ARCH} && mkdir ${INSTALL_ROOT} && mkdir ${INSTALL_ROOT}/DEBIAN INSTALL_LOCATION=${INSTALL_ROOT}/usr/local/${PACKAGE_NAME} @@ -51,9 +56,9 @@ cp /deb/agentinfo.json . # create debian package dpkg-deb --build ${INSTALL_ROOT} -cp /tmp/${PACKAGE_NAME}.deb /release/${PACKAGE_FILE_BASENAME}.deb +cp /tmp/${ARCH}/${PACKAGE_NAME}.deb /release/${PACKAGE_FILE_BASENAME}.deb # create a copy of the agent that only uses the package name to make it easy to link to builds -cp /tmp/${PACKAGE_NAME}.deb /release/${PACKAGE_NAME}.deb +cp /tmp/${ARCH}/${PACKAGE_NAME}.deb /release/${PACKAGE_NAME}_${ARCH}.deb # agentinfo.json for tar.gz cp /common/agentinfo.json . @@ -63,4 +68,4 @@ tar cvfz /release/${PACKAGE_FILE_BASENAME}.tar.gz -C ${INSTALL_LOCATION} .. if [ $? -gt 0 ] ; then echo "::error Docker run exited with code: $?" -fi \ No newline at end of file +fi diff --git a/build/Linux/docker-compose.yml b/build/Linux/docker-compose.yml index 66ca113f8b..bb34cb1366 100644 --- a/build/Linux/docker-compose.yml +++ b/build/Linux/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: build_deb: build: ./build/deb - command: bash -c "dos2unix /deb/build.sh && chmod 755 -R /deb && chmod 777 /deb/build.sh && /deb/build.sh" + command: bash -c "dos2unix /deb/build.sh && chmod 755 -R /deb && chmod 777 /deb/build.sh && /deb/build.sh && /deb/build.sh arm64" volumes: - ../../src/_build/CoreArtifacts:/release - ../../src/Agent:/data diff --git a/build/build_functions.ps1 b/build/build_functions.ps1 index e2b6eb70cb..739332f369 100644 --- a/build/build_functions.ps1 +++ b/build/build_functions.ps1 @@ -132,7 +132,7 @@ function Copy-AgentRoot { [Parameter(Mandatory=$true)][string]$Destination, [Parameter(Mandatory=$true)][ValidateSet("Debug","Release")][string]$Configuration, [Parameter(Mandatory=$true)][ValidateSet("Framework","Core")][string]$Type, - [Parameter(Mandatory=$true)][ValidateSet("x64","x86")][string]$Architecture, + [Parameter(Mandatory=$true)][ValidateSet("x64","x86","ARM64")][string]$Architecture, [switch]$Linux ) @@ -155,8 +155,14 @@ function Copy-AgentRoot { $grpcDir = Get-GrpcPackagePath $RootDirectory if ($Linux) { - Copy-Item -Path "$grpcDir\runtimes\linux-x64\native\libgrpc_csharp_ext.x64.so" -Destination "$Destination" -Force - Copy-Item -Path "$RootDirectory\src\Agent\_profilerBuild\linux-release\libNewRelicProfiler.so" -Destination "$Destination" -Force + if ($Architecture -like "x64") { + Copy-Item -Path "$grpcDir\runtimes\linux-x64\native\libgrpc_csharp_ext.x64.so" -Destination "$Destination" -Force + Copy-Item -Path "$RootDirectory\src\Agent\_profilerBuild\linux-x64-release\libNewRelicProfiler.so" -Destination "$Destination" -Force + } + if ($Architecture -like "ARM64") { + Copy-Item -Path "$grpcDir\runtimes\linux-arm64\native\libgrpc_csharp_ext.arm64.so" -Destination "$Destination" -Force + Copy-Item -Path "$RootDirectory\src\Agent\_profilerBuild\linux-arm64-release\libNewRelicProfiler.so" -Destination "$Destination" -Force + } } else { Copy-Item -Path "$grpcDir\runtimes\win-x86\native\*.dll" -Destination "$Destination" -Force diff --git a/build/build_home.ps1 b/build/build_home.ps1 index 1d11d118e8..fa3b745d43 100644 --- a/build/build_home.ps1 +++ b/build/build_home.ps1 @@ -10,7 +10,7 @@ Param( [ValidateSet("Debug","Release")][string]$Configuration = "Debug", [ValidateSet("All", "Windows", "Linux","Framework", "CoreAll","CoreWindows","CoreLinux")][string]$Type = "All", - [ValidateSet("All","x64","x86")][string]$Architecture = "All", + [ValidateSet("All","x64","x86","ARM64")][string]$Architecture = "All", [string]$HomePath = "$env:NR_DEV_HOMEROOT", [switch]$KeepNewRelicConfig = $false, [switch]$SetSystemEnvironment = $false, @@ -156,16 +156,31 @@ if ($Type -like "All" -or $Type -like "Windows" -or $Type -like "CoreAll" -or $T } } -if($Type -like "All" -or $Type -like "Linux" -or $Type -like "CoreAll" -or $Type -like "CoreLinux") { - New-HomeStructure -Path "$HomePath" -Name "newrelichome_x64_coreclr_linux" - Copy-ExtensionsInstrumentation -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Extensions $netstandard20WrapperHash - Copy-ExtensionsStorage -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Extensions $netstandard20StorageArray - Copy-ExtensionsOther -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" - Copy-AgentRoot -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" -Architecture "x64" -Linux - Copy-AgentApi -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" +if ($Type -like "All" -or $Type -like "Linux" -or $Type -like "CoreAll" -or $Type -like "CoreLinux") { + if ($Architecture -like "All" -or $Architecture -like "x64") { + New-HomeStructure -Path "$HomePath" -Name "newrelichome_x64_coreclr_linux" + Copy-ExtensionsInstrumentation -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Extensions $netstandard20WrapperHash + Copy-ExtensionsStorage -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Extensions $netstandard20StorageArray + Copy-ExtensionsOther -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" + Copy-AgentRoot -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" -Architecture "x64" -Linux + Copy-AgentApi -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux" -Configuration "$Configuration" -Type "Core" - if (-Not $KeepNewRelicConfig) { - Copy-NewRelicConfig -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux\" + if (-Not $KeepNewRelicConfig) { + Copy-NewRelicConfig -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_x64_coreclr_linux\" + } + } + + if ($Architecture -like "All" -or $Architecture -like "ARM64") { + New-HomeStructure -Path "$HomePath" -Name "newrelichome_arm64_coreclr_linux" + Copy-ExtensionsInstrumentation -Destination "$HomePath\newrelichome_arm64_coreclr_linux" -Extensions $netstandard20WrapperHash + Copy-ExtensionsStorage -Destination "$HomePath\newrelichome_arm64_coreclr_linux" -Extensions $netstandard20StorageArray + Copy-ExtensionsOther -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_arm64_coreclr_linux" -Configuration "$Configuration" -Type "Core" + Copy-AgentRoot -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_arm64_coreclr_linux" -Configuration "$Configuration" -Type "Core" -Architecture "ARM64" -Linux + Copy-AgentApi -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_arm64_coreclr_linux" -Configuration "$Configuration" -Type "Core" + + if (-Not $KeepNewRelicConfig) { + Copy-NewRelicConfig -RootDirectory "$rootDirectory" -Destination "$HomePath\newrelichome_arm64_coreclr_linux\" + } } } @@ -179,4 +194,4 @@ if ($SetSystemEnvironment) { if ($SetSessionEnvironment) { Set-SessionEnvironment -Type "$Type" -Architecture "$Architecture" -HomePath "$HomePath" -} \ No newline at end of file +} diff --git a/deploy/linux/deploy_scripts/conf/apt-generate-config.in b/deploy/linux/deploy_scripts/conf/apt-generate-config.in index e072063a6a..4db2ff3f7d 100644 --- a/deploy/linux/deploy_scripts/conf/apt-generate-config.in +++ b/deploy/linux/deploy_scripts/conf/apt-generate-config.in @@ -23,8 +23,14 @@ BinDirectory "dists/@TARGETREPO@/non-free/binary-i386" { SrcPackages "dists/@TARGETREPO@/non-free/source/Sources"; }; +BinDirectory "dists/@TARGETREPO@/non-free/binary-arm64" { + Packages "dists/@TARGETREPO@/non-free/binary-arm64/Packages"; + Contents "dists/@TARGETREPO@/Contents-arm64"; + SrcPackages "dists/@TARGETREPO@/non-free/source/Sources"; +}; + Tree "dists/@TARGETREPO@" { Sections "non-free"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; }; diff --git a/deploy/linux/deploy_scripts/conf/apt-release-config.in b/deploy/linux/deploy_scripts/conf/apt-release-config.in index e421886356..d43f6a03b7 100644 --- a/deploy/linux/deploy_scripts/conf/apt-release-config.in +++ b/deploy/linux/deploy_scripts/conf/apt-release-config.in @@ -2,7 +2,7 @@ APT::FTPArchive::Release { Origin "New Relic"; Label "New Relic"; Suite "@TARGETREPO@"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; Components "non-free"; } diff --git a/deploy/linux/deploy_scripts/conf/generate-testing.conf b/deploy/linux/deploy_scripts/conf/generate-testing.conf index e7634efdec..bfe6d11b76 100644 --- a/deploy/linux/deploy_scripts/conf/generate-testing.conf +++ b/deploy/linux/deploy_scripts/conf/generate-testing.conf @@ -23,8 +23,14 @@ BinDirectory "dists/newrelic-testing/non-free/binary-i386" { SrcPackages "dists/newrelic-testing/non-free/source/Sources"; }; +BinDirectory "dists/newrelic-testing/non-free/binary-arm64" { + Packages "dists/newrelic-testing/non-free/binary-arm64/Packages"; + Contents "dists/newrelic-testing/Contents-arm64"; + SrcPackages "dists/newrelic-testing/non-free/source/Sources"; +}; + Tree "dists/newrelic-testing" { Sections "non-free"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; }; diff --git a/deploy/linux/deploy_scripts/conf/generate.conf b/deploy/linux/deploy_scripts/conf/generate.conf index 65871b686a..3069c80dd9 100644 --- a/deploy/linux/deploy_scripts/conf/generate.conf +++ b/deploy/linux/deploy_scripts/conf/generate.conf @@ -23,8 +23,14 @@ BinDirectory "dists/newrelic/non-free/binary-i386" { SrcPackages "dists/newrelic/non-free/source/Sources"; }; +BinDirectory "dists/newrelic/non-free/binary-arm64" { + Packages "dists/newrelic/non-free/binary-arm64/Packages"; + Contents "dists/newrelic/Contents-arm64"; + SrcPackages "dists/newrelic/non-free/source/Sources"; +}; + Tree "dists/newrelic" { Sections "non-free"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; }; diff --git a/deploy/linux/deploy_scripts/conf/release-testing.conf b/deploy/linux/deploy_scripts/conf/release-testing.conf index 704d2d6f83..13f211ea41 100644 --- a/deploy/linux/deploy_scripts/conf/release-testing.conf +++ b/deploy/linux/deploy_scripts/conf/release-testing.conf @@ -2,6 +2,6 @@ APT::FTPArchive::Release { Origin "New Relic"; Label "New Relic"; Suite "newrelic-testing"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; Components "non-free"; } diff --git a/deploy/linux/deploy_scripts/conf/release.conf b/deploy/linux/deploy_scripts/conf/release.conf index 6138b0d973..fc605dd7f9 100644 --- a/deploy/linux/deploy_scripts/conf/release.conf +++ b/deploy/linux/deploy_scripts/conf/release.conf @@ -2,6 +2,6 @@ APT::FTPArchive::Release { Origin "New Relic"; Label "New Relic"; Suite "newrelic"; - Architectures "i386 amd64"; + Architectures "i386 amd64 arm64"; Components "non-free"; } diff --git a/deploy/linux/deploy_scripts/deploy-packages.bash b/deploy/linux/deploy_scripts/deploy-packages.bash index ead9c0b74e..0c9d3421e0 100644 --- a/deploy/linux/deploy_scripts/deploy-packages.bash +++ b/deploy/linux/deploy_scripts/deploy-packages.bash @@ -203,6 +203,7 @@ if [[ "$ACTION" == 'release' ]]; then findpkgs() { { find "$APT_REPO" -name "${PRODUCT_NAME}_${VERSION}_amd64.deb" + find "$APT_REPO" -name "${PRODUCT_NAME}_${VERSION}_arm64.deb" find "$YUM_REPO" -name "${PRODUCT_NAME}-${VERSION}-1.x86_64.rpm" } | unique_files_by_basename } @@ -244,6 +245,7 @@ elif [[ "$ACTION" == 'rollback' ]]; then findpkgs() { { find "$PREFIX/$TARGET" -name "${PRODUCT_NAME}_${VERSION}_amd64.deb" + find "$PREFIX/$TARGET" -name "${PRODUCT_NAME}_${VERSION}_arm64.deb" find "$PREFIX/$TARGET" -name "${PRODUCT_NAME}-${VERSION}-1.x86_64.rpm" } | unique_files_by_basename } diff --git a/deploy/linux/deploy_scripts/libexec/repoman-promote.bash b/deploy/linux/deploy_scripts/libexec/repoman-promote.bash index a4616240d6..9fa88124bd 100644 --- a/deploy/linux/deploy_scripts/libexec/repoman-promote.bash +++ b/deploy/linux/deploy_scripts/libexec/repoman-promote.bash @@ -149,11 +149,12 @@ promote_file() { # $* - package files # promote_deb() { - local SPEC ARCH_amd64 ARCH_i386 PACKAGE + local SPEC ARCH_amd64 ARCH_i386 ARCH_arm64 PACKAGE SPEC="$DESTINATION/debian" ARCH_amd64=$(repopath -d non-free -a amd64 "$SPEC") ARCH_i386=$(repopath -d non-free -a i386 "$SPEC") + ARCH_arm64=$(repopath -d non-free -a arm64 "$SPEC") while [[ $# -gt 0 ]]; do PACKAGE=$1; shift @@ -166,9 +167,13 @@ promote_deb() { *_i386.deb) copy_file "$SPEC" "$PACKAGE" "$ARCH_i386" ;; + *_arm64.deb) + copy_file "$SPEC" "$PACKAGE" "$ARCH_arm64" + ;; *_all.deb) copy_file "$SPEC" "$PACKAGE" "$ARCH_amd64" copy_file "$SPEC" "$PACKAGE" "$ARCH_i386" + copy_file "$SPEC" "$PACKAGE" "$ARCH_arm64" ;; *) skip_file "$SPEC" "$PACKAGE" diff --git a/src/Agent/CHANGELOG.md b/src/Agent/CHANGELOG.md index 28588c24de..0fc4275701 100644 --- a/src/Agent/CHANGELOG.md +++ b/src/Agent/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] changes ### New Features +* Feature [#365](https://github.com/newrelic/newrelic-dotnet-agent/issues/365): This version adds support for the Linux ARM64/AWS Graviton2 platform using .NET 5.0. ([#768](https://github.com/newrelic/newrelic-dotnet-agent/pull/768)) + * Includes a new `Processor Architecture` property reported by the Agent with the Environment. ### Fixes * Fixes issue [#754](https://github.com/newrelic/newrelic-dotnet-agent/issues/754): Agent could cause applications that use configuration builders from `Microsoft.Configuration.ConfigurationBuilders` to hang on startup. ([#753](https://github.com/newrelic/newrelic-dotnet-agent/pull/753) diff --git a/src/Agent/NewRelic/Agent/Core/NewRelic.Agent.Core/Environment.cs b/src/Agent/NewRelic/Agent/Core/NewRelic.Agent.Core/Environment.cs index 1fcb48edef..0cf5fe4409 100644 --- a/src/Agent/NewRelic/Agent/Core/NewRelic.Agent.Core/Environment.cs +++ b/src/Agent/NewRelic/Agent/Core/NewRelic.Agent.Core/Environment.cs @@ -48,11 +48,12 @@ public Environment(ISystemInfo systemInfo, IProcessStatic processStatic, IConfig // This API is only supported on .net FX 4.7 + so limiting it // to .net core since that is the one affected. AddVariable(".NET Version", () => System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.ToString()); + AddVariable("Processor Architecture", () => System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()); #else AddVariable(".NET Version", () => System.Environment.Version.ToString()); + AddVariable("Processor Architecture", () => (IntPtr.Size == 8) ? "X64" : "X86"); #endif AddVariable("Total Physical System Memory", () => TotalPhysicalMemory); - AddVariable("x64", () => (IntPtr.Size == 8) ? "yes" : "no"); var process = TryGetCurrentProcess(); AddVariable("StartTime", () => process?.StartTime.ToString("o")); diff --git a/src/Agent/NewRelic/Profiler/CMakeLists.txt b/src/Agent/NewRelic/Profiler/CMakeLists.txt index 2b154b4327..4c84065519 100644 --- a/src/Agent/NewRelic/Profiler/CMakeLists.txt +++ b/src/Agent/NewRelic/Profiler/CMakeLists.txt @@ -34,7 +34,7 @@ if(${WIN32}) else() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing -stdlib=libc++ -march=x86-64 -Wno-invalid-noreturn -Wno-ignored-attributes -Wno-macro-redefined -fms-extensions -fdeclspec -fPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing -stdlib=libc++ -Wno-invalid-noreturn -Wno-ignored-attributes -Wno-macro-redefined -fms-extensions -fdeclspec -fPIC") set (CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++") endif() diff --git a/src/Agent/NewRelic/Profiler/build/build.ps1 b/src/Agent/NewRelic/Profiler/build/build.ps1 index 8a31337b1f..b1fb3353e5 100644 --- a/src/Agent/NewRelic/Profiler/build/build.ps1 +++ b/src/Agent/NewRelic/Profiler/build/build.ps1 @@ -31,7 +31,7 @@ Write-Host "Building Platform=$Platform and Configuration=$Configuration" $profilerRoot = "$rootDirectory\src\Agent\NewRelic\Profiler" $profilerSolutionPath = "$profilerRoot\NewRelic.Profiler.sln" $outputPath = "$rootDirectory\src\Agent\_profilerBuild" -$linuxOutputPath = "$outputPath\linux-release" +$linuxamd64OutputPath = "$outputPath\linux-x64-release" $buildx64 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x64" $buildx86 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x86" @@ -55,7 +55,7 @@ if ($buildx86) { } if ($buildLinux) { - Write-Host "-- Profiler build: linux-release" + Write-Host "-- Profiler build: linux-x64-release" if ($Configuration -eq "Debug") { Write-Host "Configuration=Debug is not currently supported by this script when building the linux profiler. Building Configuration=Release instead." @@ -64,6 +64,6 @@ if ($buildLinux) { & $profilerRoot\build\scripts\build_linux.ps1 ExitIfFailLastExitCode - if (!(Test-Path $linuxOutputPath)) { New-Item $linuxOutputPath -ItemType Directory } - Move-Item "$profilerRoot\libNewRelicProfiler.so" "$linuxOutputPath" + if (!(Test-Path $linuxamd64OutputPath)) { New-Item $linuxamd64OutputPath -ItemType Directory } + Move-Item "$profilerRoot\libNewRelicProfiler.so" "$linuxamd64OutputPath" } diff --git a/src/Agent/NewRelic/Profiler/linux/Dockerfile b/src/Agent/NewRelic/Profiler/linux/Dockerfile index c718676fe7..161449e198 100644 --- a/src/Agent/NewRelic/Profiler/linux/Dockerfile +++ b/src/Agent/NewRelic/Profiler/linux/Dockerfile @@ -31,9 +31,13 @@ RUN apt-get update && apt-get install -y \ clang-3.9 \ lldb-3.9 +# Remove expired root CA cert +RUN sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf +RUN update-ca-certificates + # Install cmake 3.9 RUN curl -sSL https://cmake.org/files/v3.9/cmake-3.9.0-rc3-Linux-x86_64.tar.gz | tar -xzC /opt RUN ln -s /opt/cmake-3.9.0-rc3-Linux-x86_64/bin/cmake /usr/local/sbin/cmake RUN rm /usr/bin/cc; ln -s /usr/bin/clang-3.9 /usr/bin/cc -RUN rm /usr/bin/c++; ln -s /usr/bin/clang++-3.9 /usr/bin/c++ \ No newline at end of file +RUN rm /usr/bin/c++; ln -s /usr/bin/clang++-3.9 /usr/bin/c++ diff --git a/src/Agent/_profilerBuild/linux-arm64-release/libNewRelicProfiler.so b/src/Agent/_profilerBuild/linux-arm64-release/libNewRelicProfiler.so new file mode 100644 index 0000000000..da10b17450 Binary files /dev/null and b/src/Agent/_profilerBuild/linux-arm64-release/libNewRelicProfiler.so differ diff --git a/src/Agent/_profilerBuild/linux-release/libNewRelicProfiler.so b/src/Agent/_profilerBuild/linux-x64-release/libNewRelicProfiler.so similarity index 100% rename from src/Agent/_profilerBuild/linux-release/libNewRelicProfiler.so rename to src/Agent/_profilerBuild/linux-x64-release/libNewRelicProfiler.so diff --git a/tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/AppLifecycleManager.cs b/tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/AppLifecycleManager.cs new file mode 100644 index 0000000000..ef5b7ddcb4 --- /dev/null +++ b/tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/AppLifecycleManager.cs @@ -0,0 +1,130 @@ +// Copyright 2020 New Relic, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +using CommandLine; +using System; +using System.Diagnostics; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; + +namespace ApplicationLifecycle +{ + public class Options + { + [Option('p', "port", Required = false, HelpText = "TCP port app should listen on")] + public string Port { get; set; } + } + + public class AppLifecycleManager + { + private const string ShutdownChannelPrefix = "app_server_wait_for_all_request_done_"; + + private const string DefaultPort = "5001"; + + private const int MinutesToWait = 5; + + private static string _applicationName; + + private static readonly bool _isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + + private static EventWaitHandle _eventWaitHandle; + + private static string ApplicationName + { + get + { + return _applicationName ?? (_applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath) + + (_isLinux ? string.Empty : ".exe")); + } + } + + public static string GetPortFromArgs(string[] args) + { + var portToUse = DefaultPort; + + var commandLine = string.Join(" ", args); + Log($"Joined args: {commandLine}"); + + Parser.Default.ParseArguments(args) + .WithParsed(o => + { + portToUse = o.Port ?? DefaultPort; + Log($"Received port: {o.Port} | Using port: {portToUse}"); + }); + + return portToUse; + } + + public static void WaitForTestCompletion(string port) + { + // On Linux, we have to used named pipes as the IPC mechanism because named EventWaitHandles aren't supported + if (_isLinux) + { + using (NamedPipeServerStream pipeServer = + new NamedPipeServerStream(ShutdownChannelPrefix + port, PipeDirection.In)) + { + var task = pipeServer.WaitForConnectionAsync(); + if (task.Wait(TimeSpan.FromMinutes(MinutesToWait))) + { + try + { + // Read user input and send that to the client process. + using (StreamReader sr = new StreamReader(pipeServer)) + { + string temp; + while ((temp = sr.ReadLine()) != null) + { + Log($"Received shutdown message from test framework: {temp}"); + } + } + } + // Catch the IOException that is raised if the pipe is broken + // or disconnected. + catch (IOException e) + { + Log($"WaitForTestCompletion: exception: {e.Message}"); + } + } + else + { + Log("Timed out waiting for test completion."); + } + } + } + else + { + _eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, ShutdownChannelPrefix + port); + _eventWaitHandle.WaitOne(TimeSpan.FromMinutes(MinutesToWait)); + } + } + + public static void CreateEventWaitHandle(string port) + { + _eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, ShutdownChannelPrefix + port); + } + + public static void CreatePidFile() + { + var pid = Process.GetCurrentProcess().Id; + var applicationDirectory = + Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), + _applicationName); + var pidFilePath = applicationDirectory + ".pid"; + + using (var file = File.CreateText(pidFilePath)) + { + file.WriteLine(pid); + } + + } + + private static void Log(string message) + { + Console.WriteLine($"[{ApplicationName}] {message}"); + } + } +} diff --git a/tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/NetStandardClassLibrary.csproj b/tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/ApplicationLifecycle.csproj similarity index 70% rename from tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/NetStandardClassLibrary.csproj rename to tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/ApplicationLifecycle.csproj index 9431ea3515..2c89d083c3 100644 --- a/tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/NetStandardClassLibrary.csproj +++ b/tests/Agent/IntegrationTests/ApplicationHelperLibraries/ApplicationLifecycle/ApplicationLifecycle.csproj @@ -5,7 +5,7 @@ - + diff --git a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/AspNet5BasicWebApiApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/AspNet5BasicWebApiApplication.csproj index ab47d41124..43bd391008 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/AspNet5BasicWebApiApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/AspNet5BasicWebApiApplication.csproj @@ -8,4 +8,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Controllers/DefaultController.cs b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Controllers/DefaultController.cs index 68fd2a68fe..b8e958f445 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Controllers/DefaultController.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Controllers/DefaultController.cs @@ -34,5 +34,10 @@ public async Task MakeExternalCallUsingHttpClient(string baseAddress, st return "Error"; } } + + public string AwesomeName() + { + return "Chuck Norris"; + } } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Program.cs index ebcb6df35d..cdae19afbe 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNet5BasicWebApiApplication/Program.cs @@ -2,49 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 -using System; using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; +using System.Net; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNet5BasicWebApiApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); + _port = AppLifecycleManager.GetPortFromArgs(args); - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + OverrideSslSettingsForMockNewRelic(); Activity.DefaultIdFormat = ActivityIdFormat.W3C; var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -57,18 +41,21 @@ public static IWebHost BuildWebHost(string[] args) => .UseUrls($@"http://localhost:{_port}/") .Build(); - private static void CreatePidFile() + /// + /// When the MockNewRelic app is used in place of the normal New Relic / Collector endpoints, + /// the mock version uses a self-signed cert that will not be "trusted." + /// + /// This forces all validation checks to pass. + /// + private static void OverrideSslSettingsForMockNewRelic() { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) + ServicePointManager.ServerCertificateValidationCallback = delegate { - file.WriteLine(pid); - } + //force trust on all certificates for simplicity + return true; + }; } + + } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/AspNetCore3BasicWebApiApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/AspNetCore3BasicWebApiApplication.csproj index 878072e009..407427a4d8 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/AspNetCore3BasicWebApiApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/AspNetCore3BasicWebApiApplication.csproj @@ -8,5 +8,9 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/Program.cs index 33f4943db8..c06463f1be 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCore3BasicWebApiApplication/Program.cs @@ -2,49 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 -using System; using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNetCore3BasicWebApiApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); Activity.DefaultIdFormat = ActivityIdFormat.W3C; var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -56,19 +36,5 @@ public static IWebHost BuildWebHost(string[] args) => .UseStartup() .UseUrls($@"http://localhost:{_port}/") .Build(); - - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/AspNetCore3Features.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/AspNetCore3Features.csproj index 2d2b058e53..64bebba1df 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/AspNetCore3Features.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/AspNetCore3Features.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -12,6 +12,7 @@ + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/Program.cs index fe8ac35a52..fffa0d285b 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCore3Features/Program.cs @@ -2,47 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; using Microsoft.Extensions.Hosting; namespace AspNetCore3Features { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = CreateHostBuilder(args).Build().RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -58,18 +38,5 @@ public static IHostBuilder CreateHostBuilder(string[] args) => .UseUrls($@"http://localhost:{_port}/"); }); - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/AspNetCoreDistTracingApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/AspNetCoreDistTracingApplication.csproj index 116de73329..a2e3f13d44 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/AspNetCoreDistTracingApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/AspNetCoreDistTracingApplication.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.1 @@ -12,4 +12,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/Program.cs index 91437d5211..e64dae6d96 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreDistTracingApplication/Program.cs @@ -2,67 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNetCoreDistTracingApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); task.GetAwaiter().GetResult(); } - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } - public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/AspNetCoreMvcAsyncApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/AspNetCoreMvcAsyncApplication.csproj index d2036de4f4..c07466db07 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/AspNetCoreMvcAsyncApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/AspNetCoreMvcAsyncApplication.csproj @@ -1,8 +1,7 @@ - + netcoreapp2.1 - win10-x64 @@ -15,4 +14,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/Program.cs index 8ff4aff378..94305b012b 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcAsyncApplication/Program.cs @@ -2,49 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNetCoreMvcAsyncApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { Thread.CurrentThread.Name = "NewRelic Main Test Application Thread"; - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); + _port = AppLifecycleManager.GetPortFromArgs(args); - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -57,18 +38,5 @@ public static IWebHost BuildWebHost(string[] args) => .UseUrls($@"http://localhost:{_port}/") .Build(); - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/AspNetCoreMvcBasicRequestsApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/AspNetCoreMvcBasicRequestsApplication.csproj index 9811daac41..05f223630c 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/AspNetCoreMvcBasicRequestsApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/AspNetCoreMvcBasicRequestsApplication.csproj @@ -1,8 +1,7 @@ - + netcoreapp2.1 - win-x64 true @@ -16,4 +15,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/Program.cs index 1f823a76fc..53f6480ff0 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcBasicRequestsApplication/Program.cs @@ -2,71 +2,36 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; +using ApplicationLifecycle; using System.Net; -using System.Reflection; using System.Threading; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNetCoreMvcBasicRequestsApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); OverrideSslSettingsForMockNewRelic(); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); task.GetAwaiter().GetResult(); } - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - - } - public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/AspNetCoreMvcRejitApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/AspNetCoreMvcRejitApplication.csproj index 116de73329..a2e3f13d44 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/AspNetCoreMvcRejitApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/AspNetCoreMvcRejitApplication.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.1 @@ -12,4 +12,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/Program.cs index 0bd5a1d9f6..1b872930f1 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreMvcRejitApplication/Program.cs @@ -2,47 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; namespace AspNetCoreMvcRejitApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -55,18 +35,5 @@ public static IWebHost BuildWebHost(string[] args) => .UseUrls($@"http://localhost:{_port}/") .Build(); - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/AspNetCoreWebApiCustomAttributesApplication.csproj b/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/AspNetCoreWebApiCustomAttributesApplication.csproj index da87ad0fcb..c5929b029d 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/AspNetCoreWebApiCustomAttributesApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/AspNetCoreWebApiCustomAttributesApplication.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.1 @@ -17,4 +17,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/Program.cs index 50006d3da7..30091b4f9c 100644 --- a/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/AspNetCoreWebApiCustomAttributesApplication/Program.cs @@ -2,67 +2,34 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.IO; -using System.Linq; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.CodeAnalysis; -using System.Diagnostics; using System.Threading; -using System.Reflection; +using ApplicationLifecycle; namespace AspNetCoreWebApiCustomAttributesApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); + ct.Cancel(); task.GetAwaiter().GetResult(); } - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - - } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) diff --git a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/App.config b/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/App.config deleted file mode 100644 index 9c05822ff5..0000000000 --- a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/AttributeInstrumentation.csproj b/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/AttributeInstrumentation.csproj deleted file mode 100644 index 6878278f49..0000000000 --- a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/AttributeInstrumentation.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - net461 - Exe - AttributeInstrumentation - AttributeInstrumentation - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/Program.cs b/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/Program.cs deleted file mode 100644 index 2b8f318572..0000000000 --- a/tests/Agent/IntegrationTests/Applications/AttributeInstrumentation/Program.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using CommandLine; - -namespace AttributeInstrumentation -{ - class Program - { - [Option("port", Required = true)] - public string Port { get; set; } - - static void Main(string[] args) - { - if (Parser.Default == null) - throw new NullReferenceException("CommandLine.Parser.Default"); - - var program = new Program(); - if (!Parser.Default.ParseArgumentsStrict(args, program)) - return; - - program.RealMain(); - } - - private void RealMain() - { - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + Port); - CreatePidFile(); - - // This test application exercises attribute-based custom instrumentation in a number of different use cases. - // Each of the method calls below are meant to illustrate a different use case. They each create a transaction - // (web or other) using the Transaction attribute and exercise other methods that have been decorated with the - // Trace attribute. - - // Web trasactions (i.e. [Transaction(Web = true)]) - MakeWebTransaction(); - MakeWebTransactionWithCustomUri(); - - // Other transactions (i.e. [Transaction] or [Transaction(Web = false)]) - MakeOtherTransaction(); - MakeOtherTransactionAsync().Wait(); - MakeOtherTransactionThenCallAsyncMethod(); - MakeOtherTransactionWithCallToNetStandardMethod(); - - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); - } - - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var thisAssemblyPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath; - var pidFilePath = thisAssemblyPath + ".pid"; - var file = File.CreateText(pidFilePath); - file.WriteLine(pid); - } - - /// - /// Synchronous method creating a Web transaction - /// - [NewRelic.Api.Agent.Transaction(Web = true)] - [MethodImpl(MethodImplOptions.NoInlining)] - public void MakeWebTransaction() - { - DoSomeWork(); - } - - /// - /// Synchronous method creating a Web transaction and utilizing SetTransactionUri - /// - [NewRelic.Api.Agent.Transaction(Web = true)] - [MethodImpl(MethodImplOptions.NoInlining)] - public void MakeWebTransactionWithCustomUri() - { - var uri = new Uri("http://foo.bar.net/fizz/buzz"); - NewRelic.Api.Agent.NewRelic.SetTransactionUri(uri); - DoSomeWork(); - } - - /// - /// Synchronous method creating an Other transaction - /// - [NewRelic.Api.Agent.Transaction] - [MethodImpl(MethodImplOptions.NoInlining)] - public void MakeOtherTransaction() - { - DoSomeWork(); - } - - /// - /// Async method creating an Other transaction - /// - /// - [NewRelic.Api.Agent.Transaction] - [MethodImpl(MethodImplOptions.NoInlining)] - public async Task MakeOtherTransactionAsync() - { - await DoSomeWorkAsync(); - } - - /// - /// Synchronous method that calls async methods. - /// This use case illustrates that this scenario is possible, but it is - /// recommended that transactions involving async code start with an - /// async entry point to avoid potential pitfalls. - /// - [NewRelic.Api.Agent.Transaction] - [MethodImpl(MethodImplOptions.NoInlining)] - public void MakeOtherTransactionThenCallAsyncMethod() - { - DoSomeWorkAsync().Wait(); - } - - [NewRelic.Api.Agent.Transaction] - [MethodImpl(MethodImplOptions.NoInlining)] - private void MakeOtherTransactionWithCallToNetStandardMethod() - { - var myObj = new NetStandardClassLibrary.MyClass(); - myObj.MyMethodToBeInstrumented(); - } - - [NewRelic.Api.Agent.Trace] - [MethodImpl(MethodImplOptions.NoInlining)] - public void DoSomeWork() - { - } - - [NewRelic.Api.Agent.Trace] - [MethodImpl(MethodImplOptions.NoInlining)] - public async Task DoSomeWorkAsync() - { - await Task.Delay(TimeSpan.FromMilliseconds(10)); - return await DoSomeMoreWorkAsync(); - } - - [NewRelic.Api.Agent.Trace] - [MethodImpl(MethodImplOptions.NoInlining)] - public async Task DoSomeMoreWorkAsync() - { - return await Task.FromResult("Some work."); - } - } -} diff --git a/tests/Agent/IntegrationTests/Applications/MockNewRelic/MockNewRelic.csproj b/tests/Agent/IntegrationTests/Applications/MockNewRelic/MockNewRelic.csproj index 31de830603..c0fab3e471 100644 --- a/tests/Agent/IntegrationTests/Applications/MockNewRelic/MockNewRelic.csproj +++ b/tests/Agent/IntegrationTests/Applications/MockNewRelic/MockNewRelic.csproj @@ -1,8 +1,7 @@ - + netcoreapp2.1 - win10-x64 @@ -19,6 +18,7 @@ + diff --git a/tests/Agent/IntegrationTests/Applications/MockNewRelic/Program.cs b/tests/Agent/IntegrationTests/Applications/MockNewRelic/Program.cs index 0e371ca4a3..afcdacf234 100644 --- a/tests/Agent/IntegrationTests/Applications/MockNewRelic/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/MockNewRelic/Program.cs @@ -2,47 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; -using System.Reflection; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; -using Microsoft.CodeAnalysis; namespace MockNewRelic { public class Program { - private const string DefaultPort = "5001"; - private static string _port; public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - Console.WriteLine($"[MockNewRelic] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[MockNewRelic] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -65,19 +49,5 @@ public static IWebHost BuildWebHost(string[] args) => }) .Build(); - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/NetCoreAsyncApplication.csproj b/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/NetCoreAsyncApplication.csproj index b1993a8319..6d1b50fb35 100644 --- a/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/NetCoreAsyncApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/NetCoreAsyncApplication.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,4 +9,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/Program.cs index 8204a08995..26807d795b 100644 --- a/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/NetCoreAsyncApplication/Program.cs @@ -10,33 +10,17 @@ using System.Threading; using Microsoft.CodeAnalysis; using System.Threading.Tasks; +using ApplicationLifecycle; namespace NetCoreAsyncApplication { class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true).ToList(); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); - - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); + _port = AppLifecycleManager.GetPortFromArgs(args); var cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource.CancelAfter(TimeSpan.FromMinutes(5)); @@ -44,10 +28,9 @@ static void Main(string[] args) var doWorkTask = Task.Run(async () => await DoWorkAsync(), cancellationTokenSource.Token); doWorkTask.Wait(cancellationTokenSource.Token); - //Wait to create the Pid file until the work is done so that the agent has a chance to attach and create log directory and log files. - CreatePidFile(); + AppLifecycleManager.CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.WaitForTestCompletion(_port); } private static async Task DoWorkAsync() @@ -59,15 +42,5 @@ private static async Task DoWorkAsync() await asyncUseCases.CpuBoundTasksAsync(); } - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - var file = File.CreateText(pidFilePath); - file.WriteLine(pid); - } } } diff --git a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/NetCoreAttributeInstrumentationApplication.csproj b/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/NetCoreAttributeInstrumentationApplication.csproj deleted file mode 100644 index 968ccad6b5..0000000000 --- a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/NetCoreAttributeInstrumentationApplication.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - netcoreapp2.1 - win10-x64 - - - - - - - - - - - - - - - Always - - - - diff --git a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/Program.cs deleted file mode 100644 index ea378a53a7..0000000000 --- a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/Program.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using Microsoft.CodeAnalysis; -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using Microsoft.Extensions.Configuration; - -namespace NetCoreAttributeInstrumentationApplication -{ - class Program - { - private const string DefaultPort = "5001"; - - private static string _port; - - private static string _applicationName; - - static void Main(string[] args) - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .Build(); - - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); - - // Create handle that RemoteApplication expects - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - - CreatePidFile(); - - // Excersise this application - DoSomething(); - - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - [NewRelic.Api.Agent.Transaction] - static void DoSomething() - { - DoSomethingInside(); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - [NewRelic.Api.Agent.Trace] - private static void DoSomethingInside() - { - Thread.Sleep(2000); - } - - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - var file = File.CreateText(pidFilePath); - file.WriteLine(pid); - } - } -} diff --git a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/appsettings.json b/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/appsettings.json deleted file mode 100644 index 0db3279e44..0000000000 --- a/tests/Agent/IntegrationTests/Applications/NetCoreAttributeInstrumentationApplication/appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/Program.cs b/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/Program.cs index 13e4a0c497..b8718246a6 100644 --- a/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/Program.cs +++ b/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/Program.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Reflection; using System.Threading; +using ApplicationLifecycle; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.CodeAnalysis; @@ -16,33 +17,18 @@ namespace SerilogSumologicApplication { public class Program { - private const string DefaultPort = "5001"; - private static string _port; - private static string _applicationName; - public static void Main(string[] args) { - var commandLine = string.Join(" ", args); - - _applicationName = Path.GetFileNameWithoutExtension(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + ".exe"; - - Console.WriteLine($"[{_applicationName}] Joined args: {commandLine}"); - - var result = CommandLineParser.SplitCommandLineIntoArguments(commandLine, true); - - var argPort = result.FirstOrDefault()?.Split('=')[1]; - _port = argPort ?? DefaultPort; - - Console.WriteLine($"[{_applicationName}] Received port: {argPort} | Using port: {_port}"); + _port = AppLifecycleManager.GetPortFromArgs(args); var ct = new CancellationTokenSource(); var task = BuildWebHost(args).RunAsync(ct.Token); - var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + _port); - CreatePidFile(); - eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); + AppLifecycleManager.CreatePidFile(); + + AppLifecycleManager.WaitForTestCompletion(_port); ct.Cancel(); @@ -55,18 +41,5 @@ public static IWebHost BuildWebHost(string[] args) => .UseUrls($@"http://localhost:{_port}/") .Build(); - private static void CreatePidFile() - { - var pid = Process.GetCurrentProcess().Id; - var applicationDirectory = - Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), - _applicationName); - var pidFilePath = applicationDirectory + ".pid"; - - using (var file = File.CreateText(pidFilePath)) - { - file.WriteLine(pid); - } - } } } diff --git a/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/SerilogSumologicApplication.csproj b/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/SerilogSumologicApplication.csproj index 20b8e7dbac..e70c439695 100644 --- a/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/SerilogSumologicApplication.csproj +++ b/tests/Agent/IntegrationTests/Applications/SerilogSumologicApplication/SerilogSumologicApplication.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.1 @@ -14,4 +14,8 @@ + + + + diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/Models/UtilizationData.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/Models/UtilizationData.cs index fa4f2b7ec6..e786529ce9 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/Models/UtilizationData.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/Models/UtilizationData.cs @@ -2,11 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Newtonsoft.Json; namespace NewRelic.Agent.IntegrationTestHelpers.Models @@ -21,7 +17,7 @@ public class UtilizationData public int LogicalProcessors { get; set; } [JsonProperty("total_ram_mib")] - public int TotalRamMib { get; set; } + public int? TotalRamMib { get; set; } // this property is nullable because it doesn't get sent on Linux as of October 2021 [JsonProperty("hostname")] public string HostName { get; set; } diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteApplication.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteApplication.cs index afa93f4793..cca6eb4e0d 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteApplication.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteApplication.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.IO.Pipes; using System.Net; using System.Reflection; using System.Threading; @@ -27,7 +28,7 @@ public abstract class RemoteApplication : IDisposable private static readonly string RepositoryRootPath = Path.GetFullPath(Path.Combine(AssemblyBinPath, "..", "..", "..", "..", "..","..","..")); - protected static readonly string SourceIntegrationTestsSolutionDirectoryPath = Path.Combine(RepositoryRootPath, "tests\\Agent\\IntegrationTests"); + protected static readonly string SourceIntegrationTestsSolutionDirectoryPath = Path.Combine(RepositoryRootPath, "tests", "Agent", "IntegrationTests"); public readonly string SourceApplicationsDirectoryPath; @@ -44,7 +45,7 @@ private string SourceNewRelicHomeDirectoryPath var homeRootPath = Environment.GetEnvironmentVariable("NR_DEV_HOMEROOT"); if (!string.IsNullOrWhiteSpace(homeRootPath) && Directory.Exists(homeRootPath)) { - _sourceNewRelicHomeDirectoryPath = $@"{homeRootPath}\newrelichome_x64"; + _sourceNewRelicHomeDirectoryPath = Path.Combine(homeRootPath, "newrelichome_x64"); return _sourceNewRelicHomeDirectoryPath; } @@ -68,13 +69,15 @@ private static string SourceNewRelicHomeCoreClrDirectoryPath } var homeRootPath = Environment.GetEnvironmentVariable("NR_DEV_HOMEROOT"); + + var homeDirName = Utilities.RuntimeHomeDirName; if (!string.IsNullOrWhiteSpace(homeRootPath) && Directory.Exists(homeRootPath)) { - _sourceNewRelicHomeCoreClrDirectoryPath = $@"{homeRootPath}\newrelichome_x64_coreclr"; + _sourceNewRelicHomeCoreClrDirectoryPath = Path.Combine(homeRootPath, homeDirName); return _sourceNewRelicHomeCoreClrDirectoryPath; } - _sourceNewRelicHomeCoreClrDirectoryPath = Path.Combine(RepositoryRootPath, "src", "Agent", "newrelichome_x64_coreclr"); + _sourceNewRelicHomeCoreClrDirectoryPath = Path.Combine(RepositoryRootPath, "src", "Agent", homeDirName); return _sourceNewRelicHomeCoreClrDirectoryPath; } set @@ -89,7 +92,7 @@ private static string SourceNewRelicHomeCoreClrDirectoryPath private static string DestinationWorkingDirectoryRemotePath { get { return EnvironmentVariables.DestinationWorkingDirectoryRemotePath ?? DestinationWorkingDirectoryRemoteDefault; } } - private static readonly string DestinationWorkingDirectoryRemoteDefault = @"C:\IntegrationTestWorkingDirectory"; + private static readonly string DestinationWorkingDirectoryRemoteDefault = Utilities.IsLinux ? "/tmp/IntegrationTestWorkingDirectory" : @"C:\IntegrationTestWorkingDirectory"; #endregion @@ -110,7 +113,7 @@ public string DefaultLogFileDirectoryPath { get { - return Path.Combine(DestinationNewRelicHomeDirectoryPath, "Logs"); + return Path.Combine(DestinationNewRelicHomeDirectoryPath, Utilities.IsLinux ? "logs" : "Logs"); } } @@ -280,8 +283,21 @@ public void Kill() ? RemoteProcess.ExitCode : (int?)null; - public bool IsRunning => (!RemoteProcess?.HasExited) ?? false; - + public bool IsRunning + { + get + { + try + { + return (!RemoteProcess?.HasExited) ?? false; + } + catch (InvalidOperationException) + { + // handles Linux behavior where the process info gets cleaned up as soon as the process exits + return false; + } + } + } /// /// Determines if the process' standard input will be exposed and thus be manipulated. @@ -307,20 +323,47 @@ public virtual void Shutdown() return; } - var expectedWaitHandle = "app_server_wait_for_all_request_done_" + Port; + var shutdownChannelName = "app_server_wait_for_all_request_done_" + Port; + + TestLogger?.WriteLine($"[RemoteApplication] Sending shutdown signal to {ApplicationDirectoryName}."); - try + if (Utilities.IsLinux) { - TestLogger?.WriteLine($"[RemoteApplication] Sending shutdown signal to {ApplicationDirectoryName}."); - //The test runner opens an event created by the app server and set it to signal the app server that the test has finished. - var remoteAppEvent = EventWaitHandle.OpenExisting(expectedWaitHandle); - remoteAppEvent.Set(); + using (NamedPipeClientStream pipeClient = + new NamedPipeClientStream(".", shutdownChannelName, PipeDirection.Out)) + { + try + { + pipeClient.Connect(1000); // 1 second connect timeout + + using (StreamWriter sw = new StreamWriter(pipeClient)) + { + sw.AutoFlush = true; + sw.WriteLine("Okay to shut down now"); + } + } + catch (Exception ex) + { + TestLogger?.WriteLine($"[RemoteApplication] FAILED sending shutdown signal to named pipe \"{shutdownChannelName}\": {ex}."); + RemoteProcess.Kill(); + } + } } - catch (Exception ex) + else { - TestLogger?.WriteLine($"[RemoteApplication] FAILED sending shutdown signal to wait handle \"{expectedWaitHandle}\": {ex}."); - RemoteProcess.Kill(); + try + { + //The test runner opens an event created by the app server and set it to signal the app server that the test has finished. + var remoteAppEvent = EventWaitHandle.OpenExisting(shutdownChannelName); + remoteAppEvent.Set(); + } + catch (Exception ex) + { + TestLogger?.WriteLine($"[RemoteApplication] FAILED sending shutdown signal to wait handle \"{shutdownChannelName}\": {ex}."); + RemoteProcess.Kill(); + } } + } public virtual void Dispose() diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteConsoleApplication.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteConsoleApplication.cs index 308ba02950..8c5efd30d1 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteConsoleApplication.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteConsoleApplication.cs @@ -46,6 +46,12 @@ protected override void WaitForAppServerToStartListening(Process process, bool c public override void Shutdown() { + if (RemoteProcess is null) + { + // We might not have ever started the application, e.g. if the test is being skipped. + return; + } + if (_processHasBeenShutdown) { RemoteProcess.WaitForExit(); @@ -56,14 +62,14 @@ public override void Shutdown() try { - if (RemoteProcess.HasExited || RemoteProcess.WaitForExit(Convert.ToInt32(_timeout.TotalMilliseconds))) + if (!IsRunning || RemoteProcess.WaitForExit(Convert.ToInt32(_timeout.TotalMilliseconds))) { // Allows for any asynchronous writing to complete RemoteProcess.WaitForExit(); return; } - if (!RemoteProcess.HasExited) + if (IsRunning) { RemoteProcess.Kill(); } diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteService.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteService.cs index d70f3d4f57..45308b9ebf 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteService.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/RemoteServiceFixtures/RemoteService.cs @@ -49,16 +49,25 @@ public RemoteService(string applicationDirectoryName, string executableName, App { _publishApp = publishApp; _applicationDirectoryName = applicationDirectoryName; - _executableName = executableName; + _executableName = SanitizeExecutableName(executableName); _createsPidFile = createsPidFile; _targetFramework = string.Empty; } + private string SanitizeExecutableName(string executableName) + { + if (Utilities.IsLinux) + { + return executableName.Replace(".exe", ""); + } + return executableName; + } + public RemoteService(string applicationDirectoryName, string executableName, string targetFramework, ApplicationType applicationType, bool createsPidFile = true, bool isCoreApp = false, bool publishApp = false) : base(applicationType, isCoreApp) { _publishApp = publishApp; _applicationDirectoryName = applicationDirectoryName; - _executableName = executableName; + _executableName = SanitizeExecutableName(executableName); _createsPidFile = createsPidFile; _targetFramework = targetFramework ?? string.Empty; } @@ -102,16 +111,18 @@ private void PublishWithDotnetExe(string framework) TestLogger?.WriteLine($"[RemoteService]: Publishing to {deployPath}."); + var runtime = Utilities.CurrentRuntime; var process = new Process(); var startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; - startInfo.FileName = "dotnet.exe"; + startInfo.FileName = "dotnet"; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.Arguments = - $"publish {projectFile} --configuration Release --runtime win-x64 --framework {framework} --output {deployPath}"; + $"publish --configuration Release --runtime {runtime} --framework {framework} --output {deployPath} {projectFile}"; + TestLogger?.WriteLine($"[RemoteService]: executing 'dotnet {startInfo.Arguments}'"); process.StartInfo = startInfo; //We cannot run dotnet publish against the same directory concurrently. @@ -175,9 +186,9 @@ public override void Start(string commandLineArguments, bool captureStandardOutp : commandLineArguments; var applicationFilePath = DestinationApplicationExecutablePath; - var profilerFilePath = Path.Combine(DestinationNewRelicHomeDirectoryPath, @"NewRelic.Profiler.dll"); + var profilerFilePath = Path.Combine(DestinationNewRelicHomeDirectoryPath, Utilities.IsLinux ? @"libNewRelicProfiler.so" : @"NewRelic.Profiler.dll"); var newRelicHomeDirectoryPath = DestinationNewRelicHomeDirectoryPath; - var profilerLogDirectoryPath = Path.Combine(DestinationNewRelicHomeDirectoryPath, @"Logs"); + var profilerLogDirectoryPath = DefaultLogFileDirectoryPath; var startInfo = new ProcessStartInfo { @@ -190,6 +201,8 @@ public override void Start(string commandLineArguments, bool captureStandardOutp RedirectStandardInput = RedirectStandardInput }; + Console.WriteLine($"[{DateTime.Now}] RemoteService.Start(): FileName={applicationFilePath}, Arguments={arguments}, WorkingDirectory={DestinationApplicationDirectoryPath}, RedirectStandardOutput={captureStandardOutput}, RedirectStandardError={captureStandardOutput}, RedirectStandardInput={RedirectStandardInput}"); + startInfo.EnvironmentVariables.Remove("COR_ENABLE_PROFILING"); startInfo.EnvironmentVariables.Remove("COR_PROFILER"); startInfo.EnvironmentVariables.Remove("COR_PROFILER_PATH"); diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipUntilDateFactAttribute.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipAttributes.cs similarity index 67% rename from tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipUntilDateFactAttribute.cs rename to tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipAttributes.cs index 858331390f..6a5f335270 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipUntilDateFactAttribute.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/SkipAttributes.cs @@ -20,4 +20,14 @@ public SkipUntilDateFactAttribute(string date, string reason) } } } + public sealed class SkipOnLinuxFactAttribute : FactAttribute + { + public SkipOnLinuxFactAttribute(string reason) + { + if (Utilities.IsLinux) + { + Skip = $"Skipping test on Linux. Reason = {reason}"; + } + } + } } diff --git a/tests/Agent/IntegrationTests/IntegrationTestHelpers/Utilities.cs b/tests/Agent/IntegrationTests/IntegrationTestHelpers/Utilities.cs index ab0eb98aeb..d211c0102c 100644 --- a/tests/Agent/IntegrationTests/IntegrationTestHelpers/Utilities.cs +++ b/tests/Agent/IntegrationTests/IntegrationTestHelpers/Utilities.cs @@ -3,6 +3,7 @@ using System; +using System.Runtime.InteropServices; namespace NewRelic.Agent.IntegrationTestHelpers { @@ -14,6 +15,23 @@ public static class Utilities public static string Configuration = "Release"; #endif + public static bool IsLinux + { + get + { +#if NETFRAMEWORK + return false; +#endif +#if NETSTANDARD2_0 + return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); +#endif + } + } + + public static string Arch => RuntimeInformation.ProcessArchitecture.ToString().ToLower(); + public static string CurrentRuntime => $"{(IsLinux ? "linux" : "win")}-{Arch}"; + public static string RuntimeHomeDirName => $"newrelichome_{Arch}_coreclr{(IsLinux ? "_linux" : "")}"; + public static T ThrowIfNull(T value, string valueName) { if (value == null) diff --git a/tests/Agent/IntegrationTests/IntegrationTests.sln b/tests/Agent/IntegrationTests/IntegrationTests.sln index 5604ddc4a1..08bb2bf683 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests.sln +++ b/tests/Agent/IntegrationTests/IntegrationTests.sln @@ -18,9 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "Integra EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Applications", "Applications", "{F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29}" - ProjectSection(SolutionItems) = preProject - Applications\AspNet5BasicWebApiApplication\AspNet5BasicWebApiApplication.csproj = Applications\AspNet5BasicWebApiApplication\AspNet5BasicWebApiApplication.csproj - EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomAttributesWebApi", "Applications\CustomAttributesWebApi\CustomAttributesWebApi.csproj", "{9E5D7614-414C-427E-83A9-2A723409F45D}" EndProject @@ -54,14 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Owin3WebApi", "Applications\Owin3WebApi\Owin3WebApi.csproj", "{96FAB968-BFE7-4A47-83AC-9A49AACBA977}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttributeInstrumentation", "Applications\AttributeInstrumentation\AttributeInstrumentation.csproj", "{887C1553-B842-4712-865B-6FFAB01EE7EA}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RejitMvcApplication", "Applications\RejitMvcApplication\RejitMvcApplication.csproj", "{2F2A1324-5D9C-4C66-91EC-D66F50DC4336}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMvcBasicRequestsApplication", "Applications\AspNetCoreMvcBasicRequestsApplication\AspNetCoreMvcBasicRequestsApplication.csproj", "{EDA8AF34-CC6C-47A6-87BF-FFE7D6DC878D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreAttributeInstrumentationApplication", "Applications\NetCoreAttributeInstrumentationApplication\NetCoreAttributeInstrumentationApplication.csproj", "{1005EDC7-1531-4C38-9933-98E5B3088512}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreWebApiCustomAttributesApplication", "Applications\AspNetCoreWebApiCustomAttributesApplication\AspNetCoreWebApiCustomAttributesApplication.csproj", "{E28E36CD-A15F-4438-ADCA-40B26844592A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OwinRemotingClient", "Applications\OwinRemotingClient\OwinRemotingClient.csproj", "{C07AF48C-AFE2-40FC-AFB5-E3E872F5CD7D}" @@ -80,8 +73,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockNewRelic", "Application EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{99DA3AEA-A9F4-4E7B-9B54-D098A1C7E5DE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardClassLibrary", "Applications\NetStandardClassLibrary\NetStandardClassLibrary.csproj", "{6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMvcFrameworkApplication", "Applications\AspNetCoreMvcFrameworkApplication\AspNetCoreMvcFrameworkApplication.csproj", "{ABA2F56E-4CF6-4DB7-9168-03515AD25AE3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMvcFrameworkAsyncApplication", "Applications\AspNetCoreMvcFrameworkAsyncApplication\AspNetCoreMvcFrameworkAsyncApplication.csproj", "{F807B888-2B70-49BB-ACD8-0ACA3B168E25}" @@ -106,7 +97,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DistributedTracingApiApplic EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Owin4WebApi", "Applications\Owin4WebApi\Owin4WebApi.csproj", "{83FA6862-73F2-4305-9B7C-2DF849D80C36}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewRelic.Testing.Assertions", "..\NewRelic.Testing.Assertions\NewRelic.Testing.Assertions.csproj", "{2A932B62-8787-4963-8D53-F83BF6ACBB5C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewRelic.Testing.Assertions", "..\NewRelic.Testing.Assertions\NewRelic.Testing.Assertions.csproj", "{2A932B62-8787-4963-8D53-F83BF6ACBB5C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleInstrumentationLoader", "Applications\ConsoleInstrumentationLoader\ConsoleInstrumentationLoader.csproj", "{C3D78B19-80F7-4210-B848-A5AA2BF5D13F}" EndProject @@ -139,6 +130,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedApplications", "Share EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{30CF078E-E531-441E-83AB-24AB9B1C179F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationLifecycle", "ApplicationHelperLibraries\ApplicationLifecycle\ApplicationLifecycle.csproj", "{3C182E17-0085-4B30-8AA9-B229ABED7A39}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet5BasicWebApiApplication", "Applications\AspNet5BasicWebApiApplication\AspNet5BasicWebApiApplication.csproj", "{D11C4843-B0B9-4FB0-8D2F-DBE8604298D9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -213,10 +208,6 @@ Global {96FAB968-BFE7-4A47-83AC-9A49AACBA977}.Debug|Any CPU.Build.0 = Debug|Any CPU {96FAB968-BFE7-4A47-83AC-9A49AACBA977}.Release|Any CPU.ActiveCfg = Release|Any CPU {96FAB968-BFE7-4A47-83AC-9A49AACBA977}.Release|Any CPU.Build.0 = Release|Any CPU - {887C1553-B842-4712-865B-6FFAB01EE7EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {887C1553-B842-4712-865B-6FFAB01EE7EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {887C1553-B842-4712-865B-6FFAB01EE7EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {887C1553-B842-4712-865B-6FFAB01EE7EA}.Release|Any CPU.Build.0 = Release|Any CPU {2F2A1324-5D9C-4C66-91EC-D66F50DC4336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F2A1324-5D9C-4C66-91EC-D66F50DC4336}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F2A1324-5D9C-4C66-91EC-D66F50DC4336}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -225,10 +216,6 @@ Global {EDA8AF34-CC6C-47A6-87BF-FFE7D6DC878D}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDA8AF34-CC6C-47A6-87BF-FFE7D6DC878D}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDA8AF34-CC6C-47A6-87BF-FFE7D6DC878D}.Release|Any CPU.Build.0 = Release|Any CPU - {1005EDC7-1531-4C38-9933-98E5B3088512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1005EDC7-1531-4C38-9933-98E5B3088512}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1005EDC7-1531-4C38-9933-98E5B3088512}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1005EDC7-1531-4C38-9933-98E5B3088512}.Release|Any CPU.Build.0 = Release|Any CPU {E28E36CD-A15F-4438-ADCA-40B26844592A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E28E36CD-A15F-4438-ADCA-40B26844592A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E28E36CD-A15F-4438-ADCA-40B26844592A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -265,10 +252,6 @@ Global {99DA3AEA-A9F4-4E7B-9B54-D098A1C7E5DE}.Debug|Any CPU.Build.0 = Debug|Any CPU {99DA3AEA-A9F4-4E7B-9B54-D098A1C7E5DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {99DA3AEA-A9F4-4E7B-9B54-D098A1C7E5DE}.Release|Any CPU.Build.0 = Release|Any CPU - {6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694}.Release|Any CPU.Build.0 = Release|Any CPU {ABA2F56E-4CF6-4DB7-9168-03515AD25AE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABA2F56E-4CF6-4DB7-9168-03515AD25AE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABA2F56E-4CF6-4DB7-9168-03515AD25AE3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -365,6 +348,14 @@ Global {6FD48F14-8D60-4BB0-8DC9-72E4A4D43DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FD48F14-8D60-4BB0-8DC9-72E4A4D43DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FD48F14-8D60-4BB0-8DC9-72E4A4D43DFF}.Release|Any CPU.Build.0 = Release|Any CPU + {3C182E17-0085-4B30-8AA9-B229ABED7A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C182E17-0085-4B30-8AA9-B229ABED7A39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C182E17-0085-4B30-8AA9-B229ABED7A39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C182E17-0085-4B30-8AA9-B229ABED7A39}.Release|Any CPU.Build.0 = Release|Any CPU + {D11C4843-B0B9-4FB0-8D2F-DBE8604298D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D11C4843-B0B9-4FB0-8D2F-DBE8604298D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D11C4843-B0B9-4FB0-8D2F-DBE8604298D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D11C4843-B0B9-4FB0-8D2F-DBE8604298D9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -382,10 +373,8 @@ Global {E49FCAB4-88AB-47C3-BCD1-DCE4EFE203D2} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {5CCC0395-51F8-41FB-ABAB-332C7F686F47} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {96FAB968-BFE7-4A47-83AC-9A49AACBA977} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} - {887C1553-B842-4712-865B-6FFAB01EE7EA} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {2F2A1324-5D9C-4C66-91EC-D66F50DC4336} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {EDA8AF34-CC6C-47A6-87BF-FFE7D6DC878D} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} - {1005EDC7-1531-4C38-9933-98E5B3088512} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {E28E36CD-A15F-4438-ADCA-40B26844592A} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {C07AF48C-AFE2-40FC-AFB5-E3E872F5CD7D} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {D203693A-F862-4598-92F2-B91C3959EDE6} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} @@ -394,7 +383,6 @@ Global {A7CDAC1B-5CA6-4A35-99B7-10144D586B32} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {946BAE37-C765-47A9-AE4D-3100D115E5C0} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {38F3B035-E712-43EB-A419-5176240A06EA} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} - {6BFBB803-BBAE-4E7E-9B2B-D7835A0A6694} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {ABA2F56E-4CF6-4DB7-9168-03515AD25AE3} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {F807B888-2B70-49BB-ACD8-0ACA3B168E25} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {0BD4D452-1466-43E0-BFE9-8B15B53BB11E} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} @@ -419,6 +407,8 @@ Global {8AC32C1E-2C20-4ECE-8480-700E28C3E43D} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} {6FD48F14-8D60-4BB0-8DC9-72E4A4D43DFF} = {30CF078E-E531-441E-83AB-24AB9B1C179F} {30CF078E-E531-441E-83AB-24AB9B1C179F} = {AD5B3EF6-1222-46B1-8FD4-6084FF75FA30} + {3C182E17-0085-4B30-8AA9-B229ABED7A39} = {CB5B7DCD-F949-4435-BC39-C34F4F3D2009} + {D11C4843-B0B9-4FB0-8D2F-DBE8604298D9} = {F0F6F2CE-8AE8-49E1-8EE9-A44B451EFC29} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3830ABDF-4AEA-4D91-83A2-13F091D1DF5F} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ConfigBuilderDeadlock.cs b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ConfigBuilderDeadlock.cs index b2557dfa9e..2352ec3bec 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ConfigBuilderDeadlock.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ConfigBuilderDeadlock.cs @@ -10,6 +10,7 @@ namespace NewRelic.Agent.IntegrationTests.AgentFeatures { + [NetFrameworkTest] public class ConfigBuilderDeadlock : NewRelicIntegrationTest { protected readonly ConsoleDynamicMethodFixtureFW471 _fixture; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/EnvironmentTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/EnvironmentTests.cs index 9062cdd8f7..67a861f9dd 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/EnvironmentTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/EnvironmentTests.cs @@ -90,8 +90,8 @@ public class EnvironmentCoreTests : EnvironmentTests @"\newrelichome\newrelic.config"; - protected override string ExpectedAppConfig => @"\AspNetCoreMvcBasicRequestsApplication\appsettings.json"; + protected override string ExpectedNrConfig => Utilities.IsLinux ? @"/newrelichome/newrelic.config" : @"\newrelichome\newrelic.config"; + protected override string ExpectedAppConfig => Utilities.IsLinux ? @"/AspNetCoreMvcBasicRequestsApplication/appsettings.json" : @"\AspNetCoreMvcBasicRequestsApplication\appsettings.json"; protected override void ExerciseApplication() => _fixture.Get(); } diff --git a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ThreadProfileNetCoreTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ThreadProfileNetCoreTests.cs index a878ec4809..034dac496e 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ThreadProfileNetCoreTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/AgentFeatures/ThreadProfileNetCoreTests.cs @@ -14,12 +14,12 @@ namespace NewRelic.Agent.IntegrationTests.AgentFeatures { [NetCoreTest] - public class ThreadProfileNetCoreTests : NewRelicIntegrationTest + public class ThreadProfileNetCoreTests : NewRelicIntegrationTest { - private readonly AspNetCoreMvcWithCollectorFixture _fixture; + private readonly AspNet5WebApiWithCollectorFixture _fixture; private string _threadProfileString; - public ThreadProfileNetCoreTests(AspNetCoreMvcWithCollectorFixture fixture, ITestOutputHelper output) + public ThreadProfileNetCoreTests(AspNet5WebApiWithCollectorFixture fixture, ITestOutputHelper output) : base(fixture) { _fixture = fixture; @@ -76,7 +76,7 @@ public void Test() { NrAssert.Multiple( () => Assert.Contains(@"""OTHER"":[[[""Native"",""Function Call"",0]", _threadProfileString), - () => Assert.Contains(@"[""AspNetCoreMvcBasicRequestsApplication.Program"",""Main"",0]", _threadProfileString), + () => Assert.Contains(@"[""AspNet5BasicWebApiApplication.Program"",""Main"",0]", _threadProfileString), () => Assert.Contains(@"System.Threading", _threadProfileString), () => Assert.Contains(@"Microsoft.AspNetCore.Mvc", _threadProfileString) ); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcAsyncTests.cs index 4bfc2cd172..61b5a0ead3 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcAsyncTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -28,7 +29,7 @@ public AspNetCoreMvcAsyncTests(AspNetCoreMvcAsyncTestsFixture fixture, ITestOutp ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcFrameworkAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcFrameworkAsyncTests.cs index f5a9f23929..9e661cb32f 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcFrameworkAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/AspNetCore/AspNetCoreMvcFrameworkAsyncTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -28,7 +29,7 @@ public AspNetCoreMvcFrameworkAsyncTests(AspNetCoreMvcFrameworkAsyncTestsFixture ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/AsyncStreamTest.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/AsyncStreamTest.cs index 0e2e1cd138..4de99c1f1c 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/AsyncStreamTest.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/AsyncStreamTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using Xunit; @@ -15,8 +16,6 @@ public class AsyncStreamTests : NewRelicIntegrationTest { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.AsyncStreamController", "GetNumbers"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.AsyncStreamController", "DoSomethingAsync"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/BasicAspWebService.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/BasicAspWebService.cs index d692e7f8d5..52df935ed8 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/BasicAspWebService.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/BasicAspWebService.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -31,7 +32,7 @@ public BasicAspWebService(RemoteServiceFixtures.BasicAspWebService fixture, ITes configModifier.ForceTransactionTraces(); //The purpose of this custom instrumentation file is to ignore noisy transactions. - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web.Extensions", "System.Web.Handlers.ScriptResourceHandler", "ProcessRequest", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web", "System.Web.Handlers.AssemblyResourceLoader", "GetAssemblyInfo", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web.Extensions", "System.Web.Script.Services.RestClientProxyHandler", "ProcessRequest", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/ConsoleAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/ConsoleAsyncTests.cs index 0415a28cef..6339b4f86a 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/ConsoleAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/ConsoleAsyncTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTestHelpers.Models; @@ -30,7 +31,7 @@ public ConsoleAsyncTests(ConsoleAsyncFixture fixture, ITestOutputHelper output) _fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest"); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "IoBoundNoSpecialAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundNoSpecialAsync", 7); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "IoBoundConfigureAwaitFalseAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundConfigureAwaitFalseAsync", 7); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MsCorLibTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MsCorLibTests.cs index c28a549102..6431e55a69 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MsCorLibTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MsCorLibTests.cs @@ -8,6 +8,7 @@ using Xunit; using Xunit.Abstractions; using System.Net; +using System.IO; namespace NewRelic.Agent.IntegrationTests.BasicInstrumentation { @@ -25,7 +26,7 @@ public MsCorLibTests(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixtur ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); //System.IO.Path.Combine seems to always be hit by MVC. Could move to console application w/ direct execution if ever have issues. CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "mscorlib", "System.IO.Path", "Combine"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MvcAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MvcAsyncTests.cs index cfccdc6b44..d4002cad4d 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MvcAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/MvcAsyncTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -32,7 +33,7 @@ public MvcAsyncTests(MvcAsyncFixture fixture, ITestOutputHelper output) : base(f { var configPath = fixture.DestinationNewRelicConfigFilePath; - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/NetCoreAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/NetCoreAsyncTests.cs index 2063942108..9a16dda607 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/NetCoreAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/NetCoreAsyncTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -26,7 +27,7 @@ public NetCoreAsyncTests(NetCoreAsyncTestsFixture fixture, ITestOutputHelper out ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "IoBoundNoSpecialAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundNoSpecialAsync", 7); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "IoBoundConfigureAwaitFalseAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundConfigureAwaitFalseAsync", 7); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncForceNewTransactionTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncForceNewTransactionTests.cs index afb90d5271..67545b13b5 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncForceNewTransactionTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncForceNewTransactionTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -205,7 +206,7 @@ protected WebApiAsyncForceNewTransactionTests(WebApiAsyncFixture fixture, ITestO { var configPath = _fixture.DestinationNewRelicConfigFilePath; - var instrumentationFilePath = $@"{_fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(_fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); _fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncTests.cs index 35061bd052..6801203c4a 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/BasicInstrumentation/WebApiAsyncTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; @@ -30,7 +31,7 @@ public WebApiAsyncTests(WebApiAsyncFixture fixture, ITestOutputHelper output) : { var configPath = fixture.DestinationNewRelicConfigFilePath; - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentation.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentation.cs deleted file mode 100644 index c88e99c012..0000000000 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentation.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using System.Collections.Generic; -using Xunit; -using Xunit.Abstractions; -using NewRelic.Agent.IntegrationTestHelpers; -using NewRelic.Testing.Assertions; -using System.Linq; -using NewRelic.Agent.IntegrationTestHelpers.Models; - -namespace NewRelic.Agent.IntegrationTests.CustomInstrumentation -{ - [NetFrameworkTest] - public class AttributeInstrumentation : NewRelicIntegrationTest - { - private readonly RemoteServiceFixtures.AttributeInstrumentation _fixture; - - public AttributeInstrumentation(RemoteServiceFixtures.AttributeInstrumentation fixture, ITestOutputHelper output) - : base(fixture) - { - _fixture = fixture; - _fixture.TestLogger = output; - _fixture.Actions - ( - setupConfiguration: () => - { - var configPath = fixture.DestinationNewRelicConfigFilePath; - CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(configPath, new[] { "configuration", "log" }, "level", "debug"); - }, - exerciseApplication: () => - { - // Nothing to do. Test app does it all. - } - ); - _fixture.Initialize(); - } - - [Fact] - public void Test() - { - var expectedMetrics = new List - { - new Assertions.ExpectedMetric {metricName = @"WebTransaction", callCount = 2}, - new Assertions.ExpectedMetric {metricName = @"OtherTransaction/all", callCount = 4}, - - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWork", callCount = 3}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWorkAsync", callCount = 2}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeMoreWorkAsync", callCount = 2}, - - new Assertions.ExpectedMetric {metricName = @"WebTransaction/Custom/AttributeInstrumentation.Program/MakeWebTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeWebTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeWebTransaction", metricScope = "WebTransaction/Custom/AttributeInstrumentation.Program/MakeWebTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWork", metricScope = "WebTransaction/Custom/AttributeInstrumentation.Program/MakeWebTransaction", callCount = 1}, - - new Assertions.ExpectedMetric {metricName = @"WebTransaction/Uri/fizz/buzz", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeWebTransactionWithCustomUri", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeWebTransactionWithCustomUri", metricScope = "WebTransaction/Uri/fizz/buzz", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWork", metricScope = "WebTransaction/Uri/fizz/buzz", callCount = 1}, - - new Assertions.ExpectedMetric {metricName = @"OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransaction", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransaction", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWork", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransaction", callCount = 1}, - - new Assertions.ExpectedMetric {metricName = @"OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWorkAsync", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeMoreWorkAsync", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, - - new Assertions.ExpectedMetric {metricName = @"OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionAsync", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionAsync", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionAsync", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionAsync", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeWorkAsync", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionAsync", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/DoSomeMoreWorkAsync", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionAsync", callCount = 1}, - - new Assertions.ExpectedMetric {metricName = @"OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/AttributeInstrumentation.Program/MakeOtherTransactionWithCallToNetStandardMethod", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, - new Assertions.ExpectedMetric {metricName = @"DotNet/NetStandardClassLibrary.MyClass/MyMethodToBeInstrumented", metricScope = "OtherTransaction/Custom/AttributeInstrumentation.Program/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, - }; - - var expectedTransactionEventAgentAttributes = new Dictionary - { - { "request.uri", "/fizz/buzz" } - }; - - - var metrics = _fixture.AgentLog.GetMetrics().ToList(); - var transactionEvent = _fixture.AgentLog.GetTransactionEvents() - .Where(e => e.IntrinsicAttributes["name"].ToString() == "WebTransaction/Uri/fizz/buzz") - .FirstOrDefault(); - - - NrAssert.Multiple( - () => Assertions.MetricsExist(expectedMetrics, metrics), - () => Assertions.TransactionEventHasAttributes(expectedTransactionEventAgentAttributes, TransactionEventAttributeType.Agent, transactionEvent) - ); - } - } -} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentationTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentationTests.cs new file mode 100644 index 0000000000..acd4fd1f3e --- /dev/null +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/AttributeInstrumentationTests.cs @@ -0,0 +1,139 @@ +// Copyright 2020 New Relic, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + + +using MultiFunctionApplicationHelpers; +using System.Collections.Generic; +using System.Linq; +using NewRelic.Agent.IntegrationTestHelpers; +using NewRelic.Testing.Assertions; +using Xunit; +using Xunit.Abstractions; +using NewRelic.Agent.IntegrationTestHelpers.Models; + +namespace NewRelic.Agent.IntegrationTests.CustomInstrumentation +{ + [NetFrameworkTest] + public class AttributeInstrumentationTestsFW461 : AttributeInstrumentationTests + { + public AttributeInstrumentationTestsFW461(ConsoleDynamicMethodFixtureFW461 fixture, ITestOutputHelper output) + : base(fixture, output) + { + } + } + + [NetCoreTest] + public class AttributeInstrumentationTestsCore31 : AttributeInstrumentationTests + { + public AttributeInstrumentationTestsCore31(ConsoleDynamicMethodFixtureCore31 fixture, ITestOutputHelper output) + : base(fixture, output) + { + } + } + + public abstract class AttributeInstrumentationTests : NewRelicIntegrationTest where TFixture : ConsoleDynamicMethodFixture + { + private const string LibraryClassName = "MultiFunctionApplicationHelpers.NetStandardLibraries.Internal.AttributeInstrumentation"; + + private readonly string[] TestCommands = new string[] + { + // Web transactions (i.e. [Transaction(Web = true)] + "MakeWebTransaction", + "MakeWebTransactionWithCustomUri", + // Other transactions (i.e. [Transaction] or [Transaction(Web = false)]) + "MakeOtherTransaction", + "MakeOtherTransactionAsync", + "MakeOtherTransactionThenCallAsyncMethod", + "MakeOtherTransactionWithCallToNetStandardMethod" + }; + + + protected readonly TFixture Fixture; + + public AttributeInstrumentationTests(TFixture fixture, ITestOutputHelper output) : base(fixture) + { + Fixture = fixture; + Fixture.TestLogger = output; + + foreach (var testCommand in TestCommands) + { + Fixture.AddCommand($"AttributeInstrumentation {testCommand}"); + } + + Fixture.Actions + ( + setupConfiguration: () => + { + var configPath = fixture.DestinationNewRelicConfigFilePath; + var configModifier = new NewRelicConfigModifier(configPath); + configModifier.ForceTransactionTraces(); + } + ); + + Fixture.Initialize(); + } + + [Fact] + public void Test() + { + var expectedMetrics = new List + { + new Assertions.ExpectedMetric {metricName = $"WebTransaction", callCount = 2}, + new Assertions.ExpectedMetric {metricName = $"OtherTransaction/all", callCount = 4}, + + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", callCount = 3}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWorkAsync", callCount = 2}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeMoreWorkAsync", callCount = 2}, + + new Assertions.ExpectedMetric {metricName = $"WebTransaction/Custom/{LibraryClassName}/MakeWebTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeWebTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeWebTransaction", metricScope = $"WebTransaction/Custom/{LibraryClassName}/MakeWebTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", metricScope = $"WebTransaction/Custom/{LibraryClassName}/MakeWebTransaction", callCount = 1}, + + new Assertions.ExpectedMetric {metricName = $"WebTransaction/Uri/fizz/buzz", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeWebTransactionWithCustomUri", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeWebTransactionWithCustomUri", metricScope = "WebTransaction/Uri/fizz/buzz", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", metricScope = "WebTransaction/Uri/fizz/buzz", callCount = 1}, + + new Assertions.ExpectedMetric {metricName = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransaction", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransaction", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransaction", callCount = 1}, + + new Assertions.ExpectedMetric {metricName = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWorkAsync", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeMoreWorkAsync", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionThenCallAsyncMethod", callCount = 1}, + + new Assertions.ExpectedMetric {metricName = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionAsync", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionAsync", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionAsync", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionAsync", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWorkAsync", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionAsync", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeMoreWorkAsync", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionAsync", callCount = 1}, + + new Assertions.ExpectedMetric {metricName = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeOtherTransactionWithCallToNetStandardMethod", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, + new Assertions.ExpectedMetric {metricName = $"DotNet/NetStandardTestLibrary.MyClass/MyMethodToBeInstrumented", metricScope = $"OtherTransaction/Custom/{LibraryClassName}/MakeOtherTransactionWithCallToNetStandardMethod", callCount = 1}, + }; + + var expectedTransactionEventAgentAttributes = new Dictionary + { + { "request.uri", "/fizz/buzz" } + }; + + + var metrics = Fixture.AgentLog.GetMetrics().ToList(); + var transactionEvent = Fixture.AgentLog.GetTransactionEvents() + .Where(e => e.IntrinsicAttributes["name"].ToString() == "WebTransaction/Uri/fizz/buzz") + .FirstOrDefault(); + + + NrAssert.Multiple( + () => Assertions.MetricsExist(expectedMetrics, metrics), + () => Assertions.TransactionEventHasAttributes(expectedTransactionEventAgentAttributes, TransactionEventAttributeType.Agent, transactionEvent) + ); + } + } +} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/BasicCustomInstrumentation.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/BasicCustomInstrumentation.cs index b622fc3fbb..557e647ee9 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/BasicCustomInstrumentation.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/BasicCustomInstrumentation.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ public BasicCustomInstrumentation(RemoteServiceFixtures.BasicMvcApplicationTestF var configModifier = new NewRelicConfigModifier(configPath); configModifier.ForceTransactionTraces(); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodDefaultWrapper", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomMetricName", 7); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodDefaultTracer", "NewRelic.Agent.Core.Tracer.Factories.DefaultTracerFactory"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/ConsoleAsynConsoleAsyncForceNewTransactionTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/ConsoleAsynConsoleAsyncForceNewTransactionTests.cs index 5dd066369a..3d0aefc2a6 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/ConsoleAsynConsoleAsyncForceNewTransactionTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/ConsoleAsynConsoleAsyncForceNewTransactionTests.cs @@ -6,6 +6,7 @@ using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; using System.Collections.Generic; +using System.IO; using System.Linq; using Xunit; using Xunit.Abstractions; @@ -192,7 +193,7 @@ public ConsoleAsyncForceNewTransactionTests(ConsoleAsyncFixture fixture, ITestOu { var configPath = Fixture.DestinationNewRelicConfigFilePath; - var instrumentationFilePath = $@"{Fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); Fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/CustomInstrumentationAsync.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/CustomInstrumentationAsync.cs index 8b606ea591..4ff8509162 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/CustomInstrumentationAsync.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/CustomInstrumentationAsync.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ public CustomInstrumentationAsync(RemoteServiceFixtures.BasicMvcApplicationTestF var configModifier = new NewRelicConfigModifier(configPath); configModifier.ForceTransactionTraces(); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentationAsync.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentationAsync.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomMethodDefaultWrapperAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "MyCustomMetricName", 7); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomSegmentTransactionSegmentWrapper", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.CustomSegmentWrapperAsync"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperFrameworkTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperFrameworkTests.cs index 20200f5bc1..97c96828fd 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperFrameworkTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperFrameworkTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -32,7 +33,7 @@ public DetachWrapperFrameworkTests(RemoteServiceFixtures.AspNetCoreMvcFrameworkF ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\TerminatingSegmentInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "TerminatingSegmentInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCoreMvcFrameworkApplication", "AspNetCoreMvcFrameworkApplication.Controllers.DetachWrapperController", "AsyncMethodWithExternalCall", "DetachWrapper"); }, diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperTests.cs index 8b40f30bab..a934b60aad 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/DetachWrapperTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -29,7 +30,7 @@ public DetachWrapperTests(RemoteServiceFixtures.AspNetCoreMvcBasicRequestsFixtur ( setupConfiguration: () => { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\TerminatingSegmentInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "TerminatingSegmentInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCoreMvcBasicRequestsApplication", "AspNetCoreMvcBasicRequestsApplication.Controllers.DetachWrapperController", "AsyncMethodWithExternalCall", "DetachWrapper"); }, diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/InterfaceDefaultsInstrumentationTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/InterfaceDefaultsInstrumentationTests.cs index 92a306c53f..8b68504f5d 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/InterfaceDefaultsInstrumentationTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/InterfaceDefaultsInstrumentationTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using Xunit; @@ -15,8 +16,6 @@ public class InterfaceDefaultsInstrumentationTests : NewRelicIntegrationTest { - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ILoggerNoAttributes", "LogException"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ConsoleLoggerNoAttributesNoDefault", "LogMessage"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/NetCoreAttributeInstrumentationTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/NetCoreAttributeInstrumentationTests.cs deleted file mode 100644 index 65d086a4b9..0000000000 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/NetCoreAttributeInstrumentationTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using System; -using System.Collections.Generic; -using System.Linq; -using NewRelic.Agent.IntegrationTestHelpers; -using NewRelic.Testing.Assertions; -using Xunit; -using Xunit.Abstractions; - -namespace NewRelic.Agent.IntegrationTests.CustomInstrumentation -{ - [NetCoreTest] - public class NetCoreAttributeInstrumentationTests : NewRelicIntegrationTest - { - private readonly RemoteServiceFixtures.NetCoreAttributeInstrumentationFixture _fixture; - - public NetCoreAttributeInstrumentationTests(RemoteServiceFixtures.NetCoreAttributeInstrumentationFixture fixture, ITestOutputHelper output) : base(fixture) - { - _fixture = fixture; - _fixture.TestLogger = output; - _fixture.Actions - ( - setupConfiguration: () => - { - var configPath = fixture.DestinationNewRelicConfigFilePath; - var configModifier = new NewRelicConfigModifier(configPath); - configModifier.ForceTransactionTraces(); - - CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(fixture.DestinationNewRelicConfigFilePath, new[] { "configuration", "instrumentation", "applications", "application" }, "name", "NetCoreAttributeInstrumentationApplication.exe"); - } - ); - _fixture.Initialize(); - } - - [Fact] - public void Test() - { - var expectedMetrics = new List - { - new Assertions.ExpectedMetric { metricName = @"OtherTransaction/Custom/NetCoreAttributeInstrumentationApplication.Program/DoSomething", callCount = 1 }, - new Assertions.ExpectedMetric { metricName = @"DotNet/NetCoreAttributeInstrumentationApplication.Program/DoSomething", metricScope = @"OtherTransaction/Custom/NetCoreAttributeInstrumentationApplication.Program/DoSomething", callCount = 1 }, - new Assertions.ExpectedMetric { metricName = @"DotNet/NetCoreAttributeInstrumentationApplication.Program/DoSomethingInside", metricScope = @"OtherTransaction/Custom/NetCoreAttributeInstrumentationApplication.Program/DoSomething", callCount = 1 }, - }; - - var expectedTransactionTraceSegments = new List - { - @"DotNet/NetCoreAttributeInstrumentationApplication.Program/DoSomething", - @"DotNet/NetCoreAttributeInstrumentationApplication.Program/DoSomethingInside" - }; - - var metrics = _fixture.AgentLog.GetMetrics().ToList(); - var transactionSamples = _fixture.AgentLog.GetTransactionSamples().ToList(); - - var transactionSample = transactionSamples.Where(sample => sample.Path == @"OtherTransaction/Custom/NetCoreAttributeInstrumentationApplication.Program/DoSomething") - .FirstOrDefault(); - - Assert.NotNull(metrics); - - Assert.NotNull(transactionSample); - - NrAssert.Multiple - ( - () => Assertions.MetricsExist(expectedMetrics, metrics), - () => Assertions.TransactionTraceSegmentsExist(expectedTransactionTraceSegments, transactionSample) - ); - } - } -} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransaction.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransaction.cs index 25a2e91f58..8b02ce6c90 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransaction.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransaction.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -27,7 +28,7 @@ public OtherTransaction(RemoteServiceFixtures.AgentApiExecutor fixture, ITestOut { var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); //Use the two different wrappers here to ensure that they both filter to OtherTransactionWrapper and create the same behavior diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsync.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsync.cs index a22ceeb77f..fce0690805 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsync.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsync.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ public OtherTransactionAsync(RemoteServiceFixtures.BasicMvcApplicationTestFixtur var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath); configModifier.ForceTransactionTraces(); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomMethodBackgroundThread", "AsyncForceNewTransactionWrapper", "MyCustomMetricName"); }, diff --git a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsyncWithImmediateError.cs b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsyncWithImmediateError.cs index 7067eb1152..1e6dc4d18f 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsyncWithImmediateError.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/CustomInstrumentation/OtherTransactionAsyncWithImmediateError.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; @@ -27,7 +28,7 @@ public OtherTransactionAsyncWithError(RemoteServiceFixtures.BasicMvcApplicationT var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath); configModifier.ForceTransactionTraces(); - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomMethodBackgroundThreadWithError", "AsyncForceNewTransactionWrapper"); }, diff --git a/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/TraceIdTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/TraceIdTests.cs index 6c30a4c9eb..c63b6484f1 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/TraceIdTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/TraceIdTests.cs @@ -11,7 +11,7 @@ namespace NewRelic.Agent.IntegrationTests.DistributedTracing.W3CInstrumentationTests { - [NetFrameworkTest] + [NetCoreTest] public class TraceIdTests : NewRelicIntegrationTest { private readonly AspNetCore3BasicWebApiApplicationFixture _fixture; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/W3CValidation.cs b/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/W3CValidation.cs index 371f2fd71c..15a02bdbd2 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/W3CValidation.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/DistributedTracing/W3CInstrumentationTests/W3CValidation.cs @@ -6,6 +6,7 @@ using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Testing.Assertions; using System; +using System.IO; using Xunit; using Xunit.Abstractions; @@ -64,12 +65,12 @@ public W3CValidation(ConsoleDynamicMethodFixtureFWLatest fixture, ITestOutputHel _fixture.RemoteApplication.NewRelicConfig.ForceTransactionTraces(); _fixture.AddCommand($"W3CTestService StartService {_fixture.RemoteApplication.Port}"); - _fixture.AddCommand($@"GitCommand Clone https://github.com/w3c/trace-context.git {_fixture.RemoteApplication.DestinationApplicationDirectoryPath}\trace-context"); - _fixture.AddCommand($@"GitCommand Checkout {_fixture.RemoteApplication.DestinationApplicationDirectoryPath}\trace-context 98f210efd89c63593dce90e2bae0a1bdcb986f51"); + _fixture.AddCommand($@"GitCommand Clone https://github.com/w3c/trace-context.git {Path.Combine(_fixture.RemoteApplication.DestinationApplicationDirectoryPath, "trace-context")}"); + _fixture.AddCommand($@"GitCommand Checkout { Path.Combine(_fixture.RemoteApplication.DestinationApplicationDirectoryPath, "trace-context")} 98f210efd89c63593dce90e2bae0a1bdcb986f51"); _fixture.AddCommand("ProcessRunner ProcessName python.exe"); _fixture.AddCommand("ProcessRunner AddArgument -m unittest"); _fixture.AddCommand("ProcessRunner AddSwitch -v"); - _fixture.AddCommand($@"ProcessRunner WorkingDirectory {_fixture.RemoteApplication.DestinationApplicationDirectoryPath}\trace-context\test"); // python W3C tests are in test dir + _fixture.AddCommand($@"ProcessRunner WorkingDirectory {Path.Combine(_fixture.RemoteApplication.DestinationApplicationDirectoryPath, "trace-context", "test")}"); // python W3C tests are in test dir _fixture.AddCommand($"ProcessRunner AddEnvironmentVariable SERVICE_ENDPOINT http://localhost:{_fixture.RemoteApplication.Port}/test"); _fixture.AddCommand($"ProcessRunner AddEnvironmentVariable STRICT_LEVEL 1"); _fixture.AddCommand("ProcessRunner Start"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientInstrumentationNet5.cs b/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientInstrumentationNet5.cs index 84b79f05fc..2b26705929 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientInstrumentationNet5.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientInstrumentationNet5.cs @@ -2,11 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 -using System; using System.Collections.Generic; using System.Linq; using NewRelic.Agent.IntegrationTestHelpers; -using NewRelic.Agent.IntegrationTestHelpers.Models; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; using Xunit; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientViaFactoryNetCore.cs b/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientViaFactoryNetCore.cs index 1da67a5e09..d4257bf25f 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientViaFactoryNetCore.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/HttpClientInstrumentation/NetCore/HttpClientViaFactoryNetCore.cs @@ -12,6 +12,7 @@ namespace NewRelic.Agent.IntegrationTests.HttpClientInstrumentation.NetCore { + [NetCoreTest] public class HttpClientViaFactoryNetCore : NewRelicIntegrationTest { private readonly AspNetCoreMvcBasicRequestsFixture _fixture; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/IntegrationTests.csproj b/tests/Agent/IntegrationTests/IntegrationTests/IntegrationTests.csproj index 0e640a3696..dfc6cfd45f 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/IntegrationTests.csproj +++ b/tests/Agent/IntegrationTests/IntegrationTests/IntegrationTests.csproj @@ -2,7 +2,7 @@ NewRelic.Agent.IntegrationTests NewRelic.Agent.IntegrationTests - net461 + net461;netcoreapp3.1 true @@ -29,7 +29,6 @@ - @@ -37,7 +36,10 @@ - + + + + @@ -50,13 +52,15 @@ - + + + - + IEDriverServer.exe PreserveNewest @@ -65,4 +69,4 @@ - \ No newline at end of file + diff --git a/tests/Agent/IntegrationTests/IntegrationTests/Logging/LogLevelAndDirectoryEnvironmentTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/Logging/LogLevelAndDirectoryEnvironmentTests.cs index b726d5e3db..165aae256e 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/Logging/LogLevelAndDirectoryEnvironmentTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/Logging/LogLevelAndDirectoryEnvironmentTests.cs @@ -43,7 +43,7 @@ public LogLevelAndDirectoryEnvironmentTests(T fixture, ITestOutputHelper output) _fixture.Initialize(); } - [Fact] + [SkipOnLinuxFact("See https://github.com/newrelic/newrelic-dotnet-agent/issues/763")] public void AgentLog() { var configLocation = new AgentLogFile(_configLogDirectory, throwIfNotFound: false); @@ -59,7 +59,7 @@ public void AgentLog() Assert.DoesNotContain($"{_configLogLevel}: [pid: ", agentLines, StringComparer.OrdinalIgnoreCase); } - [Fact] + [SkipOnLinuxFact("See https://github.com/newrelic/newrelic-dotnet-agent/issues/763")] public void ProfilerLog() { var configLocation = new ProfilerLogFile(_configLogDirectory, throwIfNotFound: false); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/Owin/OwinWebApiAsyncTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/Owin/OwinWebApiAsyncTests.cs index 717dd876c5..d77e194f64 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/Owin/OwinWebApiAsyncTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/Owin/OwinWebApiAsyncTests.cs @@ -11,6 +11,7 @@ using NewRelic.Agent.IntegrationTestHelpers.Models; using Xunit; using Xunit.Abstractions; +using System.IO; namespace NewRelic.Agent.IntegrationTests.Owin { @@ -33,7 +34,7 @@ protected OwinWebApiAsyncTestsBase(TFixture fixture, ITestOutputHelper output) : { var configPath = fixture.DestinationNewRelicConfigFilePath; - var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml"; + var instrumentationFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "CustomInstrumentation.xml"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1"); CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2"); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddAttribute.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddAttribute.cs index 77c6ce3c0c..2a6a6189d6 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddAttribute.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddAttribute.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -29,7 +30,7 @@ protected RejitAddAttributeBase(TFixture fixture, ITestOutputHelper output) : ba { _fixture = fixture; - var addAttributeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddAttributeTest.xml"; + var addAttributeFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.AddAttributeTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -60,32 +61,32 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomAddAfterMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetAddAttribute", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddAfterMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddAttribute", callCount = 2 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddAfterMetricName", metricScope = "WebTransaction/Custom/MyCustomAddAfterMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddAttribute", metricScope = "WebTransaction/MVC/Rejit/GetAddAttribute", callCount = 1 } }; var notExpcetedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomAddBeforeMetricName", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomAddBeforeMetricName", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddBeforeMetricName", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddBeforeMetricName", callCount = 1 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddBeforeMetricName", metricScope = "WebTransaction/Custom/MyCustomAddBeforeMetricName", callCount = 1 } + // Scoped + new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddBeforeMetricName", metricScope = "WebTransaction/Custom/MyCustomAddBeforeMetricName", callCount = 1 } }; var metrics = CommonUtils.GetMetrics(_fixture.AgentLog); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddFile.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddFile.cs index ed2674d1b0..11a38fc6c6 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddFile.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddFile.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -42,9 +43,9 @@ protected RejitAddFileBase(TFixture fixture, ITestOutputHelper output) : base(fi _fixture.InitializeApp(); _fixture.TestAddFile(); - var createFilePath = _fixture.RemoteApplication.DestinationNewRelicHomeDirectoryPath + @"\Integration.Testing.AddXmlFileTest.xml"; + var createFilePath = Path.Combine(_fixture.RemoteApplication.DestinationNewRelicHomeDirectoryPath, "Integration.Testing.AddXmlFileTest.xml"); CommonUtils.AddCustomInstrumentation(createFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperAddFile", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomAddMetricName", 7); - var destinationFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddXmlFileTest.xml"; + var destinationFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.AddXmlFileTest.xml"); CommonUtils.MoveFile(createFilePath, destinationFilePath, TimeSpan.FromSeconds(5)); _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1)); _fixture.TestAddFile(); @@ -58,18 +59,18 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomAddMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetAddFile", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddFile", callCount = 2 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddMetricName", metricScope = "WebTransaction/Custom/MyCustomAddMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddFile", metricScope = "WebTransaction/MVC/Rejit/GetAddFile", callCount = 1 } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddNode.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddNode.cs index 9c26f0e00f..f24dbccce6 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddNode.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitAddNode.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ protected RejitAddNodeBase(TFixture fixture, ITestOutputHelper output) : base(fi { _fixture = fixture; - var addNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddNodeTest.xml"; + var addNodeFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.AddNodeTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -62,18 +63,18 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomAddMetricName", callCount = 2 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetAddNode/{id}", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddMetricName", callCount = 2 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddNode", callCount = 3 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomAddMetricName", metricScope = "WebTransaction/Custom/MyCustomAddMetricName", callCount = 2 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetAddNode", metricScope = "WebTransaction/MVC/Rejit/GetAddNode/{id}", callCount = 1 } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitChangeAttributeValue.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitChangeAttributeValue.cs index 75a252fe5f..238c495953 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitChangeAttributeValue.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitChangeAttributeValue.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ protected RejitChangeAttributeValueBase(TFixture fixture, ITestOutputHelper outp { _fixture = fixture; - var changeAttributeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.ChangeAttributeTest.xml"; + var changeAttributeFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.ChangeAttributeTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -58,30 +59,30 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomChangeMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomRenamedMetricName", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomChangeMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomRenamedMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetChangeAttributeValue", callCount = 2 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomChangeMetricName", metricScope = "WebTransaction/Custom/MyCustomChangeMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomRenamedMetricName", metricScope = "WebTransaction/Custom/MyCustomRenamedMetricName", callCount = 1 } }; var notExpectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetChangeAttributeValue" }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetChangeAttributeValue" }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetChangeAttributeValue", metricScope = "WebTransaction/MVC/Rejit/GetChangeAttributeValue" } + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetChangeAttributeValue", metricScope = "WebTransaction/MVC/Rejit/GetChangeAttributeValue" } }; var metrics = CommonUtils.GetMetrics(_fixture.AgentLog); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteAttribute.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteAttribute.cs index 982844e95f..4d93155256 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteAttribute.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteAttribute.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ protected RejitDeleteAttributeBase(TFixture fixture, ITestOutputHelper output) : { _fixture = fixture; - var deleteAttributeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteAttributeTest.xml"; + var deleteAttributeFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.DeleteAttributeTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -58,18 +59,18 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetDeleteAttribute", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetDeleteAttribute", callCount = 2 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomDeleteMetricName", metricScope = "WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetDeleteAttribute", metricScope = "WebTransaction/MVC/Rejit/GetDeleteAttribute", callCount = 1 } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteFile.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteFile.cs index f1238688b5..7739a14177 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteFile.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteFile.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ protected RejitDeleteFileBase(TFixture fixture, ITestOutputHelper output) : base { _fixture = fixture; - var deleteFileFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteXmlFileTest.xml"; + var deleteFileFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.DeleteXmlFileTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -58,18 +59,18 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Rejit/GetDeleteFile", callCount = 1 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetDeleteFile", callCount = 2 }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomDeleteMetricName", metricScope = "WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetDeleteFile", metricScope = "WebTransaction/MVC/Rejit/GetDeleteFile", callCount = 1 } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteNode.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteNode.cs index dbf5e9a69a..37240003f5 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteNode.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitDeleteNode.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -28,7 +29,7 @@ protected RejitDeleteNodeBase(TFixture fixture, ITestOutputHelper output) : base { _fixture = fixture; - var deleteNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteNodeTest.xml"; + var deleteNodeFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.DeleteNodeTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -72,18 +73,18 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric {metricName = @"WebTransaction/MVC/Home/Index", callCount = 1}, + //transactions + new Assertions.ExpectedMetric {metricName = @"WebTransaction/MVC/Home/Index", callCount = 1}, new Assertions.ExpectedMetric {metricName = @"WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 3}, new Assertions.ExpectedMetric {metricName = @"WebTransaction/MVC/Rejit/GetDeleteNode/{id}", callCount = 1}, - // Unscoped - new Assertions.ExpectedMetric {metricName = @"DotNet/HomeController/Index", callCount = 1}, + // Unscoped + new Assertions.ExpectedMetric {metricName = @"DotNet/HomeController/Index", callCount = 1}, new Assertions.ExpectedMetric {metricName = @"Custom/MyCustomDeleteMetricName", callCount = 3}, new Assertions.ExpectedMetric {metricName = @"DotNet/RejitController/GetDeleteNode", callCount = 4}, - // Scoped - new Assertions.ExpectedMetric {metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1}, + // Scoped + new Assertions.ExpectedMetric {metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1}, new Assertions.ExpectedMetric {metricName = @"Custom/MyCustomDeleteMetricName", metricScope = "WebTransaction/Custom/MyCustomDeleteMetricName", callCount = 3}, new Assertions.ExpectedMetric {metricName = @"DotNet/RejitController/GetDeleteNode", metricScope = "WebTransaction/MVC/Rejit/GetDeleteNode/{id}", callCount = 1} }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitRenameFile.cs b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitRenameFile.cs index aa28da6faa..6d7f11b7a8 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitRenameFile.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/ReJit/NetCore/RejitRenameFile.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.RemoteServiceFixtures; using NewRelic.Testing.Assertions; @@ -30,7 +31,7 @@ protected RejitRenameFileBase(TFixture fixture, ITestOutputHelper output) : base { _fixture = fixture; - _renameOriginalFileFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.RenameOriginalXmlFileTest.xml"; + _renameOriginalFileFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.RenameOriginalXmlFileTest.xml"); _fixture.TestLogger = output; _fixture.Actions( @@ -47,7 +48,7 @@ protected RejitRenameFileBase(TFixture fixture, ITestOutputHelper output) : base _fixture.InitializeApp(); _fixture.TestRenameFile(); - var renameTargetFileFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.RenameTargetXmlFileTest.xml"; + var renameTargetFileFilePath = Path.Combine(_fixture.RemoteApplication.DestinationExtensionsDirectoryPath, "Integration.Testing.RenameTargetXmlFileTest.xml"); CommonUtils.RenameFile(_renameOriginalFileFilePath, renameTargetFileFilePath, TimeSpan.FromSeconds(5)); _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1)); _fixture.TestRenameFile(); @@ -61,27 +62,27 @@ public void Test() { var expectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"WebTransaction/Custom/MyCustomRenameMetricName", callCount = 2 }, - // Unscoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, + // Unscoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomRenameMetricName", callCount = 2 }, new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetRenameFile", callCount = 2}, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/HomeController/Index", metricScope = "WebTransaction/MVC/Home/Index", callCount = 1 }, new Assertions.ExpectedMetric { metricName = @"Custom/MyCustomRenameMetricName", metricScope = "WebTransaction/Custom/MyCustomRenameMetricName", callCount = 2 } }; var notExpectedMetrics = new List { - //transactions - new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/RejitController/GetRenameFile" }, + //transactions + new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/RejitController/GetRenameFile" }, - // Scoped - new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetRenameFile", metricScope = "WebTransaction/MVC/RejitController/GetRenameFile" } + // Scoped + new Assertions.ExpectedMetric { metricName = @"DotNet/RejitController/GetRenameFile", metricScope = "WebTransaction/MVC/RejitController/GetRenameFile" } }; var metrics = CommonUtils.GetMetrics(_fixture.AgentLog); diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNet5WebApiWithCollectorFixture.cs b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNet5WebApiWithCollectorFixture.cs new file mode 100644 index 0000000000..0938bec8f7 --- /dev/null +++ b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNet5WebApiWithCollectorFixture.cs @@ -0,0 +1,21 @@ +// Copyright 2020 New Relic, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + + +using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures; + +namespace NewRelic.Agent.IntegrationTests.RemoteServiceFixtures +{ + public class AspNet5WebApiWithCollectorFixture : MockNewRelicFixture + { + public AspNet5WebApiWithCollectorFixture() : base(new RemoteService("AspNet5BasicWebApiApplication", "AspNet5BasicWebApiApplication.exe", "net5.0", ApplicationType.Bounded, true, true, true)) + { + } + + public void Get() + { + var address = $"http://localhost:{Port}/api/default/AwesomeName"; + DownloadStringAndAssertContains(address, "Chuck Norris"); + } + } +} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcBasicRequestsFixture.cs b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcBasicRequestsFixture.cs index c33825c84b..e594e5f732 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcBasicRequestsFixture.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcBasicRequestsFixture.cs @@ -41,8 +41,8 @@ public void MakePostRequestWithCustomRequestHeader(Dictionary cu var address = $"http://localhost:{Port}/"; var request = (HttpWebRequest)WebRequest.Create(address); request.Method = "POST"; - request.Referer = "http://example.com"; - request.Host = "FakeHost"; + request.Referer = "http://example.com/"; + request.Host = "fakehost:1234"; request.UserAgent = "FakeUserAgent"; request.Accept = "text/html"; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcWithCollectorFixture.cs b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcWithCollectorFixture.cs deleted file mode 100644 index 1e55d47f75..0000000000 --- a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AspNetCoreMvcWithCollectorFixture.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures; - -namespace NewRelic.Agent.IntegrationTests.RemoteServiceFixtures -{ - public class AspNetCoreMvcWithCollectorFixture : MockNewRelicFixture - { - public AspNetCoreMvcWithCollectorFixture() : base(new RemoteService("AspNetCoreMvcBasicRequestsApplication", "AspNetCoreMvcBasicRequestsApplication.exe", ApplicationType.Bounded, true, true, true)) - { - } - - public void Get() - { - var address = $"http://localhost:{Port}/"; - DownloadStringAndAssertContains(address, ""); - } - } -} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AttributeInstrumentation.cs b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AttributeInstrumentation.cs deleted file mode 100644 index 0a7f9e9d65..0000000000 --- a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/AttributeInstrumentation.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures; - -namespace NewRelic.Agent.IntegrationTests.RemoteServiceFixtures -{ - public class AttributeInstrumentation : RemoteApplicationFixture - { - private const string ApplicationDirectoryName = "AttributeInstrumentation"; - private const string ExecutableName = "AttributeInstrumentation.exe"; - private const string TargetFramework = "net461"; - - public AttributeInstrumentation() : base(new RemoteService(ApplicationDirectoryName, ExecutableName, TargetFramework, ApplicationType.Bounded)) - { - } - } -} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/NetCoreAttributeInstrumentationFixture.cs b/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/NetCoreAttributeInstrumentationFixture.cs deleted file mode 100644 index e782efa7f6..0000000000 --- a/tests/Agent/IntegrationTests/IntegrationTests/RemoteServiceFixtures/NetCoreAttributeInstrumentationFixture.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using System; -using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures; - -namespace NewRelic.Agent.IntegrationTests.RemoteServiceFixtures -{ - public class NetCoreAttributeInstrumentationFixture : RemoteApplicationFixture - { - private const string ApplicationDirectoryName = @"NetCoreAttributeInstrumentationApplication"; - private const string ExecutableName = @"NetCoreAttributeInstrumentationApplication.exe"; - public NetCoreAttributeInstrumentationFixture() : base(new RemoteService(ApplicationDirectoryName, ExecutableName, ApplicationType.Bounded, true, true, true)) - { - } - } -} diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersDisabledTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersDisabledTests.cs index 67fc9f9e9e..74e0d46960 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersDisabledTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersDisabledTests.cs @@ -50,10 +50,10 @@ public void Test() var expectedAttributes = new Dictionary { { "request.method", "POST" }, - { "request.headers.referer", "http://example.com" }, + { "request.headers.referer", "http://example.com/" }, { "request.headers.accept", "text/html" }, { "request.headers.content-length", "5" }, - { "request.headers.host", "fakehost" }, + { "request.headers.host", "fakehost:1234" }, { "request.headers.user-agent", "FakeUserAgent" } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersEnabledTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersEnabledTests.cs index a857d6cb0c..36290daf2e 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersEnabledTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/AspNetCore/AllowAllHeadersEnabledTests.cs @@ -48,10 +48,10 @@ public void Test() var expectedAttributes = new Dictionary { { "request.method", "POST" }, - { "request.headers.referer", "http://example.com" }, + { "request.headers.referer", "http://example.com/" }, { "request.headers.accept", "text/html" }, { "request.headers.content-length", "5" }, - { "request.headers.host", "fakehost" }, + { "request.headers.host", "fakehost:1234" }, { "request.headers.user-agent", "FakeUserAgent" }, { "request.headers.foo", "bar" } }; diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersDisabledTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersDisabledTests.cs index 7785e08779..805cd78b38 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersDisabledTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersDisabledTests.cs @@ -1,6 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using System.Collections.Generic; using System.Linq; using MultiFunctionApplicationHelpers; @@ -172,3 +173,4 @@ public Self_WS_AllowAllHeadersDisabledTests(ConsoleDynamicMethodFixtureFWLatest #endregion Self } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersEnabledTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersEnabledTests.cs index 615039e519..642b562e2e 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersEnabledTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/RequestHeadersCapture/WCF/AllowAllHeadersEnabledTests.cs @@ -1,6 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using System.Collections.Generic; using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; @@ -114,3 +115,4 @@ public Self_WS_AllowAllHeadersEnabledTests(ConsoleDynamicMethodFixtureFWLatest f #endregion Self } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests.cs index 599f3d5aa8..7122cbafbd 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests.cs @@ -1,6 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; @@ -231,3 +232,4 @@ public void BindingType_Metrics() } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_IISHosted.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_IISHosted.cs index 153b2d2c0d..182e4ed79a 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_IISHosted.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_IISHosted.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -203,3 +204,4 @@ public WCFClient_IIS_BasicHTTP_CAT_ASPEnabled(ConsoleDynamicMethodFixtureFWLates } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_SelfHosted.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_SelfHosted.cs index f2c71c0ef4..8f5f83f834 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_SelfHosted.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFClientTests_SelfHosted.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -144,3 +145,4 @@ public WCFClient_Self_CustomClass(ConsoleDynamicMethodFixtureFWLatest fixture, I } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFEmptyTestBase.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFEmptyTestBase.cs index cb6931b665..a1808839fd 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFEmptyTestBase.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFEmptyTestBase.cs @@ -1,6 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using System; using System.IO; using MultiFunctionApplicationHelpers; @@ -67,3 +68,4 @@ protected virtual void AddFixtureCommands() } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLegacyTestBase.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLegacyTestBase.cs index f0748cb76b..f6be4b503d 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLegacyTestBase.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLegacyTestBase.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -401,3 +402,4 @@ public void CAT() } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLogHelpers.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLogHelpers.cs index 13a06466e2..cfd2c23376 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLogHelpers.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFLogHelpers.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTestHelpers.Models; @@ -301,3 +302,4 @@ public IEnumerable QueryLog(Func> logFunction } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTests.cs index df7624a6bf..32c04bc36a 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTests.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; using Xunit; @@ -34,3 +35,4 @@ public WCFService_Self_ExternalCallsTests(ConsoleDynamicMethodFixtureFWLatest fi : base(fixture, output, HostingModel.Self) { } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTestsBase.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTestsBase.cs index 48cb2223c9..bad1a945ae 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTestsBase.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceExternalCallsTestsBase.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using System; using System.Collections.Generic; using MultiFunctionApplicationHelpers; @@ -47,3 +48,4 @@ protected void ExternalCallsTests() } } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests.cs index 2c2153cc1c..93bfd8d096 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests.cs @@ -1,7 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -485,3 +485,4 @@ public void BindingType_Metrics() } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_IISHosted.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_IISHosted.cs index ebd82c0134..16b56a432d 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_IISHosted.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_IISHosted.cs @@ -1,7 +1,7 @@ // Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -203,3 +203,4 @@ public WCFService_IIS_BasicHTTP_CAT_ASPEnabled(ConsoleDynamicMethodFixtureFWLate } } +#endif diff --git a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_SelfHosted.cs b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_SelfHosted.cs index 277357a1b2..600c793df1 100644 --- a/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_SelfHosted.cs +++ b/tests/Agent/IntegrationTests/IntegrationTests/WCF/WCFServiceTests_SelfHosted.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 +#if NETFRAMEWORK using MultiFunctionApplicationHelpers; using NewRelic.Agent.IntegrationTestHelpers; using NewRelic.Agent.IntegrationTests.Shared.Wcf; @@ -143,3 +144,4 @@ public WCFService_Self_CustomClass(ConsoleDynamicMethodFixtureFWLatest fixture, } } } +#endif diff --git a/tests/Agent/IntegrationTests/Models/Models.csproj b/tests/Agent/IntegrationTests/Models/Models.csproj index 58c61c0afe..4bfbfaa4d2 100644 --- a/tests/Agent/IntegrationTests/Models/Models.csproj +++ b/tests/Agent/IntegrationTests/Models/Models.csproj @@ -1,7 +1,7 @@ - netstandard1.2 + netstandard2.0 NewRelic.IntegrationTests.Models diff --git a/tests/Agent/IntegrationTests/Shared/IntegrationTestConfiguration.cs b/tests/Agent/IntegrationTests/Shared/IntegrationTestConfiguration.cs index aaa141a68f..86570443c9 100644 --- a/tests/Agent/IntegrationTests/Shared/IntegrationTestConfiguration.cs +++ b/tests/Agent/IntegrationTests/Shared/IntegrationTestConfiguration.cs @@ -11,9 +11,9 @@ public class IntegrationTestConfiguration { private string _configurationCategory { get; set; } - public TestSettings DefaultSetting { get; set; } + public TestSettings DefaultSetting { get; set; } = new TestSettings(); - public Dictionary TestSettingOverrides { get; set; } + public Dictionary TestSettingOverrides { get; set; } = new Dictionary(); public string this[string key] { diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj index 8b6d247e48..4b826b9707 100644 --- a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.1;netcoreapp2.2;netcoreapp3.1;net461;net471;net48 @@ -54,6 +54,7 @@ + diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/AttributeInstrumentation.cs b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/AttributeInstrumentation.cs new file mode 100644 index 0000000000..445a44ff69 --- /dev/null +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/AttributeInstrumentation.cs @@ -0,0 +1,109 @@ +// Copyright 2020 New Relic, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + + +using System; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using NewRelic.Agent.IntegrationTests.Shared.ReflectionHelpers; +using NewRelic.Api.Agent; + +namespace MultiFunctionApplicationHelpers.NetStandardLibraries.Internal +{ + [Library] + internal static class AttributeInstrumentation + { + /// + /// Synchronous method creating a Web transaction + /// + [LibraryMethod] + [Transaction(Web = true)] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static void MakeWebTransaction() + { + DoSomeWork(); + } + + /// + /// Synchronous method creating a Web transaction and utilizing SetTransactionUri + /// + [LibraryMethod] + [Transaction(Web = true)] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static void MakeWebTransactionWithCustomUri() + { + var uri = new Uri("http://foo.bar.net/fizz/buzz"); + NewRelic.Api.Agent.NewRelic.SetTransactionUri(uri); + DoSomeWork(); + } + + /// + /// Synchronous method creating an Other transaction + /// + [LibraryMethod] + [Transaction] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static void MakeOtherTransaction() + { + DoSomeWork(); + } + + /// + /// Async method creating an Other transaction + /// + /// + [LibraryMethod] + [Transaction] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static async Task MakeOtherTransactionAsync() + { + await DoSomeWorkAsync(); + } + + /// + /// Synchronous method that calls async methods. + /// This use case illustrates that this scenario is possible, but it is + /// recommended that transactions involving async code start with an + /// async entry point to avoid potential pitfalls. + /// + [LibraryMethod] + [Transaction] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static void MakeOtherTransactionThenCallAsyncMethod() + { + DoSomeWorkAsync().Wait(); + } + + [LibraryMethod] + [Transaction] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + public static void MakeOtherTransactionWithCallToNetStandardMethod() + { + var myObj = new NetStandardTestLibrary.MyClass(); + myObj.MyMethodToBeInstrumented(); + } + + [Trace] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + private static void DoSomeWork() + { + } + + [Trace] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + private static async Task DoSomeWorkAsync() + { + await Task.Delay(TimeSpan.FromMilliseconds(10)); + return await DoSomeMoreWorkAsync(); + } + + [Trace] + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] + private static async Task DoSomeMoreWorkAsync() + { + return await Task.FromResult("Some work."); + } + + + } +} diff --git a/tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/MyClass.cs b/tests/Agent/IntegrationTests/SharedApplications/Common/NetStandardTestLibrary/MyClass.cs similarity index 91% rename from tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/MyClass.cs rename to tests/Agent/IntegrationTests/SharedApplications/Common/NetStandardTestLibrary/MyClass.cs index 5aa577e512..af645e59cf 100644 --- a/tests/Agent/IntegrationTests/Applications/NetStandardClassLibrary/MyClass.cs +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/NetStandardTestLibrary/MyClass.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; -namespace NetStandardClassLibrary +namespace NetStandardTestLibrary { public class MyClass { diff --git a/tests/Agent/NewRelic.Testing.Assertions/NewRelic.Testing.Assertions.csproj b/tests/Agent/NewRelic.Testing.Assertions/NewRelic.Testing.Assertions.csproj index 0469ddaed3..cf91278a51 100644 --- a/tests/Agent/NewRelic.Testing.Assertions/NewRelic.Testing.Assertions.csproj +++ b/tests/Agent/NewRelic.Testing.Assertions/NewRelic.Testing.Assertions.csproj @@ -1,47 +1,7 @@ - - - + + - Debug - x86 - {2A932B62-8787-4963-8D53-F83BF6ACBB5C} - Library - Properties - NewRelic.Testing.Assertions - NewRelic.Testing.Assertions - v4.5 - 512 + net45;netstandard2.0 - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/tests/Agent/NewRelic.Testing.Assertions/Properties/AssemblyInfo.cs b/tests/Agent/NewRelic.Testing.Assertions/Properties/AssemblyInfo.cs deleted file mode 100644 index 6b08ca2dbf..0000000000 --- a/tests/Agent/NewRelic.Testing.Assertions/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - -using System.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NewRelic.Testing.Assertions")] -[assembly: AssemblyDescription("A set of testing tools for extended assertions")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("New Relic")] -[assembly: AssemblyProduct("NewRelic.Testing.Assertions")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")]