First cut at removing proxy tests (#4416)

* FIrst cut at removing proxy tests

Changed the proxy tests from opt-out to opt-in so they're disabled by default. Removed lines enabling proxy from ci.yml file.
This commit is contained in:
Larry Osterman 2023-03-07 15:46:25 -08:00 committed by GitHub
parent 6706c20b26
commit d8f6aa9d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 497 additions and 402 deletions

View File

@ -7,10 +7,20 @@
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DINSTALL_GTEST=OFF -DBUILD_TESTING=ON -DBUILD_TRANSPORT_CURL=ON -DBUILD_SAMPLES=ON -DBUILD_PERFORMANCE_TESTS=ON",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "INSTALL_GTEST",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TESTING",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "x64-windows-static",
@ -25,6 +35,26 @@
"name": "VCPKG_MANIFEST_MODE",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TRANSPORT_CURL",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SAMPLES",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_PERFORMANCE_TESTS",
"value": "True",
"type": "BOOL"
}
]
},
@ -74,6 +104,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_SAMPLES",
"value": "True",
@ -101,6 +136,11 @@
"name": "MSVC_USE_STATIC_CRT",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
}
]
},
@ -129,6 +169,11 @@
"name": "MSVC_USE_STATIC_CRT",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
}
]
},
@ -154,8 +199,8 @@
"type": "BOOL"
},
{
"name": "DISABLE_PROXY_TESTS",
"value": "True",
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
@ -220,6 +265,11 @@
"name": "BUILD_PERFORMANCE_TESTS",
"value": "true",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
}
]
},
@ -239,6 +289,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TRANSPORT_CURL",
"value": "True",
@ -287,6 +342,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TRANSPORT_CURL",
"value": "True",
@ -325,6 +385,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TRANSPORT_CURL",
"value": "True",
@ -367,6 +432,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_SAMPLES",
"value": "True",
@ -419,6 +489,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_PROXY_TESTS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_SAMPLES",
"value": "True",

View File

@ -15,7 +15,7 @@
"Pool": "Azure Pipelines",
"BuildArgs": "-j 10",
"VCPKG_DEFAULT_TRIPLET": "x64-osx",
"CmakeArgs": " -DBUILD_TESTING=ON -DDISABLE_PROXY_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON",
"CmakeArgs": " -DBUILD_TESTING=ON -DENABLE_PROXY_TESTS=OFF -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON",
"PublishMapFiles": "true"
}
},
@ -59,7 +59,7 @@
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON"
},
"Win32Api_release_curl": {
"CmakeArgs": " -DBUILD_TESTING=ON -DDISABLE_PROXY_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DMSVC_USE_STATIC_CRT=ON ",
"CmakeArgs": " -DBUILD_TESTING=ON -DENABLE_PROXY_TESTS=OFF -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DMSVC_USE_STATIC_CRT=ON ",
"BuildArgs": "--parallel 8 --config Release",
"PublishMapFiles": "true"
}

View File

