aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarum <tarum@yandex-team.com>2023-04-19 14:55:51 +0300
committertarum <tarum@yandex-team.com>2023-04-19 14:55:51 +0300
commitbd27a4544747a6b44dfaa9e41b84239975db9b7e (patch)
tree913941d0e2c4e68bfaa357a08dff8d5570bd0dd3
parent887be65957040bac40fa22a2af242de88920eba7 (diff)
downloadydb-bd27a4544747a6b44dfaa9e41b84239975db9b7e.tar.gz
Add config examples for some loads
-rw-r--r--ydb/core/load_test/CMakeLists.darwin-x86_64.txt1
-rw-r--r--ydb/core/load_test/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/load_test/CMakeLists.linux-x86_64.txt1
-rw-r--r--ydb/core/load_test/CMakeLists.windows-x86_64.txt1
-rw-r--r--ydb/core/load_test/config_examples.cpp78
-rw-r--r--ydb/core/load_test/config_examples.h24
-rw-r--r--ydb/core/load_test/service_actor.cpp159
7 files changed, 214 insertions, 51 deletions
diff --git a/ydb/core/load_test/CMakeLists.darwin-x86_64.txt b/ydb/core/load_test/CMakeLists.darwin-x86_64.txt
index b41dbe0c5e..f562084407 100644
--- a/ydb/core/load_test/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/load_test/CMakeLists.darwin-x86_64.txt
@@ -38,6 +38,7 @@ target_link_libraries(ydb-core-load_test PUBLIC
target_sources(ydb-core-load_test PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/load_test/aggregated_result.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/archive.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/load_test/config_examples.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/keyvalue_write.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/kqp.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/memory.cpp
diff --git a/ydb/core/load_test/CMakeLists.linux-aarch64.txt b/ydb/core/load_test/CMakeLists.linux-aarch64.txt
index 7833843d8b..6fbf175edf 100644
--- a/ydb/core/load_test/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/load_test/CMakeLists.linux-aarch64.txt
@@ -39,6 +39,7 @@ target_link_libraries(ydb-core-load_test PUBLIC
target_sources(ydb-core-load_test PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/load_test/aggregated_result.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/archive.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/load_test/config_examples.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/keyvalue_write.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/kqp.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/memory.cpp
diff --git a/ydb/core/load_test/CMakeLists.linux-x86_64.txt b/ydb/core/load_test/CMakeLists.linux-x86_64.txt
index 7833843d8b..6fbf175edf 100644
--- a/ydb/core/load_test/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/load_test/CMakeLists.linux-x86_64.txt
@@ -39,6 +39,7 @@ target_link_libraries(ydb-core-load_test PUBLIC
target_sources(ydb-core-load_test PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/load_test/aggregated_result.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/archive.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/load_test/config_examples.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/keyvalue_write.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/kqp.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/memory.cpp
diff --git a/ydb/core/load_test/CMakeLists.windows-x86_64.txt b/ydb/core/load_test/CMakeLists.windows-x86_64.txt
index b41dbe0c5e..f562084407 100644
--- a/ydb/core/load_test/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/load_test/CMakeLists.windows-x86_64.txt
@@ -38,6 +38,7 @@ target_link_libraries(ydb-core-load_test PUBLIC
target_sources(ydb-core-load_test PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/load_test/aggregated_result.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/archive.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/load_test/config_examples.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/keyvalue_write.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/kqp.cpp
${CMAKE_SOURCE_DIR}/ydb/core/load_test/memory.cpp
diff --git a/ydb/core/load_test/config_examples.cpp b/ydb/core/load_test/config_examples.cpp
new file mode 100644
index 0000000000..8c501195dc
--- /dev/null
+++ b/ydb/core/load_test/config_examples.cpp
@@ -0,0 +1,78 @@
+#include "config_examples.h"
+
+#include <util/string/subst.h>
+
+namespace NKikimr {
+
+TVector<TConfigTemplate> BuildExamples() {
+ TVector<TConfigTemplate> result = {
+ TConfigTemplate{
+ .LoadName = "KqpLoad",
+ .Template = R"_(KqpLoad: {
+ DurationSeconds: 30
+ WindowDuration: 1
+ WorkingDir: "${TENANT_NAME}"
+ NumOfSessions: 64
+ UniformPartitionsCount: 1000
+ DeleteTableOnFinish: 1
+ WorkloadType: 0
+ Kv: {
+ InitRowCount: 1000
+ PartitionsByLoad: true
+ MaxFirstKey: 18446744073709551615
+ StringLen: 8
+ ColumnsCnt: 2
+ RowsCnt: 1
+ }
+})_"
+ },
+ TConfigTemplate{
+ .LoadName = "StorageLoad",
+ .Template = R"_(StorageLoad: {
+ DurationSeconds: 60
+ Tablets: {
+ Tablets: { TabletId: 5000 Channel: 0 GroupId: 2181038080 Generation: 1 }
+ WriteSizes: { Weight: 1.0 Min: 4096 Max: 4096}
+ WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 50000 MaxUs: 50000 } }
+ MaxInFlightWriteRequests: 1
+
+ ReadSizes: { Weight: 1.0 Min: 4096 Max: 4096 }
+ ReadIntervals: { Weight: 1.0 Uniform: { MinUs: 0 MaxUs: 0 } }
+ MaxInFlightReadRequests: 16
+ FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 10000000 MaxUs: 10000000 } }
+ PutHandleClass: TabletLog
+ GetHandleClass: FastRead
+ }
+})_"
+ },
+ TConfigTemplate{
+ .LoadName = "MemoryLoad",
+ .Template = R"_(MemoryLoad: {
+ DurationSeconds: 3600
+ BlockSize: 1048576
+ IntervalUs: 9000000
+})_"
+ }
+ };
+ return result;
+}
+
+TConstArrayRef<TConfigTemplate> GetConfigTemplates() {
+ static const TVector<TConfigTemplate> kExamples = BuildExamples();
+ return kExamples;
+}
+
+TConfigExample ApplyTemplateParams(const TConfigTemplate& templ, const TString& tenantName) {
+ TString text = templ.Template;
+ SubstGlobal(text, "${TENANT_NAME}", tenantName);
+ TString escaped = text;
+ SubstGlobal(escaped, "\"", "\\\"");
+ SubstGlobal(escaped, "\n", "\\n");
+ return TConfigExample {
+ .LoadName = templ.LoadName,
+ .Text = text,
+ .Escaped = escaped
+ };
+}
+
+} // namespace NKikimr
diff --git a/ydb/core/load_test/config_examples.h b/ydb/core/load_test/config_examples.h
new file mode 100644
index 0000000000..b923c1ad5f
--- /dev/null
+++ b/ydb/core/load_test/config_examples.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <util/generic/array_ref.h>
+#include <util/generic/string.h>
+#include <util/generic/vector.h>
+
+namespace NKikimr {
+
+struct TConfigExample {
+ TString LoadName;
+ TString Text;
+ TString Escaped;
+};
+
+struct TConfigTemplate {
+ TString LoadName;
+ TString Template;
+};
+
+TConstArrayRef<TConfigTemplate> GetConfigTemplates();
+
+TConfigExample ApplyTemplateParams(const TConfigTemplate& templ, const TString& tenantName);
+
+} // namespace NKikimr
diff --git a/ydb/core/load_test/service_actor.cpp b/ydb/core/load_test/service_actor.cpp
index d0cd2082de..a12a055776 100644
--- a/ydb/core/load_test/service_actor.cpp
+++ b/ydb/core/load_test/service_actor.cpp
@@ -2,6 +2,7 @@
#include "aggregated_result.h"
#include "archive.h"
+#include "config_examples.h"
#include "yql_single_query.h"
#include <ydb/core/base/appdata.h>
@@ -31,27 +32,6 @@ namespace NKikimr {
#define LOG_I(stream) LOG_INFO_S(*TlsActivationContext, NKikimrServices::BS_LOAD_TEST, stream)
#define LOG_D(stream) LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::BS_LOAD_TEST, stream)
-namespace NKqpConstants {
- const char* DEFAULT_PROTO = R"_(
-KqpLoad: {
- DurationSeconds: 30
- WindowDuration: 1
- WorkingDir: "%s"
- NumOfSessions: 64
- UniformPartitionsCount: 1000
- DeleteTableOnFinish: 1
- WorkloadType: 0
- Kv: {
- InitRowCount: 1000
- PartitionsByLoad: true
- MaxFirstKey: 18446744073709551615
- StringLen: 8
- ColumnsCnt: 2
- RowsCnt: 1
- }
-})_";
-}
-
namespace {
bool IsJsonContentType(const TString& acceptFormat) {
@@ -210,6 +190,8 @@ class TLoadActor : public TActorBootstrapped<TLoadActor> {
THashMap<ui32, TEvNodeFinishResponse> NodeResponses; // key is node id
};
+ TVector<TConfigExample> ConfigExamples;
+
// info about finished actors
TVector<TFinishedTestInfo> FinishedTests;
@@ -247,6 +229,16 @@ class TLoadActor : public TActorBootstrapped<TLoadActor> {
TVector<TAggregatedResult> ArchivedResults;
private:
+ TConstArrayRef<TConfigExample> GetConfigExamples() {
+ if (ConfigExamples.empty()) {
+ const TString tenantName = AppData()->TenantName;
+ for (const auto& templ : GetConfigTemplates()) {
+ ConfigExamples.push_back(ApplyTemplateParams(templ, tenantName));
+ }
+ }
+ return ConfigExamples;
+ }
+
ui64 GetTag(const TEvLoadTestRequest& origRequest, bool legacyRequest) {
if (legacyRequest) {
ui64 tag = ExtractTagFromCommand(origRequest);
@@ -1021,6 +1013,100 @@ public:
InfoRequests.erase(it);
}
+ void RenderStartForm(IOutputStream& str) {
+ str << R"___(
+ <script>
+ function updateStatus(new_class, new_text) {
+ let line = $("#start-status-line");
+ line.removeClass();
+ if (new_class) {
+ line.addClass(new_class);
+ }
+ line.text(new_text);
+ }
+ function sendStartRequest(button, run_all) {
+ updateStatus("", "Starting..");
+ $.ajax({
+ url: "",
+ data: {
+ mode: "start",
+ all_nodes: run_all,
+ config: $("#config").val()
+ },
+ method: "POST",
+ contentType: "application/x-protobuf-text",
+ success: function(result) {
+ if (result.status == "ok") {
+ updateStatus(
+ "text-success",
+ "Started: UUID# " + result.uuid + ", node tag# " + result.tag + ", status# " + result.status
+ );
+ } else {
+ updateStatus(
+ "text-danger",
+ "Status# " + result.status
+ );
+ }
+ }
+ });
+ })___";
+
+ str << "let kPresetConfigs=[";
+ bool first = true;
+ for (const auto& example : GetConfigExamples()) {
+ if (first) {
+ first = false;
+ } else {
+ str << ", ";
+ }
+ str << '"' << example.Escaped << '"';
+ }
+ str << "];";
+ str << R"___(
+ function loadConfigExample() {
+ let selectValue = $("#example-select").get(0).value;
+ let pos = Number(selectValue);
+ $("#config").val(kPresetConfigs[pos]);
+ }
+ </script>
+ )___";
+
+ HTML(str) {
+ FORM() {
+ DIV_CLASS("form-group") {
+ LABEL_CLASS_FOR("", "example-select") {
+ str << "Load example:";
+ }
+ str << "<select name='examples' id='example-select' onChange='loadConfigExample()'>\n";
+ ui32 pos = 0;
+ for (const auto& example : GetConfigExamples()) {
+ str << "<option value='" << ToString(pos) << "'>" << example.LoadName << "</option>\n";
+ ++pos;
+ }
+ str << "</select>\n";
+ }
+ DIV_CLASS("form-group") {
+ str << "<textarea id='config' name='config' rows='20' cols='50'>";
+ str << GetConfigExamples()[0].Text;
+ str << "</textarea>\n";
+ }
+ DIV_CLASS("form-group") {
+ str << "<button type='button' onClick='sendStartRequest(this, false)' name='startNewLoadOneNode' class='btn btn-default'>\n";
+ str << "Start new load on current node\n";
+ str << "</button>\n";
+ }
+ DIV_CLASS("form-group") {
+ str << "<button type='button' onClick='sendStartRequest(this, true)' name='startNewLoadAllNodes' class='btn btn-default'>\n";
+ str << "Start new load on all tenant nodes\n";
+ str << "</button>\n";
+ }
+ DIV_CLASS("form-group") {
+ str << "<p id='start-status-line'></p>";
+ }
+ }
+ }
+ }
+
void GenerateHttpInfoRes(const TString& mode, ui32 id) {
auto it = InfoRequests.find(id);
Y_VERIFY(it != InfoRequests.end());
@@ -1041,36 +1127,7 @@ public:
str << "<div>";
if (mode == "start") {
- str << R"___(
- <script>
- function sendStartRequest(button, run_all) {
- $.ajax({
- url: "",
- data: {
- mode: "start",
- all_nodes: run_all,
- config: $('#config').val()
- },
- method: "POST",
- contentType: "application/x-protobuf-text",
- success: function(result) {
- $(button).prop('disabled', true);
- $(button).text('started');
- $('#config').val('uuid: ' + result.uuid + ', tag: ' + result.tag + ', status: ' + result.status);
- }
- });
- }
- </script>
- )___";
- str << R"_(
- <textarea id="config" name="config" rows="20" cols="50">)_" << Sprintf(NKqpConstants::DEFAULT_PROTO, AppData()->TenantName.data())
- << R"_(
- </textarea>
- <br><br>
- <button onClick='sendStartRequest(this, false)' name='startNewLoadOneNode' class='btn btn-default'>Start new load on current node</button>
- <br>
- <button onClick='sendStartRequest(this, true)' name='startNewLoadAllNodes' class='btn btn-default'>Start new load on all tenant nodes</button>
- )_";
+ RenderStartForm(str);
} else if (mode == "stop") {
str << R"___(
<script>