You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by fg...@apache.org on 2025/06/26 13:49:22 UTC
(nifi-minifi-cpp) 06/09: MINIFICPP-2580 Upgrade GCP and googletest libraries
This is an automated email from the ASF dual-hosted git repository.
fgerlits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit eb899598ac0c5705c9762a2cd89b2a6498a2fa2f
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Wed Jun 18 14:54:35 2025 +0200
MINIFICPP-2580 Upgrade GCP and googletest libraries
- Upgrade GCP library to v2.38.0
- Upgrade googletest library to v1.17.0
Signed-off-by: Ferenc Gerlits <fg...@gmail.com>
Closes #1981
---
cmake/GoogleCloudCpp.cmake | 33 ++---
extensions/gcp/tests/CMakeLists.txt | 3 +-
.../tests/GCPCredentialsControllerServiceTests.cpp | 19 +--
.../mock-client-without-decorators.patch | 153 ---------------------
.../google-cloud-cpp/mock_client_target.patch | 26 ----
.../google-cloud-cpp/remove-find_package.patch | 15 +-
6 files changed, 32 insertions(+), 217 deletions(-)
diff --git a/cmake/GoogleCloudCpp.cmake b/cmake/GoogleCloudCpp.cmake
index 855130a02..c02804455 100644
--- a/cmake/GoogleCloudCpp.cmake
+++ b/cmake/GoogleCloudCpp.cmake
@@ -22,27 +22,23 @@ include(Crc32c)
set(PATCH_FILE_1 "${CMAKE_SOURCE_DIR}/thirdparty/google-cloud-cpp/remove-find_package.patch")
set(PATCH_FILE_2 "${CMAKE_SOURCE_DIR}/thirdparty/google-cloud-cpp/nlohmann_lib_as_interface.patch")
-set(PATCH_FILE_3 "${CMAKE_SOURCE_DIR}/thirdparty/google-cloud-cpp/mock-client-without-decorators.patch")
-set(PATCH_FILE_4 "${CMAKE_SOURCE_DIR}/thirdparty/google-cloud-cpp/mock_client_target.patch")
-if (SKIP_TESTS)
- set(PC ${Bash_EXECUTABLE} -c "set -x &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_1}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_1}\\\") &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_2}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_2}\\\")")
-else()
+set(PC ${Bash_EXECUTABLE} -c "set -x &&\
+ (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_1}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_1}\\\") &&\
+ (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_2}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_2}\\\")")
+
+set(GOOGLE_CLOUD_CPP_WITH_MOCKS OFF CACHE BOOL "" FORCE)
+if (NOT SKIP_TESTS)
include(GoogleTest)
include(FetchContent)
FetchContent_Declare(
googletest
- URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
- URL_HASH SHA256=b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5
+ URL https://github.com/google/googletest/releases/download/v1.17.0/googletest-1.17.0.tar.gz
+ URL_HASH SHA256=65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c
)
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
- set(PC ${Bash_EXECUTABLE} -c "set -x &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_1}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_1}\\\") &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_2}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_2}\\\") &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_3}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_3}\\\") &&\
- (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_4}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_4}\\\")")
+
+ set(GOOGLE_CLOUD_CPP_WITH_MOCKS ON CACHE BOOL "" FORCE)
endif()
set(GOOGLE_CLOUD_CPP_ENABLE storage CACHE INTERNAL storage-api)
@@ -50,13 +46,8 @@ set(GOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK OFF CACHE INTERNAL macos-openssl
set(BUILD_TESTING OFF CACHE INTERNAL testing-off)
set(GOOGLE_CLOUD_CPP_ENABLE_WERROR OFF CACHE INTERNAL warnings-off)
FetchContent_Declare(google-cloud-cpp
- URL https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.10.1.tar.gz
- URL_HASH SHA256=dbd8ff9cdda8b991049094c41d9125438098422658c77dc1afab524c589efeda
+ URL https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.38.0.tar.gz
+ URL_HASH SHA256=f1493b2dce9b379714342f2be7ccb483d70d13aac09d4a90ae3b4756693b72fc
PATCH_COMMAND "${PC}")
add_compile_definitions(_SILENCE_CXX20_REL_OPS_DEPRECATION_WARNING _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING CURL_STATICLIB)
FetchContent_MakeAvailable(google-cloud-cpp)
-
-if (NOT SKIP_TESTS)
- get_target_property(GMOCK_INC_DIR mock_google_cloud_client INTERFACE_INCLUDE_DIRECTORIES)
- set_target_properties(mock_google_cloud_client PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${GMOCK_INC_DIR}")
-endif()
diff --git a/extensions/gcp/tests/CMakeLists.txt b/extensions/gcp/tests/CMakeLists.txt
index 9f77a7a3a..ed119eb1d 100644
--- a/extensions/gcp/tests/CMakeLists.txt
+++ b/extensions/gcp/tests/CMakeLists.txt
@@ -20,6 +20,7 @@ file(GLOB GCS_TESTS "*.cpp")
FOREACH(testfile ${GCS_TESTS})
get_filename_component(testfilename "${testfile}" NAME_WE)
add_minifi_executable("${testfilename}" "${testfile}")
+ target_compile_definitions(${testfilename} PRIVATE _SILENCE_CXX20_REL_OPS_DEPRECATION_WARNING)
target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors")
target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/expression-language")
target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/gcp")
@@ -32,7 +33,7 @@ FOREACH(testfile ${GCS_TESTS})
target_link_libraries(${testfilename} minifi-gcp)
target_link_libraries(${testfilename} minifi-standard-processors)
target_link_libraries(${testfilename} minifi-expression-language-extensions)
- target_link_libraries(${testfilename} gtest_main gmock mock_google_cloud_client)
+ target_link_libraries(${testfilename} gtest_main gmock)
gtest_add_tests(TARGET "${testfilename}")
ENDFOREACH()
diff --git a/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp b/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
index dccddba08..eb71f1d28 100644
--- a/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
+++ b/extensions/gcp/tests/GCPCredentialsControllerServiceTests.cpp
@@ -38,15 +38,16 @@ std::string create_mock_service_json() {
root.AddMember("type", "service_account", root.GetAllocator());
root.AddMember("project_id", "mock_project_id", root.GetAllocator());
root.AddMember("private_key_id", "my_private_key_id", root.GetAllocator());
- root.AddMember("private_key", "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIIBOgIBAAJBAKNhMsOin3GDkg9A9e3MN/jP0JL+cV8GscR5QGZPgbHI5Jtkt+4k\n"
- "MJvO5i54cq+55wFF2Ux7Eekg6wYY+/cbzNUCAwEAAQJAdUUyS+xxp+f5sgs9uyeH\n"
- "0YdRPgF23O+QL+ecixNsk2/qsH195ngMNHWQCEUPGbl8O7Lu9W1tmMgeN0cFzpxl\n"
- "rQIhANM6NG7uofCzwCvcuuc8PCjbhQPkYn+fuytdrr9V4AlrAiEAxgKkh+iU6CO8\n"
- "hzrqeO1zNQijJ4wQ3uuxMST7gx9x0r8CIACPkQASZh+reoEjTuO6RzacjpfaDWDl\n"
- "XavZzdL4OWYNAiEAxA41zoPRfJB1yQfixV2Gpsooka2zvqVrypctmUT3NI0CIH2c\n"
- "h9CRoySmUy6INeKMMgAPiVJB04exJvKPXr/DHi6D\n"
- "-----END RSA PRIVATE KEY-----", root.GetAllocator());
+ root.AddMember("private_key", "-----BEGIN PRIVATE KEY-----\n"
+ "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAo2Eyw6KfcYOSD0D1\n"
+ "7cw3+M/Qkv5xXwaxxHlAZk+Bscjkm2S37iQwm87mLnhyr7nnAUXZTHsR6SDrBhj7\n"
+ "9xvM1QIDAQABAkB1RTJL7HGn5/myCz27J4fRh1E+AXbc75Av55yLE2yTb+qwfX3m\n"
+ "eAw0dZAIRQ8ZuXw7su71bW2YyB43RwXOnGWtAiEA0zo0bu6h8LPAK9y65zw8KNuF\n"
+ "A+Rif5+7K12uv1XgCWsCIQDGAqSH6JToI7yHOup47XM1CKMnjBDe67ExJPuDH3HS\n"
+ "vwIgAI+RABJmH6t6gSNO47pHNpyOl9oNYOVdq9nN0vg5Zg0CIQDEDjXOg9F8kHXJ\n"
+ "B+LFXYamyiiRrbO+pWvKly2ZRPc0jQIgfZyH0JGjJKZTLog14owyAA+JUkHTh7Em\n"
+ "8o9ev8MeLoM=\n"
+ "-----END PRIVATE KEY-----", root.GetAllocator());
root.AddMember("client_email", "my_client_email", root.GetAllocator());
root.AddMember("client_id", "my_client_id", root.GetAllocator());
rapidjson::StringBuffer buffer;
diff --git a/thirdparty/google-cloud-cpp/mock-client-without-decorators.patch b/thirdparty/google-cloud-cpp/mock-client-without-decorators.patch
deleted file mode 100644
index 5b5822a64..000000000
--- a/thirdparty/google-cloud-cpp/mock-client-without-decorators.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-diff --git a/google/cloud/storage/examples/storage_client_mock_samples.cc b/google/cloud/storage/examples/storage_client_mock_samples.cc
-index c34002cad1..cee48946a6 100644
---- a/google/cloud/storage/examples/storage_client_mock_samples.cc
-+++ b/google/cloud/storage/examples/storage_client_mock_samples.cc
-@@ -29,7 +29,7 @@ TEST(StorageMockingSamples, MockReadObject) {
-
- std::shared_ptr<gcs::testing::MockClient> mock =
- std::make_shared<gcs::testing::MockClient>();
-- auto client = gcs::testing::ClientFromMock(mock);
-+ auto client = gcs::testing::UndecoratedClientFromMock(mock);
-
- std::string const text = "this is a mock http response";
- std::size_t offset = 0;
-@@ -72,7 +72,7 @@ TEST(StorageMockingSamples, MockWriteObject) {
-
- std::shared_ptr<gcs::testing::MockClient> mock =
- std::make_shared<gcs::testing::MockClient>();
-- auto client = gcs::testing::ClientFromMock(mock);
-+ auto client = gcs::testing::UndecoratedClientFromMock(mock);
-
- gcs::ObjectMetadata expected_metadata;
-
-@@ -97,7 +97,7 @@ TEST(StorageMockingSamples, MockReadObjectFailure) {
-
- std::shared_ptr<gcs::testing::MockClient> mock =
- std::make_shared<gcs::testing::MockClient>();
-- auto client = gcs::testing::ClientFromMock(mock);
-+ auto client = gcs::testing::UndecoratedClientFromMock(mock);
-
- std::string text = "this is a mock http response";
- EXPECT_CALL(*mock, ReadObject)
-@@ -130,7 +130,7 @@ TEST(StorageMockingSamples, MockWriteObjectFailure) {
-
- std::shared_ptr<gcs::testing::MockClient> mock =
- std::make_shared<gcs::testing::MockClient>();
-- auto client = gcs::testing::ClientFromMock(mock);
-+ auto client = gcs::testing::UndecoratedClientFromMock(mock);
-
- using gcs::internal::CreateResumableUploadResponse;
- using gcs::internal::QueryResumableUploadResponse;
-diff --git a/google/cloud/storage/google_cloud_cpp_storage.cmake b/google/cloud/storage/google_cloud_cpp_storage.cmake
-index d475554d45..5e53e972a9 100644
---- a/google/cloud/storage/google_cloud_cpp_storage.cmake
-+++ b/google/cloud/storage/google_cloud_cpp_storage.cmake
-@@ -406,6 +406,7 @@ if (BUILD_TESTING)
- testing/client_unit_test.cc
- testing/client_unit_test.h
- testing/constants.h
-+ testing/mock_client.cc
- testing/mock_client.h
- testing/mock_http_request.cc
- testing/mock_http_request.h
-diff --git a/google/cloud/storage/storage_client_testing.bzl b/google/cloud/storage/storage_client_testing.bzl
-index e060351a27..5727e9f9a9 100644
---- a/google/cloud/storage/storage_client_testing.bzl
-+++ b/google/cloud/storage/storage_client_testing.bzl
-@@ -35,6 +35,7 @@ storage_client_testing_hdrs = [
-
- storage_client_testing_srcs = [
- "testing/client_unit_test.cc",
-+ "testing/mock_client.cc",
- "testing/mock_http_request.cc",
- "testing/object_integration_test.cc",
- "testing/random_names.cc",
-diff --git a/google/cloud/storage/testing/mock_client.cc b/google/cloud/storage/testing/mock_client.cc
-new file mode 100644
-index 0000000000..88cd26aba3
---- /dev/null
-+++ b/google/cloud/storage/testing/mock_client.cc
-@@ -0,0 +1,29 @@
-+// Copyright 2023 Google LLC
-+//
-+// Licensed under the Apache License, Version 2.0 (the "License");
-+// you may not use this file except in compliance with the License.
-+// You may obtain a copy of the License at
-+//
-+// https://www.apache.org/licenses/LICENSE-2.0
-+//
-+// Unless required by applicable law or agreed to in writing, software
-+// distributed under the License is distributed on an "AS IS" BASIS,
-+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-+// See the License for the specific language governing permissions and
-+// limitations under the License.
-+
-+#include "google/cloud/storage/testing/mock_client.h"
-+
-+namespace google {
-+namespace cloud {
-+namespace storage {
-+namespace testing {
-+
-+Client UndecoratedClientFromMock(std::shared_ptr<MockClient> mock) {
-+ return internal::ClientImplDetails::CreateWithoutDecorations(std::move(mock));
-+}
-+
-+} // namespace testing
-+} // namespace storage
-+} // namespace cloud
-+} // namespace google
-diff --git a/google/cloud/storage/testing/mock_client.h b/google/cloud/storage/testing/mock_client.h
-index 9d71ac94b9..6a763d82c6 100644
---- a/google/cloud/storage/testing/mock_client.h
-+++ b/google/cloud/storage/testing/mock_client.h
-@@ -185,7 +185,12 @@ class MockStreambuf : public internal::ObjectWriteStreambuf {
- MOCK_METHOD(std::uint64_t, next_expected_byte, (), (const, override));
- };
-
--/// Create a client configured to use the given mock.
-+/**
-+ * Create a client configured to use the given mock.
-+ *
-+ * Unless you specifically need to mock the behavior of retries, prefer
-+ * `UndecoratedClientFromMock()`.
-+ */
- template <typename... Policies>
- Client ClientFromMock(std::shared_ptr<MockClient> const& mock,
- Policies&&... p) {
-@@ -193,6 +198,13 @@ Client ClientFromMock(std::shared_ptr<MockClient> const& mock,
- mock, std::forward<Policies>(p)...);
- }
-
-+/**
-+ * Create a client configured to use the given mock.
-+ *
-+ * This client does not retry on transient errors.
-+ */
-+Client UndecoratedClientFromMock(std::shared_ptr<MockClient> mock);
-+
- } // namespace testing
- } // namespace storage
- } // namespace cloud
-diff --git a/google/cloud/storage/testing/remove_stale_buckets_test.cc b/google/cloud/storage/testing/remove_stale_buckets_test.cc
-index 23c1962fcc..afc5e85c03 100644
---- a/google/cloud/storage/testing/remove_stale_buckets_test.cc
-+++ b/google/cloud/storage/testing/remove_stale_buckets_test.cc
-@@ -72,7 +72,7 @@ TEST(CleanupStaleBucketsTest, RemoveBucketContents) {
- EXPECT_CALL(*mock, GetBucketMetadata)
- .WillOnce(
- Return(make_status_or(BucketMetadata{}.set_name("fake-bucket"))));
-- auto client = internal::ClientImplDetails::CreateWithoutDecorations(mock);
-+ auto client = UndecoratedClientFromMock(mock);
- auto const actual = RemoveBucketAndContents(client, "fake-bucket");
- EXPECT_STATUS_OK(actual);
- }
-@@ -114,7 +114,7 @@ TEST(CleanupStaleBucketsTest, RemoveStaleBuckets) {
- return response;
- });
-
-- auto client = internal::ClientImplDetails::CreateWithoutDecorations(mock);
-+ auto client = UndecoratedClientFromMock(mock);
- auto const actual = RemoveStaleBuckets(client, "matching", create_time_limit);
- EXPECT_STATUS_OK(actual);
- }
diff --git a/thirdparty/google-cloud-cpp/mock_client_target.patch b/thirdparty/google-cloud-cpp/mock_client_target.patch
deleted file mode 100644
index 70b3af164..000000000
--- a/thirdparty/google-cloud-cpp/mock_client_target.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/google/cloud/storage/google_cloud_cpp_storage.cmake b/google/cloud/storage/google_cloud_cpp_storage.cmake
-index 5e53e972a9..7c1f1b6542 100644
---- a/google/cloud/storage/google_cloud_cpp_storage.cmake
-+++ b/google/cloud/storage/google_cloud_cpp_storage.cmake
-@@ -399,6 +399,21 @@ install(
- DESTINATION include/google/cloud/storage/testing
- COMPONENT google_cloud_cpp_development)
-
-+add_library(
-+ mock_google_cloud_client # cmake-format: sort
-+ testing/mock_client.cc
-+ testing/mock_client.h)
-+target_link_libraries(
-+ mock_google_cloud_client
-+ PUBLIC google-cloud-cpp::storage
-+ GTest::gmock)
-+google_cloud_cpp_add_common_options(mock_google_cloud_client)
-+target_include_directories(
-+ mock_google_cloud_client PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
-+ $<INSTALL_INTERFACE:include>)
-+target_compile_options(mock_google_cloud_client
-+ PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
-+
- if (BUILD_TESTING)
- add_library(
- storage_client_testing # cmake-format: sort
diff --git a/thirdparty/google-cloud-cpp/remove-find_package.patch b/thirdparty/google-cloud-cpp/remove-find_package.patch
index 74c16ee98..100873ada 100644
--- a/thirdparty/google-cloud-cpp/remove-find_package.patch
+++ b/thirdparty/google-cloud-cpp/remove-find_package.patch
@@ -1,11 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
---- a/CMakeLists.txt (revision 334e481f49c78c9e22aa48e59d044f6051ce99a7)
-+++ b/CMakeLists.txt (date 1646227181483)
-@@ -251,7 +251,6 @@
- # Each subproject adds dependencies to this target to have their docs generated.
+index 257f1807e4..2fcb543167 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -218,7 +218,6 @@ add_custom_target(google-cloud-cpp-protos)
add_custom_target(doxygen-docs)
-
+ add_custom_target(all-docfx)
+
-find_package(absl CONFIG REQUIRED)
- if (${GOOGLE_CLOUD_CPP_ENABLE_GRPC})
+ if (GOOGLE_CLOUD_CPP_ENABLE_GRPC)
find_package(gRPC REQUIRED QUIET)
- find_package(ProtobufWithTargets REQUIRED QUIET)
+ # `Protobuf_PROTOC_EXECUTABLE` is pretty standard. It has been in use by