Skip to content

Commit

Permalink
cleanup(storage): move test protos
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Jul 24, 2024
1 parent 867f021 commit 8a3539f
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 26 deletions.
3 changes: 3 additions & 0 deletions cmake/GoogleCloudCppFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ function (google_cloud_cpp_enable_features)
if (NOT ("storage" IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
add_subdirectory(google/cloud/storage)
endif ()
elseif ("${feature}" STREQUAL "storage")
add_subdirectory(protos/google/cloud/storage/tests)
add_subdirectory(google/cloud/storage)
elseif ("${feature}" STREQUAL "experimental-bigquery_rest")
if (NOT ("bigquery" IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
add_subdirectory(google/cloud/bigquery)
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
2 changes: 1 addition & 1 deletion google/cloud/storage/tests/signed_url_conformance_test.cc
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__",
],
)
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 ()

# 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 "")

0 comments on commit 8a3539f

Please sign in to comment.