From 76c82f0b9e546f8c7a5d0f6da4565850ca101648 Mon Sep 17 00:00:00 2001 From: Larry Osterman Date: Wed, 24 Jan 2024 13:33:40 -0800 Subject: [PATCH] Fixed bug in Eventhubs live tests (#5290) * Fixed bug in Eventhubs live tests * switched back to DAC for tests --- .../eventhubs/processor_partition_client.hpp | 7 +++-- .../test/ut/eventhubs_admin_client.cpp | 29 ------------------- .../test/ut/processor_test.cpp | 9 ++++-- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/processor_partition_client.hpp b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/processor_partition_client.hpp index 1ab010be5..9d17d4ec8 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/processor_partition_client.hpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/processor_partition_client.hpp @@ -58,8 +58,11 @@ namespace Azure { namespace Messaging { namespace EventHubs { /// Returns the partition ID associated with this ProcessorPartitionClient. std::string PartitionId() const { return m_partitionId; } - /** Closes the partition client. */ - void Close(Core::Context const& context) + /** @brief Closes the partition client. + * + * @param context The context to pass to the close operation. + */ + void Close(Core::Context const& context = {}) { if (m_cleanupFunc) { diff --git a/sdk/eventhubs/azure-messaging-eventhubs/test/ut/eventhubs_admin_client.cpp b/sdk/eventhubs/azure-messaging-eventhubs/test/ut/eventhubs_admin_client.cpp index 94323c5d4..ec451ccf1 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/test/ut/eventhubs_admin_client.cpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/test/ut/eventhubs_admin_client.cpp @@ -48,35 +48,6 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test { std::move(perCallpolicies)); } - Azure::Core::Json::_internal::json ParseAzureCliOutput(std::string const& cliOutput) - { - GTEST_LOG_(INFO) << "Azure CLI output: " << cliOutput; - std::string jsonOutput = cliOutput; - if (jsonOutput.find("WARNING:") == 0) - { - // Erase the warning from the CLI. - jsonOutput = jsonOutput.erase(0, cliOutput.find('\n') + 1); - } - if (jsonOutput.find("DEBUG:") == 0) - { - // Erase the warning from the CLI. - GTEST_LOG_(WARNING) << "Azure CLI debug output: " << jsonOutput; - jsonOutput = jsonOutput.erase(0, cliOutput.find('\n') + 1); - } - if (jsonOutput.find("ERROR:") == 0) - { - throw std::runtime_error("Error processing Azure CLI: " + jsonOutput); - } - if (jsonOutput.empty()) - { - return {}; - } - else - { - return Azure::Core::Json::_internal::json::parse(jsonOutput); - } - } - EventHubsManagement::EventHubsCreateOrUpdateOperation EventHubsManagement::CreateNamespace( std::string const& namespaceName, EventHubsPricingTier pricingTier, diff --git a/sdk/eventhubs/azure-messaging-eventhubs/test/ut/processor_test.cpp b/sdk/eventhubs/azure-messaging-eventhubs/test/ut/processor_test.cpp index 17eb04b4a..b38792af3 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/test/ut/processor_test.cpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/test/ut/processor_test.cpp @@ -581,12 +581,17 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test { while (!partitionClients.empty()) { auto partitionClientIterator = partitionClients.begin(); - auto partitionClient = partitionClientIterator->second; + std::shared_ptr partitionClient; if (partitionClientIterator != partitionClients.end()) { + partitionClient = partitionClientIterator->second; partitionClients.erase(partitionClientIterator); } - partitionClient->Close(context); + // Don't re-use the context variable here, because it's been canceled. + if (partitionClient) + { + partitionClient->Close(); + } } processor.Stop();