Skip to content

Commit e19dc23

Browse files
Use GetTestCredentials in eventhubs admin client; updated samples to allow sample execution to be disabled (#5799)
* Use GetTestCredentials in eventhubs admin client; updated samples to allow sample execution to be disabled * Made sample execution optional * re-enabled building keyvault samples * Disabled RetrieveMultipleEvents test * Disabled RetrieveMultipleEvents test * Pull request feedback
1 parent 7e9906f commit e19dc23

29 files changed

Lines changed: 69 additions & 49 deletions

File tree

cmake-modules/AzureBuildTargetForCI.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ macro(create_per_service_target_build_for_sample service target)
3232
if(CMAKE_GENERATOR MATCHES "Visual Studio.*")
3333
SET(binary "Release/${binary}")
3434
endif()
35-
file(APPEND ${CMAKE_BINARY_DIR}/${service}-samples.txt "${CMAKE_CURRENT_BINARY_DIR}/${binary}\n")
36-
35+
36+
set(RUN_SAMPLE TRUE)
37+
if(${ARGC} GREATER 2)
38+
set(extra_args "${ARGN}")
39+
foreach(arg IN LISTS extra_args)
40+
if (${arg} MATCHES "DISABLE_RUN")
41+
set(RUN_SAMPLE FALSE)
42+
message("Disabling sample execution for ${service}/${binary}")
43+
else()
44+
message(FATAL_ERROR "Unknown extra argument: ${arg}")
45+
endif()
46+
endforeach()
47+
endif()
48+
if (RUN_SAMPLE)
49+
file(APPEND ${CMAKE_BINARY_DIR}/${service}-samples.txt "${CMAKE_CURRENT_BINARY_DIR}/${binary}\n")
50+
endif()
3751
endmacro()

sdk/attestation/azure-security-attestation/samples/attestation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ add_executable (
1515
attestation_collateral.cpp
1616
attestation_collateral.hpp)
1717

18-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
18+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
1919

2020
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation get-env-helper)
2121

sdk/attestation/azure-security-attestation/samples/basic-operations/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_executable (
1212
attestation-${samplename}
1313
${samplename}.cpp)
1414

15-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
15+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
1616

1717
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity get-env-helper)
1818

sdk/attestation/azure-security-attestation/samples/policy-certificates/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_executable (
1414
cryptohelpers.hpp
1515
)
1616

17-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation-${samplename} attestation)
17+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation-${samplename} attestation DISABLE_RUN)
1818

1919
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity OpenSSL::Crypto get-env-helper)
2020

sdk/attestation/azure-security-attestation/samples/policy/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_executable (
1414
cryptohelpers.hpp
1515
)
1616

17-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
17+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
1818

1919
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity get-env-helper)
2020

sdk/eventhubs/azure-messaging-eventhubs/samples/basic-operations/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_executable (
1212
eventhubs-${samplename}
1313
${samplename}.cpp)
1414

15-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
15+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
1616

1717
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
1818
endmacro()

sdk/eventhubs/azure-messaging-eventhubs/samples/consume-events/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_executable (
1212
eventhubs-${samplename}
1313
${samplename}.cpp)
1414

15-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
15+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
1616

1717
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
1818
endmacro()

sdk/eventhubs/azure-messaging-eventhubs/samples/produce-events/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_executable (
1212
eventhubs-${samplename}
1313
${samplename}.cpp)
1414

15-
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
15+
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
1616

1717
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
1818
endmacro()

sdk/eventhubs/azure-messaging-eventhubs/test/ut/consumer_client_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,16 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
303303
return name;
304304
}
305305

306-
TEST_P(ConsumerClientTest, RetrieveMultipleEvents)
306+
TEST_P(ConsumerClientTest, DISABLED_RetrieveMultipleEvents)
307307
{
308308
// This test depends on being able to create a new eventhub instance, so skip it on the
309309
// emulator.
310310
if (GetParam() == AuthType::Emulator)
311311
{
312312
GTEST_SKIP();
313313
}
314+
315+
// Disabled test for now.
314316
EventHubsManagement administrationClient;
315317
auto eventhubNamespace{administrationClient.GetNamespace(GetEnv("EVENTHUBS_NAMESPACE"))};
316318

sdk/eventhubs/azure-messaging-eventhubs/test/ut/eventhubs_admin_client.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <azure/core/internal/json/json.hpp>
1010
#include <azure/core/platform.hpp>
1111
#include <azure/core/response.hpp>
12-
#include <azure/identity/default_azure_credential.hpp>
1312

1413
#include <memory>
1514
#include <sstream>
@@ -35,7 +34,7 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
3534
tokenContext.Scopes = {"https://management.azure.com/.default"};
3635
perRetrypolicies.emplace_back(
3736
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
38-
std::make_unique<Azure::Identity::DefaultAzureCredential>(), tokenContext));
37+
GetTestCredential(), tokenContext));
3938
}
4039
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perCallpolicies;
4140
options.Telemetry.ApplicationId = "eventhubs.test";

0 commit comments

Comments
 (0)