Skip to content

Commit 2407454

Browse files
committed
add integration golden test
1 parent 4f16dfb commit 2407454

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2777
-0
lines changed

generator/integration_tests/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ proto_library(
3030
"common.proto",
3131
"test.proto",
3232
"test2.proto",
33+
"test_deprecated.proto",
3334
"test_request_id.proto",
3435
],
3536
deps = [

generator/integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ google_cloud_cpp_grpcpp_library(
3131
${PROJECT_SOURCE_DIR}/generator/integration_tests/test.proto
3232
${PROJECT_SOURCE_DIR}/generator/integration_tests/test2.proto
3333
${PROJECT_SOURCE_DIR}/generator/integration_tests/test_request_id.proto
34+
${PROJECT_SOURCE_DIR}/generator/integration_tests/test_deprecated.proto
3435
PROTO_PATH_DIRECTORIES
3536
${PROTO_INCLUDE_DIR}
3637
${PROJECT_SOURCE_DIR}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: generator/integration_tests/test_deprecated.proto
18+
19+
#include "google/cloud/internal/disable_deprecation_warnings.inc"
20+
#include "generator/integration_tests/golden/v1/deprecated_client.h"
21+
#include <memory>
22+
#include <utility>
23+
24+
namespace google {
25+
namespace cloud {
26+
namespace golden_v1 {
27+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28+
29+
DeprecatedServiceClient::DeprecatedServiceClient(
30+
std::shared_ptr<DeprecatedServiceConnection> connection, Options opts)
31+
: connection_(std::move(connection)),
32+
options_(internal::MergeOptions(std::move(opts),
33+
connection_->options())) {}
34+
DeprecatedServiceClient::~DeprecatedServiceClient() = default;
35+
36+
Status
37+
DeprecatedServiceClient::Noop(google::test::deprecated::v1::DeprecatedServiceRequest const& request, Options opts) {
38+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
39+
return connection_->Noop(request);
40+
}
41+
42+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
43+
} // namespace golden_v1
44+
} // namespace cloud
45+
} // namespace google
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: generator/integration_tests/test_deprecated.proto
18+
19+
#ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_V1_DEPRECATED_CLIENT_H
20+
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_V1_DEPRECATED_CLIENT_H
21+
22+
#include "google/cloud/internal/disable_deprecation_warnings.inc"
23+
#include "generator/integration_tests/golden/v1/deprecated_connection.h"
24+
#include "google/cloud/future.h"
25+
#include "google/cloud/options.h"
26+
#include "google/cloud/polling_policy.h"
27+
#include "google/cloud/status_or.h"
28+
#include "google/cloud/version.h"
29+
#include <memory>
30+
#include <string>
31+
32+
namespace google {
33+
namespace cloud {
34+
namespace golden_v1 {
35+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
36+
37+
///
38+
/// Service to test deprecated services.
39+
///
40+
/// @par Equality
41+
///
42+
/// Instances of this class created via copy-construction or copy-assignment
43+
/// always compare equal. Instances created with equal
44+
/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
45+
/// equal share the same underlying resources.
46+
///
47+
/// @par Performance
48+
///
49+
/// Creating a new instance of this class is a relatively expensive operation,
50+
/// new objects establish new connections to the service. In contrast,
51+
/// copy-construction, move-construction, and the corresponding assignment
52+
/// operations are relatively efficient as the copies share all underlying
53+
/// resources.
54+
///
55+
/// @par Thread Safety
56+
///
57+
/// Concurrent access to different instances of this class, even if they compare
58+
/// equal, is guaranteed to work. Two or more threads operating on the same
59+
/// instance of this class is not guaranteed to work. Since copy-construction
60+
/// and move-construction is a relatively efficient operation, consider using
61+
/// such a copy when using this class from multiple threads.
62+
///
63+
class DeprecatedServiceClient {
64+
public:
65+
explicit DeprecatedServiceClient(std::shared_ptr<DeprecatedServiceConnection> connection, Options opts = {});
66+
~DeprecatedServiceClient();
67+
68+
///@{
69+
/// @name Copy and move support
70+
DeprecatedServiceClient(DeprecatedServiceClient const&) = default;
71+
DeprecatedServiceClient& operator=(DeprecatedServiceClient const&) = default;
72+
DeprecatedServiceClient(DeprecatedServiceClient&&) = default;
73+
DeprecatedServiceClient& operator=(DeprecatedServiceClient&&) = default;
74+
///@}
75+
76+
///@{
77+
/// @name Equality
78+
friend bool operator==(DeprecatedServiceClient const& a, DeprecatedServiceClient const& b) {
79+
return a.connection_ == b.connection_;
80+
}
81+
friend bool operator!=(DeprecatedServiceClient const& a, DeprecatedServiceClient const& b) {
82+
return !(a == b);
83+
}
84+
///@}
85+
86+
// clang-format off
87+
///
88+
/// Does nothing.
89+
///
90+
/// @param request Unary RPCs, such as the one wrapped by this
91+
/// function, receive a single `request` proto message which includes all
92+
/// the inputs for the RPC. In this case, the proto message is a
93+
/// [google.test.deprecated.v1.DeprecatedServiceRequest].
94+
/// Proto messages are converted to C++ classes by Protobuf, using the
95+
/// [Protobuf mapping rules].
96+
/// @param opts Optional. Override the class-level options, such as retry and
97+
/// backoff policies.
98+
/// @return a [`Status`] object. If the request failed, the
99+
/// status contains the details of the failure.
100+
///
101+
/// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
102+
/// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
103+
/// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
104+
/// [`future`]: @ref google::cloud::future
105+
/// [`StatusOr`]: @ref google::cloud::StatusOr
106+
/// [`Status`]: @ref google::cloud::Status
107+
/// [google.test.deprecated.v1.DeprecatedServiceRequest]: @googleapis_reference_link{generator/integration_tests/test_deprecated.proto#L39}
108+
///
109+
// clang-format on
110+
Status
111+
Noop(google::test::deprecated::v1::DeprecatedServiceRequest const& request, Options opts = {});
112+
113+
private:
114+
std::shared_ptr<DeprecatedServiceConnection> connection_;
115+
Options options_;
116+
};
117+
118+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
119+
} // namespace golden_v1
120+
} // namespace cloud
121+
} // namespace google
122+
123+
#endif // GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_V1_DEPRECATED_CLIENT_H
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: generator/integration_tests/test_deprecated.proto
18+
19+
#include "google/cloud/internal/disable_deprecation_warnings.inc"
20+
#include "generator/integration_tests/golden/v1/deprecated_connection.h"
21+
#include "generator/integration_tests/golden/v1/deprecated_options.h"
22+
#include "generator/integration_tests/golden/v1/internal/deprecated_connection_impl.h"
23+
#include "generator/integration_tests/golden/v1/internal/deprecated_option_defaults.h"
24+
#include "generator/integration_tests/golden/v1/internal/deprecated_stub_factory.h"
25+
#include "generator/integration_tests/golden/v1/internal/deprecated_tracing_connection.h"
26+
#include "google/cloud/background_threads.h"
27+
#include "google/cloud/common_options.h"
28+
#include "google/cloud/credentials.h"
29+
#include "google/cloud/grpc_options.h"
30+
#include "google/cloud/internal/unified_grpc_credentials.h"
31+
#include <memory>
32+
#include <utility>
33+
34+
namespace google {
35+
namespace cloud {
36+
namespace golden_v1 {
37+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
38+
39+
DeprecatedServiceConnection::~DeprecatedServiceConnection() = default;
40+
41+
Status
42+
DeprecatedServiceConnection::Noop(
43+
google::test::deprecated::v1::DeprecatedServiceRequest const&) {
44+
return Status(StatusCode::kUnimplemented, "not implemented");
45+
}
46+
47+
std::shared_ptr<DeprecatedServiceConnection> MakeDeprecatedServiceConnection(
48+
Options options) {
49+
internal::CheckExpectedOptions<CommonOptionList, GrpcOptionList,
50+
UnifiedCredentialsOptionList,
51+
DeprecatedServicePolicyOptionList>(options, __func__);
52+
options = golden_v1_internal::DeprecatedServiceDefaultOptions(
53+
std::move(options));
54+
auto background = internal::MakeBackgroundThreadsFactory(options)();
55+
auto auth = internal::CreateAuthenticationStrategy(background->cq(), options);
56+
auto stub = golden_v1_internal::CreateDefaultDeprecatedServiceStub(
57+
std::move(auth), options);
58+
return golden_v1_internal::MakeDeprecatedServiceTracingConnection(
59+
std::make_shared<golden_v1_internal::DeprecatedServiceConnectionImpl>(
60+
std::move(background), std::move(stub), std::move(options)));
61+
}
62+
63+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
64+
} // namespace golden_v1
65+
} // namespace cloud
66+
} // namespace google

0 commit comments

Comments
 (0)