Skip to content

Commit

Permalink
[Disk Manager] internal/pkg/tasks should not depend on cloud/disk_man…
Browse files Browse the repository at this point in the history
…ager/test/recipe (#142)
  • Loading branch information
SvartMetal authored Jan 14, 2024
1 parent 297b541 commit c1d748b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from library.python.testing.recipe import declare_recipe, set_env

from cloud.disk_manager.internal.pkg.tasks.acceptance_tests.recipe.node_launcher import NodeLauncher
Expand All @@ -12,9 +10,8 @@ def start(argv):
nodes = []
for i in range(0, NODES_COUNT):
nodes.append(NodeLauncher(
"localhost{}".format(i),
os.getenv("DISK_MANAGER_RECIPE_YDB_PORT"),
i
hostname="node{}".format(i),
idx=i
))
nodes[-1].start()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
HangingTaskTimeout: "100s"
>
PersistenceConfig: <
Endpoint: "localhost:{kikimr_port}"
Database: "/Root"
RootPath: "disk_manager/tasks/acceptance_tests/recipe"
Endpoint: "{ydb_endpoint}"
Database: "{ydb_database}"
RootPath: "tasks"
>
LoggingConfig: <
LoggingStderr: <>
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(self, config_file, working_dir):

class NodeLauncher:

def __init__(self, hostname, kikimr_port, idx):
def __init__(self, hostname, idx):
self.__idx = idx

working_dir = get_unique_path_for_current_test(
Expand All @@ -77,7 +77,8 @@ def __init__(self, hostname, kikimr_port, idx):

self.__config_string = DEFAULT_CONFIG_TEMPLATE.format(
hostname=hostname,
kikimr_port=kikimr_port,
ydb_endpoint=os.getenv("YDB_ENDPOINT"),
ydb_database=os.getenv("YDB_DATABASE")
)
with open(config_file, "w") as f:
f.write(self.__config_string)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GO_TEST()

SET(RECIPE_ARGS --ydb-only)
INCLUDE(${ARCADIA_ROOT}/cloud/disk_manager/test/recipe/recipe.inc)
INCLUDE(${ARCADIA_ROOT}/contrib/ydb/public/tools/ydb_recipe/recipe.inc)

INCLUDE(${ARCADIA_ROOT}/cloud/disk_manager/internal/pkg/tasks/acceptance_tests/recipe/recipe.inc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ func newContext() context.Context {
}

func newYDB(ctx context.Context) (*persistence.YDBClient, error) {
endpoint := fmt.Sprintf(
"localhost:%v",
os.Getenv("DISK_MANAGER_RECIPE_YDB_PORT"),
)
database := "/Root"
rootPath := "disk_manager"
endpoint := os.Getenv("YDB_ENDPOINT")
database := os.Getenv("YDB_DATABASE")
rootPath := "tasks"

return persistence.NewYDBClient(
ctx,
Expand Down
3 changes: 1 addition & 2 deletions cloud/disk_manager/internal/pkg/tasks/storage/tests/ya.make
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GO_TEST_FOR(cloud/disk_manager/internal/pkg/tasks/storage)

SET_APPEND(RECIPE_ARGS --ydb-only)
INCLUDE(${ARCADIA_ROOT}/cloud/disk_manager/test/recipe/recipe.inc)
INCLUDE(${ARCADIA_ROOT}/contrib/ydb/public/tools/ydb_recipe/recipe.inc)

IF (RACE)
SIZE(LARGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ func newContext() context.Context {
}

func newYDB(ctx context.Context) (*persistence.YDBClient, error) {
endpoint := fmt.Sprintf(
"localhost:%v",
os.Getenv("DISK_MANAGER_RECIPE_YDB_PORT"),
)
database := "/Root"
rootPath := "disk_manager"
endpoint := os.Getenv("YDB_ENDPOINT")
database := os.Getenv("YDB_DATABASE")
rootPath := "tasks"

return persistence.NewYDBClient(
ctx,
Expand Down
3 changes: 1 addition & 2 deletions cloud/disk_manager/internal/pkg/tasks/tasks_tests/ya.make
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GO_TEST()

SET(RECIPE_ARGS --ydb-only)
INCLUDE(${ARCADIA_ROOT}/cloud/disk_manager/test/recipe/recipe.inc)
INCLUDE(${ARCADIA_ROOT}/contrib/ydb/public/tools/ydb_recipe/recipe.inc)

GO_XTEST_SRCS(
tasks_test.go
Expand Down
7 changes: 4 additions & 3 deletions cloud/disk_manager/test/common/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def kill_processes(service_name: str):
pids_file_name = _get_pids_file_name(service_name)
if not os.path.exists(pids_file_name):
return

with open(pids_file_name) as f:
for s in f.readlines():
pid_and_command = s.split()
Expand All @@ -44,13 +45,13 @@ def kill_processes(service_name: str):
try:
os.kill(pid, signal.SIGTERM)
except OSError as e:
logger.debug("Manual recover core dump for %d '%s'", pid,
logger.debug("Manual recovery of core dump for %d '%s'", pid,
command)
process = _BareProcess(command, pid)
execution = _Execution(command, process, None, None)
execution.verify_no_coredumps()
raise e


def _get_pids_file_name(process_name: str):
return "disk_manager_recipe_%s.pids" % process_name
def _get_pids_file_name(service_name: str):
return "disk_manager_recipe_%s.pids" % service_name

0 comments on commit c1d748b

Please sign in to comment.