From 5fa5a3614a2c0c6041061c197130d742f4ec0179 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Thu, 14 Jan 2021 11:13:22 +1000 Subject: [PATCH] Run test assemblies in parallel (#1106) This commit separates out the common test components from Elastic.Apm.Tests into a new assembly, Elastic.Apm.Tests.Utilities. This allows assemblies containing tests to be run in parallel, which is not possible when test assemblies reference another test assembly that may potentially be running at the same time. Update linux CI scripts to run tests by targeting the solution file. In conjunction with the xunit.runner.json configuration, this allows test assemblies to run in parallel. Add coverlet and JunitXml.TestLogger packages to all test projects using Directory.Build.Props in tests directory. This removes the need to add them in CI scripts or to each project individually. Update packages to newer versions. - Run tests with Release configuration - Include only Elastic.Apm.* and exclude all Elastic.Apm test assemblies from code coverage - Rename Elastic.Apm.DockerTests to Elastic.Apm.Docker.Tests for consistency - Rename Elastic.Apm.PerfTests to Elastic.Apm.Benchmarks - Use TestAgentComponents in test Update tests to use TestAgentComponents where possible, to mitigate intermittent failures with using AgentComponents related to reading environment variables that may be set by other concurrently running tests - Check token cancellation in Workloop check token cancellation in the BackendCommComponentBase Workloop, and break if cancellation is requested. - Don't Use SourceLink in coverlet.settings Jenkins cannot display Sourcelinked source code - Fix hanging tests Remove netcoreapp2.2 from tests. netcoreapp2.2 consistently hangs in CI on Linux due to MSBuild worker node reuse by dotnet test. This is the issue outlined in https://github.com/dotnet/sdk/issues/9452#issuecomment-417681156. Setting `nodereuse:false` when running linux dotnet test on netcoreapp2.2 fixes the tests hanging, but since netcoreapp2.2 is EOL by Microsoft on December 23, 2019 (https://dotnet.microsoft.com/platform/support/policy/dotnet-core), netcoreapp2.2 has been removed from tests in line with the policy that we should only support versions that are supported by Microsoft. --- .ci/linux/benchmark.sh | 2 +- .ci/linux/release.sh | 2 +- .ci/linux/test.sh | 66 +++++++------------ .ci/windows/dotnet.bat | 2 +- .ci/windows/msbuild.bat | 2 +- .ci/windows/test-iis.bat | 7 +- .ci/windows/test-tools.ps1 | 2 +- .ci/windows/test.bat | 5 +- .ci/windows/testnet461.bat | 2 +- CONTRIBUTING.md | 4 +- ElasticApmAgent.sln | 13 +++- Jenkinsfile | 2 +- coverlet.runsettings | 9 +-- src/Elastic.Apm.AspNetCore/ApmMiddleware.cs | 2 +- src/Elastic.Apm/Agent.cs | 20 +++--- .../BackendComm/BackendCommComponentBase.cs | 6 +- src/Elastic.Apm/Metrics/MetricsCollector.cs | 18 +++-- test/Directory.Build.props | 22 +++++++ .../ConfigTests.cs | 3 +- ...Elastic.Apm.AspNetCore.Static.Tests.csproj | 14 ++-- .../AspNetCoreBasicTests.cs | 3 +- .../AspNetCoreDiagnosticListenerTest.cs | 2 +- .../BodyCapturingTests.cs | 4 +- .../CaptureUserTest.cs | 3 +- .../DiagnosticListenerTests.cs | 2 +- .../DistributedTracingAspNetCoreTests.cs | 2 +- .../Elastic.Apm.AspNetCore.Tests.csproj | 13 ++-- .../FailedRequestTests.cs | 2 +- .../MicrosoftExtensionsConfigTests.cs | 4 +- .../SanitizeFieldNamesTests.cs | 2 +- .../TraceIdWithActivityTests.cs | 2 +- .../TransactionIgnoreUrlsTest.cs | 2 +- .../TransactionNameTests.cs | 3 +- .../CentralConfigTests.cs | 2 +- .../DbSpanTests.cs | 3 +- ...astic.Apm.AspNetFullFramework.Tests.csproj | 11 ++-- .../ErrorsTests.cs | 3 +- .../TestsBase.cs | 3 +- .../TestsEnabledDetector.cs | 2 +- .../WebApiTests.cs | 4 +- .../AspNetCoreLoadTestWithAgent.cs | 2 +- .../AspNetCoreLoadTestWithoutAgent.cs | 2 +- .../AspNetCorePerf/AspNetCoreSampleRunner.cs | 2 +- .../Elastic.Apm.Benchmarks.csproj} | 3 +- .../Helpers/GitInfo.cs | 2 +- .../MetricsBenchmarks.cs | 4 +- .../PerfTestLogger.cs | 2 +- .../Program.cs | 4 +- .../PropertyFetcherBenchmark.cs | 2 +- .../TraceParentBenchmarks.cs | 2 +- .../TracerBenchmarks.cs | 4 +- .../WildcardMatcherBenchmark.cs | 2 +- .../BasicDockerTests.cs | 2 +- .../ContainerIdCalculationTests.cs | 4 +- .../Elastic.Apm.Docker.Tests.csproj} | 15 ++--- .../Elastic.Apm.Elasticsearch.Tests.csproj | 11 ++-- .../VirtualElasticsearchTests.cs | 2 +- .../EfCoreDiagnosticListenerTests.cs | 3 +- ...astic.Apm.EntityFrameworkCore.Tests.csproj | 13 ++-- .../ExternalDbTests.cs | 4 +- ...lastic.Apm.Extensions.Hosting.Tests.csproj | 11 ++-- .../Elastic.Apm.Feature.Tests.csproj | 8 +-- .../FeatureContexts/ApiKeyFeatureContext.cs | 2 +- .../Elastic.Apm.Grpc.Tests.csproj | 13 ++-- test/Elastic.Apm.Grpc.Tests/GrpcTests.cs | 2 +- .../EfCoreWithMsSqlTests.cs | 5 +- .../Elastic.Apm.SqlClient.Tests.csproj | 15 ++--- .../SqlClientListenerTests.cs | 5 +- ...astic.Apm.StackExchange.Redis.Tests.csproj | 11 ++-- .../ProfilingSessionTests.cs | 2 +- .../AssertValidExtensions.cs | 2 +- .../Controllers/IntakeV2EventsController.cs | 2 +- .../Elastic.Apm.Tests.MockApmServer.csproj | 4 +- .../Program.cs | 2 +- .../AgentTimerForTesting.cs | 17 +++-- .../Data/TransactionMaxSpansTestData.cs | 2 +- .../DummyTestException.cs | 2 +- .../Elastic.Apm.Tests.Utilities.csproj | 19 ++++++ .../EnumerableExtensions.cs | 2 +- .../EnumerableTestExtensions.cs | 4 +- .../EnvVarUtils.cs | 2 +- .../FakeMetricsCollector.cs | 2 +- .../FluentAssertionsUtils.cs | 2 +- .../FlushingTextWriterToLineWriterAdaptor.cs | 2 +- .../FlushingTextWriterToLoggerAdaptor.cs | 2 +- .../ILineWriter.cs | 2 +- .../InMemoryBlockingLogger.cs | 2 +- .../IntExtensions.cs | 2 +- .../InternalsVisibleTo.cs | 50 ++++++++++++++ .../JsonUtils.cs | 2 +- .../LineWriterToLoggerAdaptor.cs | 2 +- .../LocalServer.cs | 2 +- .../LoggingTestBase.cs | 2 +- .../MockAgentTimer.cs | 27 ++++---- .../MockApmServerInfo.cs | 2 +- .../MockConfigSnapshot.cs | 2 +- .../MockHttpMessageHandler.cs | 2 +- .../MockPayloadSender.cs | 10 +-- .../MockPayloadSenderWithFilters.cs | 2 +- .../MultiThreadsTestUtils.cs | 5 +- .../NoopCentralConfigFetcher.cs | 3 +- .../NoopCurrentExecutionSegmentsContainer.cs | 3 +- .../NoopLogger.cs | 2 +- .../NoopPayloadSender.cs | 2 +- .../RandomTestHelper.cs | 2 +- .../ShouldWaitDurationExtensions.cs | 3 +- .../SplittingLineWriter.cs | 2 +- .../SystemDiagnosticsTraceLineWriter.cs | 2 +- .../TaskTestExtensions.cs | 4 +- .../TempFile.cs | 4 +- .../TestAgentComponents.cs | 3 +- .../TestLogger.cs | 2 +- .../TestingConfig.cs | 5 +- .../ThreadSafeIntCounter.cs | 2 +- .../ThreadSafeLongCounter.cs | 2 +- .../ToAllSinksLogger.cs | 2 +- .../WaitExtensions.cs | 2 +- .../XunitOutputToLineWriterAdaptor.cs | 2 +- .../ActivityIntegrationTests.cs | 2 +- test/Elastic.Apm.Tests/ApiTests/ApiTests.cs | 2 +- .../ApiTests/ConvenientApiSpanTests.cs | 34 +++++----- .../ApiTests/ConvenientApiTransactionTests.cs | 34 +++++----- .../ApiTests/CulpritTests.cs | 6 +- .../ApiTests/DistributedTracingDataTests.cs | 2 +- .../BackendCommTests/BackendCommUtilsTests.cs | 5 +- .../CentralConfigFetcherTests.cs | 48 ++++++++++---- .../CentralConfigResponseParserTests.cs | 2 +- .../BackendCommTests/PayloadSenderTests.cs | 5 +- test/Elastic.Apm.Tests/BasicAgentTests.cs | 6 +- .../Cloud/AwsCloudMetadataProviderTests.cs | 2 +- .../AzureAppServiceMetadataProviderTests.cs | 2 +- .../Cloud/AzureCloudMetadataProviderTests.cs | 2 +- .../CloudMetadataProviderCollectionTests.cs | 2 +- .../Cloud/GcpCloudMetadataProviderTests.cs | 2 +- test/Elastic.Apm.Tests/ConfigTests.cs | 4 +- .../Elastic.Apm.Tests.csproj | 14 ++-- .../EnabledAndRecordingTests.cs | 8 +-- test/Elastic.Apm.Tests/ErrorTests.cs | 36 +++++----- .../Extensions/EnumerableExtensionsTests.cs | 1 + test/Elastic.Apm.Tests/FilterTests.cs | 3 +- .../HelpersTests/AgentSpinLockTests.cs | 5 +- .../HelpersTests/AgentTimeInstantTests.cs | 7 +- .../HelpersTests/AgentTimerTests.cs | 5 +- .../HelpersTests/AssertionTests.cs | 2 +- .../HelpersTests/ContractExtensionsTests.cs | 2 +- .../DbConnectionStringParserTests.cs | 3 +- .../HelpersTests/DisposableHelperTests.cs | 2 +- .../HelpersTests/ExceptionUtilsTests.cs | 3 +- .../HelpersTests/IntExtensionsTests.cs | 2 +- .../HelpersTests/LazyContextualInitTests.cs | 3 +- .../HelpersTests/PlatformDetectionTests.cs | 4 +- .../HelpersTests/StringExtensionsTests.cs | 2 +- .../HelpersTests/TimeExtensionsTests.cs | 23 ++++--- .../HelpersTests/TimeUtilsTests.cs | 2 +- .../HelpersTests/UrlUtilsTests.cs | 2 +- .../HttpDiagnosticListenerTests.cs | 3 +- .../InstrumentationFlagTests.cs | 2 +- test/Elastic.Apm.Tests/LabelTests.cs | 2 +- test/Elastic.Apm.Tests/LoggerTests.cs | 6 +- .../Metrics/CgroupMetricsProviderTests.cs | 3 +- test/Elastic.Apm.Tests/MetricsTests.cs | 3 +- test/Elastic.Apm.Tests/SamplerTests.cs | 3 +- test/Elastic.Apm.Tests/SerializationTests.cs | 2 +- test/Elastic.Apm.Tests/SpanTests.cs | 10 +-- test/Elastic.Apm.Tests/StackTraceTests.cs | 2 +- test/Elastic.Apm.Tests/StaticTests.cs | 2 +- .../SystemInfoHelperTests.cs | 2 +- .../EnumerableTestExtensionsTests.cs | 1 + .../TestHelpers/MultiThreadsTestUtilsTests.cs | 1 + .../TestHelpers/RandomTestHelperTests.cs | 2 +- .../TestHelpers/TestingConfigTests.cs | 6 +- .../TestHelpers/TimeTestExtensions.cs | 25 ------- .../TestHelpers/TimeTestExtensionsTests.cs | 46 ------------- .../TransactionIgnoreUrlsTests.cs | 2 +- .../TransactionSamplingTests.cs | 3 +- .../MockAgentTimerTests.cs | 13 ++-- xunit.runner.json | 4 ++ 177 files changed, 552 insertions(+), 541 deletions(-) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs (95%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs (95%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/AspNetCorePerf/AspNetCoreSampleRunner.cs (96%) rename test/{Elastic.Apm.PerfTests/Elastic.Apm.PerfTests.csproj => Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj} (82%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/Helpers/GitInfo.cs (96%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/MetricsBenchmarks.cs (96%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/PerfTestLogger.cs (97%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/Program.cs (96%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/PropertyFetcherBenchmark.cs (98%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/TraceParentBenchmarks.cs (94%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/TracerBenchmarks.cs (97%) rename test/{Elastic.Apm.PerfTests => Elastic.Apm.Benchmarks}/WildcardMatcherBenchmark.cs (97%) rename test/{Elastic.Apm.DockerTests => Elastic.Apm.Docker.Tests}/BasicDockerTests.cs (95%) rename test/{Elastic.Apm.DockerTests => Elastic.Apm.Docker.Tests}/ContainerIdCalculationTests.cs (97%) rename test/{Elastic.Apm.DockerTests/Elastic.Apm.DockerTests.csproj => Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj} (56%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/AgentTimerForTesting.cs (88%) rename test/{Elastic.Apm.Tests => Elastic.Apm.Tests.Utilities}/Data/TransactionMaxSpansTestData.cs (95%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/DummyTestException.cs (93%) create mode 100644 test/Elastic.Apm.Tests.Utilities/Elastic.Apm.Tests.Utilities.csproj rename test/{Elastic.Apm.Tests/Extensions => Elastic.Apm.Tests.Utilities}/EnumerableExtensions.cs (98%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/EnumerableTestExtensions.cs (74%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/EnvVarUtils.cs (96%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/FakeMetricsCollector.cs (89%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/FluentAssertionsUtils.cs (89%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/FlushingTextWriterToLineWriterAdaptor.cs (94%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/FlushingTextWriterToLoggerAdaptor.cs (92%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/ILineWriter.cs (87%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/InMemoryBlockingLogger.cs (97%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/IntExtensions.cs (94%) create mode 100644 test/Elastic.Apm.Tests.Utilities/InternalsVisibleTo.cs rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/JsonUtils.cs (95%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/LineWriterToLoggerAdaptor.cs (96%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/LocalServer.cs (98%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/LoggingTestBase.cs (98%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockAgentTimer.cs (85%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockApmServerInfo.cs (93%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockConfigSnapshot.cs (99%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockHttpMessageHandler.cs (95%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockPayloadSender.cs (97%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/MockPayloadSenderWithFilters.cs (95%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/MultiThreadsTestUtils.cs (92%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/NoopCentralConfigFetcher.cs (84%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/NoopCurrentExecutionSegmentsContainer.cs (87%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/NoopLogger.cs (92%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/NoopPayloadSender.cs (93%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/RandomTestHelper.cs (98%) rename test/{Elastic.Apm.Tests/Extensions => Elastic.Apm.Tests.Utilities}/ShouldWaitDurationExtensions.cs (93%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/SplittingLineWriter.cs (92%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/SystemDiagnosticsTraceLineWriter.cs (93%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/TaskTestExtensions.cs (93%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/TempFile.cs (90%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/TestAgentComponents.cs (94%) rename test/{Elastic.Apm.Tests/Mocks => Elastic.Apm.Tests.Utilities}/TestLogger.cs (99%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/TestingConfig.cs (98%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/ThreadSafeIntCounter.cs (92%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/ThreadSafeLongCounter.cs (92%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/ToAllSinksLogger.cs (94%) rename test/{Elastic.Apm.Tests/Extensions => Elastic.Apm.Tests.Utilities}/WaitExtensions.cs (97%) rename test/{Elastic.Apm.Tests/TestHelpers => Elastic.Apm.Tests.Utilities}/XunitOutputToLineWriterAdaptor.cs (94%) delete mode 100644 test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensions.cs delete mode 100644 test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensionsTests.cs rename test/Elastic.Apm.Tests/{Mocks => Utilities}/MockAgentTimerTests.cs (96%) create mode 100644 xunit.runner.json diff --git a/.ci/linux/benchmark.sh b/.ci/linux/benchmark.sh index 43f809757..f7b931a6a 100755 --- a/.ci/linux/benchmark.sh +++ b/.ci/linux/benchmark.sh @@ -4,6 +4,6 @@ # set -euxo pipefail -cd ./test/Elastic.Apm.PerfTests +cd ./test/Elastic.Apm.Benchmarks dotnet run -c Release --filter AspNetCoreLoadTestWithAgent AspNetCoreLoadTestWithoutAgent dotnet run -c Release --filter *CollectAllMetrics2X* *Simple100Transaction10Spans* *SimpleTransactionsWith* diff --git a/.ci/linux/release.sh b/.ci/linux/release.sh index 5ef4c854c..e326546ab 100755 --- a/.ci/linux/release.sh +++ b/.ci/linux/release.sh @@ -19,7 +19,7 @@ if [ "${VERSION_SUFFIX_ENABLED}" = "true" ]; then fi # Remove sample projects - and other we don't want to pack -dotnet sln remove test/Elastic.Apm.PerfTests/Elastic.Apm.PerfTests.csproj +dotnet sln remove test/Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj dotnet sln remove test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj dotnet sln remove sample/AspNetFullFrameworkSampleApp/AspNetFullFrameworkSampleApp.csproj # shellcheck disable=SC2086 diff --git a/.ci/linux/test.sh b/.ci/linux/test.sh index 6f1a995b7..83562466d 100755 --- a/.ci/linux/test.sh +++ b/.ci/linux/test.sh @@ -8,46 +8,28 @@ set -euxo pipefail # Remove Full Framework projects .ci/linux/remove-projects.sh -# Configure the projects for coverage and testing -while IFS= read -r -d '' file -do - if [[ $file == *"AspNetFullFrameworkSampleApp.csproj"* ]]; then - continue - fi - if [[ $file == *"Elastic.Apm.AspNetFullFramework.csproj"* ]]; then - continue - fi - if [[ $file == *"Elastic.Apm.AspNetFullFramework.Tests.csproj"* ]]; then - continue - fi - dotnet add "$file" package JunitXml.TestLogger --version 2.1.15 -done < <(find . -name '*.csproj' -print0) +# Run tests for all solution +dotnet test -c Release ElasticApmAgent.sln \ + --verbosity normal \ + --results-directory target \ + --diag "target/diag-ElasticApmAgent.log" \ + --logger:"junit;LogFilePath=junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \ + --collect:"XPlat Code Coverage" \ + --settings coverlet.runsettings \ + /p:CollectCoverage=true \ + /p:CoverletOutputFormat=cobertura \ + /p:CoverletOutput=target/Coverage/ \ + /p:Threshold=0 \ + /p:ThresholdType=branch \ + /p:ThresholdStat=total \ + || echo -e "\033[31;49mTests FAILED\033[0m" -# Run tests per project to generate the coverage report individually. -while IFS= read -r -d '' file -do - projectName=$(basename "$file") - dotnet test "$file" \ - --verbosity normal \ - --results-directory target \ - --diag "target/diag-${projectName}.log" \ - --logger:"junit;LogFilePath=junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \ - --collect:"XPlat Code Coverage" \ - --settings coverlet.runsettings \ - /p:CollectCoverage=true \ - /p:CoverletOutputFormat=cobertura \ - /p:CoverletOutput=target/Coverage/ \ - /p:Threshold=0 \ - /p:ThresholdType=branch \ - /p:ThresholdStat=total \ - || echo -e "\033[31;49mTests FAILED\033[0m" - - echo 'Move coverage files if they were generated!' - if [ -d target ] ; then - find target -type f -name 'coverage.cobertura.xml' | - while IFS= read -r fileName; do - target=$(dirname "$fileName") - mv "$fileName" "${target}/${projectName}-${fileName##*\/}" - done - fi -done < <(find test -name '*.csproj' -print0) +echo 'Move coverage files if they were generated!' +if [ -d target ] ; then + find target -type f -name 'coverage.cobertura.xml' | + while IFS= read -r fileName; do + target=$(dirname "$fileName") + parent=$(basename "$target") + mv "$fileName" "${target}/${parent}-${fileName##*\/}" + done +fi diff --git a/.ci/windows/dotnet.bat b/.ci/windows/dotnet.bat index 3ba04bc13..dea6785a1 100644 --- a/.ci/windows/dotnet.bat +++ b/.ci/windows/dotnet.bat @@ -7,4 +7,4 @@ dotnet sln remove test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetF dotnet sln remove test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj dotnet sln remove test/Elastic.Apm.EntityFramework6.Tests/Elastic.Apm.EntityFramework6.Tests.csproj -dotnet build --verbosity detailed +dotnet build -c Release --verbosity detailed diff --git a/.ci/windows/msbuild.bat b/.ci/windows/msbuild.bat index 3cfb4451b..e501f816e 100644 --- a/.ci/windows/msbuild.bat +++ b/.ci/windows/msbuild.bat @@ -5,4 +5,4 @@ echo "Prepare context for VsDevCmd.bat" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat" nuget restore -verbosity detailed -NonInteractive -msbuild +msbuild /p:Configuration=Release diff --git a/.ci/windows/test-iis.bat b/.ci/windows/test-iis.bat index c1ac261e7..62cbda136 100644 --- a/.ci/windows/test-iis.bat +++ b/.ci/windows/test-iis.bat @@ -4,5 +4,8 @@ if not exist "%sample_app_log_dir%" mkdir "%sample_app_log_dir%" icacls %sample_app_log_dir% /t /grant Everyone:F set ELASTIC_APM_ASP_NET_FULL_FRAMEWORK_SAMPLE_APP_LOG_FILE=%sample_app_log_dir%\Elastic.Apm.AspNetFullFramework.Tests.SampleApp.log -dotnet test test\Elastic.Apm.AspNetFullFramework.Tests -v n -r target -d target\diag-iis.log --no-build ^ - --logger:"junit;LogFilePath=junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" ^ +dotnet test -c Release test\Elastic.Apm.AspNetFullFramework.Tests --no-build ^ + --verbosity normal ^ + --results-directory target ^ + --diag target\diag-iis.log ^ + --logger:"junit;LogFilePath=junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" diff --git a/.ci/windows/test-tools.ps1 b/.ci/windows/test-tools.ps1 index 3692ec6a5..3cfc5dbdf 100644 --- a/.ci/windows/test-tools.ps1 +++ b/.ci/windows/test-tools.ps1 @@ -7,6 +7,6 @@ dotnet tool install -g Codecov.Tool --version 1.2.0 Get-ChildItem -Path . -Recurse -Filter *.csproj | Foreach-Object { - dotnet add $_.FullName package JunitXml.TestLogger --version 2.1.15 + dotnet add $_.FullName package JunitXml.TestLogger --version 2.1.78 dotnet add $_.FullName package coverlet.msbuild --version 2.9.0 } diff --git a/.ci/windows/test.bat b/.ci/windows/test.bat index c7595032d..a1e43cb5b 100644 --- a/.ci/windows/test.bat +++ b/.ci/windows/test.bat @@ -2,7 +2,10 @@ :: This script runs the tests and stored them in an xml file defined in the :: LogFilePath property :: -dotnet test -v n -r target -d target\diag.log --no-build ^ +dotnet test -c Release --no-build ^ + --verbosity normal ^ + --results-directory target ^ + --diag target\diag.log ^ --logger:"junit;LogFilePath=junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" ^ /p:CollectCoverage=true ^ /p:CoverletOutputFormat=cobertura ^ diff --git a/.ci/windows/testnet461.bat b/.ci/windows/testnet461.bat index c96e50fbd..e6669bfdd 100644 --- a/.ci/windows/testnet461.bat +++ b/.ci/windows/testnet461.bat @@ -2,7 +2,7 @@ :: This script runs the tests and stored them in an xml file defined in the :: LogFilePath property :: -dotnet publish test\Elastic.Apm.Tests --framework net461 -o outtestnet461 +dotnet publish -c Release test\Elastic.Apm.Tests --framework net461 -o outtestnet461 dotnet vstest outtestnet461\Elastic.Apm.Tests.dll ^ --logger:"junit;LogFilePath=test\junit-{framework}-{assembly}.xml;MethodFormat=Class;FailureBodyFormat=Verbose" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 274f770be..f9eacf11e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -121,9 +121,9 @@ The agent is designed to monitor production applications. Therefore it's very im It's not uncommon that you write or change code that can potentially change the performance characteristics of the agent and therefore also of the application's of our users. -If this is the case then a perf. test should be added to the `test\Elastic.Apm.PerfTests` project which proves that the new code does not make the performance of the agent worse than it was before your PR. +If this is the case then a perf. test should be added to the `test\Elastic.Apm.Benchmarks` project which proves that the new code does not make the performance of the agent worse than it was before your PR. -We care both about memory and CPU overhead and both should be measured. The `test\Elastic.Apm.PerfTests` is configured to measure both. +We care both about memory and CPU overhead and both should be measured. The `test\Elastic.Apm.Benchmarks` is configured to measure both. #### Compatibility diff --git a/ElasticApmAgent.sln b/ElasticApmAgent.sln index ef0f980fa..dc7257abf 100644 --- a/ElasticApmAgent.sln +++ b/ElasticApmAgent.sln @@ -51,9 +51,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "files", "files", "{B406113B build.bat = build.bat build.sh = build.sh dotnet-tools.json = dotnet-tools.json + xunit.runner.json = xunit.runner.json + coverlet.runsettings = coverlet.runsettings EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.PerfTests", "test\Elastic.Apm.PerfTests\Elastic.Apm.PerfTests.csproj", "{F069CE99-F418-4BC2-9E44-8F03497D8DA8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.Benchmarks", "test\Elastic.Apm.Benchmarks\Elastic.Apm.Benchmarks.csproj", "{F069CE99-F418-4BC2-9E44-8F03497D8DA8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetFullFrameworkSampleApp", "sample\AspNetFullFrameworkSampleApp\AspNetFullFrameworkSampleApp.csproj", "{C45DCD78-7E8A-437C-ABBB-01D154ABCFC4}" EndProject @@ -63,7 +65,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.AspNetFullFrame EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.EntityFramework6", "src\Elastic.Apm.EntityFramework6\Elastic.Apm.EntityFramework6.csproj", "{12FFCFF6-858C-4E6E-935C-E304712DECA4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.DockerTests", "test\Elastic.Apm.DockerTests\Elastic.Apm.DockerTests.csproj", "{40B47FD4-6E67-4D52-B9A4-607B9D01D9F5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.Docker.Tests", "test\Elastic.Apm.Docker.Tests\Elastic.Apm.Docker.Tests.csproj", "{40B47FD4-6E67-4D52-B9A4-607B9D01D9F5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.AspNetFullFramework.Tests", "test\Elastic.Apm.AspNetFullFramework.Tests\Elastic.Apm.AspNetFullFramework.Tests.csproj", "{4253798D-A160-40B3-8F16-5BF64C559B93}" EndProject @@ -113,6 +115,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Specification", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.AspNetCore.Static.Tests", "test\Elastic.Apm.AspNetCore.Static.Tests\Elastic.Apm.AspNetCore.Static.Tests.csproj", "{2250D888-E4CC-4B2B-AF31-5C78D76EC73D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Tests.Utilities", "test\Elastic.Apm.Tests.Utilities\Elastic.Apm.Tests.Utilities.csproj", "{43F9247D-544B-49FB-9E50-FC236D90DE1A}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution test\Elastic.Apm.DatabaseTests.Common\Elastic.Apm.DatabaseTests.Common.projitems*{968e1e85-e996-42de-9845-d20dae16165a}*SharedItemsImports = 5 @@ -274,6 +278,10 @@ Global {2250D888-E4CC-4B2B-AF31-5C78D76EC73D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2250D888-E4CC-4B2B-AF31-5C78D76EC73D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2250D888-E4CC-4B2B-AF31-5C78D76EC73D}.Release|Any CPU.Build.0 = Release|Any CPU + {43F9247D-544B-49FB-9E50-FC236D90DE1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43F9247D-544B-49FB-9E50-FC236D90DE1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43F9247D-544B-49FB-9E50-FC236D90DE1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43F9247D-544B-49FB-9E50-FC236D90DE1A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -317,6 +325,7 @@ Global {CB623206-F69E-4004-8527-D4B971AA981A} = {B406113B-0917-4531-AFEE-66DDB952590F} {5D076C7F-1F8B-4B11-9910-48717D133963} = {3734A52F-2222-454B-BF58-1BA5C1F29D77} {2250D888-E4CC-4B2B-AF31-5C78D76EC73D} = {267A241E-571F-458F-B04C-B6C4DE79E735} + {43F9247D-544B-49FB-9E50-FC236D90DE1A} = {267A241E-571F-458F-B04C-B6C4DE79E735} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {69E02FD9-C9DE-412C-AB6B-5B8BECC6BFA5} diff --git a/Jenkinsfile b/Jenkinsfile index fe6ee814e..93bf9a461 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,7 +49,7 @@ pipeline { // Look for changes related to the benchmark, if so then set the env variable. def patternList = [ - '^test/Elastic.Apm.PerfTests/.*' + '^test/Elastic.Apm.Benchmarks/.*' ] env.BENCHMARK_UPDATED = isGitRegionMatch(patterns: patternList) } diff --git a/coverlet.runsettings b/coverlet.runsettings index b3cabb732..a1d76f6e0 100644 --- a/coverlet.runsettings +++ b/coverlet.runsettings @@ -4,11 +4,12 @@ - cobertura - "[Elastic.Apm.Tests]*,[SampleAspNetCoreApp*]*,[xunit*]*" + cobertura + [Elastic.*]*,[ElasticApmStartupHook]* + [Elastic.Apm.Tests]*,[Elastic.Apm.*.Tests]*,[Elastic.Apm.Tests.*]*,[Elastic.Apm.Benchmarks]* false - true - true + false + false diff --git a/src/Elastic.Apm.AspNetCore/ApmMiddleware.cs b/src/Elastic.Apm.AspNetCore/ApmMiddleware.cs index 33158b291..c1a632cee 100644 --- a/src/Elastic.Apm.AspNetCore/ApmMiddleware.cs +++ b/src/Elastic.Apm.AspNetCore/ApmMiddleware.cs @@ -19,7 +19,7 @@ "Elastic.Apm.AspNetCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] [assembly: InternalsVisibleTo( - "Elastic.Apm.PerfTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] + "Elastic.Apm.Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] [assembly: InternalsVisibleTo( "Elastic.Apm.Grpc.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] diff --git a/src/Elastic.Apm/Agent.cs b/src/Elastic.Apm/Agent.cs index 07aec4e64..e8154b874 100644 --- a/src/Elastic.Apm/Agent.cs +++ b/src/Elastic.Apm/Agent.cs @@ -12,6 +12,10 @@ using Elastic.Apm.Report; //TODO: It'd be nice to move this into the .csproj +// Moq library uses CastleProxy to build mocks, which generates temporary assembly DynamicProxyGenAssembly2. +[assembly: + InternalsVisibleTo( + "DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: InternalsVisibleTo( "Elastic.Apm.Extensions.Hosting, PublicKey=" + Signing.PublicKey)] @@ -47,19 +51,16 @@ "Elastic.Apm.AspNetCore.Static.Tests, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( - "Elastic.Apm.NetCoreAll, PublicKey=" + Signing.PublicKey)] + "Elastic.Apm.Benchmarks, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( "Elastic.Apm.NetCoreAll.Tests, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( - "Elastic.Apm.PerfTests, PublicKey=" + Signing.PublicKey)] + "Elastic.Apm.Docker.Tests, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( "Elastic.Apm.AspNetFullFramework, PublicKey=" + Signing.PublicKey)] -[assembly: - InternalsVisibleTo( - "Elastic.Apm.DockerTests, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( "Elastic.Apm.AspNetFullFramework.Tests, PublicKey=" + Signing.PublicKey)] @@ -72,10 +73,6 @@ [assembly: InternalsVisibleTo( "Elastic.Apm.Elasticsearch.Tests, PublicKey=" + Signing.PublicKey)] -// Moq library uses CastleProxy to build mocks, which generates temporary assembly DynamicProxyGenAssembly2. -[assembly: - InternalsVisibleTo( - "DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: InternalsVisibleTo( "Elastic.Apm.Feature.Tests, PublicKey=" + Signing.PublicKey)] @@ -90,13 +87,16 @@ "Elastic.Apm.Grpc.Tests, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( - "Elastic.Apm.Specification, PublicKey=" + Signing.PublicKey)] + "Elastic.Apm.Specification, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( "Elastic.Apm.StackExchange.Redis, PublicKey=" + Signing.PublicKey)] [assembly: InternalsVisibleTo( "Elastic.Apm.StackExchange.Redis.Tests, PublicKey=" + Signing.PublicKey)] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Tests.Utilities, PublicKey=" + Signing.PublicKey)] internal static class Signing { diff --git a/src/Elastic.Apm/BackendComm/BackendCommComponentBase.cs b/src/Elastic.Apm/BackendComm/BackendCommComponentBase.cs index d69895ce2..65b70f606 100644 --- a/src/Elastic.Apm/BackendComm/BackendCommComponentBase.cs +++ b/src/Elastic.Apm/BackendComm/BackendCommComponentBase.cs @@ -86,7 +86,8 @@ private async Task WorkLoop() await ExceptionUtils.DoSwallowingExceptions(_logger, async () => { - while (true) await WorkLoopIteration().ConfigureAwait(false); + while (!CancellationTokenSource.IsCancellationRequested) + await WorkLoopIteration().ConfigureAwait(false); // ReSharper disable once FunctionNeverReturns } , dbgCallerMethodName: ThisClassName + "." + DbgUtils.CurrentMethodName()).ConfigureAwait(false); @@ -106,13 +107,12 @@ public void Dispose() _disposableHelper.DoOnce(_logger, _dbgName, () => { _logger.Debug()?.Log("Calling CancellationTokenSource.Cancel()..."); - // ReSharper disable once AccessToDisposedClosure CancellationTokenSource.Cancel(); _logger.Debug()?.Log("Called CancellationTokenSource.Cancel()"); _logger.Debug() ?.Log("Waiting for loop to exit... Is cancellation token signaled: {IsCancellationRequested}", - CancellationTokenSource.Token.IsCancellationRequested); + CancellationTokenSource.IsCancellationRequested); _loopCompleted.Wait(); _logger.Debug()?.Log("Disposing _singleThreadTaskScheduler ..."); diff --git a/src/Elastic.Apm/Metrics/MetricsCollector.cs b/src/Elastic.Apm/Metrics/MetricsCollector.cs index 4e7cf4dc4..f703cd3e7 100644 --- a/src/Elastic.Apm/Metrics/MetricsCollector.cs +++ b/src/Elastic.Apm/Metrics/MetricsCollector.cs @@ -236,15 +236,19 @@ private List CollectMetricsFromProviders() public void Dispose() { - if (MetricsProviders == null) return; - - _timer?.Stop(); - _timer?.Dispose(); + if (_timer != null) + { + _timer.Stop(); + _timer.Dispose(); + } - foreach (var provider in MetricsProviders) + if (MetricsProviders != null) { - if (provider is IDisposable disposable) - disposable.Dispose(); + foreach (var provider in MetricsProviders) + { + if (provider is IDisposable disposable) + disposable.Dispose(); + } } } } diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 6504a1a59..c201ea535 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -8,5 +8,27 @@ false True + + true + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file diff --git a/test/Elastic.Apm.AspNetCore.Static.Tests/ConfigTests.cs b/test/Elastic.Apm.AspNetCore.Static.Tests/ConfigTests.cs index 01dac141f..f890d311f 100644 --- a/test/Elastic.Apm.AspNetCore.Static.Tests/ConfigTests.cs +++ b/test/Elastic.Apm.AspNetCore.Static.Tests/ConfigTests.cs @@ -10,8 +10,7 @@ using Elastic.Apm.AspNetCore.Tests; using Elastic.Apm.Config; using Elastic.Apm.Extensions.Hosting.Config; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.Configuration; diff --git a/test/Elastic.Apm.AspNetCore.Static.Tests/Elastic.Apm.AspNetCore.Static.Tests.csproj b/test/Elastic.Apm.AspNetCore.Static.Tests/Elastic.Apm.AspNetCore.Static.Tests.csproj index 01d5cc26a..44263fe04 100644 --- a/test/Elastic.Apm.AspNetCore.Static.Tests/Elastic.Apm.AspNetCore.Static.Tests.csproj +++ b/test/Elastic.Apm.AspNetCore.Static.Tests/Elastic.Apm.AspNetCore.Static.Tests.csproj @@ -5,15 +5,13 @@ - - + + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - - @@ -36,7 +34,7 @@ - + diff --git a/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreBasicTests.cs b/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreBasicTests.cs index 93ccaef2d..870afffe6 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreBasicTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreBasicTests.cs @@ -18,8 +18,7 @@ using Elastic.Apm.Extensions.Hosting; using Elastic.Apm.Logging; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; diff --git a/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreDiagnosticListenerTest.cs b/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreDiagnosticListenerTest.cs index 9a99050d8..d9de53a71 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreDiagnosticListenerTest.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/AspNetCoreDiagnosticListenerTest.cs @@ -10,7 +10,7 @@ using Elastic.Apm.AspNetCore.DiagnosticListener; using Elastic.Apm.Config; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetCore.Tests/BodyCapturingTests.cs b/test/Elastic.Apm.AspNetCore.Tests/BodyCapturingTests.cs index 0a0ee7870..1c128c5da 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/BodyCapturingTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/BodyCapturingTests.cs @@ -14,9 +14,7 @@ using System.Threading.Tasks; using Elastic.Apm.Config; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Core; diff --git a/test/Elastic.Apm.AspNetCore.Tests/CaptureUserTest.cs b/test/Elastic.Apm.AspNetCore.Tests/CaptureUserTest.cs index 3747769fd..2b5e7630b 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/CaptureUserTest.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/CaptureUserTest.cs @@ -10,10 +10,11 @@ using System.Security.Claims; using System.Threading.Tasks; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetCore.Tests/DiagnosticListenerTests.cs b/test/Elastic.Apm.AspNetCore.Tests/DiagnosticListenerTests.cs index 5df9dbf7d..7821bf4c9 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/DiagnosticListenerTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/DiagnosticListenerTests.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Elastic.Apm.AspNetCore.DiagnosticListener; using Elastic.Apm.EntityFrameworkCore; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetCore.Tests/DistributedTracingAspNetCoreTests.cs b/test/Elastic.Apm.AspNetCore.Tests/DistributedTracingAspNetCoreTests.cs index fced6af35..6aa7ea146 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/DistributedTracingAspNetCoreTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/DistributedTracingAspNetCoreTests.cs @@ -10,7 +10,7 @@ using Elastic.Apm.DiagnosticSource; using Elastic.Apm.DistributedTracing; using Elastic.Apm.EntityFrameworkCore; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; diff --git a/test/Elastic.Apm.AspNetCore.Tests/Elastic.Apm.AspNetCore.Tests.csproj b/test/Elastic.Apm.AspNetCore.Tests/Elastic.Apm.AspNetCore.Tests.csproj index cd834f311..9d8c156be 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/Elastic.Apm.AspNetCore.Tests.csproj +++ b/test/Elastic.Apm.AspNetCore.Tests/Elastic.Apm.AspNetCore.Tests.csproj @@ -7,14 +7,13 @@ - - + + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - @@ -37,7 +36,7 @@ - + diff --git a/test/Elastic.Apm.AspNetCore.Tests/FailedRequestTests.cs b/test/Elastic.Apm.AspNetCore.Tests/FailedRequestTests.cs index acd65564d..e8e57a6f5 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/FailedRequestTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/FailedRequestTests.cs @@ -9,7 +9,7 @@ using Elastic.Apm.Api; using Elastic.Apm.DiagnosticSource; using Elastic.Apm.EntityFrameworkCore; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; diff --git a/test/Elastic.Apm.AspNetCore.Tests/MicrosoftExtensionsConfigTests.cs b/test/Elastic.Apm.AspNetCore.Tests/MicrosoftExtensionsConfigTests.cs index 15e66a553..5e714bec3 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/MicrosoftExtensionsConfigTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/MicrosoftExtensionsConfigTests.cs @@ -12,8 +12,8 @@ using Elastic.Apm.Config; using Elastic.Apm.Extensions.Hosting.Config; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Data; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; +using Elastic.Apm.Tests.Utilities.Data; using FluentAssertions; using FluentAssertions.Extensions; using Microsoft.AspNetCore.Mvc.Testing; diff --git a/test/Elastic.Apm.AspNetCore.Tests/SanitizeFieldNamesTests.cs b/test/Elastic.Apm.AspNetCore.Tests/SanitizeFieldNamesTests.cs index 653cf117a..98c9ca3b6 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/SanitizeFieldNamesTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/SanitizeFieldNamesTests.cs @@ -8,7 +8,7 @@ using System.Net.Http; using System.Threading.Tasks; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetCore.Tests/TraceIdWithActivityTests.cs b/test/Elastic.Apm.AspNetCore.Tests/TraceIdWithActivityTests.cs index 591f9c2e8..780d5469f 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/TraceIdWithActivityTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/TraceIdWithActivityTests.cs @@ -7,7 +7,7 @@ using System.Net.Http; using System.Threading.Tasks; using Elastic.Apm.Extensions.Hosting; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using Xunit; diff --git a/test/Elastic.Apm.AspNetCore.Tests/TransactionIgnoreUrlsTest.cs b/test/Elastic.Apm.AspNetCore.Tests/TransactionIgnoreUrlsTest.cs index 23707678a..dcc90e16f 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/TransactionIgnoreUrlsTest.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/TransactionIgnoreUrlsTest.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Elastic.Apm.Extensions.Hosting; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetCore.Tests/TransactionNameTests.cs b/test/Elastic.Apm.AspNetCore.Tests/TransactionNameTests.cs index ac0a04597..2b09fd414 100644 --- a/test/Elastic.Apm.AspNetCore.Tests/TransactionNameTests.cs +++ b/test/Elastic.Apm.AspNetCore.Tests/TransactionNameTests.cs @@ -6,8 +6,7 @@ using System.Threading.Tasks; using Elastic.Apm.Extensions.Hosting; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using SampleAspNetCoreApp; diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/CentralConfigTests.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/CentralConfigTests.cs index 19ef20866..87f0cafb6 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/CentralConfigTests.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/CentralConfigTests.cs @@ -11,7 +11,7 @@ using AspNetFullFrameworkSampleApp.Controllers; using Elastic.Apm.Config; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Extensions; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/DbSpanTests.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/DbSpanTests.cs index a0f40634b..25e352c44 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/DbSpanTests.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/DbSpanTests.cs @@ -7,9 +7,8 @@ using System.Threading.Tasks; using AspNetFullFrameworkSampleApp.Controllers; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Extensions; using Elastic.Apm.Tests.MockApmServer; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj b/test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj index 5c0c72bf4..6e7211b51 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj @@ -14,13 +14,12 @@ - - + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - @@ -31,7 +30,7 @@ TargetFramework=net461 - + diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/ErrorsTests.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/ErrorsTests.cs index 3d4747684..74fd1af59 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/ErrorsTests.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/ErrorsTests.cs @@ -7,9 +7,8 @@ using System.Threading.Tasks; using AspNetFullFrameworkSampleApp.Controllers; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Extensions; using Elastic.Apm.Tests.MockApmServer; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs index a8b86c40f..dcdd39ff3 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs @@ -19,9 +19,8 @@ using Elastic.Apm.Config; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Extensions; using Elastic.Apm.Tests.MockApmServer; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/TestsEnabledDetector.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/TestsEnabledDetector.cs index 3d1719718..7418c2d12 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/TestsEnabledDetector.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/TestsEnabledDetector.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; namespace Elastic.Apm.AspNetFullFramework.Tests { diff --git a/test/Elastic.Apm.AspNetFullFramework.Tests/WebApiTests.cs b/test/Elastic.Apm.AspNetFullFramework.Tests/WebApiTests.cs index a7926fd27..694b2e24e 100644 --- a/test/Elastic.Apm.AspNetFullFramework.Tests/WebApiTests.cs +++ b/test/Elastic.Apm.AspNetFullFramework.Tests/WebApiTests.cs @@ -5,10 +5,8 @@ using System.IO; using System.Net.Http; -using System.Net.Http.Headers; -using System.Text; using System.Threading.Tasks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs similarity index 95% rename from test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs rename to test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs index 55618a262..3374ce3b3 100644 --- a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs +++ b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithAgent.cs @@ -5,7 +5,7 @@ using System.Net.Http; using BenchmarkDotNet.Attributes; -namespace Elastic.Apm.PerfTests.AspNetCorePerf +namespace Elastic.Apm.Benchmarks.AspNetCorePerf { /// /// A Test which triggers a simple ASP.NET Core endpoint and measures the response time while the agent is active in the diff --git a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs similarity index 95% rename from test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs rename to test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs index 922139377..c690047d5 100644 --- a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs +++ b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreLoadTestWithoutAgent.cs @@ -5,7 +5,7 @@ using System.Net.Http; using BenchmarkDotNet.Attributes; -namespace Elastic.Apm.PerfTests.AspNetCorePerf +namespace Elastic.Apm.Benchmarks.AspNetCorePerf { /// /// A Test which triggers a simple ASP.NET Core endpoint and measures the response WITHOUT agent. diff --git a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreSampleRunner.cs b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreSampleRunner.cs similarity index 96% rename from test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreSampleRunner.cs rename to test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreSampleRunner.cs index d22929517..d47924d1f 100644 --- a/test/Elastic.Apm.PerfTests/AspNetCorePerf/AspNetCoreSampleRunner.cs +++ b/test/Elastic.Apm.Benchmarks/AspNetCorePerf/AspNetCoreSampleRunner.cs @@ -12,7 +12,7 @@ using Microsoft.Extensions.DependencyInjection; using SampleAspNetCoreApp; -namespace Elastic.Apm.PerfTests.AspNetCorePerf +namespace Elastic.Apm.Benchmarks.AspNetCorePerf { public class AspNetCoreSampleRunner { diff --git a/test/Elastic.Apm.PerfTests/Elastic.Apm.PerfTests.csproj b/test/Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj similarity index 82% rename from test/Elastic.Apm.PerfTests/Elastic.Apm.PerfTests.csproj rename to test/Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj index 23bc39bea..844f70756 100644 --- a/test/Elastic.Apm.PerfTests/Elastic.Apm.PerfTests.csproj +++ b/test/Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj @@ -4,6 +4,7 @@ Exe netcoreapp3.0 7.3 + false @@ -15,7 +16,7 @@ - + diff --git a/test/Elastic.Apm.PerfTests/Helpers/GitInfo.cs b/test/Elastic.Apm.Benchmarks/Helpers/GitInfo.cs similarity index 96% rename from test/Elastic.Apm.PerfTests/Helpers/GitInfo.cs rename to test/Elastic.Apm.Benchmarks/Helpers/GitInfo.cs index 80aa9c04e..8e35558e7 100644 --- a/test/Elastic.Apm.PerfTests/Helpers/GitInfo.cs +++ b/test/Elastic.Apm.Benchmarks/Helpers/GitInfo.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; -namespace Elastic.Apm.PerfTests.Helpers +namespace Elastic.Apm.Benchmarks.Helpers { /// /// A helper class to get git related info about the git repo where the benchmark is running. diff --git a/test/Elastic.Apm.PerfTests/MetricsBenchmarks.cs b/test/Elastic.Apm.Benchmarks/MetricsBenchmarks.cs similarity index 96% rename from test/Elastic.Apm.PerfTests/MetricsBenchmarks.cs rename to test/Elastic.Apm.Benchmarks/MetricsBenchmarks.cs index 8f80a3ba8..8b2bc5bc6 100644 --- a/test/Elastic.Apm.PerfTests/MetricsBenchmarks.cs +++ b/test/Elastic.Apm.Benchmarks/MetricsBenchmarks.cs @@ -6,9 +6,9 @@ using Elastic.Apm.Config; using Elastic.Apm.Metrics; using Elastic.Apm.Metrics.MetricsProvider; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { [MemoryDiagnoser] public class MetricsBenchmarks diff --git a/test/Elastic.Apm.PerfTests/PerfTestLogger.cs b/test/Elastic.Apm.Benchmarks/PerfTestLogger.cs similarity index 97% rename from test/Elastic.Apm.PerfTests/PerfTestLogger.cs rename to test/Elastic.Apm.Benchmarks/PerfTestLogger.cs index 5a3b765b2..b057318dd 100644 --- a/test/Elastic.Apm.PerfTests/PerfTestLogger.cs +++ b/test/Elastic.Apm.Benchmarks/PerfTestLogger.cs @@ -8,7 +8,7 @@ using System.Text; using Elastic.Apm.Logging; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { /// /// A logger that doesn't do anything. diff --git a/test/Elastic.Apm.PerfTests/Program.cs b/test/Elastic.Apm.Benchmarks/Program.cs similarity index 96% rename from test/Elastic.Apm.PerfTests/Program.cs rename to test/Elastic.Apm.Benchmarks/Program.cs index 7738909d5..99cc8678d 100644 --- a/test/Elastic.Apm.PerfTests/Program.cs +++ b/test/Elastic.Apm.Benchmarks/Program.cs @@ -7,10 +7,10 @@ using System.IO; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Running; -using Elastic.Apm.PerfTests.Helpers; +using Elastic.Apm.Benchmarks.Helpers; using Elastic.CommonSchema.BenchmarkDotNetExporter; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { public class Program { diff --git a/test/Elastic.Apm.PerfTests/PropertyFetcherBenchmark.cs b/test/Elastic.Apm.Benchmarks/PropertyFetcherBenchmark.cs similarity index 98% rename from test/Elastic.Apm.PerfTests/PropertyFetcherBenchmark.cs rename to test/Elastic.Apm.Benchmarks/PropertyFetcherBenchmark.cs index cce5f0241..f35a871b6 100644 --- a/test/Elastic.Apm.PerfTests/PropertyFetcherBenchmark.cs +++ b/test/Elastic.Apm.Benchmarks/PropertyFetcherBenchmark.cs @@ -8,7 +8,7 @@ using Elastic.Apm.Helpers; using Microsoft.Data.SqlClient; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { public class PropertyFetcherBenchmark { diff --git a/test/Elastic.Apm.PerfTests/TraceParentBenchmarks.cs b/test/Elastic.Apm.Benchmarks/TraceParentBenchmarks.cs similarity index 94% rename from test/Elastic.Apm.PerfTests/TraceParentBenchmarks.cs rename to test/Elastic.Apm.Benchmarks/TraceParentBenchmarks.cs index 0757cbe2d..d801daf45 100644 --- a/test/Elastic.Apm.PerfTests/TraceParentBenchmarks.cs +++ b/test/Elastic.Apm.Benchmarks/TraceParentBenchmarks.cs @@ -6,7 +6,7 @@ using BenchmarkDotNet.Attributes; using Elastic.Apm.DistributedTracing; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { [MemoryDiagnoser] public class TraceParentBenchmarks diff --git a/test/Elastic.Apm.PerfTests/TracerBenchmarks.cs b/test/Elastic.Apm.Benchmarks/TracerBenchmarks.cs similarity index 97% rename from test/Elastic.Apm.PerfTests/TracerBenchmarks.cs rename to test/Elastic.Apm.Benchmarks/TracerBenchmarks.cs index add0c52c3..49bfb5c91 100644 --- a/test/Elastic.Apm.PerfTests/TracerBenchmarks.cs +++ b/test/Elastic.Apm.Benchmarks/TracerBenchmarks.cs @@ -4,9 +4,9 @@ using BenchmarkDotNet.Attributes; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { /// /// Benchmarks related to tracer (like starting a transaction, span, etc.) diff --git a/test/Elastic.Apm.PerfTests/WildcardMatcherBenchmark.cs b/test/Elastic.Apm.Benchmarks/WildcardMatcherBenchmark.cs similarity index 97% rename from test/Elastic.Apm.PerfTests/WildcardMatcherBenchmark.cs rename to test/Elastic.Apm.Benchmarks/WildcardMatcherBenchmark.cs index 4fcf1cf43..5b7e13003 100644 --- a/test/Elastic.Apm.PerfTests/WildcardMatcherBenchmark.cs +++ b/test/Elastic.Apm.Benchmarks/WildcardMatcherBenchmark.cs @@ -7,7 +7,7 @@ using BenchmarkDotNet.Attributes; using Elastic.Apm.Helpers; -namespace Elastic.Apm.PerfTests +namespace Elastic.Apm.Benchmarks { [MemoryDiagnoser] public class WildcardMatcherBenchmark diff --git a/test/Elastic.Apm.DockerTests/BasicDockerTests.cs b/test/Elastic.Apm.Docker.Tests/BasicDockerTests.cs similarity index 95% rename from test/Elastic.Apm.DockerTests/BasicDockerTests.cs rename to test/Elastic.Apm.Docker.Tests/BasicDockerTests.cs index 60d16414b..894fac504 100644 --- a/test/Elastic.Apm.DockerTests/BasicDockerTests.cs +++ b/test/Elastic.Apm.Docker.Tests/BasicDockerTests.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Xunit; -namespace Elastic.Apm.DockerTests +namespace Elastic.Apm.Docker.Tests { public class BasicDockerTests { diff --git a/test/Elastic.Apm.DockerTests/ContainerIdCalculationTests.cs b/test/Elastic.Apm.Docker.Tests/ContainerIdCalculationTests.cs similarity index 97% rename from test/Elastic.Apm.DockerTests/ContainerIdCalculationTests.cs rename to test/Elastic.Apm.Docker.Tests/ContainerIdCalculationTests.cs index d7c74ea95..f21502aa7 100644 --- a/test/Elastic.Apm.DockerTests/ContainerIdCalculationTests.cs +++ b/test/Elastic.Apm.Docker.Tests/ContainerIdCalculationTests.cs @@ -7,11 +7,11 @@ using Elastic.Apm.Config; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; -namespace Elastic.Apm.DockerTests +namespace Elastic.Apm.Docker.Tests { public class ContainerIdCalculationTests { diff --git a/test/Elastic.Apm.DockerTests/Elastic.Apm.DockerTests.csproj b/test/Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj similarity index 56% rename from test/Elastic.Apm.DockerTests/Elastic.Apm.DockerTests.csproj rename to test/Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj index 553d0c409..d1205cff8 100644 --- a/test/Elastic.Apm.DockerTests/Elastic.Apm.DockerTests.csproj +++ b/test/Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj @@ -1,24 +1,21 @@  - netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 - Elastic.Apm.DockerTests - Elastic.Apm.DockerTests + netcoreapp2.1;netcoreapp3.0;netcoreapp3.1 - - + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - + diff --git a/test/Elastic.Apm.Elasticsearch.Tests/Elastic.Apm.Elasticsearch.Tests.csproj b/test/Elastic.Apm.Elasticsearch.Tests/Elastic.Apm.Elasticsearch.Tests.csproj index 4f02ecf71..79e37b08d 100644 --- a/test/Elastic.Apm.Elasticsearch.Tests/Elastic.Apm.Elasticsearch.Tests.csproj +++ b/test/Elastic.Apm.Elasticsearch.Tests/Elastic.Apm.Elasticsearch.Tests.csproj @@ -8,10 +8,13 @@ - + - - + + + all + runtime; build; native; contentfiles; analyzers + @@ -19,7 +22,7 @@ - + diff --git a/test/Elastic.Apm.Elasticsearch.Tests/VirtualElasticsearchTests.cs b/test/Elastic.Apm.Elasticsearch.Tests/VirtualElasticsearchTests.cs index 52f7699b3..aa8e60723 100644 --- a/test/Elastic.Apm.Elasticsearch.Tests/VirtualElasticsearchTests.cs +++ b/test/Elastic.Apm.Elasticsearch.Tests/VirtualElasticsearchTests.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Threading.Tasks; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using Elasticsearch.Net; using Elasticsearch.Net.VirtualizedCluster; using FluentAssertions; diff --git a/test/Elastic.Apm.EntityFrameworkCore.Tests/EfCoreDiagnosticListenerTests.cs b/test/Elastic.Apm.EntityFrameworkCore.Tests/EfCoreDiagnosticListenerTests.cs index 33a519b67..d8ced584f 100644 --- a/test/Elastic.Apm.EntityFrameworkCore.Tests/EfCoreDiagnosticListenerTests.cs +++ b/test/Elastic.Apm.EntityFrameworkCore.Tests/EfCoreDiagnosticListenerTests.cs @@ -6,7 +6,7 @@ using System.Data.Common; using System.Threading.Tasks; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; @@ -43,6 +43,7 @@ public EfCoreDiagnosticListenerTests() public void Dispose() { _connection?.Close(); + _connection?.Dispose(); _dbContext?.Dispose(); _apmAgent?.Dispose(); } diff --git a/test/Elastic.Apm.EntityFrameworkCore.Tests/Elastic.Apm.EntityFrameworkCore.Tests.csproj b/test/Elastic.Apm.EntityFrameworkCore.Tests/Elastic.Apm.EntityFrameworkCore.Tests.csproj index 4b40f6e6c..733d84941 100644 --- a/test/Elastic.Apm.EntityFrameworkCore.Tests/Elastic.Apm.EntityFrameworkCore.Tests.csproj +++ b/test/Elastic.Apm.EntityFrameworkCore.Tests/Elastic.Apm.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.0;netcoreapp3.1 Elastic.Apm.EntityFrameworkCore.Tests Elastic.Apm.EntityFrameworkCore.Tests @@ -12,19 +12,18 @@ - - + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - + diff --git a/test/Elastic.Apm.EntityFrameworkCore.Tests/ExternalDbTests.cs b/test/Elastic.Apm.EntityFrameworkCore.Tests/ExternalDbTests.cs index ec509ab8b..eecf4ec76 100644 --- a/test/Elastic.Apm.EntityFrameworkCore.Tests/ExternalDbTests.cs +++ b/test/Elastic.Apm.EntityFrameworkCore.Tests/ExternalDbTests.cs @@ -9,9 +9,7 @@ using Elastic.Apm.Api; using Elastic.Apm.Helpers; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.EntityFrameworkCore; using MySql.Data.MySqlClient; diff --git a/test/Elastic.Apm.Extensions.Hosting.Tests/Elastic.Apm.Extensions.Hosting.Tests.csproj b/test/Elastic.Apm.Extensions.Hosting.Tests/Elastic.Apm.Extensions.Hosting.Tests.csproj index c9f13f1ce..e44a08e92 100644 --- a/test/Elastic.Apm.Extensions.Hosting.Tests/Elastic.Apm.Extensions.Hosting.Tests.csproj +++ b/test/Elastic.Apm.Extensions.Hosting.Tests/Elastic.Apm.Extensions.Hosting.Tests.csproj @@ -7,14 +7,13 @@ - - + + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - diff --git a/test/Elastic.Apm.Feature.Tests/Elastic.Apm.Feature.Tests.csproj b/test/Elastic.Apm.Feature.Tests/Elastic.Apm.Feature.Tests.csproj index 57b6ad3e4..85a3dd649 100644 --- a/test/Elastic.Apm.Feature.Tests/Elastic.Apm.Feature.Tests.csproj +++ b/test/Elastic.Apm.Feature.Tests/Elastic.Apm.Feature.Tests.csproj @@ -7,11 +7,7 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -19,7 +15,7 @@ - + diff --git a/test/Elastic.Apm.Feature.Tests/FeatureContexts/ApiKeyFeatureContext.cs b/test/Elastic.Apm.Feature.Tests/FeatureContexts/ApiKeyFeatureContext.cs index 20a610948..5ddd3c6a0 100644 --- a/test/Elastic.Apm.Feature.Tests/FeatureContexts/ApiKeyFeatureContext.cs +++ b/test/Elastic.Apm.Feature.Tests/FeatureContexts/ApiKeyFeatureContext.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Elastic.Apm.Model; using Elastic.Apm.Report; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; namespace Elastic.Apm.Feature.Tests.FeatureContexts diff --git a/test/Elastic.Apm.Grpc.Tests/Elastic.Apm.Grpc.Tests.csproj b/test/Elastic.Apm.Grpc.Tests/Elastic.Apm.Grpc.Tests.csproj index 605a7bea9..8f8d046e6 100644 --- a/test/Elastic.Apm.Grpc.Tests/Elastic.Apm.Grpc.Tests.csproj +++ b/test/Elastic.Apm.Grpc.Tests/Elastic.Apm.Grpc.Tests.csproj @@ -8,14 +8,13 @@ - - + + + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers - - - @@ -33,7 +32,7 @@ - + diff --git a/test/Elastic.Apm.Grpc.Tests/GrpcTests.cs b/test/Elastic.Apm.Grpc.Tests/GrpcTests.cs index 9294746c3..56672fdad 100644 --- a/test/Elastic.Apm.Grpc.Tests/GrpcTests.cs +++ b/test/Elastic.Apm.Grpc.Tests/GrpcTests.cs @@ -6,7 +6,7 @@ using Elastic.Apm.AspNetCore.DiagnosticListener; using Elastic.Apm.DiagnosticSource; using Elastic.Apm.GrpcClient; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Grpc.Net.Client; using GrpcServiceSample; diff --git a/test/Elastic.Apm.SqlClient.Tests/EfCoreWithMsSqlTests.cs b/test/Elastic.Apm.SqlClient.Tests/EfCoreWithMsSqlTests.cs index 42a7441fe..07947f1a3 100644 --- a/test/Elastic.Apm.SqlClient.Tests/EfCoreWithMsSqlTests.cs +++ b/test/Elastic.Apm.SqlClient.Tests/EfCoreWithMsSqlTests.cs @@ -7,8 +7,7 @@ using System.Linq; using Elastic.Apm.DatabaseTests.Common; using Elastic.Apm.EntityFrameworkCore; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.EntityFrameworkCore; using Xunit; @@ -32,7 +31,7 @@ public EfCoreWithMsSqlTests(ITestOutputHelper testOutputHelper, DatabaseFixture _connectionString = sqlClientListenerFixture.ConnectionString; _payloadSender = new MockPayloadSender(); - _apmAgent = new ApmAgent(new AgentComponents( + _apmAgent = new ApmAgent(new TestAgentComponents( new LineWriterToLoggerAdaptor(new XunitOutputToLineWriterAdaptor(testOutputHelper)), payloadSender: _payloadSender)); _apmAgent.Subscribe(new SqlClientDiagnosticSubscriber(), new EfCoreDiagnosticsSubscriber()); diff --git a/test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj b/test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj index 3b86c96e4..097439f5a 100644 --- a/test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj +++ b/test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj @@ -15,17 +15,16 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + + all + runtime; build; native; contentfiles; analyzers + @@ -33,7 +32,7 @@ - + diff --git a/test/Elastic.Apm.SqlClient.Tests/SqlClientListenerTests.cs b/test/Elastic.Apm.SqlClient.Tests/SqlClientListenerTests.cs index 2e4000c9f..79cd998c7 100644 --- a/test/Elastic.Apm.SqlClient.Tests/SqlClientListenerTests.cs +++ b/test/Elastic.Apm.SqlClient.Tests/SqlClientListenerTests.cs @@ -9,8 +9,7 @@ using System.Threading.Tasks; using Elastic.Apm.Api; using Elastic.Apm.DatabaseTests.Common; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; @@ -36,7 +35,7 @@ public SqlClientListenerTests(ITestOutputHelper testOutputHelper, DatabaseFixtur _testOutputHelper = testOutputHelper; _payloadSender = new MockPayloadSender(); - _apmAgent = new ApmAgent(new AgentComponents( + _apmAgent = new ApmAgent(new TestAgentComponents( new LineWriterToLoggerAdaptor(new XunitOutputToLineWriterAdaptor(_testOutputHelper)), payloadSender: _payloadSender)); _apmAgent.Subscribe(new SqlClientDiagnosticSubscriber()); diff --git a/test/Elastic.Apm.StackExchange.Redis.Tests/Elastic.Apm.StackExchange.Redis.Tests.csproj b/test/Elastic.Apm.StackExchange.Redis.Tests/Elastic.Apm.StackExchange.Redis.Tests.csproj index 528cf3f98..9dbaf85ef 100644 --- a/test/Elastic.Apm.StackExchange.Redis.Tests/Elastic.Apm.StackExchange.Redis.Tests.csproj +++ b/test/Elastic.Apm.StackExchange.Redis.Tests/Elastic.Apm.StackExchange.Redis.Tests.csproj @@ -8,10 +8,13 @@ - + - - + + + all + runtime; build; native; contentfiles; analyzers + @@ -21,7 +24,7 @@ - + diff --git a/test/Elastic.Apm.StackExchange.Redis.Tests/ProfilingSessionTests.cs b/test/Elastic.Apm.StackExchange.Redis.Tests/ProfilingSessionTests.cs index 702a7bc19..a505f49c6 100644 --- a/test/Elastic.Apm.StackExchange.Redis.Tests/ProfilingSessionTests.cs +++ b/test/Elastic.Apm.StackExchange.Redis.Tests/ProfilingSessionTests.cs @@ -10,8 +10,8 @@ using DotNet.Testcontainers.Containers.Configurations.Databases; using DotNet.Testcontainers.Containers.Modules.Databases; using Elastic.Apm.Api; +using Elastic.Apm.Tests.Utilities; using StackExchange.Redis; -using Elastic.Apm.Tests.Mocks; using FluentAssertions; namespace Elastic.Apm.StackExchange.Redis.Tests diff --git a/test/Elastic.Apm.Tests.MockApmServer/AssertValidExtensions.cs b/test/Elastic.Apm.Tests.MockApmServer/AssertValidExtensions.cs index f41e940f7..3f3547e4a 100644 --- a/test/Elastic.Apm.Tests.MockApmServer/AssertValidExtensions.cs +++ b/test/Elastic.Apm.Tests.MockApmServer/AssertValidExtensions.cs @@ -7,7 +7,7 @@ using Elastic.Apm.Api; using Elastic.Apm.DistributedTracing; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; namespace Elastic.Apm.Tests.MockApmServer diff --git a/test/Elastic.Apm.Tests.MockApmServer/Controllers/IntakeV2EventsController.cs b/test/Elastic.Apm.Tests.MockApmServer/Controllers/IntakeV2EventsController.cs index b157c2dd3..0d278dfb5 100644 --- a/test/Elastic.Apm.Tests.MockApmServer/Controllers/IntakeV2EventsController.cs +++ b/test/Elastic.Apm.Tests.MockApmServer/Controllers/IntakeV2EventsController.cs @@ -11,8 +11,8 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; +using Elastic.Apm.Tests.Utilities; using Elastic.Apm.Specification; -using Elastic.Apm.Tests.TestHelpers; using FluentAssertions; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; diff --git a/test/Elastic.Apm.Tests.MockApmServer/Elastic.Apm.Tests.MockApmServer.csproj b/test/Elastic.Apm.Tests.MockApmServer/Elastic.Apm.Tests.MockApmServer.csproj index f530409be..e800bcaac 100644 --- a/test/Elastic.Apm.Tests.MockApmServer/Elastic.Apm.Tests.MockApmServer.csproj +++ b/test/Elastic.Apm.Tests.MockApmServer/Elastic.Apm.Tests.MockApmServer.csproj @@ -3,6 +3,7 @@ netcoreapp2.1 Elastic.Apm.Tests.MockApmServer Elastic.Apm.Tests.MockApmServer + false @@ -10,7 +11,8 @@ - + + diff --git a/test/Elastic.Apm.Tests.MockApmServer/Program.cs b/test/Elastic.Apm.Tests.MockApmServer/Program.cs index 5084d29b3..bc44d8c24 100644 --- a/test/Elastic.Apm.Tests.MockApmServer/Program.cs +++ b/test/Elastic.Apm.Tests.MockApmServer/Program.cs @@ -5,7 +5,7 @@ using System; using Elastic.Apm.Config; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; namespace Elastic.Apm.Tests.MockApmServer { diff --git a/test/Elastic.Apm.Tests/TestHelpers/AgentTimerForTesting.cs b/test/Elastic.Apm.Tests.Utilities/AgentTimerForTesting.cs similarity index 88% rename from test/Elastic.Apm.Tests/TestHelpers/AgentTimerForTesting.cs rename to test/Elastic.Apm.Tests.Utilities/AgentTimerForTesting.cs index 91c3a3096..5116c1527 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/AgentTimerForTesting.cs +++ b/test/Elastic.Apm.Tests.Utilities/AgentTimerForTesting.cs @@ -9,11 +9,10 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; using FluentAssertions.Extensions; using Xunit.Sdk; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal interface IAgentTimerForTesting : IAgentTimer { @@ -78,7 +77,7 @@ public void WaitForTimeToPassAndUntil(TimeSpan timeSpan, Func untilConditi _logger.Debug() ?.Log("Waiting for time to pass..." - + $" dbgDesc: {(dbgDesc?.Invoke()).AsNullableToString()}. leftToWait: {leftToWait}. realNow: {realNow}." + + $" dbgDesc: {ObjectExtensions.AsNullableToString((dbgDesc?.Invoke()))}. leftToWait: {leftToWait}. realNow: {realNow}." + $" timeSpan: {timeSpan}. targetInstant: {targetInstant}"); Thread.Sleep(leftToWait); @@ -91,11 +90,11 @@ public void WaitForTimeToPassAndUntil(TimeSpan timeSpan, Func untilConditi private void WaitUntil(Func untilCondition, Func dbgDesc) { - _logger.Debug()?.Log($"Waiting until condition is true... dbgDesc: {(dbgDesc?.Invoke()).AsNullableToString()}."); + _logger.Debug()?.Log($"Waiting until condition is true... dbgDesc: {ObjectExtensions.AsNullableToString((dbgDesc?.Invoke()))}."); var maxTotalTimeToWait = 5.Minutes(); var timeToWaitBetweenChecks = 10.Milliseconds(); - var minTimeBetweenLogs = 1.Second(); + var minTimeBetweenLogs = 1.Seconds(); var stopwatch = Stopwatch.StartNew(); var attemptCount = 0; @@ -113,8 +112,8 @@ private void WaitUntil(Func untilCondition, Func dbgDesc) if (elapsedTime > maxTotalTimeToWait) { throw new XunitException("Wait-until-condition is still false even after max allotted time to wait." - + $" dbgDesc: {(dbgDesc?.Invoke()).AsNullableToString()}." - + $" elapsedTime: {elapsedTime.ToHmsInSeconds()}." + + $" dbgDesc: {ObjectExtensions.AsNullableToString((dbgDesc?.Invoke()))}." + + $" elapsedTime: {TimeExtensions.ToHmsInSeconds(elapsedTime)}." + $" attemptCount: {attemptCount}."); } @@ -122,8 +121,8 @@ private void WaitUntil(Func untilCondition, Func dbgDesc) { _logger.Debug() ?.Log("Delaying until next check..." - + $" dbgDesc: {(dbgDesc?.Invoke()).AsNullableToString()}." - + $" elapsedTime: {elapsedTime.ToHms()}." + + $" dbgDesc: {ObjectExtensions.AsNullableToString((dbgDesc?.Invoke()))}." + + $" elapsedTime: {TimeExtensions.ToHms(elapsedTime)}." + $" attemptCount: {attemptCount}." + $" maxTotalTimeToWait: {maxTotalTimeToWait}." + $" timeToWaitBetweenChecks: {timeToWaitBetweenChecks}."); diff --git a/test/Elastic.Apm.Tests/Data/TransactionMaxSpansTestData.cs b/test/Elastic.Apm.Tests.Utilities/Data/TransactionMaxSpansTestData.cs similarity index 95% rename from test/Elastic.Apm.Tests/Data/TransactionMaxSpansTestData.cs rename to test/Elastic.Apm.Tests.Utilities/Data/TransactionMaxSpansTestData.cs index 8c786898b..5351de4c2 100644 --- a/test/Elastic.Apm.Tests/Data/TransactionMaxSpansTestData.cs +++ b/test/Elastic.Apm.Tests.Utilities/Data/TransactionMaxSpansTestData.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using Elastic.Apm.Config; -namespace Elastic.Apm.Tests.Data +namespace Elastic.Apm.Tests.Utilities.Data { public class TransactionMaxSpansTestData : IEnumerable { diff --git a/test/Elastic.Apm.Tests/TestHelpers/DummyTestException.cs b/test/Elastic.Apm.Tests.Utilities/DummyTestException.cs similarity index 93% rename from test/Elastic.Apm.Tests/TestHelpers/DummyTestException.cs rename to test/Elastic.Apm.Tests.Utilities/DummyTestException.cs index 054e7e34f..c4e688d92 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/DummyTestException.cs +++ b/test/Elastic.Apm.Tests.Utilities/DummyTestException.cs @@ -4,7 +4,7 @@ using System; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal class DummyTestException : Exception { diff --git a/test/Elastic.Apm.Tests.Utilities/Elastic.Apm.Tests.Utilities.csproj b/test/Elastic.Apm.Tests.Utilities/Elastic.Apm.Tests.Utilities.csproj new file mode 100644 index 000000000..dadf038c8 --- /dev/null +++ b/test/Elastic.Apm.Tests.Utilities/Elastic.Apm.Tests.Utilities.csproj @@ -0,0 +1,19 @@ + + + + netstandard2.0;net461 + false + + + + + + + + + + + + + + diff --git a/test/Elastic.Apm.Tests/Extensions/EnumerableExtensions.cs b/test/Elastic.Apm.Tests.Utilities/EnumerableExtensions.cs similarity index 98% rename from test/Elastic.Apm.Tests/Extensions/EnumerableExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/EnumerableExtensions.cs index ba4f48c69..073b9ab52 100644 --- a/test/Elastic.Apm.Tests/Extensions/EnumerableExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/EnumerableExtensions.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; -namespace Elastic.Apm.Tests.Extensions +namespace Elastic.Apm.Tests.Utilities { /// /// Credit: http://source.roslyn.io/#microsoft.codeanalysis/InternalUtilities/EnumerableExtensions.cs diff --git a/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensions.cs b/test/Elastic.Apm.Tests.Utilities/EnumerableTestExtensions.cs similarity index 74% rename from test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/EnumerableTestExtensions.cs index c075f52b3..a1998b5df 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/EnumerableTestExtensions.cs @@ -6,11 +6,11 @@ using System.Collections.Generic; using System.Linq; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal static class EnumerableTestExtensions { internal static IEnumerable> ZipWithIndex(this IEnumerable source, int start = 0) => - Enumerable.Range(start, start == 0 ? int.MaxValue - 1 : int.MaxValue - start + 1).Zip(source, (i, t) => (i, t)); + source.Select((t, i) => (i + start, t)); } } diff --git a/test/Elastic.Apm.Tests/TestHelpers/EnvVarUtils.cs b/test/Elastic.Apm.Tests.Utilities/EnvVarUtils.cs similarity index 96% rename from test/Elastic.Apm.Tests/TestHelpers/EnvVarUtils.cs rename to test/Elastic.Apm.Tests.Utilities/EnvVarUtils.cs index 8423c4bc1..18d8617ee 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/EnvVarUtils.cs +++ b/test/Elastic.Apm.Tests.Utilities/EnvVarUtils.cs @@ -4,7 +4,7 @@ using System; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal static class EnvVarUtils { diff --git a/test/Elastic.Apm.Tests/Mocks/FakeMetricsCollector.cs b/test/Elastic.Apm.Tests.Utilities/FakeMetricsCollector.cs similarity index 89% rename from test/Elastic.Apm.Tests/Mocks/FakeMetricsCollector.cs rename to test/Elastic.Apm.Tests.Utilities/FakeMetricsCollector.cs index af64325b6..16eb0bce5 100644 --- a/test/Elastic.Apm.Tests/Mocks/FakeMetricsCollector.cs +++ b/test/Elastic.Apm.Tests.Utilities/FakeMetricsCollector.cs @@ -4,7 +4,7 @@ using Elastic.Apm.Metrics; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class FakeMetricsCollector : IMetricsCollector { diff --git a/test/Elastic.Apm.Tests/TestHelpers/FluentAssertionsUtils.cs b/test/Elastic.Apm.Tests.Utilities/FluentAssertionsUtils.cs similarity index 89% rename from test/Elastic.Apm.Tests/TestHelpers/FluentAssertionsUtils.cs rename to test/Elastic.Apm.Tests.Utilities/FluentAssertionsUtils.cs index bf99b8adb..a63d21ab8 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/FluentAssertionsUtils.cs +++ b/test/Elastic.Apm.Tests.Utilities/FluentAssertionsUtils.cs @@ -4,7 +4,7 @@ using System; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public static class FluentAssertionsUtils { diff --git a/test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLineWriterAdaptor.cs b/test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLineWriterAdaptor.cs similarity index 94% rename from test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLineWriterAdaptor.cs rename to test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLineWriterAdaptor.cs index 4f315ab69..5e1475499 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLineWriterAdaptor.cs +++ b/test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLineWriterAdaptor.cs @@ -5,7 +5,7 @@ using System.IO; using Elastic.Apm.Helpers; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class FlushingTextWriterToLineWriterAdaptor : ILineWriter { diff --git a/test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLoggerAdaptor.cs b/test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLoggerAdaptor.cs similarity index 92% rename from test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLoggerAdaptor.cs rename to test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLoggerAdaptor.cs index 18ad7873d..d070bb9ac 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/FlushingTextWriterToLoggerAdaptor.cs +++ b/test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLoggerAdaptor.cs @@ -5,7 +5,7 @@ using System.IO; using Elastic.Apm.Logging; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class FlushingTextWriterToLoggerAdaptor : LineWriterToLoggerAdaptor { diff --git a/test/Elastic.Apm.Tests/TestHelpers/ILineWriter.cs b/test/Elastic.Apm.Tests.Utilities/ILineWriter.cs similarity index 87% rename from test/Elastic.Apm.Tests/TestHelpers/ILineWriter.cs rename to test/Elastic.Apm.Tests.Utilities/ILineWriter.cs index eee876779..7e023bd13 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/ILineWriter.cs +++ b/test/Elastic.Apm.Tests.Utilities/ILineWriter.cs @@ -2,7 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public interface ILineWriter { diff --git a/test/Elastic.Apm.Tests/Mocks/InMemoryBlockingLogger.cs b/test/Elastic.Apm.Tests.Utilities/InMemoryBlockingLogger.cs similarity index 97% rename from test/Elastic.Apm.Tests/Mocks/InMemoryBlockingLogger.cs rename to test/Elastic.Apm.Tests.Utilities/InMemoryBlockingLogger.cs index ec26cd732..904eeb3eb 100644 --- a/test/Elastic.Apm.Tests/Mocks/InMemoryBlockingLogger.cs +++ b/test/Elastic.Apm.Tests.Utilities/InMemoryBlockingLogger.cs @@ -4,7 +4,7 @@ using System.Timers; using Elastic.Apm.Logging; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { /// /// An in-memory logger which blocks until the 1. log line is received or a timeout is reached diff --git a/test/Elastic.Apm.Tests/TestHelpers/IntExtensions.cs b/test/Elastic.Apm.Tests.Utilities/IntExtensions.cs similarity index 94% rename from test/Elastic.Apm.Tests/TestHelpers/IntExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/IntExtensions.cs index da7f8accf..fe3837a18 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/IntExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/IntExtensions.cs @@ -5,7 +5,7 @@ using System; using System.Threading.Tasks; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public static class IntExtensions { diff --git a/test/Elastic.Apm.Tests.Utilities/InternalsVisibleTo.cs b/test/Elastic.Apm.Tests.Utilities/InternalsVisibleTo.cs new file mode 100644 index 000000000..d5037d273 --- /dev/null +++ b/test/Elastic.Apm.Tests.Utilities/InternalsVisibleTo.cs @@ -0,0 +1,50 @@ +// Licensed to Elasticsearch B.V under +// one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo( + "Elastic.Apm.AspNetCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.AspNetCore.Static.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.EntityFrameworkCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Docker.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.AspNetFullFramework.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Tests.MockApmServer, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.SqlClient.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Feature.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Elasticsearch.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.EntityFramework6.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Grpc.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.StackExchange.Redis.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] +[assembly: + InternalsVisibleTo( + "Elastic.Apm.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] + diff --git a/test/Elastic.Apm.Tests/TestHelpers/JsonUtils.cs b/test/Elastic.Apm.Tests.Utilities/JsonUtils.cs similarity index 95% rename from test/Elastic.Apm.Tests/TestHelpers/JsonUtils.cs rename to test/Elastic.Apm.Tests.Utilities/JsonUtils.cs index c4b5708cd..7d6929ef8 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/JsonUtils.cs +++ b/test/Elastic.Apm.Tests.Utilities/JsonUtils.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public static class JsonUtils { diff --git a/test/Elastic.Apm.Tests/TestHelpers/LineWriterToLoggerAdaptor.cs b/test/Elastic.Apm.Tests.Utilities/LineWriterToLoggerAdaptor.cs similarity index 96% rename from test/Elastic.Apm.Tests/TestHelpers/LineWriterToLoggerAdaptor.cs rename to test/Elastic.Apm.Tests.Utilities/LineWriterToLoggerAdaptor.cs index 9350b9a72..803c7f1e3 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/LineWriterToLoggerAdaptor.cs +++ b/test/Elastic.Apm.Tests.Utilities/LineWriterToLoggerAdaptor.cs @@ -5,7 +5,7 @@ using System; using Elastic.Apm.Logging; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class LineWriterToLoggerAdaptor : IApmLogger, ILogLevelSwitchable { diff --git a/test/Elastic.Apm.Tests/Mocks/LocalServer.cs b/test/Elastic.Apm.Tests.Utilities/LocalServer.cs similarity index 98% rename from test/Elastic.Apm.Tests/Mocks/LocalServer.cs rename to test/Elastic.Apm.Tests.Utilities/LocalServer.cs index f1723b639..e29aaf6d6 100644 --- a/test/Elastic.Apm.Tests/Mocks/LocalServer.cs +++ b/test/Elastic.Apm.Tests.Utilities/LocalServer.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Xunit.Sdk; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class LocalServer : IDisposable { diff --git a/test/Elastic.Apm.Tests/TestHelpers/LoggingTestBase.cs b/test/Elastic.Apm.Tests.Utilities/LoggingTestBase.cs similarity index 98% rename from test/Elastic.Apm.Tests/TestHelpers/LoggingTestBase.cs rename to test/Elastic.Apm.Tests.Utilities/LoggingTestBase.cs index a14a85dcf..b4cff0b41 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/LoggingTestBase.cs +++ b/test/Elastic.Apm.Tests.Utilities/LoggingTestBase.cs @@ -9,7 +9,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class LoggingTestBase : IDisposable { diff --git a/test/Elastic.Apm.Tests/Mocks/MockAgentTimer.cs b/test/Elastic.Apm.Tests.Utilities/MockAgentTimer.cs similarity index 85% rename from test/Elastic.Apm.Tests/Mocks/MockAgentTimer.cs rename to test/Elastic.Apm.Tests.Utilities/MockAgentTimer.cs index efc05ca16..1437fa14e 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockAgentTimer.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockAgentTimer.cs @@ -11,10 +11,9 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.TestHelpers; using FluentAssertions; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { [DebuggerDisplay(nameof(_dbgName) + " = {" + nameof(_dbgName) + "}" + ", " + nameof(Now) + " = {" + nameof(Now) + "}")] internal class MockAgentTimer : IAgentTimerForTesting @@ -32,7 +31,7 @@ internal MockAgentTimer(string dbgName = null, IApmLogger logger = null) WhenStarted = new AgentTimeInstant(this, TimeSpan.Zero); Now = WhenStarted; _dbgName = dbgName ?? "#" + RuntimeHelpers.GetHashCode(this).ToString("X"); - _logger = logger == null ? (IApmLogger)new NoopLogger() : logger.Scoped($"{ThisClassName}-{_dbgName}"); + _logger = logger == null ? (IApmLogger)new NoopLogger() : LoggingExtensions.Scoped(logger, $"{ThisClassName}-{_dbgName}"); } public AgentTimeInstant Now @@ -68,11 +67,11 @@ private async Task DelayAsyncImpl(AgentTimeInstant until, CancellationToken canc var (now, delayItemId) = _delayItems.Add(until, triggerTcs, cancellationToken); if (!delayItemId.HasValue) { - _logger.Trace()?.Log($"Delay item already reached its trigger time. When to trigger: {until}. now: {now}."); + LoggingExtensions.Trace(_logger)?.Log($"Delay item already reached its trigger time. When to trigger: {until}. now: {now}."); return; } - _logger.Trace()?.Log($"Added delay item. When to trigger: {until}. Delay item ID: {delayItemId.Value}"); + LoggingExtensions.Trace(_logger)?.Log($"Added delay item. When to trigger: {until}. Delay item ID: {delayItemId.Value}"); cancellationToken.Register(() => DelayCancelled(delayItemId.Value)); @@ -81,7 +80,7 @@ private async Task DelayAsyncImpl(AgentTimeInstant until, CancellationToken canc internal void FastForward(TimeSpan timeSpanToFastForward, string dbgGoalDescription = null) { - _logger.Debug()?.Log($"Fast forwarding... timeSpanToFastForward: {timeSpanToFastForward}, dbgGoalDescription: {dbgGoalDescription}"); + LoggingExtensions.Debug(_logger)?.Log($"Fast forwarding... timeSpanToFastForward: {timeSpanToFastForward}, dbgGoalDescription: {dbgGoalDescription}"); using (var acq = _fastForwardSpinLock.TryAcquireWithDisposable()) { @@ -97,7 +96,7 @@ internal void FastForward(TimeSpan timeSpanToFastForward, string dbgGoalDescript Assertion.IfEnabled?.That(delayItem.Value.WhenToTrigger >= Now, "Delay item should not have past trigger time"); Now = delayItem.Value.WhenToTrigger; - _logger.Trace()?.Log($"Notifying delay item... Delay item ID: {delayItem.Value.Id}"); + LoggingExtensions.Trace(_logger)?.Log($"Notifying delay item... Delay item ID: {delayItem.Value.Id}"); delayItem.Value.TriggerTcs.SetResult(null); } @@ -108,7 +107,7 @@ internal void FastForward(TimeSpan timeSpanToFastForward, string dbgGoalDescript public void WaitForTimeToPassAndUntil(TimeSpan timeSpan, Func untilCondition = null, Func dbgDesc = null) { FastForward(timeSpan, dbgDesc?.Invoke()); - untilCondition?.Invoke().Should().BeTrue($"because dbgDesc: {(dbgDesc?.Invoke()).AsNullableToString()}"); + untilCondition?.Invoke().Should().BeTrue($"because dbgDesc: {ObjectExtensions.AsNullableToString((dbgDesc?.Invoke()))}"); } private void DelayCancelled(long delayItemId) @@ -116,11 +115,11 @@ private void DelayCancelled(long delayItemId) var delayItem = _delayItems.RemoveById(delayItemId); if (!delayItem.HasValue) { - _logger.Debug()?.Log($"DelayItem with ID: {delayItemId} was not found (it's possible that it was already completed) - exiting"); + LoggingExtensions.Debug(_logger)?.Log($"DelayItem with ID: {delayItemId} was not found (it's possible that it was already completed) - exiting"); return; } - _logger.Trace()?.Log($"Cancelling delay item... Delay item ID: {delayItem.Value.Id}"); + LoggingExtensions.Trace(_logger)?.Log($"Cancelling delay item... Delay item ID: {delayItem.Value.Id}"); var cancelled = delayItem.Value.TriggerTcs.TrySetCanceled(delayItem.Value.CancellationToken); Assertion.IfEnabled?.That(cancelled, $"Delay item task should not be in any final state before we cancel it because it was in {nameof(_delayItems)} list"); @@ -152,13 +151,13 @@ private class DelayItems private long _nextItemId = 1; private AgentTimeInstant _now; - internal int Count => DoUnderLock(() => _items.Count); + internal int Count => DoUnderLock(() => _items.Count); internal IReadOnlyList DelayTasks => DoUnderLock(() => _items.Select(d => d.TriggerTcs.Task).ToList()); internal AgentTimeInstant Now { - get => DoUnderLock(() => + get => DoUnderLock(() => { var localCopy = _now; return localCopy; @@ -170,7 +169,7 @@ internal AgentTimeInstant Now internal (AgentTimeInstant, long?) Add(AgentTimeInstant whenToTrigger, TaskCompletionSource triggerTcs, CancellationToken cancellationToken ) => - DoUnderLock(() => + DoUnderLock<(AgentTimeInstant _now, long?)>(() => { if (whenToTrigger <= _now) return (_now, (long?)null); @@ -234,7 +233,7 @@ private TResult DoUnderLock(Func doFunc) } private void DoUnderLock(Action doAction) => - DoUnderLock(() => + DoUnderLock(() => { doAction(); return (object)null; diff --git a/test/Elastic.Apm.Tests/Mocks/MockApmServerInfo.cs b/test/Elastic.Apm.Tests.Utilities/MockApmServerInfo.cs similarity index 93% rename from test/Elastic.Apm.Tests/Mocks/MockApmServerInfo.cs rename to test/Elastic.Apm.Tests.Utilities/MockApmServerInfo.cs index 003189d55..fe5900162 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockApmServerInfo.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockApmServerInfo.cs @@ -5,7 +5,7 @@ using Elastic.Apm.ServerInfo; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class MockApmServerInfo : IApmServerInfo { diff --git a/test/Elastic.Apm.Tests/Mocks/MockConfigSnapshot.cs b/test/Elastic.Apm.Tests.Utilities/MockConfigSnapshot.cs similarity index 99% rename from test/Elastic.Apm.Tests/Mocks/MockConfigSnapshot.cs rename to test/Elastic.Apm.Tests.Utilities/MockConfigSnapshot.cs index 014b0138a..4da68f86e 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockConfigSnapshot.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockConfigSnapshot.cs @@ -9,7 +9,7 @@ using Elastic.Apm.Logging; using static Elastic.Apm.Config.ConfigConsts; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class MockConfigSnapshot : AbstractConfigurationReader, IConfigSnapshot { diff --git a/test/Elastic.Apm.Tests/Mocks/MockHttpMessageHandler.cs b/test/Elastic.Apm.Tests.Utilities/MockHttpMessageHandler.cs similarity index 95% rename from test/Elastic.Apm.Tests/Mocks/MockHttpMessageHandler.cs rename to test/Elastic.Apm.Tests.Utilities/MockHttpMessageHandler.cs index ddb861958..1b41dae2c 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockHttpMessageHandler.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockHttpMessageHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class MockHttpMessageHandler : DelegatingHandler { diff --git a/test/Elastic.Apm.Tests/Mocks/MockPayloadSender.cs b/test/Elastic.Apm.Tests.Utilities/MockPayloadSender.cs similarity index 97% rename from test/Elastic.Apm.Tests/Mocks/MockPayloadSender.cs rename to test/Elastic.Apm.Tests.Utilities/MockPayloadSender.cs index f47e685c0..1265231d3 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockPayloadSender.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockPayloadSender.cs @@ -14,7 +14,7 @@ using Elastic.Apm.Model; using Elastic.Apm.Report; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class MockPayloadSender : IPayloadSender { @@ -174,7 +174,7 @@ public void WaitForMetrics(TimeSpan? timeout = null) /// public void SignalEndSpans() => _spanWaitHandle.Set(); - public IReadOnlyList Errors => CreateImmutableSnapshot(_errors); + public IReadOnlyList Errors => CreateImmutableSnapshot(_errors); public Error FirstError => _errors.FirstOrDefault() as Error; public MetricSet FirstMetric => _metrics.FirstOrDefault() as MetricSet; @@ -187,11 +187,11 @@ public void WaitForMetrics(TimeSpan? timeout = null) public Transaction FirstTransaction => Transactions.FirstOrDefault() as Transaction; - public IReadOnlyList Metrics => CreateImmutableSnapshot(_metrics); + public IReadOnlyList Metrics => CreateImmutableSnapshot(_metrics); - public IReadOnlyList Spans => CreateImmutableSnapshot(_spans); + public IReadOnlyList Spans => CreateImmutableSnapshot(_spans); - public IReadOnlyList Transactions => CreateImmutableSnapshot(_transactions); + public IReadOnlyList Transactions => CreateImmutableSnapshot(_transactions); public Span[] SpansOnFirstTransaction => _spans.Where(n => n.TransactionId == Transactions.First().Id).Select(n => n as Span).ToArray(); diff --git a/test/Elastic.Apm.Tests/Mocks/MockPayloadSenderWithFilters.cs b/test/Elastic.Apm.Tests.Utilities/MockPayloadSenderWithFilters.cs similarity index 95% rename from test/Elastic.Apm.Tests/Mocks/MockPayloadSenderWithFilters.cs rename to test/Elastic.Apm.Tests.Utilities/MockPayloadSenderWithFilters.cs index eeb7e4a12..e2d31808f 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockPayloadSenderWithFilters.cs +++ b/test/Elastic.Apm.Tests.Utilities/MockPayloadSenderWithFilters.cs @@ -8,7 +8,7 @@ using Elastic.Apm.Api; using Elastic.Apm.Filters; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class MockPayloadSenderWithFilters : MockPayloadSender { diff --git a/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtils.cs b/test/Elastic.Apm.Tests.Utilities/MultiThreadsTestUtils.cs similarity index 92% rename from test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtils.cs rename to test/Elastic.Apm.Tests.Utilities/MultiThreadsTestUtils.cs index 6d575dfb7..da520ebaf 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtils.cs +++ b/test/Elastic.Apm.Tests.Utilities/MultiThreadsTestUtils.cs @@ -6,17 +6,16 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -using Elastic.Apm.Tests.Extensions; using FluentAssertions; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal static class MultiThreadsTestUtils { internal static int NumberOfThreadsForTest => Math.Max(Environment.ProcessorCount, 2); internal static IList TestOnThreads(Func threadAction) => - TestOnThreads(NumberOfThreadsForTest, threadAction); + TestOnThreads(NumberOfThreadsForTest, threadAction); internal static TResult[] TestOnThreads(int numberOfThreads, Func threadAction) { diff --git a/test/Elastic.Apm.Tests/Mocks/NoopCentralConfigFetcher.cs b/test/Elastic.Apm.Tests.Utilities/NoopCentralConfigFetcher.cs similarity index 84% rename from test/Elastic.Apm.Tests/Mocks/NoopCentralConfigFetcher.cs rename to test/Elastic.Apm.Tests.Utilities/NoopCentralConfigFetcher.cs index 502dd8dbc..dffbb9c95 100644 --- a/test/Elastic.Apm.Tests/Mocks/NoopCentralConfigFetcher.cs +++ b/test/Elastic.Apm.Tests.Utilities/NoopCentralConfigFetcher.cs @@ -2,10 +2,9 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using Elastic.Apm.BackendComm; using Elastic.Apm.BackendComm.CentralConfig; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class NoopCentralConfigFetcher : ICentralConfigFetcher { diff --git a/test/Elastic.Apm.Tests/Mocks/NoopCurrentExecutionSegmentsContainer.cs b/test/Elastic.Apm.Tests.Utilities/NoopCurrentExecutionSegmentsContainer.cs similarity index 87% rename from test/Elastic.Apm.Tests/Mocks/NoopCurrentExecutionSegmentsContainer.cs rename to test/Elastic.Apm.Tests.Utilities/NoopCurrentExecutionSegmentsContainer.cs index ec9e7e802..637679581 100644 --- a/test/Elastic.Apm.Tests/Mocks/NoopCurrentExecutionSegmentsContainer.cs +++ b/test/Elastic.Apm.Tests.Utilities/NoopCurrentExecutionSegmentsContainer.cs @@ -3,9 +3,8 @@ // See the LICENSE file in the project root for more information using Elastic.Apm.Api; -using Elastic.Apm.Model; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class NoopCurrentExecutionSegmentsContainer : ICurrentExecutionSegmentsContainer { diff --git a/test/Elastic.Apm.Tests/Mocks/NoopLogger.cs b/test/Elastic.Apm.Tests.Utilities/NoopLogger.cs similarity index 92% rename from test/Elastic.Apm.Tests/Mocks/NoopLogger.cs rename to test/Elastic.Apm.Tests.Utilities/NoopLogger.cs index 74476e47d..4ad93968a 100644 --- a/test/Elastic.Apm.Tests/Mocks/NoopLogger.cs +++ b/test/Elastic.Apm.Tests.Utilities/NoopLogger.cs @@ -5,7 +5,7 @@ using System; using Elastic.Apm.Logging; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class NoopLogger : IApmLogger { diff --git a/test/Elastic.Apm.Tests/Mocks/NoopPayloadSender.cs b/test/Elastic.Apm.Tests.Utilities/NoopPayloadSender.cs similarity index 93% rename from test/Elastic.Apm.Tests/Mocks/NoopPayloadSender.cs rename to test/Elastic.Apm.Tests.Utilities/NoopPayloadSender.cs index 8f7ae4459..7c75ce3aa 100644 --- a/test/Elastic.Apm.Tests/Mocks/NoopPayloadSender.cs +++ b/test/Elastic.Apm.Tests.Utilities/NoopPayloadSender.cs @@ -5,7 +5,7 @@ using Elastic.Apm.Api; using Elastic.Apm.Report; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class NoopPayloadSender : IPayloadSender { diff --git a/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelper.cs b/test/Elastic.Apm.Tests.Utilities/RandomTestHelper.cs similarity index 98% rename from test/Elastic.Apm.Tests/TestHelpers/RandomTestHelper.cs rename to test/Elastic.Apm.Tests.Utilities/RandomTestHelper.cs index 868dfecd5..a0dfed892 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelper.cs +++ b/test/Elastic.Apm.Tests.Utilities/RandomTestHelper.cs @@ -10,7 +10,7 @@ using Elastic.Apm.Logging; using Xunit.Abstractions; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal class RandomTestHelper { diff --git a/test/Elastic.Apm.Tests/Extensions/ShouldWaitDurationExtensions.cs b/test/Elastic.Apm.Tests.Utilities/ShouldWaitDurationExtensions.cs similarity index 93% rename from test/Elastic.Apm.Tests/Extensions/ShouldWaitDurationExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/ShouldWaitDurationExtensions.cs index 796ebb6ce..d35953114 100644 --- a/test/Elastic.Apm.Tests/Extensions/ShouldWaitDurationExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/ShouldWaitDurationExtensions.cs @@ -2,11 +2,10 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using Elastic.Apm.Tests.Extensions; using FluentAssertions; using FluentAssertions.Numeric; -namespace Elastic.Apm.Tests +namespace Elastic.Apm.Tests.Utilities { public static class ShouldWaitDurationExtensions { diff --git a/test/Elastic.Apm.Tests/TestHelpers/SplittingLineWriter.cs b/test/Elastic.Apm.Tests.Utilities/SplittingLineWriter.cs similarity index 92% rename from test/Elastic.Apm.Tests/TestHelpers/SplittingLineWriter.cs rename to test/Elastic.Apm.Tests.Utilities/SplittingLineWriter.cs index 981823076..1a24eac32 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/SplittingLineWriter.cs +++ b/test/Elastic.Apm.Tests.Utilities/SplittingLineWriter.cs @@ -2,7 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class SplittingLineWriter : ILineWriter { diff --git a/test/Elastic.Apm.Tests/TestHelpers/SystemDiagnosticsTraceLineWriter.cs b/test/Elastic.Apm.Tests.Utilities/SystemDiagnosticsTraceLineWriter.cs similarity index 93% rename from test/Elastic.Apm.Tests/TestHelpers/SystemDiagnosticsTraceLineWriter.cs rename to test/Elastic.Apm.Tests.Utilities/SystemDiagnosticsTraceLineWriter.cs index ae0d7a359..f4384fd35 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/SystemDiagnosticsTraceLineWriter.cs +++ b/test/Elastic.Apm.Tests.Utilities/SystemDiagnosticsTraceLineWriter.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using Elastic.Apm.Helpers; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class SystemDiagnosticsTraceLineWriter : ILineWriter { diff --git a/test/Elastic.Apm.Tests/TestHelpers/TaskTestExtensions.cs b/test/Elastic.Apm.Tests.Utilities/TaskTestExtensions.cs similarity index 93% rename from test/Elastic.Apm.Tests/TestHelpers/TaskTestExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/TaskTestExtensions.cs index 19a69252e..623c8379a 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/TaskTestExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/TaskTestExtensions.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal static class TaskTestExtensions { @@ -17,7 +17,7 @@ internal static class TaskTestExtensions /// so the only option is to implement IsCompletedSuccessfully as an extension method. /// internal static bool IsCompletedSuccessfully(this Task thisObj) => -#if NETFRAMEWORK +#if NETFRAMEWORK || NETSTANDARD thisObj.IsCompleted && !(thisObj.IsFaulted || thisObj.IsCanceled); #else thisObj.IsCompletedSuccessfully; diff --git a/test/Elastic.Apm.Tests/TestHelpers/TempFile.cs b/test/Elastic.Apm.Tests.Utilities/TempFile.cs similarity index 90% rename from test/Elastic.Apm.Tests/TestHelpers/TempFile.cs rename to test/Elastic.Apm.Tests.Utilities/TempFile.cs index c7d201976..8897b9876 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/TempFile.cs +++ b/test/Elastic.Apm.Tests.Utilities/TempFile.cs @@ -6,7 +6,7 @@ using System; using System.IO; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { /// /// A temporary file that is deleted on dispose. @@ -30,7 +30,7 @@ public TempFile(string path) /// /// The path to the temporary file /// - /// + /// public string Path { get diff --git a/test/Elastic.Apm.Tests/Mocks/TestAgentComponents.cs b/test/Elastic.Apm.Tests.Utilities/TestAgentComponents.cs similarity index 94% rename from test/Elastic.Apm.Tests/Mocks/TestAgentComponents.cs rename to test/Elastic.Apm.Tests.Utilities/TestAgentComponents.cs index f1b88b622..4dd3816da 100644 --- a/test/Elastic.Apm.Tests/Mocks/TestAgentComponents.cs +++ b/test/Elastic.Apm.Tests.Utilities/TestAgentComponents.cs @@ -2,14 +2,13 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using Elastic.Apm.BackendComm; using Elastic.Apm.BackendComm.CentralConfig; using Elastic.Apm.Config; using Elastic.Apm.Logging; using Elastic.Apm.Report; using Elastic.Apm.ServerInfo; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class TestAgentComponents : AgentComponents { diff --git a/test/Elastic.Apm.Tests/Mocks/TestLogger.cs b/test/Elastic.Apm.Tests.Utilities/TestLogger.cs similarity index 99% rename from test/Elastic.Apm.Tests/Mocks/TestLogger.cs rename to test/Elastic.Apm.Tests.Utilities/TestLogger.cs index 2962f982e..4060e9c20 100644 --- a/test/Elastic.Apm.Tests/Mocks/TestLogger.cs +++ b/test/Elastic.Apm.Tests.Utilities/TestLogger.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Elastic.Apm.Logging; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { internal class TestLogger : ConsoleLogger { diff --git a/test/Elastic.Apm.Tests/TestHelpers/TestingConfig.cs b/test/Elastic.Apm.Tests.Utilities/TestingConfig.cs similarity index 98% rename from test/Elastic.Apm.Tests/TestHelpers/TestingConfig.cs rename to test/Elastic.Apm.Tests.Utilities/TestingConfig.cs index 36504ddec..091ace83a 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/TestingConfig.cs +++ b/test/Elastic.Apm.Tests.Utilities/TestingConfig.cs @@ -9,10 +9,9 @@ using Elastic.Apm.Config; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; using Xunit.Abstractions; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal static class TestingConfig { @@ -173,7 +172,7 @@ internal StringOptionMetadata(string optionName, string defaultValue, Expression internal class NullableIntOptionMetadata : OptionMetadata { internal NullableIntOptionMetadata(string optionName, int? defaultValue, Expression> propExpr) - : base(optionName, defaultValue, CreateNullableParser(int.Parse), propExpr) { } + : base(optionName, defaultValue, CreateNullableParser(int.Parse), propExpr) { } } } diff --git a/test/Elastic.Apm.Tests/TestHelpers/ThreadSafeIntCounter.cs b/test/Elastic.Apm.Tests.Utilities/ThreadSafeIntCounter.cs similarity index 92% rename from test/Elastic.Apm.Tests/TestHelpers/ThreadSafeIntCounter.cs rename to test/Elastic.Apm.Tests.Utilities/ThreadSafeIntCounter.cs index 31e999aeb..73824b44e 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/ThreadSafeIntCounter.cs +++ b/test/Elastic.Apm.Tests.Utilities/ThreadSafeIntCounter.cs @@ -4,7 +4,7 @@ using System.Threading; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { internal class ThreadSafeIntCounter { diff --git a/test/Elastic.Apm.Tests/TestHelpers/ThreadSafeLongCounter.cs b/test/Elastic.Apm.Tests.Utilities/ThreadSafeLongCounter.cs similarity index 92% rename from test/Elastic.Apm.Tests/TestHelpers/ThreadSafeLongCounter.cs rename to test/Elastic.Apm.Tests.Utilities/ThreadSafeLongCounter.cs index e37a47e7f..bee724e2a 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/ThreadSafeLongCounter.cs +++ b/test/Elastic.Apm.Tests.Utilities/ThreadSafeLongCounter.cs @@ -4,7 +4,7 @@ using System.Threading; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class ThreadSafeLongCounter { diff --git a/test/Elastic.Apm.Tests/TestHelpers/ToAllSinksLogger.cs b/test/Elastic.Apm.Tests.Utilities/ToAllSinksLogger.cs similarity index 94% rename from test/Elastic.Apm.Tests/TestHelpers/ToAllSinksLogger.cs rename to test/Elastic.Apm.Tests.Utilities/ToAllSinksLogger.cs index a8ac47999..80e41a8d1 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/ToAllSinksLogger.cs +++ b/test/Elastic.Apm.Tests.Utilities/ToAllSinksLogger.cs @@ -6,7 +6,7 @@ using Elastic.Apm.Logging; using Xunit.Abstractions; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class ToAllSinksLogger : LineWriterToLoggerAdaptor { diff --git a/test/Elastic.Apm.Tests/Extensions/WaitExtensions.cs b/test/Elastic.Apm.Tests.Utilities/WaitExtensions.cs similarity index 97% rename from test/Elastic.Apm.Tests/Extensions/WaitExtensions.cs rename to test/Elastic.Apm.Tests.Utilities/WaitExtensions.cs index e21bb7fe1..aef048ce1 100644 --- a/test/Elastic.Apm.Tests/Extensions/WaitExtensions.cs +++ b/test/Elastic.Apm.Tests.Utilities/WaitExtensions.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using FluentAssertions; -namespace Elastic.Apm.Tests.Extensions +namespace Elastic.Apm.Tests.Utilities { /// /// Helper class that runs Task.Delay and Thread.Sleep diff --git a/test/Elastic.Apm.Tests/TestHelpers/XunitOutputToLineWriterAdaptor.cs b/test/Elastic.Apm.Tests.Utilities/XunitOutputToLineWriterAdaptor.cs similarity index 94% rename from test/Elastic.Apm.Tests/TestHelpers/XunitOutputToLineWriterAdaptor.cs rename to test/Elastic.Apm.Tests.Utilities/XunitOutputToLineWriterAdaptor.cs index 0e2a2aa71..c0eccefe8 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/XunitOutputToLineWriterAdaptor.cs +++ b/test/Elastic.Apm.Tests.Utilities/XunitOutputToLineWriterAdaptor.cs @@ -5,7 +5,7 @@ using Elastic.Apm.Helpers; using Xunit.Abstractions; -namespace Elastic.Apm.Tests.TestHelpers +namespace Elastic.Apm.Tests.Utilities { public class XunitOutputToLineWriterAdaptor : ILineWriter { diff --git a/test/Elastic.Apm.Tests/ActivityIntegrationTests.cs b/test/Elastic.Apm.Tests/ActivityIntegrationTests.cs index 245e4d532..c9940cad1 100644 --- a/test/Elastic.Apm.Tests/ActivityIntegrationTests.cs +++ b/test/Elastic.Apm.Tests/ActivityIntegrationTests.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Threading; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/ApiTests/ApiTests.cs b/test/Elastic.Apm.Tests/ApiTests/ApiTests.cs index 9737ea5ce..350c94c46 100644 --- a/test/Elastic.Apm.Tests/ApiTests/ApiTests.cs +++ b/test/Elastic.Apm.Tests/ApiTests/ApiTests.cs @@ -12,7 +12,7 @@ using Elastic.Apm.Helpers; using Elastic.Apm.Logging; using Elastic.Apm.Tests.HelpersTests; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/ApiTests/ConvenientApiSpanTests.cs b/test/Elastic.Apm.Tests/ApiTests/ConvenientApiSpanTests.cs index 9a626c60c..1106271ee 100644 --- a/test/Elastic.Apm.Tests/ApiTests/ConvenientApiSpanTests.cs +++ b/test/Elastic.Apm.Tests/ApiTests/ConvenientApiSpanTests.cs @@ -10,7 +10,7 @@ using Elastic.Apm.Model; using Elastic.Apm.Tests.Extensions; using Elastic.Apm.Tests.HelpersTests; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; @@ -40,7 +40,7 @@ public class ConvenientApiSpanTests private const string TransactionType = "Test"; /// - /// Tests the method. + /// Tests the method. /// It wraps a fake span (Thread.Sleep) into the CaptureSpan method /// and it makes sure that the span is captured by the agent. /// @@ -49,7 +49,7 @@ public void SimpleAction() => AssertWith1TransactionAnd1Span(t => { t.CaptureSpan(SpanName, SpanType, () => { WaitHelpers.Sleep2XMinimum(); }); }); /// - /// Tests the method with an exception. + /// Tests the method with an exception. /// It wraps a fake span (Thread.Sleep) that throws an exception into the CaptureSpan method /// and it makes sure that the span and the exception are captured by the agent. /// @@ -84,7 +84,7 @@ public void SimpleActionWithException_OnSubSpan() }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake span (Thread.Sleep) into the CaptureSpan method with an parameter /// and it makes sure that the span is captured by the agent and the parameter is not null /// @@ -113,7 +113,7 @@ public void SimpleActionWithParameter_OnSubSpan() }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake span (Thread.Sleep) that throws an exception into the CaptureSpan method with an /// parameter @@ -153,7 +153,7 @@ public void SimpleActionWithExceptionAndParameter_OnSubSpan() }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake span (Thread.Sleep) with a return value into the CaptureSpan method /// and it makes sure that the span is captured by the agent and the return value is correct. /// @@ -184,7 +184,7 @@ public void SimpleActionWithReturnType_OnSubSpan() }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake span (Thread.Sleep) with a return value into the CaptureSpan method with an /// parameter /// and it makes sure that the span is captured by the agent and the return value is correct and the @@ -219,7 +219,7 @@ public void SimpleActionWithReturnTypeAndParameter_OnSubSpan() }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake span (Thread.Sleep) with a return value that throws an exception into the CaptureSpan method with an /// parameter @@ -269,7 +269,7 @@ public void SimpleActionWithReturnTypeAndExceptionAndParameter_OnSubSpan() }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake span (Thread.Sleep) with a return value that throws an exception into the CaptureSpan method with an /// parameter @@ -311,7 +311,7 @@ public void SimpleActionWithReturnTypeAndException_OnSubSpan() }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake async span (Task.Delay) into the CaptureSpan method /// and it makes sure that the span is captured. /// @@ -330,7 +330,7 @@ public async Task AsyncTask_OnSubSpan() }); /// - /// Tests the method with an + /// Tests the method with an /// exception /// It wraps a fake async span (Task.Delay) that throws an exception into the CaptureSpan method /// and it makes sure that the span and the error are captured. @@ -368,7 +368,7 @@ await t.CaptureSpan(SpanName, SpanType, async () => }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake async span (Task.Delay) into the CaptureSpan method with an parameter /// and it makes sure that the span is captured and the parameter is not null. /// @@ -397,7 +397,7 @@ await s.CaptureSpan(SpanName, SpanType, }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake async span (Task.Delay) that throws an exception into the CaptureSpan method with an /// parameter @@ -437,7 +437,7 @@ await s.CaptureSpan(SpanName, SpanType, async s2 => /// - /// Tests the method. + /// Tests the method. /// It wraps a fake async span (Task.Delay) with a return value into the CaptureSpan method /// and it makes sure that the span is captured by the agent and the return value is correct. /// @@ -466,7 +466,7 @@ public async Task AsyncTaskWithReturnType_OnSubSpan() }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake async span (Task.Delay) with a return value into the CaptureSpan method with an /// parameter /// and it makes sure that the span is captured by the agent and the return value is correct and the @@ -503,7 +503,7 @@ public async Task AsyncTaskWithReturnTypeAndParameter_OnSubSpan() }); /// - /// Tests the method with + /// Tests the method with /// an exception. /// It wraps a fake async span (Task.Delay) with a return value that throws an exception into the CaptureSpan method with /// an parameter @@ -551,7 +551,7 @@ await s.CaptureSpan(SpanName, SpanType, async s2 => }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake async span (Task.Delay) with a return value that throws an exception into the CaptureSpan method /// and it makes sure that the span and the error are captured by the agent. diff --git a/test/Elastic.Apm.Tests/ApiTests/ConvenientApiTransactionTests.cs b/test/Elastic.Apm.Tests/ApiTests/ConvenientApiTransactionTests.cs index 34adc08a6..5c608acea 100644 --- a/test/Elastic.Apm.Tests/ApiTests/ConvenientApiTransactionTests.cs +++ b/test/Elastic.Apm.Tests/ApiTests/ConvenientApiTransactionTests.cs @@ -9,10 +9,10 @@ using Elastic.Apm.Helpers; using Elastic.Apm.Model; using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.Mocks; using FluentAssertions; using Xunit; using System.Diagnostics; +using Elastic.Apm.Tests.Utilities; using Xunit.Abstractions; namespace Elastic.Apm.Tests.ApiTests @@ -37,7 +37,7 @@ public class ConvenientApiTransactionTests public ConvenientApiTransactionTests(ITestOutputHelper testOutputHelper) => testOutputHelper.WriteLine($" Stopwatch.Frequency: {Stopwatch.Frequency}"); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake transaction (Thread.Sleep) into the CaptureTransaction method /// and it makes sure that the transaction is captured by the agent. /// @@ -49,7 +49,7 @@ public void SimpleAction() => AssertWith1Transaction(agent => }); /// - /// Tests the method with an + /// Tests the method with an /// exception. /// It wraps a fake transaction (Thread.Sleep) that throws an exception into the CaptureTransaction method /// and it makes sure that the transaction and the exception are captured by the agent. @@ -69,7 +69,7 @@ public void SimpleActionWithException() => AssertWith1TransactionAnd1Error(agent }); /// - /// Tests the + /// Tests the /// method. /// It wraps a fake transaction (Thread.Sleep) into the CaptureTransaction method with an /// parameter @@ -88,7 +88,7 @@ public void SimpleActionWithParameter() => AssertWith1Transaction(agent => }); /// - /// Tests the + /// Tests the /// method with an exception. /// It wraps a fake transaction (Thread.Sleep) that throws an exception into the CaptureTransaction method with an /// parameter @@ -111,7 +111,7 @@ public void SimpleActionWithExceptionAndParameter() => AssertWith1TransactionAnd }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake transaction (Thread.Sleep) with a return value into the CaptureTransaction method /// and it makes sure that the transaction is captured by the agent and the return value is correct. /// @@ -129,7 +129,7 @@ public void SimpleActionWithReturnType() => AssertWith1Transaction(agent => /// /// Tests the - /// method. + /// method. /// It wraps a fake transaction (Thread.Sleep) with a return value into the CaptureTransaction method with an /// parameter /// and it makes sure that the transaction is captured by the agent and the return value is correct and the @@ -151,7 +151,7 @@ public void SimpleActionWithReturnTypeAndParameter() => AssertWith1Transaction(a /// /// Tests the - /// method + /// method /// with an /// exception. /// It wraps a fake transaction (Thread.Sleep) with a return value that throws an exception into the CaptureTransaction @@ -180,7 +180,7 @@ public void SimpleActionWithReturnTypeAndExceptionAndParameter() => AssertWith1T }); /// - /// Tests the method with + /// Tests the method with /// an exception. /// It wraps a fake transaction (Thread.Sleep) with a return value that throws an exception into the CaptureTransaction /// method @@ -206,7 +206,7 @@ public void SimpleActionWithReturnTypeAndException() => AssertWith1TransactionAn }); /// - /// Tests the method. + /// Tests the method. /// It wraps a fake async transaction (Task.Delay) into the CaptureTransaction method /// and it makes sure that the transaction is captured. /// @@ -218,7 +218,7 @@ await agent.Tracer.CaptureTransaction(TransactionName, TransactionType, }); /// - /// Tests the method with + /// Tests the method with /// an exception /// It wraps a fake async transaction (Task.Delay) that throws an exception into the CaptureTransaction method /// and it makes sure that the transaction and the error are captured. @@ -239,7 +239,7 @@ await agent.Tracer.CaptureTransaction(TransactionName, TransactionType, async () /// /// Tests the - /// method. + /// method. /// It wraps a fake async transaction (Task.Delay) into the CaptureTransaction method with an /// parameter /// and it makes sure that the transaction is captured and the parameter is not null. @@ -257,7 +257,7 @@ await agent.Tracer.CaptureTransaction(TransactionName, TransactionType, /// /// Tests the - /// method + /// method /// with an /// exception. /// It wraps a fake async transaction (Task.Delay) that throws an exception into the CaptureTransaction method with an @@ -281,7 +281,7 @@ await agent.Tracer.CaptureTransaction(TransactionName, TransactionType, async t }); /// - /// Tests the + /// Tests the /// method. /// It wraps a fake async transaction (Task.Delay) with a return value into the CaptureTransaction method /// and it makes sure that the transaction is captured by the agent and the return value is correct. @@ -299,7 +299,7 @@ public async Task AsyncTaskWithReturnType() => await AssertWith1TransactionAsync /// /// Tests the - /// + /// /// method. /// It wraps a fake async transaction (Task.Delay) with a return value into the CaptureTransaction method with an /// parameter @@ -322,7 +322,7 @@ public async Task AsyncTaskWithReturnTypeAndParameter() => await AssertWith1Tran /// /// Tests the - /// + /// /// method with an /// exception. /// It wraps a fake async transaction (Task.Delay) with a return value that throws an exception into the CaptureTransaction @@ -350,7 +350,7 @@ await agent.Tracer.CaptureTransaction(TransactionName, TransactionType, async t }); /// - /// Tests the + /// Tests the /// method with an exception. /// It wraps a fake async transaction (Task.Delay) with a return value that throws an exception into the CaptureTransaction /// method diff --git a/test/Elastic.Apm.Tests/ApiTests/CulpritTests.cs b/test/Elastic.Apm.Tests/ApiTests/CulpritTests.cs index 47863be8d..b12d332a4 100644 --- a/test/Elastic.Apm.Tests/ApiTests/CulpritTests.cs +++ b/test/Elastic.Apm.Tests/ApiTests/CulpritTests.cs @@ -3,11 +3,13 @@ // See the LICENSE file in the project root for more information using System; -using Elastic.Apm.Tests.Mocks; +using System.Runtime.CompilerServices; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using LibraryNamespace; using Test.Application; using Xunit; +using Xunit.Abstractions; namespace Elastic.Apm.Tests.ApiTests { @@ -135,6 +137,8 @@ namespace Test.Application { public class ApplicationClass { + // Don't allow the method to be inlined, which it might be in Release Configuration + [MethodImpl(MethodImplOptions.NoInlining)] public void Method1() => new LibraryClass().LibraryMethod(); } } diff --git a/test/Elastic.Apm.Tests/ApiTests/DistributedTracingDataTests.cs b/test/Elastic.Apm.Tests/ApiTests/DistributedTracingDataTests.cs index b95561039..fa676f584 100644 --- a/test/Elastic.Apm.Tests/ApiTests/DistributedTracingDataTests.cs +++ b/test/Elastic.Apm.Tests/ApiTests/DistributedTracingDataTests.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Elastic.Apm.Api; using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/BackendCommTests/BackendCommUtilsTests.cs b/test/Elastic.Apm.Tests/BackendCommTests/BackendCommUtilsTests.cs index 4f226f17e..cf4cc43c2 100644 --- a/test/Elastic.Apm.Tests/BackendCommTests/BackendCommUtilsTests.cs +++ b/test/Elastic.Apm.Tests/BackendCommTests/BackendCommUtilsTests.cs @@ -4,13 +4,12 @@ using System; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; using static Elastic.Apm.BackendComm.BackendCommUtils.ApmServerEndpoints; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; // ReSharper disable ImplicitlyCapturedClosure diff --git a/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigFetcherTests.cs b/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigFetcherTests.cs index 33c4a7e4c..feace4e90 100644 --- a/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigFetcherTests.cs +++ b/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigFetcherTests.cs @@ -15,8 +15,7 @@ using Elastic.Apm.Helpers; using Elastic.Apm.Logging; using Elastic.Apm.Report; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using FluentAssertions.Extensions; using RichardSzalay.MockHttp; @@ -37,15 +36,14 @@ public void Should_Update_Logger_That_Is_ILogLevelSwitchable() { var testLogger = new ConsoleLogger(LogLevel.Trace); - var environmentConfigurationReader = new EnvironmentConfigurationReader(); - var configSnapshotFromReader = new ConfigSnapshotFromReader(environmentConfigurationReader, "local"); + var configSnapshotFromReader = new MockConfigSnapshot(testLogger); var configStore = new ConfigStore(configSnapshotFromReader, testLogger); - var service = Service.GetDefaultService(environmentConfigurationReader, testLogger); + var service = Service.GetDefaultService(configSnapshotFromReader, testLogger); var waitHandle = new ManualResetEvent(false); var handler = new MockHttpMessageHandler(); var configUrl = BackendCommUtils.ApmServerEndpoints - .BuildGetConfigAbsoluteUrl(environmentConfigurationReader.ServerUrl, service); + .BuildGetConfigAbsoluteUrl(configSnapshotFromReader.ServerUrl, service); handler.When(configUrl.AbsoluteUri) .Respond(_ => @@ -66,7 +64,7 @@ public void Should_Update_Logger_That_Is_ILogLevelSwitchable() { centralConfigFetcher.IsRunning.Should().BeTrue(); waitHandle.WaitOne(); - Thread.Sleep(TimeSpan.FromSeconds(3)); + Thread.Sleep(5.Seconds()); } testLogger.LogLevelSwitch.Level.Should().Be(LogLevel.Error); @@ -93,15 +91,14 @@ public void Should_Not_Update_Logger_That_Is_Not_ILogLevelSwitchable() { var testLogger = new UnswitchableLogger(new LogLevelSwitch(LogLevel.Trace)); - var environmentConfigurationReader = new EnvironmentConfigurationReader(); - var configSnapshotFromReader = new ConfigSnapshotFromReader(environmentConfigurationReader, "local"); + var configSnapshotFromReader = new MockConfigSnapshot(testLogger); var configStore = new ConfigStore(configSnapshotFromReader, testLogger); - var service = Service.GetDefaultService(environmentConfigurationReader, testLogger); + var service = Service.GetDefaultService(configSnapshotFromReader, testLogger); var waitHandle = new ManualResetEvent(false); var handler = new MockHttpMessageHandler(); var configUrl = BackendCommUtils.ApmServerEndpoints - .BuildGetConfigAbsoluteUrl(environmentConfigurationReader.ServerUrl, service); + .BuildGetConfigAbsoluteUrl(configSnapshotFromReader.ServerUrl, service); handler.When(configUrl.AbsoluteUri) .Respond(_ => @@ -134,8 +131,18 @@ public void Dispose_stops_the_thread() var configSnapshotFromReader = new ConfigSnapshotFromReader(new EnvironmentConfigurationReader(), "local"); var configStore = new ConfigStore(configSnapshotFromReader, LoggerBase); var service = Service.GetDefaultService(new EnvironmentConfigurationReader(), LoggerBase); + var handler = new MockHttpMessageHandler(); + var configUrl = BackendCommUtils.ApmServerEndpoints + .BuildGetConfigAbsoluteUrl(configSnapshotFromReader.ServerUrl, service); + handler.When(configUrl.AbsoluteUri) + .Respond(_ => new HttpResponseMessage(HttpStatusCode.OK) + { + Headers = { ETag = new EntityTagHeaderValue("\"etag\"") }, + Content = new StringContent("{}", Encoding.UTF8) + }); + using (var agent = new ApmAgent(new TestAgentComponents(LoggerBase, - centralConfigFetcher: new CentralConfigFetcher(LoggerBase, configStore, service), + centralConfigFetcher: new CentralConfigFetcher(LoggerBase, configStore, service, handler), payloadSender: new PayloadSenderV2(LoggerBase, configSnapshotFromReader, service, new SystemInfoHelper(LoggerBase).ParseSystemInfo(null), MockApmServerInfo.Version710)))) { @@ -159,12 +166,25 @@ public void Dispose_stops_the_thread() public void Create_many_concurrent_instances(int numberOfAgentInstances) { var agents = new ApmAgent[numberOfAgentInstances]; + numberOfAgentInstances.Repeat(i => { var configSnapshotFromReader = new ConfigSnapshotFromReader(new EnvironmentConfigurationReader(), "local"); - var configStore = new ConfigStore(configSnapshotFromReader, LoggerBase); var service = Service.GetDefaultService(new EnvironmentConfigurationReader(), LoggerBase); - var centralConfigFetcher = new CentralConfigFetcher(LoggerBase, configStore, service); + var configStore = new ConfigStore(configSnapshotFromReader, LoggerBase); + + var handler = new MockHttpMessageHandler(); + var configUrl = BackendCommUtils.ApmServerEndpoints + .BuildGetConfigAbsoluteUrl(configSnapshotFromReader.ServerUrl, service); + + handler.When(configUrl.AbsoluteUri) + .Respond(_ => new HttpResponseMessage(HttpStatusCode.OK) + { + Headers = { ETag = new EntityTagHeaderValue("\"etag\"") }, + Content = new StringContent("{}", Encoding.UTF8) + }); + + var centralConfigFetcher = new CentralConfigFetcher(LoggerBase, configStore, service, handler); var payloadSender = new PayloadSenderV2( LoggerBase, configSnapshotFromReader, diff --git a/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigResponseParserTests.cs b/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigResponseParserTests.cs index 77b37dd63..d2a868e7b 100644 --- a/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigResponseParserTests.cs +++ b/test/Elastic.Apm.Tests/BackendCommTests/CentralConfig/CentralConfigResponseParserTests.cs @@ -11,7 +11,7 @@ using Elastic.Apm.BackendComm.CentralConfig; using Elastic.Apm.Config; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/BackendCommTests/PayloadSenderTests.cs b/test/Elastic.Apm.Tests/BackendCommTests/PayloadSenderTests.cs index 2e3b1f1af..fc8f0e9f9 100644 --- a/test/Elastic.Apm.Tests/BackendCommTests/PayloadSenderTests.cs +++ b/test/Elastic.Apm.Tests/BackendCommTests/PayloadSenderTests.cs @@ -16,13 +16,12 @@ using Elastic.Apm.Logging; using Elastic.Apm.Model; using Elastic.Apm.Report; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using FluentAssertions.Extensions; using Xunit; using Xunit.Abstractions; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.BackendCommTests { diff --git a/test/Elastic.Apm.Tests/BasicAgentTests.cs b/test/Elastic.Apm.Tests/BasicAgentTests.cs index e86146c26..898a153f6 100644 --- a/test/Elastic.Apm.Tests/BasicAgentTests.cs +++ b/test/Elastic.Apm.Tests/BasicAgentTests.cs @@ -7,7 +7,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; @@ -22,10 +22,10 @@ "Elastic.Apm.EntityFrameworkCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] [assembly: InternalsVisibleTo( - "Elastic.Apm.PerfTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] + "Elastic.Apm.Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] [assembly: InternalsVisibleTo( - "Elastic.Apm.DockerTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] + "Elastic.Apm.Docker.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] [assembly: InternalsVisibleTo( "Elastic.Apm.AspNetFullFramework.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1")] diff --git a/test/Elastic.Apm.Tests/Cloud/AwsCloudMetadataProviderTests.cs b/test/Elastic.Apm.Tests/Cloud/AwsCloudMetadataProviderTests.cs index 54bc66cbc..a7a05bcd3 100644 --- a/test/Elastic.Apm.Tests/Cloud/AwsCloudMetadataProviderTests.cs +++ b/test/Elastic.Apm.Tests/Cloud/AwsCloudMetadataProviderTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Elastic.Apm.Cloud; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Newtonsoft.Json; using RichardSzalay.MockHttp; diff --git a/test/Elastic.Apm.Tests/Cloud/AzureAppServiceMetadataProviderTests.cs b/test/Elastic.Apm.Tests/Cloud/AzureAppServiceMetadataProviderTests.cs index 87f459f00..b7b9888d3 100644 --- a/test/Elastic.Apm.Tests/Cloud/AzureAppServiceMetadataProviderTests.cs +++ b/test/Elastic.Apm.Tests/Cloud/AzureAppServiceMetadataProviderTests.cs @@ -6,7 +6,7 @@ using System.Collections; using System.Threading.Tasks; using Elastic.Apm.Cloud; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/Cloud/AzureCloudMetadataProviderTests.cs b/test/Elastic.Apm.Tests/Cloud/AzureCloudMetadataProviderTests.cs index 763cd2ec2..902345ec2 100644 --- a/test/Elastic.Apm.Tests/Cloud/AzureCloudMetadataProviderTests.cs +++ b/test/Elastic.Apm.Tests/Cloud/AzureCloudMetadataProviderTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Elastic.Apm.Cloud; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Newtonsoft.Json; using RichardSzalay.MockHttp; diff --git a/test/Elastic.Apm.Tests/Cloud/CloudMetadataProviderCollectionTests.cs b/test/Elastic.Apm.Tests/Cloud/CloudMetadataProviderCollectionTests.cs index ffae9fa6e..e6ba9655d 100644 --- a/test/Elastic.Apm.Tests/Cloud/CloudMetadataProviderCollectionTests.cs +++ b/test/Elastic.Apm.Tests/Cloud/CloudMetadataProviderCollectionTests.cs @@ -5,7 +5,7 @@ using System.Linq; using Elastic.Apm.Cloud; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using static Elastic.Apm.Config.ConfigConsts; diff --git a/test/Elastic.Apm.Tests/Cloud/GcpCloudMetadataProviderTests.cs b/test/Elastic.Apm.Tests/Cloud/GcpCloudMetadataProviderTests.cs index b6c097166..20247f51a 100644 --- a/test/Elastic.Apm.Tests/Cloud/GcpCloudMetadataProviderTests.cs +++ b/test/Elastic.Apm.Tests/Cloud/GcpCloudMetadataProviderTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Elastic.Apm.Cloud; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Newtonsoft.Json; using RichardSzalay.MockHttp; diff --git a/test/Elastic.Apm.Tests/ConfigTests.cs b/test/Elastic.Apm.Tests/ConfigTests.cs index 1cf5341ac..27bc41ccf 100644 --- a/test/Elastic.Apm.Tests/ConfigTests.cs +++ b/test/Elastic.Apm.Tests/ConfigTests.cs @@ -10,8 +10,8 @@ using Elastic.Apm.Helpers; using Elastic.Apm.Logging; using Elastic.Apm.Metrics; -using Elastic.Apm.Tests.Data; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; +using Elastic.Apm.Tests.Utilities.Data; using FluentAssertions; using Xunit; using static Elastic.Apm.Config.ConfigConsts; diff --git a/test/Elastic.Apm.Tests/Elastic.Apm.Tests.csproj b/test/Elastic.Apm.Tests/Elastic.Apm.Tests.csproj index b735e4dfb..b270b2ed5 100644 --- a/test/Elastic.Apm.Tests/Elastic.Apm.Tests.csproj +++ b/test/Elastic.Apm.Tests/Elastic.Apm.Tests.csproj @@ -11,21 +11,21 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + + all + runtime; build; native; contentfiles; analyzers + + diff --git a/test/Elastic.Apm.Tests/EnabledAndRecordingTests.cs b/test/Elastic.Apm.Tests/EnabledAndRecordingTests.cs index 2e0b5f955..9789eac90 100644 --- a/test/Elastic.Apm.Tests/EnabledAndRecordingTests.cs +++ b/test/Elastic.Apm.Tests/EnabledAndRecordingTests.cs @@ -8,7 +8,7 @@ using Elastic.Apm.Api; using Elastic.Apm.DiagnosticSource; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Moq; using Xunit; @@ -233,7 +233,7 @@ public void CaptureTransactionAndSpansWithEnabledOnFalse() { var mockPayloadSender = new MockPayloadSender(); var mockConfigSnapshot = new MockConfigSnapshot(enabled: "false"); - using var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender, configurationReader: mockConfigSnapshot)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender, config: mockConfigSnapshot)); CreateTransactionsAndSpans(agent); @@ -253,7 +253,7 @@ public void CaptureTransactionAndSpansWithRecordingOnFalse() { var mockPayloadSender = new MockPayloadSender(); var mockConfigSnapshot = new MockConfigSnapshot(recording: "false"); - using var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender, configurationReader: mockConfigSnapshot)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender, config: mockConfigSnapshot)); CreateTransactionsAndSpans(agent); @@ -273,7 +273,7 @@ public void CustomAndLabelDontThrowNullRef() { var mockPayloadSender = new MockPayloadSender(); var mockConfigSnapshot = new MockConfigSnapshot(enabled: "false"); - using var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender, configurationReader: mockConfigSnapshot)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender, config: mockConfigSnapshot)); var transaction = agent.Tracer.StartTransaction("foo", "bar"); transaction.Should().BeOfType(); diff --git a/test/Elastic.Apm.Tests/ErrorTests.cs b/test/Elastic.Apm.Tests/ErrorTests.cs index 42daacd54..8ce9d0c60 100644 --- a/test/Elastic.Apm.Tests/ErrorTests.cs +++ b/test/Elastic.Apm.Tests/ErrorTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using Elastic.Apm.Api; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; @@ -52,14 +52,14 @@ public void ChangeTransactionContextAfterError() mockPayloadSender.FirstError.Should().NotBeNull("first error should not be null"); mockPayloadSender.FirstError.Context.Should().NotBeNull("context should not be null"); mockPayloadSender.FirstError.Context.Request.Method.Should().Be("GET"); - mockPayloadSender.FirstError.Context.Request.Body = "abc"; + mockPayloadSender.FirstError.Context.Request.Body.Should().Be("abc"); mockPayloadSender.FirstError.Context.Request.Headers.Count.Should().Be(1); - mockPayloadSender.FirstError.Context.Request.Headers["header1"] = "headerValue"; - mockPayloadSender.FirstError.Context.Request.Url.Full = "http://localhost"; - mockPayloadSender.FirstError.Context.Request.Url.Protocol = "http"; - mockPayloadSender.FirstError.Context.Request.Url.Search = "abc"; - mockPayloadSender.FirstError.Context.Response.StatusCode = 404; - mockPayloadSender.FirstError.Context.Response.Finished = false; + mockPayloadSender.FirstError.Context.Request.Headers["header1"].Should().Be("headerValue"); + mockPayloadSender.FirstError.Context.Request.Url.Full.Should().Be("http://localhost"); + mockPayloadSender.FirstError.Context.Request.Url.Protocol.Should().Be("http"); + mockPayloadSender.FirstError.Context.Request.Url.Search.Should().Be("abc"); + mockPayloadSender.FirstError.Context.Response.StatusCode.Should().Be(404); + mockPayloadSender.FirstError.Context.Response.Finished.Should().BeFalse(); mockPayloadSender.FirstError.Context.InternalLabels.Value.InnerDictionary["foo"].Value.Should().Be("bar"); mockPayloadSender.FirstError.Context.Response.Headers.Should().BeNull(); }); @@ -67,15 +67,15 @@ public void ChangeTransactionContextAfterError() // Asserts on the captured transaction mockPayloadSender.WaitForTransactions(); mockPayloadSender.FirstTransaction.Context.Request.Method.Should().Be("PUT"); - mockPayloadSender.FirstTransaction.Context.Request.Body = "cde"; + mockPayloadSender.FirstTransaction.Context.Request.Body.Should().Be("cde"); mockPayloadSender.FirstTransaction.Context.Request.Headers.Count.Should().Be(2); - mockPayloadSender.FirstTransaction.Context.Request.Headers["header1"] = "headerValue"; - mockPayloadSender.FirstTransaction.Context.Request.Headers["header2"] = "headerValue"; - mockPayloadSender.FirstTransaction.Context.Request.Url.Full = "http://elastic.co"; - mockPayloadSender.FirstTransaction.Context.Request.Url.Protocol = "tcp"; - mockPayloadSender.FirstTransaction.Context.Request.Url.Search = "cde"; - mockPayloadSender.FirstTransaction.Context.Response.StatusCode = 500; - mockPayloadSender.FirstTransaction.Context.Response.Finished = true; + mockPayloadSender.FirstTransaction.Context.Request.Headers["header1"].Should().Be("headerValue"); + mockPayloadSender.FirstTransaction.Context.Request.Headers["header2"].Should().Be("headerValue"); + mockPayloadSender.FirstTransaction.Context.Request.Url.Full.Should().Be("http://elastic.co"); + mockPayloadSender.FirstTransaction.Context.Request.Url.Protocol.Should().Be("tcp"); + mockPayloadSender.FirstTransaction.Context.Request.Url.Search.Should().Be("cde"); + mockPayloadSender.FirstTransaction.Context.Response.StatusCode.Should().Be(500); + mockPayloadSender.FirstTransaction.Context.Response.Finished.Should().BeTrue(); mockPayloadSender.FirstTransaction.Context.InternalLabels.Value.InnerDictionary["foo"].Value.Should().Be("bar"); mockPayloadSender.FirstTransaction.Context.Response.Headers.Should().BeNull(); } @@ -87,7 +87,7 @@ public void ChangeTransactionContextAfterError() public void ErrorOnEmptyTransaction() { var mockPayloadSender = new MockPayloadSender(); - using var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender)); agent.Tracer.CaptureTransaction("Test", "Test", t => { @@ -109,7 +109,7 @@ public void ErrorOnEmptyTransaction() public void ErrorOnTransactionWithEmptyHeaders() { var mockPayloadSender = new MockPayloadSender(); - using var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender)); agent.Tracer.CaptureTransaction("Test", "Test", t => { diff --git a/test/Elastic.Apm.Tests/Extensions/EnumerableExtensionsTests.cs b/test/Elastic.Apm.Tests/Extensions/EnumerableExtensionsTests.cs index ba2227fa8..7488f40d3 100644 --- a/test/Elastic.Apm.Tests/Extensions/EnumerableExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/Extensions/EnumerableExtensionsTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/FilterTests.cs b/test/Elastic.Apm.Tests/FilterTests.cs index c2bf3d53a..1ac1e21b2 100644 --- a/test/Elastic.Apm.Tests/FilterTests.cs +++ b/test/Elastic.Apm.Tests/FilterTests.cs @@ -16,8 +16,7 @@ using Elastic.Apm.Model; using Elastic.Apm.Report; using Elastic.Apm.Report.Serialization; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/test/Elastic.Apm.Tests/HelpersTests/AgentSpinLockTests.cs b/test/Elastic.Apm.Tests/HelpersTests/AgentSpinLockTests.cs index 7f812cff0..88edadb6a 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/AgentSpinLockTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/AgentSpinLockTests.cs @@ -7,12 +7,11 @@ using System.Threading; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.HelpersTests { diff --git a/test/Elastic.Apm.Tests/HelpersTests/AgentTimeInstantTests.cs b/test/Elastic.Apm.Tests/HelpersTests/AgentTimeInstantTests.cs index c18ab7c37..66e44e11d 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/AgentTimeInstantTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/AgentTimeInstantTests.cs @@ -5,13 +5,12 @@ using System; using System.Collections.Generic; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using FluentAssertions.Extensions; using Xunit; using Xunit.Abstractions; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.HelpersTests { @@ -35,7 +34,7 @@ public static IEnumerable AgentTimeInstantSourceVariantsToTest() var longTimeSpans = new[] { 0.Days() + 9.Hours() + 8.Minutes() + 7.Seconds() + 6.Milliseconds(), - 1.Day() + 2.Hours() + 3.Minutes() + 4.Seconds() + 5.Milliseconds() + 1.Days() + 2.Hours() + 3.Minutes() + 4.Seconds() + 5.Milliseconds() }; foreach (var timeSpan in longTimeSpans) yield return new[] { (object)new MockAgentTimer(), timeSpan }; diff --git a/test/Elastic.Apm.Tests/HelpersTests/AgentTimerTests.cs b/test/Elastic.Apm.Tests/HelpersTests/AgentTimerTests.cs index fd1a80925..fc5793aed 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/AgentTimerTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/AgentTimerTests.cs @@ -9,8 +9,7 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using FluentAssertions.Extensions; using Xunit; @@ -23,7 +22,7 @@ public class AgentTimerTests : LoggingTestBase private const string ThisClassName = nameof(AgentTimerTests); private static readonly TimeSpan ShortTimeAfterTaskStarted = 10.Milliseconds(); - private static readonly TimeSpan VeryLongTimeout = 1.Day(); + private static readonly TimeSpan VeryLongTimeout = 1.Days(); private static readonly TimeSpan VeryShortTimeout = 20.Milliseconds(); private readonly IApmLogger _logger; diff --git a/test/Elastic.Apm.Tests/HelpersTests/AssertionTests.cs b/test/Elastic.Apm.Tests/HelpersTests/AssertionTests.cs index f9770d7c9..879bf345b 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/AssertionTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/AssertionTests.cs @@ -5,7 +5,7 @@ using Elastic.Apm.Helpers; using FluentAssertions; using Xunit; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; // ReSharper disable ImplicitlyCapturedClosure diff --git a/test/Elastic.Apm.Tests/HelpersTests/ContractExtensionsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/ContractExtensionsTests.cs index 0b2fb0a65..04195aa0b 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/ContractExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/ContractExtensionsTests.cs @@ -6,7 +6,7 @@ using Elastic.Apm.Helpers; using FluentAssertions; using Xunit; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.HelpersTests { diff --git a/test/Elastic.Apm.Tests/HelpersTests/DbConnectionStringParserTests.cs b/test/Elastic.Apm.Tests/HelpersTests/DbConnectionStringParserTests.cs index 2fabfa6ba..a50435b40 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/DbConnectionStringParserTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/DbConnectionStringParserTests.cs @@ -5,8 +5,7 @@ using System.Text; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.Tests/HelpersTests/DisposableHelperTests.cs b/test/Elastic.Apm.Tests/HelpersTests/DisposableHelperTests.cs index ce810737c..25172a240 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/DisposableHelperTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/DisposableHelperTests.cs @@ -6,7 +6,7 @@ using System.Linq; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/HelpersTests/ExceptionUtilsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/ExceptionUtilsTests.cs index 651ea9970..d69dfdf74 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/ExceptionUtilsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/ExceptionUtilsTests.cs @@ -7,8 +7,7 @@ using System.Threading.Tasks; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/HelpersTests/IntExtensionsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/IntExtensionsTests.cs index ecbca0eae..5532ad68d 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/IntExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/IntExtensionsTests.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information using System.Threading.Tasks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/HelpersTests/LazyContextualInitTests.cs b/test/Elastic.Apm.Tests/HelpersTests/LazyContextualInitTests.cs index 286d435dc..fc25e93aa 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/LazyContextualInitTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/LazyContextualInitTests.cs @@ -6,8 +6,7 @@ using System.Collections.Generic; using System.Linq; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/HelpersTests/PlatformDetectionTests.cs b/test/Elastic.Apm.Tests/HelpersTests/PlatformDetectionTests.cs index 33768e405..5c3687e55 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/PlatformDetectionTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/PlatformDetectionTests.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; using Elastic.Apm.Api; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; @@ -21,7 +21,7 @@ public class PlatformDetectionTests public void RuntimeName() { var mockPayloadSender = new MockPayloadSender(); - using (var agent = new ApmAgent(new AgentComponents(payloadSender: mockPayloadSender))) + using (var agent = new ApmAgent(new TestAgentComponents(payloadSender: mockPayloadSender))) agent.Tracer.CaptureTransaction("TestTransaction", "Test", () => { }); switch (RuntimeInformation.FrameworkDescription) diff --git a/test/Elastic.Apm.Tests/HelpersTests/StringExtensionsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/StringExtensionsTests.cs index 8ca103ba2..b6b6c40dc 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/StringExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/StringExtensionsTests.cs @@ -6,7 +6,7 @@ using Elastic.Apm.Helpers; using FluentAssertions; using Xunit; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.HelpersTests { diff --git a/test/Elastic.Apm.Tests/HelpersTests/TimeExtensionsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/TimeExtensionsTests.cs index f0c605106..1ae7bc811 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/TimeExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/TimeExtensionsTests.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.TestHelpers; using FluentAssertions; using FluentAssertions.Extensions; using Xunit; @@ -16,9 +15,9 @@ public class TimeExtensionsTests { private static readonly ValueTuple[] ToHmsStringVariantsInternal = { - (TimeSpan.Zero, "0"), (1.Nanosecond(), "0"), (49.Nanosecond(), "0"), (51.Nanosecond(), "100ns"), (99.Nanosecond(), "100ns"), - (100.Nanosecond(), "100ns"), (150.Nanosecond(), "200ns"), (199.Nanosecond(), "200ns"), (200.Nanosecond(), "200ns"), - (1200.Nanosecond(), "1us 200ns"), (1.Microseconds(), "1us"), (1.Millisecond(), "1ms"), (2.Second(), "2s"), (3.Minutes(), "3m"), + (TimeSpan.Zero, "0"), (1.Nanoseconds(), "0"), (49.Nanoseconds(), "0"), (51.Nanoseconds(), "100ns"), (99.Nanoseconds(), "100ns"), + (100.Nanoseconds(), "100ns"), (150.Nanoseconds(), "200ns"), (199.Nanoseconds(), "200ns"), (200.Nanoseconds(), "200ns"), + (1200.Nanoseconds(), "1us 200ns"), (1.Microseconds(), "1us"), (1.Milliseconds(), "1ms"), (2.Seconds(), "2s"), (3.Minutes(), "3m"), (4.Hours(), "4h"), (5.Days(), "5d"), (678.Days(), "678d"), (9.Days() + 8.Hours() + 7.Minutes() + 6.Seconds() + 5.Milliseconds(), "9d 8h 7m 6s 5ms"), ( 1200.Days() + 25.Hours() + 59.Minutes() + 52.Seconds() + 9876.Milliseconds() + 2345.Microseconds() + 6789.Nanoseconds() @@ -115,14 +114,14 @@ public static IEnumerable GenTruncateToSecondsVariants() { TimeSpan[] deltas = { - TimeSpan.Zero, TimeSpan.FromTicks(1), 1.Nanosecond(), 999.Nanosecond(), 1.Microsecond(), 999.Microseconds(), 1.Millisecond(), + TimeSpan.Zero, TimeSpan.FromTicks(1), 1.Nanoseconds(), 999.Nanoseconds(), 1.Microseconds(), 999.Microseconds(), 1.Milliseconds(), 501.Milliseconds(), 789.Milliseconds(), 999.Milliseconds() }; TimeSpan[] baseTimeSpans = { - TimeSpan.Zero, 1.Second(), 59.Second(), 1.Minute() + 7.Second(), 29.Minutes() + 23.Second(), 53.Minutes(), 1.Hour(), - 13.Hours() + 29.Minutes() + 23.Second(), 22.Hours() + 1.Minute() + 7.Second() + TimeSpan.Zero, 1.Seconds(), 59.Seconds(), 1.Minutes() + 7.Seconds(), 29.Minutes() + 23.Seconds(), 53.Minutes(), 1.Hours(), + 13.Hours() + 29.Minutes() + 23.Seconds(), 22.Hours() + 1.Minutes() + 7.Seconds() }; IEnumerable> GenBasePlusDeltas() @@ -165,15 +164,15 @@ public static IEnumerable GenToHmsInSecondsVariants() { TimeSpan[] deltas = { - TimeSpan.Zero, TimeSpan.FromTicks(1), 1.Nanosecond(), 999.Nanosecond(), 1.Microsecond(), 999.Microseconds(), 1.Millisecond(), + TimeSpan.Zero, TimeSpan.FromTicks(1), 1.Nanoseconds(), 999.Nanoseconds(), 1.Microseconds(), 999.Microseconds(), 1.Milliseconds(), 501.Milliseconds(), 789.Milliseconds(), 999.Milliseconds() }; ValueTuple[] baseVariants = { - (TimeSpan.Zero, "0s"), (1.Second(), "1s"), (59.Second(), "59s"), (1.Minute() + 7.Second(), "1m 7s"), - (29.Minutes() + 23.Second(), "29m 23s"), (53.Minutes(), "53m"), (1.Hour() + 29.Minutes() + 23.Second(), "1h 29m 23s"), - (13.Hours() + 59.Second(), "13h 59s"), (22.Hours() + 1.Minute() + 7.Second(), "22h 1m 7s") + (TimeSpan.Zero, "0s"), (1.Seconds(), "1s"), (59.Seconds(), "59s"), (1.Minutes() + 7.Seconds(), "1m 7s"), + (29.Minutes() + 23.Seconds(), "29m 23s"), (53.Minutes(), "53m"), (1.Hours() + 29.Minutes() + 23.Seconds(), "1h 29m 23s"), + (13.Hours() + 59.Seconds(), "13h 59s"), (22.Hours() + 1.Minutes() + 7.Seconds(), "22h 1m 7s") }; IEnumerable> GenBasePlusDeltas() @@ -203,7 +202,7 @@ IEnumerable> AddNegativeVariants(IEnumerable= 1.Second()) + if (timeSpan >= 1.Seconds()) yield return (-timeSpan, "-" + hmsInSeconds); else yield return (-timeSpan, ">-1s"); diff --git a/test/Elastic.Apm.Tests/HelpersTests/TimeUtilsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/TimeUtilsTests.cs index f86bb86c9..54ace11cb 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/TimeUtilsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/TimeUtilsTests.cs @@ -6,7 +6,7 @@ using Elastic.Apm.Helpers; using FluentAssertions; using Xunit; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; namespace Elastic.Apm.Tests.HelpersTests { diff --git a/test/Elastic.Apm.Tests/HelpersTests/UrlUtilsTests.cs b/test/Elastic.Apm.Tests/HelpersTests/UrlUtilsTests.cs index 9661c5a06..b0d64c860 100644 --- a/test/Elastic.Apm.Tests/HelpersTests/UrlUtilsTests.cs +++ b/test/Elastic.Apm.Tests/HelpersTests/UrlUtilsTests.cs @@ -5,7 +5,7 @@ using System; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/HttpDiagnosticListenerTests.cs b/test/Elastic.Apm.Tests/HttpDiagnosticListenerTests.cs index d0da671ab..641e353fe 100644 --- a/test/Elastic.Apm.Tests/HttpDiagnosticListenerTests.cs +++ b/test/Elastic.Apm.Tests/HttpDiagnosticListenerTests.cs @@ -17,8 +17,7 @@ using Elastic.Apm.DiagnosticSource; using Elastic.Apm.Logging; using Elastic.Apm.Tests.HelpersTests; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using FluentAssertions.Execution; using Xunit; diff --git a/test/Elastic.Apm.Tests/InstrumentationFlagTests.cs b/test/Elastic.Apm.Tests/InstrumentationFlagTests.cs index 5b8c1961b..0adea546d 100644 --- a/test/Elastic.Apm.Tests/InstrumentationFlagTests.cs +++ b/test/Elastic.Apm.Tests/InstrumentationFlagTests.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/LabelTests.cs b/test/Elastic.Apm.Tests/LabelTests.cs index ef1c119cd..eaf8a6f00 100644 --- a/test/Elastic.Apm.Tests/LabelTests.cs +++ b/test/Elastic.Apm.Tests/LabelTests.cs @@ -10,7 +10,7 @@ using System.Linq; using Elastic.Apm.Api; using Elastic.Apm.Report.Serialization; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/LoggerTests.cs b/test/Elastic.Apm.Tests/LoggerTests.cs index ff47221c8..320fd2b31 100644 --- a/test/Elastic.Apm.Tests/LoggerTests.cs +++ b/test/Elastic.Apm.Tests/LoggerTests.cs @@ -11,7 +11,7 @@ using Elastic.Apm.Config; using Elastic.Apm.Logging; using Elastic.Apm.Report; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; @@ -354,7 +354,7 @@ public void PayloadSenderNoUserNamePwPrintedForServerUrl() using var payloadSender = new PayloadSenderV2(inMemoryLogger, configReader, Service.GetDefaultService(configReader, inMemoryLogger), new Api.System(), MockApmServerInfo.Version710); - using var agent = new ApmAgent(new AgentComponents(payloadSender: payloadSender)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender)); agent.Tracer.CaptureTransaction("Test", "TestTransaction", () => { }); @@ -384,7 +384,7 @@ public void PayloadSenderNoUserNamePwPrintedForServerUrlWithServerReturn() using var payloadSender = new PayloadSenderV2(inMemoryLogger, configReader, Service.GetDefaultService(configReader, inMemoryLogger), new Api.System(), MockApmServerInfo.Version710); - using var agent = new ApmAgent(new AgentComponents(payloadSender: payloadSender)); + using var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender)); agent.Tracer.CaptureTransaction("Test", "TestTransaction", () => { }); diff --git a/test/Elastic.Apm.Tests/Metrics/CgroupMetricsProviderTests.cs b/test/Elastic.Apm.Tests/Metrics/CgroupMetricsProviderTests.cs index cb6be8e65..0c649bce9 100644 --- a/test/Elastic.Apm.Tests/Metrics/CgroupMetricsProviderTests.cs +++ b/test/Elastic.Apm.Tests/Metrics/CgroupMetricsProviderTests.cs @@ -7,8 +7,7 @@ using System.IO; using System.Linq; using Elastic.Apm.Metrics.MetricsProvider; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using static Elastic.Apm.Metrics.MetricsProvider.CgroupMetricsProvider; diff --git a/test/Elastic.Apm.Tests/MetricsTests.cs b/test/Elastic.Apm.Tests/MetricsTests.cs index 3a6d903bc..e278a61de 100644 --- a/test/Elastic.Apm.Tests/MetricsTests.cs +++ b/test/Elastic.Apm.Tests/MetricsTests.cs @@ -15,8 +15,7 @@ using Elastic.Apm.Logging; using Elastic.Apm.Metrics; using Elastic.Apm.Metrics.MetricsProvider; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Microsoft.Diagnostics.Tracing.Session; using Moq; diff --git a/test/Elastic.Apm.Tests/SamplerTests.cs b/test/Elastic.Apm.Tests/SamplerTests.cs index 6c0cda38a..88416fbde 100644 --- a/test/Elastic.Apm.Tests/SamplerTests.cs +++ b/test/Elastic.Apm.Tests/SamplerTests.cs @@ -7,8 +7,7 @@ using System.Globalization; using Elastic.Apm.Helpers; using Elastic.Apm.Model; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/SerializationTests.cs b/test/Elastic.Apm.Tests/SerializationTests.cs index 4b85f5e11..c534410a1 100644 --- a/test/Elastic.Apm.Tests/SerializationTests.cs +++ b/test/Elastic.Apm.Tests/SerializationTests.cs @@ -10,7 +10,7 @@ using Elastic.Apm.Metrics; using Elastic.Apm.Model; using Elastic.Apm.Report.Serialization; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/test/Elastic.Apm.Tests/SpanTests.cs b/test/Elastic.Apm.Tests/SpanTests.cs index 4f570708f..ccd8eb639 100644 --- a/test/Elastic.Apm.Tests/SpanTests.cs +++ b/test/Elastic.Apm.Tests/SpanTests.cs @@ -1,10 +1,10 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information - +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + using System; using System.Diagnostics; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/StackTraceTests.cs b/test/Elastic.Apm.Tests/StackTraceTests.cs index 65808db57..e262bb65b 100644 --- a/test/Elastic.Apm.Tests/StackTraceTests.cs +++ b/test/Elastic.Apm.Tests/StackTraceTests.cs @@ -12,7 +12,7 @@ using Elastic.Apm.Model; using Elastic.Apm.ServerInfo; using Elastic.Apm.Tests.Extensions; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/StaticTests.cs b/test/Elastic.Apm.Tests/StaticTests.cs index 7ce37b87a..6c9e5202c 100644 --- a/test/Elastic.Apm.Tests/StaticTests.cs +++ b/test/Elastic.Apm.Tests/StaticTests.cs @@ -2,7 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/SystemInfoHelperTests.cs b/test/Elastic.Apm.Tests/SystemInfoHelperTests.cs index d0ed95095..d37f327aa 100644 --- a/test/Elastic.Apm.Tests/SystemInfoHelperTests.cs +++ b/test/Elastic.Apm.Tests/SystemInfoHelperTests.cs @@ -7,7 +7,7 @@ using Elastic.Apm.Api; using Elastic.Apm.Api.Kubernetes; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensionsTests.cs b/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensionsTests.cs index 2cc0b27a8..b46d56208 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensionsTests.cs +++ b/test/Elastic.Apm.Tests/TestHelpers/EnumerableTestExtensionsTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information using System; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtilsTests.cs b/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtilsTests.cs index 362c7a8c0..43d0ab21e 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtilsTests.cs +++ b/test/Elastic.Apm.Tests/TestHelpers/MultiThreadsTestUtilsTests.cs @@ -4,6 +4,7 @@ using System; using Elastic.Apm.Tests.Extensions; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelperTests.cs b/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelperTests.cs index 3e6e45075..a7e70ee33 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelperTests.cs +++ b/test/Elastic.Apm.Tests/TestHelpers/RandomTestHelperTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; diff --git a/test/Elastic.Apm.Tests/TestHelpers/TestingConfigTests.cs b/test/Elastic.Apm.Tests/TestHelpers/TestingConfigTests.cs index c34fbb77c..945a26419 100644 --- a/test/Elastic.Apm.Tests/TestHelpers/TestingConfigTests.cs +++ b/test/Elastic.Apm.Tests/TestHelpers/TestingConfigTests.cs @@ -9,11 +9,11 @@ using System.Reflection; using Elastic.Apm.Helpers; using Elastic.Apm.Logging; -using Elastic.Apm.Tests.Extensions; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; using Xunit.Abstractions; -using static Elastic.Apm.Tests.TestHelpers.TestingConfig; +using static Elastic.Apm.Tests.Utilities.TestingConfig; namespace Elastic.Apm.Tests.TestHelpers { @@ -212,7 +212,7 @@ private static void TestOptionMetadata( } } - private class MockRawConfigSnapshot : IRawConfigSnapshot + private class MockRawConfigSnapshot : TestingConfig.IRawConfigSnapshot { private readonly IReadOnlyDictionary _dictionary; diff --git a/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensions.cs b/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensions.cs deleted file mode 100644 index 768da0dcf..000000000 --- a/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information - -using System; - -namespace Elastic.Apm.Tests.TestHelpers -{ - internal static class TimeTestExtensions - { - internal static TimeSpan Nanosecond(this int amount) => TimeSpan.FromTicks((long)Math.Round(amount * 0.01)); - - internal static TimeSpan Microsecond(this int amount) => TimeSpan.FromTicks(amount * 10); - - internal static TimeSpan Millisecond(this int amount) => TimeSpan.FromMilliseconds(amount); - - internal static TimeSpan Second(this int amount) => TimeSpan.FromSeconds(amount); - - internal static TimeSpan Minute(this int amount) => TimeSpan.FromMinutes(amount); - - internal static TimeSpan Hour(this int amount) => TimeSpan.FromHours(amount); - - internal static TimeSpan Day(this int amount) => TimeSpan.FromDays(amount); - } -} diff --git a/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensionsTests.cs b/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensionsTests.cs deleted file mode 100644 index 860509c1c..000000000 --- a/test/Elastic.Apm.Tests/TestHelpers/TimeTestExtensionsTests.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information - -using System; -using FluentAssertions; -using FluentAssertions.Extensions; -using Xunit; - -namespace Elastic.Apm.Tests.TestHelpers -{ - public class TimeTestExtensionsTests - { - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(12)] - [InlineData(24)] - [InlineData(60)] - [InlineData(365)] - [InlineData(-1)] - [InlineData(-2)] - [InlineData(-12)] - [InlineData(-24)] - [InlineData(-60)] - [InlineData(-365)] - public void test_unit_extensions(int amount) - { - amount.Nanosecond().Should().Be(amount.Nanoseconds()); - amount.Nanosecond().Should().Be(TimeSpan.FromTicks((long)Math.Round(amount / 100.0))); - amount.Microsecond().Should().Be(amount.Microseconds()); - amount.Microsecond().Should().Be(TimeSpan.FromTicks(amount * 10)); - amount.Millisecond().Should().Be(amount.Milliseconds()); - amount.Millisecond().Should().Be(TimeSpan.FromMilliseconds(amount)); - amount.Second().Should().Be(amount.Seconds()); - amount.Second().Should().Be(TimeSpan.FromSeconds(amount)); - amount.Minute().Should().Be(amount.Minutes()); - amount.Minute().Should().Be(TimeSpan.FromMinutes(amount)); - amount.Hour().Should().Be(amount.Hours()); - amount.Hour().Should().Be(TimeSpan.FromHours(amount)); - amount.Day().Should().Be(amount.Days()); - amount.Day().Should().Be(TimeSpan.FromDays(amount)); - } - } -} diff --git a/test/Elastic.Apm.Tests/TransactionIgnoreUrlsTests.cs b/test/Elastic.Apm.Tests/TransactionIgnoreUrlsTests.cs index 2a6b9e9e4..d3d98ac17 100644 --- a/test/Elastic.Apm.Tests/TransactionIgnoreUrlsTests.cs +++ b/test/Elastic.Apm.Tests/TransactionIgnoreUrlsTests.cs @@ -6,7 +6,7 @@ using System; using Elastic.Apm.Api; using Elastic.Apm.Report; -using Elastic.Apm.Tests.Mocks; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/TransactionSamplingTests.cs b/test/Elastic.Apm.Tests/TransactionSamplingTests.cs index 961ec426e..a5d431bc0 100644 --- a/test/Elastic.Apm.Tests/TransactionSamplingTests.cs +++ b/test/Elastic.Apm.Tests/TransactionSamplingTests.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information using System.Linq; -using Elastic.Apm.Tests.Mocks; -using Elastic.Apm.Tests.TestHelpers; +using Elastic.Apm.Tests.Utilities; using FluentAssertions; using Xunit; diff --git a/test/Elastic.Apm.Tests/Mocks/MockAgentTimerTests.cs b/test/Elastic.Apm.Tests/Utilities/MockAgentTimerTests.cs similarity index 96% rename from test/Elastic.Apm.Tests/Mocks/MockAgentTimerTests.cs rename to test/Elastic.Apm.Tests/Utilities/MockAgentTimerTests.cs index 3adbb622e..f9feaaf8e 100644 --- a/test/Elastic.Apm.Tests/Mocks/MockAgentTimerTests.cs +++ b/test/Elastic.Apm.Tests/Utilities/MockAgentTimerTests.cs @@ -6,13 +6,12 @@ using System.Threading; using System.Threading.Tasks; using Elastic.Apm.Helpers; -using Elastic.Apm.Tests.TestHelpers; using FluentAssertions; using FluentAssertions.Extensions; using Xunit; -using static Elastic.Apm.Tests.TestHelpers.FluentAssertionsUtils; +using static Elastic.Apm.Tests.Utilities.FluentAssertionsUtils; -namespace Elastic.Apm.Tests.Mocks +namespace Elastic.Apm.Tests.Utilities { public class MockAgentTimerTests { @@ -51,9 +50,9 @@ public void Delay_simple_test() var delayTask = agentTimer.Delay(agentTimer.Now + 2.Days()); delayTask.IsCompleted.Should().BeFalse(); - agentTimer.FastForward(1.Day()); + agentTimer.FastForward(1.Days()); delayTask.IsCompleted.Should().BeFalse(); - agentTimer.FastForward(1.Day()); + agentTimer.FastForward(1.Days()); delayTask.IsCompleted.Should().BeTrue(); } @@ -75,13 +74,13 @@ public void calling_FastForward_while_one_already_in_progress_throws() var reachedBeforeInnerFastForward = false; var reachedAfterInnerFastForward = false; - agentTimer.Delay(agentTimer.Now + 1.Hour()) + agentTimer.Delay(agentTimer.Now + 1.Hours()) .AttachSynchronousContinuation(() => { AsAction(() => { reachedBeforeInnerFastForward = true; - agentTimer.FastForward(1.Minute()); + agentTimer.FastForward(1.Minutes()); reachedAfterInnerFastForward = true; }) .Should() diff --git a/xunit.runner.json b/xunit.runner.json new file mode 100644 index 000000000..242469919 --- /dev/null +++ b/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "parallelizeAssembly": true +} \ No newline at end of file