diff options
author | tarum <tarum@yandex-team.com> | 2023-04-18 15:52:28 +0300 |
---|---|---|
committer | tarum <tarum@yandex-team.com> | 2023-04-18 15:52:28 +0300 |
commit | 55252393655d7fd1e71407001d063f0938012899 (patch) | |
tree | 73c0e70ccd344496327762e9a835cd09639ab3ae | |
parent | 1bee262f7c4849ea77c887f75a9eb7e995fec477 (diff) | |
download | ydb-55252393655d7fd1e71407001d063f0938012899.tar.gz |
Indicate successful finish and render final HTML in storage load test
-rw-r--r-- | ydb/core/load_test/group_write.cpp | 89 |
1 files changed, 71 insertions, 18 deletions
diff --git a/ydb/core/load_test/group_write.cpp b/ydb/core/load_test/group_write.cpp index 56b30b9c598..d03cbdd876a 100644 --- a/ydb/core/load_test/group_write.cpp +++ b/ydb/core/load_test/group_write.cpp @@ -409,12 +409,17 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo std::bind(&TTabletWriter::ExposeCounters, this, _1), ctx); } - void DumpState(IOutputStream& str) { -#define DUMP_PARAM(NAME) \ - TABLER() { \ - TABLED() { str << #NAME; } \ - TABLED() { str << NAME; } \ + void DumpState(IOutputStream& str, bool finalResult) { +#define DUMP_PARAM_IMPL(NAME, INCLUDE_IN_FINAL) \ + if (!finalResult || INCLUDE_IN_FINAL) { \ + TABLER() { \ + TABLED() { str << #NAME; } \ + TABLED() { str << NAME; } \ + } \ } +#define DUMP_PARAM(NAME) DUMP_PARAM_IMPL(NAME, false) +#define DUMP_PARAM_FINAL(NAME) DUMP_PARAM_IMPL(NAME, true) + HTML(str) { TDuration EarliestTimestamp = TDuration::Zero(); const ui64 nowCycles = GetCycleCountFast(); @@ -437,16 +442,16 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo DUMP_PARAM(NextWriteTimestamp) DUMP_PARAM(WritesInFlight) DUMP_PARAM(WriteBytesInFlight) - DUMP_PARAM(MaxWritesInFlight) - DUMP_PARAM(MaxWriteBytesInFlight) - DUMP_PARAM(TotalBytesWritten) - DUMP_PARAM(MaxTotalBytesWritten) - DUMP_PARAM(TotalBytesRead) + DUMP_PARAM_FINAL(MaxWritesInFlight) + DUMP_PARAM_FINAL(MaxWriteBytesInFlight) + DUMP_PARAM_FINAL(TotalBytesWritten) + DUMP_PARAM_FINAL(MaxTotalBytesWritten) + DUMP_PARAM_FINAL(TotalBytesRead) DUMP_PARAM(NextReadTimestamp) DUMP_PARAM(ReadsInFlight) DUMP_PARAM(ReadBytesInFlight) - DUMP_PARAM(MaxReadsInFlight) - DUMP_PARAM(MaxReadBytesInFlight) + DUMP_PARAM_FINAL(MaxReadsInFlight) + DUMP_PARAM_FINAL(MaxReadBytesInFlight) DUMP_PARAM(ConfirmedBlobIds.size()) static constexpr size_t count = 5; @@ -483,6 +488,9 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo } } } +#undef DUMP_PARAM_IMPL +#undef DUMP_PARAM +#undef DUMP_PARAM_FINAL } private: @@ -742,6 +750,8 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo const TActorId Parent; TMaybe<TDuration> TestDuration; + TInstant TestStartTime; + bool EarlyStop = false; TVector<TTabletWriter> TabletWriters; @@ -833,6 +843,8 @@ public: void Bootstrap(const TActorContext& ctx) { Become(&TLogWriterLoadTestActor::StateFunc); + EarlyStop = false; + TestStartTime = TAppData::TimeProvider->Now(); if (TestDuration) { ctx.Schedule(*TestDuration, new TEvents::TEvPoisonPill()); } @@ -844,6 +856,9 @@ public: } void HandlePoison(const TActorContext& ctx) { + if (TestDuration.Defined()) { + EarlyStop = TAppData::TimeProvider->Now() - TestStartTime < TestDuration; + } LOG_DEBUG_S(ctx, NKikimrServices::BS_LOAD_TEST, "Load tablet recieved PoisonPill, going to die"); for (auto& writer : TabletWriters) { writer.StopWorking(ctx); // Sends TEvStopTest then all garbage is collected @@ -853,9 +868,27 @@ public: void HandleStopTest(const TActorContext& ctx) { ++TestStoppedReceived; if (TestStoppedReceived == TabletWriters.size()) { - ctx.Send(Parent, new TEvLoad::TEvLoadTestFinished(Tag, nullptr, "HandleStopTest")); - Die(ctx); + DeathReport(ctx); + } + } + + void DeathReport(const TActorContext& ctx) { + TIntrusivePtr<TEvLoad::TLoadReport> report = nullptr; + TString errorReason; + if (EarlyStop) { + errorReason = "Abort, stop signal received"; + } else { + report.Reset(new TEvLoad::TLoadReport()); + if (TestDuration.Defined()) { + report->Duration = TestDuration.GetRef(); + } + errorReason = "HandleStopTest"; } + + auto* finishEv = new TEvLoad::TEvLoadTestFinished(Tag, report, errorReason); + finishEv->LastHtmlPage = RenderHTML(true); + ctx.Send(Parent, finishEv); + Die(ctx); } void HandleUpdateQuantile(const TActorContext& ctx) { @@ -893,7 +926,7 @@ public: HandleWakeup(ctx); } - void Handle(NMon::TEvHttpInfo::TPtr& ev, const TActorContext& ctx) { + TString RenderHTML(bool finalResult) { TStringStream str; HTML(str) { TABLE_CLASS("table table-condensed") { @@ -908,9 +941,24 @@ public: } } TABLEBODY() { + TABLER() { + TABLED() { + str << "Passed/Total, sec"; + } + TABLED() { + str << (TAppData::TimeProvider->Now() - TestStartTime).Seconds() << " / "; + if (TestDuration.Defined()) { + str << TestDuration->Seconds(); + } else { + str << "-"; + } + } + } for (auto& writer : TabletWriters) { - str << "<tr><td colspan=\"2\">" << "<b>Tablet</b>" << "</td></tr>"; - writer.DumpState(str); + TABLER() { + str << "<td colspan=\"2\">" << "<b>Tablet</b>" << "</td>"; + } + writer.DumpState(str, finalResult); } } } @@ -918,7 +966,12 @@ public: str << "<pre>" << ConfingString << "</pre>"; } } - ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(str.Str(), ev->Get()->SubRequestId)); + return str.Str(); + } + + void Handle(NMon::TEvHttpInfo::TPtr& ev, const TActorContext& ctx) { + TString html = RenderHTML(false); + ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(html, ev->Get()->SubRequestId)); } void Handle(TEvents::TEvUndelivered::TPtr ev, const TActorContext& /*ctx*/) { |