Skip to content

Commit 017da80

Browse files
committed
file formatting
1 parent 1a4aebe commit 017da80

File tree

9 files changed

+233
-230
lines changed

9 files changed

+233
-230
lines changed

google/cloud/storage/async/object_descriptor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ absl::optional<google::storage::v2::Object> ObjectDescriptor::metadata() const {
2828
std::pair<AsyncReader, AsyncToken> ObjectDescriptor::Read(std::int64_t offset,
2929
std::int64_t limit) {
3030
std::int64_t max_range =
31-
impl_->options().get<storage_experimental::MaximumRangeSizeOption>();
31+
impl_->options().get<storage_experimental::MaximumRangeSizeOption>();
3232
if (limit > max_range) {
3333
impl_->MakeSubsequentStream();
3434
}

google/cloud/storage/internal/async/connection_impl_open_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ using ::google::cloud::testing_util::IsProtoEqual;
4444
using ::google::cloud::testing_util::MockCompletionQueueImpl;
4545
using ::google::cloud::testing_util::StatusIs;
4646
using ::google::protobuf::TextFormat;
47+
using ::testing::InvokeWithoutArgs;
48+
using ::testing::NiceMock;
4749
using ::testing::NotNull;
4850
using ::testing::Optional;
51+
using ::testing::Return;
4952

5053
using BidiReadStream = google::cloud::AsyncStreamingReadWriteRpc<
5154
google::storage::v2::BidiReadObjectRequest,
@@ -183,6 +186,19 @@ TEST(AsyncConnectionImplTest, OpenSimple) {
183186
[](auto) { return Status{}; });
184187
});
185188

189+
return std::unique_ptr<BidiReadStream>(std::move(stream));
190+
})
191+
.WillRepeatedly([](CompletionQueue const&,
192+
std::shared_ptr<grpc::ClientContext> const&,
193+
google::cloud::internal::ImmutableOptions const&) {
194+
auto stream = std::make_unique<NiceMock<MockStream>>();
195+
ON_CALL(*stream, Start).WillByDefault(InvokeWithoutArgs([] {
196+
return make_ready_future(false);
197+
}));
198+
ON_CALL(*stream, Finish).WillByDefault(InvokeWithoutArgs([] {
199+
return make_ready_future(Status{});
200+
}));
201+
ON_CALL(*stream, Cancel).WillByDefault([] {});
186202
return std::unique_ptr<BidiReadStream>(std::move(stream));
187203
});
188204

google/cloud/storage/internal/async/multi_stream_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

