Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
maximyurchuk committed Jan 10, 2025
1 parent 68b1397 commit d7b36e1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
8 changes: 8 additions & 0 deletions ydb/library/workload/kv/kv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ TVector<TRow> TKvWorkloadGenerator::GenerateRandomRows(bool randomValues) {
}

void TKvWorkloadParams::ConfigureOpts(NLastGetopt::TOpts& opts, const ECommandType commandType, int workloadType) {
opts.AddLongOption('p', "path", "Path where benchmark tables are located")
.Optional()
.DefaultValue(TableName)
.Handler1T<TStringBuf>([this](TStringBuf arg) {
while(arg.SkipPrefix("/"));
while(arg.ChopSuffix("/"));
TableName = arg;
});
switch (commandType) {
case TWorkloadParams::ECommandType::Init:
opts.AddLongOption("init-upserts", "count of upserts need to create while table initialization")
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/workload/kv/kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TKvWorkloadParams : public TWorkloadParams {
ui64 MixedDoReadRows = KvWorkloadConstants::MIXED_DO_READ_ROWS;
ui64 MixedDoSelect = KvWorkloadConstants::MIXED_DO_SELECT;

const std::string TableName = "kv_test";
std::string TableName = "kv_test";

bool StaleRO = KvWorkloadConstants::STALE_RO;
YDB_READONLY(EStoreType, StoreType, EStoreType::Row);
Expand Down
83 changes: 43 additions & 40 deletions ydb/tests/workloads/kv/tests/test_workload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import os

import pytest

import yatest

from ydb.tests.library.harness.kikimr_runner import KiKiMR
Expand All @@ -13,48 +15,49 @@ class TestYdbKvWorkload(object):
def setup_class(cls):
cls.cluster = KiKiMR(KikimrConfigGenerator(erasure=Erasure.MIRROR_3_DC))
cls.cluster.start()
cls.init_command_prefix = [
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
"--verbose",
"--endpoint", "grpc://localhost:%d" % cls.cluster.nodes[1].grpc_port,
"--database=/Root",
"workload", "kv", "init",
"--min-partitions", "1",
"--partition-size", "10",
"--auto-partition", "0",
"--init-upserts", "0",
"--cols", "5",
"--int-cols", "2",
"--key-cols", "3",
]

cls.run_command_prefix = [
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
"--verbose",
"--endpoint", "grpc://localhost:%d" % cls.cluster.nodes[1].grpc_port,
"--database=/Root",
"workload", "kv", "run", "mixed",
"--seconds", "100",
"--threads", "10",
"--cols", "5",
"--len", "200",
"--int-cols", "2",
"--key-cols", "3"
]

@classmethod
def teardown_class(cls):
cls.cluster.stop()

def test(self):
yatest.common.execute(
[
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
"--verbose",
"--endpoint", "grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
"--database=/Root",

"workload", "kv", "init",

"--min-partitions", "1",
"--partition-size", "10",
"--auto-partition", "0",
"--init-upserts", "0",
"--cols", "5",
"--int-cols", "2",
"--key-cols", "3",
"--store", "column",
],
wait=True
)

yatest.common.execute(
[
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
"--verbose",
"--endpoint", "grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
"--database=/Root",

"workload", "kv", "run", "mixed",
"--seconds", "100",
"--threads", "10",

"--cols", "5",
"--len", "200",
"--int-cols", "2",
"--key-cols", "3"
],
wait=True
)
@pytest.mark.parametrize("store_type", ["row", "column"])
def test(self, store_type):
init_command = self.init_command_prefix
init_command.extend([
"--path", store_type,
"--store", store_type,
])
run_command = self.run_command_prefix
run_command.extend([
"--path", store_type,
])
yatest.common.execute(init_command, wait=True)
yatest.common.execute(run_command, wait=True)

0 comments on commit d7b36e1

Please sign in to comment.