Skip to content

Commit

Permalink
fix endpoint storage reading (#147)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Rigachnyi <[email protected]>
  • Loading branch information
2 people authored and qkrorlqr committed Jan 17, 2024
1 parent 9410571 commit a6c45cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
33 changes: 8 additions & 25 deletions cloud/blockstore/libs/endpoints/service_endpoint_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(request);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
diskId,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

{
Expand Down Expand Up @@ -334,9 +332,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(startRequest);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
diskId,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

auto request = std::make_shared<NProto::TKickEndpointRequest>();
Expand Down Expand Up @@ -411,12 +407,9 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
size_t wrongDataCount = 3;
size_t wrongSocketCount = 4;
size_t correctCount = 5;
size_t num = 0;

for (size_t i = 0; i < wrongDataCount; ++i) {
auto keyOrError = mutableStorage->AddEndpoint(
TStringBuilder() << "endpoint" << ++num,
"invalid proto request data");
auto keyOrError = endpointStorage->AddEndpoint("invalid proto request data");
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());
}

Expand All @@ -427,9 +420,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(request);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
TStringBuilder() << "endpoint" << ++num,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());
}

Expand All @@ -440,9 +431,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(request);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
TStringBuilder() << "endpoint" << ++num,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());
}

Expand Down Expand Up @@ -563,9 +552,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(request);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
TStringBuilder() << "endpoint" << i,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());
}

Expand Down Expand Up @@ -644,9 +631,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(request);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
request.GetDiskId(),
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

requests.emplace(keyOrError.GetResult(), request);
Expand Down Expand Up @@ -931,9 +916,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(*startRequest);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
"endpoint",
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

auto restoreFuture = endpointService->RestoreEndpoints();
Expand Down
12 changes: 3 additions & 9 deletions cloud/filestore/libs/endpoint/service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(start);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
id,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

auto request = std::make_shared<NProto::TKickEndpointRequest>();
Expand Down Expand Up @@ -260,9 +258,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(start);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
id,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

auto request = std::make_shared<NProto::TKickEndpointRequest>();
Expand Down Expand Up @@ -309,9 +305,7 @@ Y_UNIT_TEST_SUITE(TServiceEndpointTest)
auto strOrError = SerializeEndpoint(start);
UNIT_ASSERT_C(!HasError(strOrError), strOrError.GetError());

auto keyOrError = mutableStorage->AddEndpoint(
id,
strOrError.GetResult());
auto keyOrError = endpointStorage->AddEndpoint(strOrError.GetResult());
UNIT_ASSERT_C(!HasError(keyOrError), keyOrError.GetError());

auto request = std::make_shared<NProto::TKickEndpointRequest>();
Expand Down
2 changes: 1 addition & 1 deletion cloud/storage/core/libs/keyring/endpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class TFileStorage final
<< "Failed to open file " << filepath.GetPath().Quote());
}

return Strip(TFileInput(file).ReadAll());
return TFileInput(file).ReadAll();
}

ui32 GetFreeId()
Expand Down

0 comments on commit a6c45cf

Please sign in to comment.