* lll

* sss

* oipio

* vcvc

* enable test proxy start at test suite start for KV and storage , example created for attestation, we cannot find the base definitions for the test suites,

* Contrib

* clangs

* clangs

* test logs

* pipeline

* more clangs

* pipeline

* clang

* try try again

* try try again

* try again

* try again

* again

* update paths , moved to macro , call macro in target code

* core

* capitalization
This commit is contained in:
George Arama 2023-02-07 10:52:20 -08:00 коммит произвёл GitHub
Родитель 39ec586d96
Коммит 3762c59552
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 86 добавлений и 7 удалений

1
.vscode/cspell.json поставляемый
Просмотреть файл

@ -80,6 +80,7 @@
"IMDS",
"immutability",
"Intel",
"isoutput",
"issecret",
"itfactor",
"iusg",

Просмотреть файл

@ -207,6 +207,11 @@ Even for running on `PLAYBACK` mode, the env configuration is mandatory. This is
Take a look to [this file](https://github.com/Azure/azure-sdk-for-cpp/blob/main/sdk/core/ci.yml#L52) which defines the required configuarion for each SDK package. Those settings are used to run all unit test on `PLAYBACK` mode on CI, you can use the same settings from that file to run on `PLAYBACK` locally.
##### Test-Proxy
Recording and playing back tests depends on an external tool called "test-proxy" (see doc/TestProxy.md)
You can start this tool manually or autmatically as part of you development flow.
For automatic start you will need to set the environment variable "AZURE_TEST_USE_TEST_PROXY" to value "ON".
##### Running tests

Просмотреть файл

@ -2,9 +2,12 @@
# SPDX-License-Identifier: MIT
#
macro(CopyTestProxyScripts)
file(COPY ${CMAKE_SOURCE_DIR}/eng/Scripts/Start-TestProxy.ps1
macro(SetUpTestProxy subDir)
# assets.json dir
add_compile_definitions(AZURE_TEST_ASSETS_DIR="${AZ_ROOT_DIR}/${subDir}/")
#copy start stop scripts to the bin folder
file(COPY ${AZ_ROOT_DIR}/eng/scripts/Start-TestProxy.ps1
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/eng/Scripts/Stop-TestProxy.ps1
file(COPY ${AZ_ROOT_DIR}/eng/scripts/Stop-TestProxy.ps1
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endmacro()

Просмотреть файл

@ -186,6 +186,7 @@ jobs:
workingDirectory: '$(Build.SourcesDirectory)/sdk/${{parameters.ServiceDirectory}}'
displayName: Restore Recordings
condition: and(succeeded(), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'), ne('${{parameters.ServiceDirectory}}', 'core'),ne('${{parameters.ServiceDirectory}}', 'template'))
name: RestoreRecordings
- pwsh: |
ctest `
@ -200,7 +201,9 @@ jobs:
- ${{ parameters.PostTestSteps }}
- pwsh: |
$ErrorActionPreference = 'SilentlyContinue'
get-content test-proxy.log
displayName: TestProxy Log
condition: and(succeededOrFailed(), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'),ne('${{parameters.ServiceDirectory}}', 'template'))

Просмотреть файл

@ -37,6 +37,6 @@ if($error){
}
}
echo "Start test proxy with argument list --storage-location $AssetsPath"
echo "Start test proxy with argument list -l $AssetsPath"
#starts it in a separate process that will outlive pwsh in order to serve requests.
Start-Process 'test-proxy' -ArgumentList "--storage-location $AssetsPath"
Start-Process 'test-proxy' -ArgumentList "start -l $AssetsPath" -WorkingDirectory $AssetsPath

Просмотреть файл

@ -17,6 +17,9 @@ add_compile_definitions(AZURE_TEST_DATA_PATH="${CMAKE_BINARY_DIR}")
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/attestation")
include(GoogleTest)
add_executable (

Просмотреть файл

@ -25,6 +25,9 @@ namespace Azure { namespace Security { namespace Attestation { namespace Test {
// cspell: words aikcert
class TpmAttestationTests : public Azure::Core::Test::TestBase {
public:
TpmAttestationTests() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); };
private:
protected:
std::shared_ptr<Azure::Core::Credentials::TokenCredential> m_credential;

Просмотреть файл

@ -30,6 +30,9 @@ add_library (
${AZURE_CORE_TEST_SOURCE}
)
include(TestProxyPrep)
SetUpTestProxy("sdk/core")
if (MSVC)
# - C6326: Google comparisons
target_compile_options(azure-core-test-fw PUBLIC /wd6326)

Просмотреть файл

@ -406,9 +406,34 @@ namespace Azure { namespace Core { namespace Test {
*/
void TearDown() override;
void SetUpTestSuiteLocal(std::string const& assetsPath)
{
if (Azure::Core::_internal::Environment::GetVariable("AZURE_TEST_USE_TEST_PROXY") == "ON")
{
std::string finalAsets(assetsPath);
std::string pwshCommand
= "pwsh -NoProfile -ExecutionPolicy Unrestricted Start-TestProxy.ps1 -AssetsPath "
+ finalAsets;
int result = system(pwshCommand.c_str());
if (result != 0)
{
std::cout << "Non zero exit code for start proxy : " << result;
}
}
};
static void TearDownTestSuite()
{
if (Azure::Core::_internal::Environment::GetVariable("AZURE_TEST_USE_TEST_PROXY") == "ON")
{
int result
= std::system("pwsh -NoProfile -ExecutionPolicy Unrestricted Stop-TestProxy.ps1");
std::cout << "Non zero exit code for stop proxy : " << result;
}
};
/**
* Returns the assets.json file path used when invoking the test-proxy playback/record
*/
virtual std::string GetAssetsPath() { return "assets.json"; }
static std::string GetAssetsPath() { return "assets.json"; }
};
}}} // namespace Azure::Core::Test

Просмотреть файл

@ -8,10 +8,13 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(GoogleTest)
include(TestProxyPrep)
SetUpTestProxy("sdk/keyvault")
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
# Additional test files to be copied to the output directory.
add_executable (
azure-security-keyvault-administration-test
macro_guard.cpp

Просмотреть файл

@ -79,5 +79,7 @@ namespace Azure {
{
return Azure::Core::Test::TestBase::GetTestNameSuffix(sanitize);
}
SettingsClientTest() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); }
};
}}}}} // namespace Azure::Security::KeyVault::Administration::Test

Просмотреть файл

@ -12,6 +12,9 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/keyvault")
add_executable (
azure-security-keyvault-certificates-test
macro_guard.cpp

Просмотреть файл

@ -43,6 +43,8 @@ namespace Azure {
class KeyVaultCertificateClientTest : public Azure::Core::Test::TestBase,
public ::testing::WithParamInterface<int> {
public:
KeyVaultCertificateClientTest() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); }
private:
std::unique_ptr<Azure::Security::KeyVault::Certificates::CertificateClient> m_client;

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/keyvault")
################## Unit Tests ##########################
add_executable (

Просмотреть файл

@ -23,6 +23,9 @@
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test {
class KeyVaultKeyClient : public Azure::Core::Test::TestBase {
public:
KeyVaultKeyClient() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); }
private:
std::unique_ptr<Azure::Security::KeyVault::Keys::KeyClient> m_client;

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/keyvault")
add_executable (
azure-security-keyvault-secrets-test

Просмотреть файл

@ -18,6 +18,9 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
class KeyVaultSecretClientTest : public Azure::Core::Test::TestBase,
public ::testing::WithParamInterface<int> {
public:
KeyVaultSecretClientTest() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); }
private:
std::unique_ptr<Azure::Security::KeyVault::Secrets::SecretClient> m_client;

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/storage")
add_executable (
azure-storage-blobs-test

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/storage")
add_executable (
azure-storage-common-test

Просмотреть файл

@ -26,6 +26,9 @@ namespace Azure { namespace Storage {
namespace Test {
class StorageTest : public Azure::Core::Test::TestBase {
public:
StorageTest() { TestBase::SetUpTestSuiteLocal(AZURE_TEST_ASSETS_DIR); }
protected:
const std::string& StandardStorageConnectionString();
const std::string& PremiumStorageConnectionString();

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/storage")
add_executable (
azure-storage-files-datalake-test

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/storage")
add_executable (
azure-storage-files-shares-test

Просмотреть файл

@ -11,6 +11,8 @@ include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
include(TestProxyPrep)
SetUpTestProxy("sdk/storage")
add_executable (
azure-storage-queues-test