Skip to content

Commit 1a50a11

Browse files
authored
Add simple UT for storage load test actor. (#10894)
1 parent 634dc20 commit 1a50a11

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <ydb/core/blobstorage/ut_blobstorage/lib/env.h>
2+
#include <ydb/core/load_test/service_actor.h>
3+
4+
#include <library/cpp/protobuf/util/pb_io.h>
5+
6+
namespace {
7+
8+
struct TTetsEnv {
9+
TTetsEnv()
10+
: Env({
11+
.NodeCount = 8,
12+
.VDiskReplPausedAtStart = false,
13+
.Erasure = TBlobStorageGroupType::Erasure4Plus2Block,
14+
})
15+
, Counters(new ::NMonitoring::TDynamicCounters())
16+
{
17+
Env.CreateBoxAndPool(1, 1);
18+
Env.Sim(TDuration::Minutes(1));
19+
20+
auto groups = Env.GetGroups();
21+
UNIT_ASSERT_VALUES_EQUAL(groups.size(), 1);
22+
GroupInfo = Env.GetGroupInfo(groups.front());
23+
24+
VDiskActorId = GroupInfo->GetActorId(0);
25+
26+
Env.Runtime->SetLogPriority(NKikimrServices::BS_LOAD_TEST, NLog::PRI_DEBUG);
27+
}
28+
29+
TString RunSingleLoadTest(const TString& command) {
30+
const auto sender = Env.Runtime->AllocateEdgeActor(VDiskActorId.NodeId(), __FILE__, __LINE__);
31+
auto stream = TStringInput(command);
32+
33+
const ui64 tag = 42ULL;
34+
GroupWriteActorId = Env.Runtime->Register(CreateWriterLoadTest(ParseFromTextFormat<NKikimr::TEvLoadTestRequest::TStorageLoad>(stream), sender, Counters, tag), sender, 0, std::nullopt, VDiskActorId.NodeId());
35+
36+
const auto res = Env.WaitForEdgeActorEvent<TEvLoad::TEvLoadTestFinished>(sender, true);
37+
UNIT_ASSERT_VALUES_EQUAL(res->Get()->Tag, tag);
38+
return res->Get()->LastHtmlPage;
39+
}
40+
41+
TEnvironmentSetup Env;
42+
TIntrusivePtr<TBlobStorageGroupInfo> GroupInfo;
43+
TActorId VDiskActorId;
44+
TActorId GroupWriteActorId;
45+
TIntrusivePtr<::NMonitoring::TDynamicCounters> Counters;
46+
};
47+
48+
}
49+
50+
Y_UNIT_TEST_SUITE(GroupWriteTest) {
51+
52+
Y_UNIT_TEST(Simple) {
53+
TTetsEnv env;
54+
55+
const TString conf(R"(DurationSeconds: 3
56+
Tablets: {
57+
Tablets: { TabletId: 1 Channel: 0 GroupId: )" + ToString(env.GroupInfo->GroupID) + R"( Generation: 1 }
58+
WriteSizes: { Weight: 1.0 Min: 1000000 Max: 4000000 }
59+
WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
60+
MaxInFlightWriteRequests: 10
61+
FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 1000000 MaxUs: 1000000 } }
62+
PutHandleClass: TabletLog
63+
})"
64+
);
65+
66+
const auto html = env.RunSingleLoadTest(conf);
67+
UNIT_ASSERT(html.Contains("<tr><td>BadPutResults</td><td>0</td></tr>"));
68+
}
69+
}

ydb/core/load_test/ut/ya.make

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
UNITTEST_FOR(ydb/core/load_test)
2+
3+
FORK_SUBTESTS(MODULO)
4+
5+
TIMEOUT(600)
6+
SIZE(MEDIUM)
7+
8+
PEERDIR(
9+
ydb/core/blobstorage/ut_blobstorage/lib
10+
ydb/core/testlib/default
11+
)
12+
13+
YQL_LAST_ABI_VERSION()
14+
15+
SRCS(group_test_ut.cpp)
16+
17+
END()

ydb/core/load_test/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ GENERATE_ENUM_SERIALIZATION(percentile.h)
6262
END()
6363

6464
RECURSE_FOR_TESTS(
65+
ut
6566
ut_ycsb
6667
)

0 commit comments

Comments
 (0)