Skip to content

Commit

Permalink
Remove yatest_common from ydb (#10964)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximyurchuk authored Oct 27, 2024
1 parent 74e259f commit e0f8bdc
Show file tree
Hide file tree
Showing 53 changed files with 359 additions and 313 deletions.
9 changes: 4 additions & 5 deletions ydb/library/yaml_config/ut_transform/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
import yatest
import pytest
from ydb.tests.library.common import yatest_common

import json
import logging
Expand All @@ -15,7 +14,7 @@

def bin_from_env(name):
if os.getenv(name):
return yatest_common.binary_path(os.getenv(name))
return yatest.common.binary_path(os.getenv(name))
raise RuntimeError(f'{name} enviroment variable is not specified')


Expand All @@ -35,7 +34,7 @@ class TestYamlConfigTransformations(object):
@classmethod
def execute(cls, binary, stdin=None, args=[]):
try:
execution = yatest_common.execute(
execution = yatest.common.execute(
[binary] + args,
stdin=stdin,
)
Expand All @@ -50,7 +49,7 @@ def canonical_result(output_result, filename, out_path):
result_path = os.path.join(out_path, result_filename)
with open(result_path, "w") as f:
f.write(output_result)
return yatest_common.canonical_file(str(result_path), diff_tool=json_diff_bin(), local=True, universal_lines=True)
return yatest.common.canonical_file(str(result_path), diff_tool=json_diff_bin(), local=True, universal_lines=True)

def cleanup_errors(self, errors):
return re.sub(r'address -> 0x[a-zA-Z0-9]+', 'address -> REDACTED', errors)
Expand All @@ -65,7 +64,7 @@ def execute_test(self, data, binary, args=[]):
success, result = self.execute(stdin=f, binary=binary, args=args)
if not success:
result = json.dumps({"error": True, "stderr": self.cleanup_errors(result)})
results[entry.name] = self.canonical_result(result, entry.name, yatest_common.output_path())
results[entry.name] = self.canonical_result(result, entry.name, yatest.common.output_path())
return [results[key] for key in sorted(results.keys(), reverse=True)]

@pytest.mark.parametrize('binary', [('dump', dump_bin()), ('dump_ds_init', dump_ds_init_bin())], ids=lambda binary: binary[0])
Expand Down
13 changes: 7 additions & 6 deletions ydb/public/tools/lib/cmds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import sys
from six.moves.urllib.parse import urlparse

import yatest

from ydb.library.yql.providers.common.proto.gateways_config_pb2 import TGenericConnectorConfig
from ydb.tests.library.common import yatest_common
from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
from ydb.tests.library.common.types import Erasure
Expand Down Expand Up @@ -56,15 +57,15 @@ def parse_erasure(args):


def driver_path_packages(package_path):
return yatest_common.build_path(
return yatest.commmon.build_path(
"{}/Berkanavt/kikimr/bin/kikimr".format(
package_path
)
)


def udfs_path_packages(package_path):
return yatest_common.build_path(
return yatest.commmon.build_path(
"{}/Berkanavt/kikimr/libs".format(
package_path
)
Expand Down Expand Up @@ -93,7 +94,7 @@ def write_file(args, suffix, content):
write_file_flushed(os.path.join(args.ydb_working_dir, suffix), content)
return

write_file_flushed(os.path.join(yatest_common.output_path(suffix)), content)
write_file_flushed(os.path.join(yatest.common.output_path(suffix)), content)

try:
write_file_flushed(suffix, content)
Expand All @@ -106,7 +107,7 @@ def read_file(args, suffix):
with open(os.path.join(args.ydb_working_dir, suffix), 'r') as fd:
return fd.read()

with open(os.path.join(yatest_common.output_path(suffix)), 'r') as fd:
with open(os.path.join(yatest.common.output_path(suffix)), 'r') as fd:
return fd.read()


Expand Down Expand Up @@ -222,7 +223,7 @@ def generate_data_path(self):
if self.arguments.ydb_working_dir:
self.data_path = self.arguments.ydb_working_dir
return self.data_path
self.data_path = yatest_common.output_path(self.data_path_template % random_string())
self.data_path = yatest.common.output_path(self.data_path_template % random_string())
return ensure_path_exists(self.data_path)


Expand Down
13 changes: 7 additions & 6 deletions ydb/tests/acceptance/test_slice.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import sys

import yatest

import ydb
from ydb.tests.library.common import yatest_common
from ydb.tests.library.harness.ydbd_slice import YdbdSlice


Expand All @@ -13,8 +14,8 @@ class TestWithSlice(object):
@classmethod
def setup_class(cls):
cls.cluster = YdbdSlice(
config_path=yatest_common.source_path(os.environ["YDB_CLUSTER_YAML"]),
binary_path=yatest_common.binary_path(os.environ["YDB_DRIVER_BINARY"])
config_path=yatest.common.source_path(os.environ["YDB_CLUSTER_YAML"]),
binary_path=yatest.common.binary_path(os.environ["YDB_DRIVER_BINARY"])
)
cls.cluster.start()

Expand Down Expand Up @@ -42,12 +43,12 @@ def test_slice_sample(self):
)

def test_serializable(self):
yatest_common.execute(
yatest.common.execute(
[
yatest_common.binary_path('ydb/tests/tools/ydb_serializable/ydb_serializable'),
yatest.common.binary_path('ydb/tests/tools/ydb_serializable/ydb_serializable'),
'--endpoint=%s:%d' % (self.cluster.nodes[1].host, self.cluster.nodes[1].grpc_port),
'--database=%s' % self.cluster.db_path,
'--output-path=%s' % yatest_common.output_path(),
'--output-path=%s' % yatest.common.output_path(),
'--iterations=25',
'--processes=1'
],
Expand Down
6 changes: 3 additions & 3 deletions ydb/tests/fq/mem_alloc/test_alloc_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import six
import time

from ydb.tests.library.common.helpers import plain_or_under_sanitizer
from ydb.tests.tools.datastreams_helpers.test_yds_base import TestYdsBase
import ydb.tests.library.common.yatest_common as yatest_common
from ydb.tests.tools.fq_runner.fq_client import FederatedQueryClient
from ydb.tests.tools.fq_runner.kikimr_runner import StreamingOverKikimr
from ydb.tests.tools.fq_runner.kikimr_runner import StreamingOverKikimrConfig
Expand Down Expand Up @@ -54,8 +54,8 @@ def kikimr(request):

def wait_until(
predicate,
wait_time=yatest_common.plain_or_under_sanitizer(10, 50),
wait_step=yatest_common.plain_or_under_sanitizer(0.5, 2),
wait_time=plain_or_under_sanitizer(10, 50),
wait_step=plain_or_under_sanitizer(0.5, 2),
):
deadline = time.time() + wait_time
while time.time() < deadline:
Expand Down
8 changes: 4 additions & 4 deletions ydb/tests/fq/mem_alloc/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import time

import ydb.tests.library.common.yatest_common as yatest_common
from ydb.tests.library.common.helpers import plain_or_under_sanitizer
from ydb.tests.tools.fq_runner.fq_client import FederatedQueryClient
from ydb.tests.tools.fq_runner.kikimr_runner import StreamingOverKikimr
from ydb.tests.tools.fq_runner.kikimr_runner import StreamingOverKikimrConfig
Expand All @@ -18,8 +18,8 @@
G = 1024 * 1024 * 1024
DEFAULT_LIMIT = 8 * G
DEFAULT_DELTA = 30 * M
DEFAULT_WAIT_TIME = yatest_common.plain_or_under_sanitizer(10, 50)
LONG_WAIT_TIME = yatest_common.plain_or_under_sanitizer(60, 300)
DEFAULT_WAIT_TIME = plain_or_under_sanitizer(10, 50)
LONG_WAIT_TIME = plain_or_under_sanitizer(60, 300)


@pytest.fixture
Expand All @@ -37,7 +37,7 @@ def kikimr(request):
kikimr.stop()


def wait_until(predicate, wait_time=DEFAULT_WAIT_TIME, wait_step=yatest_common.plain_or_under_sanitizer(0.5, 2)):
def wait_until(predicate, wait_time=DEFAULT_WAIT_TIME, wait_step=plain_or_under_sanitizer(0.5, 2)):
deadline = time.time() + wait_time
while time.time() < deadline:
if predicate():
Expand Down
4 changes: 2 additions & 2 deletions ydb/tests/fq/restarts/test_insert_restarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import ydb.public.api.protos.draft.fq_pb2 as fq

import ydb.tests.library.common.yatest_common as yatest_common
from ydb.tests.library.common.helpers import plain_or_under_sanitizer
from ydb.tests.tools.fq_runner.kikimr_utils import yq_all


Expand Down Expand Up @@ -71,7 +71,7 @@ def test_atomic_upload_commit(self, kikimr, s3, client):
query_id = client.create_query("simple", sql, type=fq.QueryContent.QueryType.ANALYTICS).result.query_id

# Checking insert query
timeout = yatest_common.plain_or_under_sanitizer(250, 250 * 5)
timeout = plain_or_under_sanitizer(250, 250 * 5)
start = time.time()
deadline = start + timeout
while True:
Expand Down
4 changes: 2 additions & 2 deletions ydb/tests/fq/s3/s3_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import dataclass
import boto3

import ydb.tests.library.common.yatest_common as yatest_common
import yatest


@dataclass
Expand All @@ -20,4 +20,4 @@ def create_bucket_and_upload_file(filename, s3_url, bucket_name, base_path):
bucket.objects.all().delete()

s3_client = boto3.client("s3", endpoint_url=s3_url, aws_access_key_id="key", aws_secret_access_key="secret_key")
s3_client.upload_file(yatest_common.source_path("{}/{}".format(base_path, filename)), bucket_name, filename)
s3_client.upload_file(yatest.common.source_path("{}/{}".format(base_path, filename)), bucket_name, filename)
Loading

0 comments on commit e0f8bdc

Please sign in to comment.