google/cloud/storage/internal/async/multi_stream_manager.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -62,7 +62,8 @@ class MultiStreamManager {
6262

6363
// Constructor accepts an already-created initial stream.
6464
// This is required by ObjectDescriptorImpl which receives an OpenStream.
65-
MultiStreamManager(StreamFactory stream_factory, std::shared_ptr<StreamT> initial_stream)
65+
MultiStreamManager(StreamFactory stream_factory,
66+
std::shared_ptr<StreamT> initial_stream)
6667
: stream_factory_(std::move(stream_factory)) {
6768
streams_.push_back(Stream{std::move(initial_stream), {}});
6869
}
@@ -72,7 +73,7 @@ class MultiStreamManager {
7273
// In ObjectDescriptorImpl, we ensure there is always at least one stream,
7374
// but this assertion protects against future refactoring errors.
7475
assert(!streams_.empty());
75-
return std::prev(streams_.end());
76+
return std::prev(streams_.end());
7677
}
7778

7879
StreamIterator GetLeastBusyStream() {

google/cloud/storage/internal/async/multi_stream_manager_test.cc

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -39,7 +39,9 @@ struct FakeStream : public StreamBase {
3939
using Manager = MultiStreamManager<FakeStream, FakeRange>;
4040

4141
struct MultiStreamManagerTest : public ::testing::Test {
42-
static Manager MakeManager() { return Manager([] { return std::make_shared<FakeStream>(); }); }
42+
static Manager MakeManager() {
43+
return Manager([] { return std::make_shared<FakeStream>(); });
44+
}
4345
};
4446

4547
} // namespace
@@ -72,9 +74,10 @@ TEST(MultiStreamManagerTest, AddStreamAppendsAndGetLastReturnsNew) {
7274

7375
TEST(MultiStreamManagerTest, GetLeastBusyPrefersFewestActiveRanges) {
7476
auto mgr = MultiStreamManagerTest::MakeManager();
75-
76-
// The manager starts with an initial stream (size 0).
77-
// We must make it "busy" so it doesn't win the comparison against our test streams.
77+
78+
// The manager starts with an initial stream (size 0).
79+
// We must make it "busy" so it doesn't win the comparison against our test
80+
// streams.
7881
auto it_init = mgr.GetLastStream();
7982
it_init->active_ranges.emplace(999, std::make_shared<FakeRange>());
8083
it_init->active_ranges.emplace(998, std::make_shared<FakeRange>());
@@ -87,23 +90,26 @@ TEST(MultiStreamManagerTest, GetLeastBusyPrefersFewestActiveRanges) {
8790
// s1 has 2 ranges.
8891
it1->active_ranges.emplace(1, std::make_shared<FakeRange>());
8992
it1->active_ranges.emplace(2, std::make_shared<FakeRange>());
90-
93+
9194
// s2 has 1 range.
9295
it2->active_ranges.emplace(3, std::make_shared<FakeRange>());
93-
96+
9497
auto it_least = mgr.GetLeastBusyStream();
95-
98+
9699
// Expect it2 (1 range) over it1 (2 ranges) and it_init (2 ranges).
97-
EXPECT_EQ(it_least, it2);
100+
EXPECT_EQ(it_least, it2);
98101
EXPECT_EQ(it_least->active_ranges.size(), 1u);
99102
}
100103

101104
TEST(MultiStreamManagerTest, CleanupDoneRangesRemovesFinished) {
102105
auto mgr = MultiStreamManagerTest::MakeManager();
103106
auto it = mgr.GetLastStream();
104-
auto r1 = std::make_shared<FakeRange>(); r1->done = false;
105-
auto r2 = std::make_shared<FakeRange>(); r2->done = true;
106-
auto r3 = std::make_shared<FakeRange>(); r3->done = true;
107+
auto r1 = std::make_shared<FakeRange>();
108+
r1->done = false;
109+
auto r2 = std::make_shared<FakeRange>();
110+
r2->done = true;
111+
auto r3 = std::make_shared<FakeRange>();
112+
r3->done = true;
107113
it->active_ranges.emplace(1, r1);
108114
it->active_ranges.emplace(2, r2);
109115
it->active_ranges.emplace(3, r3);
@@ -142,26 +148,24 @@ TEST(MultiStreamManagerTest, ReuseIdleStreamToBackMovesElement) {
142148
auto factory_ptr = mgr.GetLastStream()->stream.get();
143149
auto s1 = std::make_shared<FakeStream>();
144150
mgr.AddStream(s1);
145-
bool moved = mgr.ReuseIdleStreamToBack(
146-
[](Manager::Stream const& s) {
147-
auto fs = s.stream.get();
148-
return fs != nullptr && s.active_ranges.empty() && !fs->write_pending;
149-
});
151+
bool moved = mgr.ReuseIdleStreamToBack([](Manager::Stream const& s) {
152+
auto fs = s.stream.get();
153+
return fs != nullptr && s.active_ranges.empty() && !fs->write_pending;
154+
});
150155
EXPECT_TRUE(moved);
151156
auto it_last = mgr.GetLastStream();
152157
// After move, the factory stream should be last
153158
EXPECT_EQ(it_last->stream.get(), factory_ptr);
154159
EXPECT_NE(it_last->stream.get(), s1.get());
155160
}
156161

157-
TEST(MultiStreamManagerTest, ReuseIdleStreamAlreadyAtBackReturnsTrueWithoutMove) {
162+
TEST(MultiStreamManagerTest,
163+
ReuseIdleStreamAlreadyAtBackReturnsTrueWithoutMove) {
158164
auto mgr = MultiStreamManagerTest::MakeManager();
159165
// The manager starts with one stream. It is the last stream, and it is idle.
160166
auto initial_last = mgr.GetLastStream();
161167
bool reused = mgr.ReuseIdleStreamToBack(
162-
[](Manager::Stream const& s) {
163-
return s.active_ranges.empty();
164-
});
168+
[](Manager::Stream const& s) { return s.active_ranges.empty(); });
165169
EXPECT_TRUE(reused);
166170
// Pointer should remain the same (it was already at the back)
167171
EXPECT_EQ(mgr.GetLastStream(), initial_last);
@@ -174,11 +178,10 @@ TEST(MultiStreamManagerTest, ReuseIdleStreamDoesNotMoveWhenWritePending) {
174178
auto s1 = std::make_shared<FakeStream>();
175179
s1->write_pending = true; // also mark appended stream as not reusable
176180
mgr.AddStream(s1);
177-
bool moved = mgr.ReuseIdleStreamToBack(
178-
[](Manager::Stream const& s) {
179-
auto fs = s.stream.get();
180-
return fs != nullptr && s.active_ranges.empty() && !fs->write_pending;
181-
});
181+
bool moved = mgr.ReuseIdleStreamToBack([](Manager::Stream const& s) {
182+
auto fs = s.stream.get();
183+
return fs != nullptr && s.active_ranges.empty() && !fs->write_pending;
184+
});
182185
EXPECT_FALSE(moved);
183186
auto it_last = mgr.GetLastStream();
184187
EXPECT_EQ(it_last->stream.get(), s1.get());
@@ -206,10 +209,9 @@ TEST(MultiStreamManagerTest, GetLastStreamReflectsRecentAppendAndReuse) {
206209
auto s1 = std::make_shared<FakeStream>();
207210
mgr.AddStream(s1);
208211
EXPECT_EQ(mgr.GetLastStream()->stream.get(), s1.get());
209-
bool moved = mgr.ReuseIdleStreamToBack(
210-
[](Manager::Stream const& s) {
211-
return s.stream != nullptr && s.active_ranges.empty();
212-
});
212+
bool moved = mgr.ReuseIdleStreamToBack([](Manager::Stream const& s) {
213+
return s.stream != nullptr && s.active_ranges.empty();
214+
});
213215
EXPECT_TRUE(moved);
214216
auto it_last = mgr.GetLastStream();
215217
EXPECT_NE(it_last->stream.get(), s1.get());

0 commit comments

Comments
 (0)