@ -5,9 +5,11 @@ cmake_minimum_required (VERSION 3.13)
set(azure-core-test)
# Create test data for FileUpload test (100K) by writing 1K * 100 times
# Create test data for FileUpload test (100K) by writing 100 * 1000 times
set(RANGE 0)
#cSpell:disable
set(1K "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
#cSpell:enable
file(WRITE ${CMAKE_BINARY_DIR}/fileData "")
while(RANGE LESS 100)
file(APPEND ${CMAKE_BINARY_DIR}/fileData "${1K}")
@ -109,6 +111,11 @@ if (DISABLE_PROXY_TESTS)
add_compile_definitions(DISABLE_PROXY_TESTS)
endif()
if (ENABLE_PROXY_TESTS)
message(STATUS "Enabling proxy tests." )
add_compile_definitions(ENABLE_PROXY_TESTS)
endif()
# If the System.TeamProjectId ADO variable is set, we are running in the pipeline, behave accordingly.
if (ENV{SYSTEM_TEAMPROJECTID})
add_compile_definitions(IN_CI_PIPELINE)

View File

@ -87,7 +87,7 @@ namespace Azure { namespace Core { namespace Test {
static void checkResponseCode(
Azure::Core::Http::HttpStatusCode code,
Azure::Core::Http::HttpStatusCode expectedCode = Azure::Core::Http::HttpStatusCode::Ok);
#if defined(ENABLE_PROXY_TESTS)
std::string HttpProxyServer()
{
std::string proxyUrl{Azure::Core::_internal::Environment::GetVariable("SQUID_PROXY_URL")};
@ -107,6 +107,7 @@ namespace Azure { namespace Core { namespace Test {
}
return proxyUrl;
}
#endif
std::string TestProxyUrl()
{
std::string proxyUrl{Azure::Core::_internal::Environment::GetVariable("PROXY_URL")};
@ -116,20 +117,23 @@ namespace Azure { namespace Core { namespace Test {
}
return proxyUrl;
}
#if defined(ENABLE_PROXY_TESTS)
static bool ProxyStatusChecked;
static bool IsSquidProxyRunning;
#endif
static bool IsTestProxyRunning;
protected:
// Create
virtual void SetUp() override
{
#if defined(ENABLE_PROXY_TESTS)
#if defined(IN_CI_PIPELINE)
// If we're in the CI pipeline, don't probe for the squid or test proxy running - just assume
// they are.
// If we're in the CI pipeline, don't probe for the squid or test proxy running - just
// assume they are.
IsSquidProxyRunning = true;
IsTestProxyRunning = true;
#else // !defined(IN_CI_PIPELINE)
IsTestProxyRunning = true;
if (!ProxyStatusChecked)
{
Azure::Core::Http::Policies::TransportOptions options;
@ -177,10 +181,13 @@ namespace Azure { namespace Core { namespace Test {
ProxyStatusChecked = true;
}
#endif
#endif // ENABLE_PROXY_TESTS
}
};
#if defined(ENABLE_PROXY_TESTS)
bool TransportAdapterOptions::ProxyStatusChecked{false};
bool TransportAdapterOptions::IsSquidProxyRunning{false};
#endif
bool TransportAdapterOptions::IsTestProxyRunning{false};
void TransportAdapterOptions::checkResponseCode(
@ -272,7 +279,7 @@ namespace Azure { namespace Core { namespace Test {
using namespace Azure::Core::Http::_internal;
using namespace Azure::Core::Http::Policies::_internal;
#if !defined(DISABLE_PROXY_TESTS)
#if defined(ENABLE_PROXY_TESTS)
// constexpr char SocksProxyServer[] = "socks://98.162.96.41:4145";
TEST_F(TransportAdapterOptions, SimpleProxyTests)
{
@ -416,7 +423,7 @@ namespace Azure { namespace Core { namespace Test {
}
}
#endif // defined(DISABLE_PROXY_TESTS)
#endif // defined(ENABLE_PROXY_TESTS)
TEST_F(TransportAdapterOptions, DisableCrlValidation)
{
@ -435,7 +442,7 @@ namespace Azure { namespace Core { namespace Test {
auto response = pipeline.Send(request, Azure::Core::Context::ApplicationContext);
EXPECT_EQ(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok);
}
#if !defined(DISABLE_PROXY_TESTS)
#if defined(ENABLE_PROXY_TESTS)
if (IsSquidProxyRunning)
{
Azure::Core::Http::Policies::TransportOptions transportOptions;
@ -524,6 +531,8 @@ namespace Azure { namespace Core { namespace Test {
#endif
}
// Not strictly a proxy test, but this test case has been unreliable over time.
#if defined(ENABLE_PROXY_TESTS)
TEST_F(TransportAdapterOptions, MultipleCrlOperations)
{
// LetsEncrypt certificates don't contain a distribution point URL extension. While this seems
@ -609,6 +618,7 @@ namespace Azure { namespace Core { namespace Test {
}
}
}
#endif
TEST_F(TransportAdapterOptions, TestRootCertificate)
{
@ -800,7 +810,8 @@ namespace Azure { namespace Core { namespace Test {
auto response = m_pipeline->Send(request, Azure::Core::Context::ApplicationContext);
auto responseCode = response->GetStatusCode();
return Azure::Response<Azure::Core::Http::HttpStatusCode>(responseCode, std::move(response));
return Azure::Response<Azure::Core::Http::HttpStatusCode>(
responseCode, std::move(response));
}
Azure::Response<std::string> PostStartPlayback(std::string const& recordingFile)
@ -826,12 +837,14 @@ namespace Azure { namespace Core { namespace Test {
std::string const& recordingId)
{
auto request = Azure::Core::Http::Request(
Azure::Core::Http::HttpMethod::Post, Azure::Core::Url(TestProxyUrl() + "/playback/stop"));
Azure::Core::Http::HttpMethod::Post,
Azure::Core::Url(TestProxyUrl() + "/playback/stop"));
request.SetHeader("x-recording-id", recordingId);
auto response = m_pipeline->Send(request, Azure::Core::Context::ApplicationContext);
auto responseCode = response->GetStatusCode();
return Azure::Response<Azure::Core::Http::HttpStatusCode>(responseCode, std::move(response));
return Azure::Response<Azure::Core::Http::HttpStatusCode>(
responseCode, std::move(response));
}
Azure::Response<std::string> ProxyServerGetUrl(
@ -856,7 +869,8 @@ namespace Azure { namespace Core { namespace Test {
Azure::Response<Azure::Core::Http::HttpStatusCode> IsAlive()
{
auto request = Azure::Core::Http::Request(
Azure::Core::Http::HttpMethod::Get, Azure::Core::Url(TestProxyUrl() + "/Admin/IsAlive"));
Azure::Core::Http::HttpMethod::Get,
Azure::Core::Url(TestProxyUrl() + "/Admin/IsAlive"));
auto response = m_pipeline->Send(request, Azure::Core::Context::ApplicationContext);
auto statusCode = response->GetStatusCode();
return Azure::Response<Azure::Core::Http::HttpStatusCode>(statusCode, std::move(response));
@ -915,5 +929,4 @@ namespace Azure { namespace Core { namespace Test {
EXPECT_THROW(proxyServer.IsAlive(), Azure::Core::Http::TransportException);
}
}}} // namespace Azure::Core::Test

View File

@ -44,39 +44,39 @@ stages:
CtestRegex: azure-core.|json-test
LiveTestCtestRegex: azure-core.|json-test
LiveTestTimeoutInMinutes: 90 # default is 60 min. We need a little longer on worst case for Win+jsonTests
LineCoverageTarget: 93
LineCoverageTarget: 92
BranchCoverageTarget: 50
PreTestSteps:
- pwsh: |
docker build -t squid-local $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy
docker build -t squid-local.passwd $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy.passwd
$(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/runproxy.ps1
displayName: Launch Linux Docker container proxy
# If we're on Ubuntu and running proxy tests, build and launch a local squid proxy
condition: and(succeeded(), contains(variables['Agent.OS'], 'linux'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
# PreTestSteps:
# - pwsh: |
# docker build -t squid-local $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy
# docker build -t squid-local.passwd $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy.passwd
# $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/runproxy.ps1
# displayName: Launch Linux Docker container proxy
# # If we're on Ubuntu and running proxy tests, build and launch a local squid proxy
# condition: and(succeeded(), contains(variables['Agent.OS'], 'linux'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
#
# - pwsh: eng/scripts/Install-WSL.ps1
# displayName: Install WSL on Windows hosts when proxy tests are enabled..
# condition: and(succeeded(), contains(variables['Agent.OS'], 'windows'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
#
# - pwsh: ./run_wsl_proxy.ps1
# displayName: Launch WSL Proxy Server.
# workingDirectory: $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests
# condition: and(succeeded(), contains(variables['Agent.OS'], 'windows'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
#
# # Verify that the proxy servers are running locally whenever we're expected to run proxy tests.
# - pwsh: ./verify_proxy.ps1
# workingDirectory: $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests
# displayName: Verify Proxy Server Working Correctly.
# condition: and(succeeded(), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
- pwsh: eng/scripts/Install-WSL.ps1
displayName: Install WSL on Windows hosts when proxy tests are enabled..
condition: and(succeeded(), contains(variables['Agent.OS'], 'windows'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
- pwsh: ./run_wsl_proxy.ps1
displayName: Launch WSL Proxy Server.
workingDirectory: $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests
condition: and(succeeded(), contains(variables['Agent.OS'], 'windows'), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
# Verify that the proxy servers are running locally whenever we're expected to run proxy tests.
- pwsh: ./verify_proxy.ps1
workingDirectory: $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests
displayName: Verify Proxy Server Working Correctly.
condition: and(succeeded(), variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
PostTestSteps:
- pwsh: |
docker ps -q -f ancestor=ubuntu/squid | ForEach-Object { `
docker stop $_ `
}
displayName: Shutdown Squid Proxy.
condition: and(variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'), contains(variables['OSVmImage'], 'linux'))
# PostTestSteps:
# - pwsh: |
# docker ps -q -f ancestor=ubuntu/squid | ForEach-Object { `
# docker stop $_ `
# }
# displayName: Shutdown Squid Proxy.
# condition: and(variables.RunProxyTests, contains(variables.CmakeArgs, 'BUILD_TESTING=ON'), contains(variables['OSVmImage'], 'linux'))
Artifacts:
- Name: azure-core