Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(storage): move test protos #14508

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/GoogleCloudCppFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,13 @@ function (google_cloud_cpp_enable_features)
)
continue()
endif ()
if (IS_DIRECTORY
"${PROJECT_SOURCE_DIR}/protos/google/cloud/${feature}"
AND EXISTS
"${PROJECT_SOURCE_DIR}/protos/google/cloud/${feature}/CMakeLists.txt"
)
add_subdirectory(protos/google/cloud/${feature})
endif ()
add_subdirectory(google/cloud/${feature})
if (GOOGLE_CLOUD_CPP_ENABLE_EXAMPLES
AND IS_DIRECTORY
Expand Down
16 changes: 2 additions & 14 deletions google/cloud/storage/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

proto_library(
name = "storage_conformance_tests_proto",
srcs = [
"conformance_tests.proto",
],
deps = ["@com_google_protobuf//:timestamp_proto"],
)

cc_proto_library(
name = "storage_conformance_tests_cc_proto",
deps = [":storage_conformance_tests_proto"],
)

VARIATIONS = {
"default": {"GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG": "none"},
"grpc-metadata": {"GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG": "metadata"},
Expand All @@ -56,12 +43,13 @@ VARIATIONS = {
"integration-test-" + v_label,
] + (["integration-test-gha"] if test.startswith("smoke_test") else []),
deps = [
":storage_conformance_tests_cc_proto",
"//:common",
"//:storage",
"//google/cloud/storage:storage_client_testing",
"//google/cloud/testing_util:google_cloud_cpp_testing_grpc_private",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
"//protos:system_includes",
"//protos/google/cloud/storage/tests:storage_conformance_tests_cc_proto",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
],
Expand Down
10 changes: 0 additions & 10 deletions google/cloud/storage/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ export_list_to_bazel(
"storage_client_integration_tests.bzl" "storage_client_integration_tests"
"storage_client_integration_tests_production" YEAR "2018")

# Signed URL conformance tests are parsed using protos. In order to simplify the
# build files, only build these conformance tests if gRPC in GCS is compiled.
if (GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC)
# We need to disable clang tidy for the generated CC files.
google_cloud_cpp_proto_library(
google_cloud_cpp_storage_tests_conformance_protos
conformance_tests.proto PROTO_PATH_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR})
endif ()

foreach (fname IN LISTS storage_client_integration_tests)
google_cloud_cpp_add_executable(target "storage" "${fname}")
target_link_libraries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include "google/cloud/storage/internal/base64.h"
#include "google/cloud/storage/internal/signed_url_requests.h"
#include "google/cloud/storage/list_objects_reader.h"
#include "google/cloud/storage/tests/conformance_tests.pb.h"
#include "google/cloud/internal/format_time_point.h"
#include "google/cloud/internal/getenv.h"
#include "google/cloud/internal/time_utils.h"
#include "google/cloud/terminate_handler.h"
#include "google/cloud/testing_util/scoped_environment.h"
#include "google/cloud/testing_util/status_matchers.h"
#include <google/cloud/storage/tests/conformance_tests.pb.h>
#include <google/protobuf/util/json_util.h>
#include <gmock/gmock.h>
#include <algorithm>
Expand Down
5 changes: 4 additions & 1 deletion protos/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ licenses(["notice"]) # Apache 2.0
cc_library(
name = "system_includes",
includes = ["."],
visibility = ["//google/cloud/compute:__pkg__"],
visibility = [
"//google/cloud/compute:__pkg__",
"//google/cloud/storage/tests:__pkg__",
],
)
15 changes: 15 additions & 0 deletions protos/google/cloud/storage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 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.

add_subdirectory(tests)
33 changes: 33 additions & 0 deletions protos/google/cloud/storage/tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 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.

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

proto_library(
name = "storage_conformance_tests_proto",
srcs = [
"conformance_tests.proto",
],
deps = ["@com_google_protobuf//:timestamp_proto"],
)

cc_proto_library(
name = "storage_conformance_tests_cc_proto",
visibility = [
"//google/cloud/storage/tests:__pkg__",
],
deps = [":storage_conformance_tests_proto"],
)
49 changes: 49 additions & 0 deletions protos/google/cloud/storage/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2024 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.

# Signed URL conformance tests are parsed using protos. In order to simplify the
# build files, only build these conformance tests if gRPC in GCS is compiled.
if ((NOT GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) OR (NOT BUILD_TESTING))
return()
endif ()

include(GoogleCloudCppCommon)
find_package(Protobuf CONFIG QUIET)
if (NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif ()
dbolduc marked this conversation as resolved.
Show resolved Hide resolved

# Generate protobuf code and library
if (COMMAND protobuf_generate)
set(protobuf_PROTOC_EXE ${Protobuf_PROTOC_EXECUTABLE})
add_library(google_cloud_cpp_storage_tests_conformance_protos)
protobuf_generate(
LANGUAGE cpp TARGET google_cloud_cpp_storage_tests_conformance_protos
PROTOS conformance_tests.proto)
elseif (COMMAND protobuf_generate_cpp)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS conformance_tests.proto)
add_library(google_cloud_cpp_storage_tests_conformance_protos ${PROTO_HDRS}
${PROTO_SRCS})
else ()
message(FATAL_ERROR "Missing protobuf_generate_cpp and protobuf_generate")
endif ()

target_link_libraries(google_cloud_cpp_storage_tests_conformance_protos
PUBLIC protobuf::libprotobuf)
target_include_directories(google_cloud_cpp_storage_tests_conformance_protos
SYSTEM PUBLIC "${PROJECT_BINARY_DIR}/protos")
google_cloud_cpp_add_common_options(
google_cloud_cpp_storage_tests_conformance_protos NO_WARNINGS)
set_target_properties(google_cloud_cpp_storage_tests_conformance_protos
PROPERTIES CXX_CLANG_TIDY "")
Loading