1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
# coding: utf-8
import re
RESTART_TEST_INDICATOR = '##restart-test##'
INFRASTRUCTURE_ERROR_INDICATOR = '##infrastructure-error##'
RESTART_TEST_INDICATORS = [
RESTART_TEST_INDICATOR,
"network error",
]
UID_PREFIX_DELIMITER = '-'
# testing
BIN_DIRECTORY = 'bin'
CANON_DATA_DIR_NAME = "canondata"
CANON_RESULT_FILE_NAME = "result.json"
CANONIZATION_RESULT_FILE_NAME = "canonization_res.json"
COMMON_CONTEXT_FILE_NAME = "common_test.context"
CONSOLE_SNIPPET_LIMIT = 5000
FAKE_OUTPUT_EXTS = frozenset([".mf", ".fake", ".cpf", ".cpsf"])
LIST_NODE_LOG_FILE = "test_list.log"
LIST_NODE_RESULT_FILE = "test_list.json"
LIST_RESULT_NODE_LOG_FILE = "list_result.log"
LIST_TRACE_FILE_NAME = "ytest_list.report.trace"
MAX_FILE_SIZE = 1024 * 1024 * 2 # 2 MB
MAX_TEST_RESTART_COUNT = 3
NO_LISTED_TESTS = "NO_LISTED_TESTS"
REPORT_SNIPPET_LIMIT = 12000
SANITIZER_ERROR_RC = 100
SUITE_CONTEXT_FILE_NAME = "test.context"
TEST_LIST_FILE = "test_names_list.json"
TEST_SUBTEST_SEPARATOR = '::'
TESTING_OUT_DIR_NAME = "testing_out_stuff"
TESTING_OUT_RAM_DRIVE_DIR_NAME = "ram_drive_output"
TESTING_OUT_TAR_NAME = TESTING_OUT_DIR_NAME + ".tar.zstd"
TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
TRACE_FILE_NAME = "ytest.report.trace"
TRUNCATING_IGNORE_FILE_LIST = {TRACE_FILE_NAME, SUITE_CONTEXT_FILE_NAME, "run_test.log"}
YT_RUN_TEST_DIR_NAME = "yt_run_test"
YT_RUN_TEST_TAR_NAME = "yt_run_test.tar"
COVERAGE_CFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping", "-DCLANG_COVERAGE"]
COVERAGE_LDFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping"]
CANON_BACKEND_KEY = "{canondata_backend}"
DEFAULT_CANONIZATION_BACKEND = "storage.yandex-team.ru/get-devtools"
MDS_URI_PREFIX = 'https://storage.yandex-team.ru/get-devtools/'
BACKEND_URI_PREFIX = 'https://' + CANON_BACKEND_KEY + '/'
MDS_SCHEME = 'mds'
CANON_MDS_RESOURCE_REGEX = re.compile(re.escape(MDS_URI_PREFIX) + r'(.*?)($|#)')
CANON_BACKEND_RESOURCE_REGEX = re.compile(re.escape(BACKEND_URI_PREFIX) + r'(.*?)($|#)')
CANON_SBR_RESOURCE_REGEX = re.compile(r'(sbr:/?/?(\d+))')
MANDATORY_ENV_VAR_NAME = 'YA_MANDATORY_ENV_VARS'
BUILD_FLAGS_ALLOWED_IN_CONTEXT = {
'AUTOCHECK',
# Required for local test runs
'TESTS_REQUESTED',
'USE_ARCADIA_PYTHON',
'USE_SYSTEM_PYTHON',
}
STYLE_TEST_TYPES = [
"classpath.clash",
"clang_tidy",
"eslint",
"gofmt",
"govet",
"java.style",
"ktlint",
"py2_flake8",
"py3_flake8",
"black",
]
REGULAR_TEST_TYPES = [
"benchmark",
"boost_test",
"exectest",
"fuzz",
"g_benchmark",
"go_bench",
"go_test",
"gtest",
"hermione",
"java",
"jest",
"py2test",
"py3test",
"pytest",
"unittest",
]
TEST_NODE_OUTPUT_RESULTS = [TESTING_OUT_TAR_NAME, YT_RUN_TEST_TAR_NAME]
# kvm
DEFAULT_RAM_REQUIREMENTS_FOR_KVM = 4
MAX_RAM_REQUIREMENTS_FOR_KVM = 16
# distbuild
DISTBUILD_STATUS_REPORT_ENV_NAME = 'NODE_EXTENDED_STATUS_FILE_PATH'
DEFAULT_TEST_NODE_TIMEOUT = 15 * 60
TEST_NODE_FINISHING_TIME = 5 * 60
# coverage
COVERAGE_FUNCTION_ENTRIES_LIMIT = 2
COVERAGE_PYTHON_EXTS = (".py", ".pyx", ".pxi", ".pxd")
COVERAGE_RESOLVED_FILE_NAME_PATTERN = "coverage_resolved.{}.json"
CPP_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("cpp")
GO_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("go")
JAVA_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("java")
NLG_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("nlg")
PYTHON2_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py2")
PYTHON3_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py3")
TS_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("ts")
COVERAGE_CLANG_ENV_NAME = 'LLVM_PROFILE_FILE'
COVERAGE_GCOV_ENV_NAME = 'GCOV_PREFIX'
COVERAGE_GO_ENV_NAME = 'GO_COVERAGE_PREFIX'
COVERAGE_PYTHON_ENV_NAME = 'PYTHON_COVERAGE_PREFIX'
COVERAGE_TS_ENV_NAME = 'TS_COVERAGE_PREFIX'
COVERAGE_NLG_ENV_NAME = 'NLG_COVERAGE_FILENAME'
COVERAGE_ENV_VARS = (
COVERAGE_CLANG_ENV_NAME,
COVERAGE_GCOV_ENV_NAME,
COVERAGE_GO_ENV_NAME,
COVERAGE_NLG_ENV_NAME,
COVERAGE_PYTHON_ENV_NAME,
COVERAGE_TS_ENV_NAME,
)
PYTHON_COVERAGE_PREFIX_FILTER_ENV_NAME = 'PYTHON_COVERAGE_PREFIX_FILTER'
PYTHON_COVERAGE_EXCLUDE_REGEXP_ENV_NAME = 'PYTHON_COVERAGE_EXCLUDE_REGEXP'
CLANG_COVERAGE_TEST_TYPES = (
"boost_test",
"coverage_extractor",
"exectest",
"gtest",
# java tests might use shared libraries
"java",
"py2test",
"py3test",
"pytest",
"unittest",
)
COVERAGE_TABLE_CHUNKS = 20
COVERAGE_TESTS_TIMEOUT_FACTOR = 1.5
COVERAGE_YT_PROXY = "hahn.yt.yandex.net"
COVERAGE_YT_ROOT_PATH = "//home/codecoverage"
COVERAGE_YT_TABLE_PREFIX = "datatable"
# fuzzing
CORPUS_DATA_FILE_NAME = 'corpus.json'
CORPUS_DATA_ROOT_DIR = 'fuzzing'
CORPUS_DIR_NAME = 'corpus'
FUZZING_COVERAGE_ARGS = ['--sanitize-coverage=trace-div,trace-gep']
FUZZING_COMPRESSION_COEF = 1.1
FUZZING_DEFAULT_TIMEOUT = 3600
FUZZING_FINISHING_TIME = 600
FUZZING_TIMEOUT_RE = re.compile(r'(^|\s)-max_total_time=(?P<max_time>\d+)')
GENERATED_CORPUS_DIR_NAME = 'mined_corpus'
MAX_CORPUS_RESOURCES_ALLOWED = 5
# hermione
HERMIONE_REPORT_DIR_NAME = "hermione-report"
HERMIONE_REPORT_TAR_NAME = HERMIONE_REPORT_DIR_NAME + ".tar"
HERMIONE_REPORT_INDEX_FILE_NAME = "index.html"
HERMIONE_REPORT_DB_URLS_FILE_NAME = "databaseUrls.json"
HERMIONE_TESTS_READ_FILE_NAME = "tests.json"
HERMIONE_TESTS_READ_STDOUT_FILE_NAME = "read_tests.out"
HERMIONE_TESTS_READ_STDERR_FILE_NAME = "read_tests.err"
HERMIONE_TESTS_RUN_FILE_NAME = "test_results.jsonl"
HERMIONE_TESTS_RUN_STDOUT_FILE_NAME = "run_tests.out"
HERMIONE_TESTS_RUN_STDERR_FILE_NAME = "run_tests.err"
# yt
YT_OPERATION_ID_SUBSTITUTION = '$OPERATION_ID'
YT_SANDBOX_ROOT_PREFIX = '$(YT_SANDBOX_ROOT)'
# sandbox
SANDBOX_RUN_TEST_YT_TOKEN_VALUE_NAME = 'YA_MAKE_SANDBOX_RUN_TEST_YT_TOKEN'
# global resources
ANDROID_AVD_ROOT = 'ANDROID_AVD_RESOURCE_GLOBAL'
ANDROID_SDK_ROOT = 'ANDROID_SDK_RESOURCE_GLOBAL'
COVERAGE_PUSH_TOOL_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL'
COVERAGE_PUSH_TOOL_RESOURCE = 'COVERAGE_PUSH_TOOL_RESOURCE_GLOBAL'
COVERAGE_PUSH_TOOL_LB_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL_LB'
COVERAGE_PUSH_TOOL_LB_RESOURCE = 'COVERAGE_PUSH_TOOL_LB_RESOURCE_GLOBAL'
FLAKE8_PY2_RESOURCE = 'FLAKE8_PY2_RESOURCE_GLOBAL'
FLAKE8_PY3_RESOURCE = 'FLAKE8_PY3_RESOURCE_GLOBAL'
GO_TOOLS_RESOURCE = 'GO_TOOLS_RESOURCE_GLOBAL'
JSTYLE_RUNNER_LIB = 'JSTYLE_LIB_RESOURCE_GLOBAL'
NODEJS_RESOURCE = 'NODEJS_RESOURCE_GLOBAL'
NYC_RESOURCE = 'NYC_RESOURCE_GLOBAL'
TEST_TOOL3_HOST = 'TEST_TOOL3_HOST_RESOURCE_GLOBAL'
TEST_TOOL3_HOST_LOCAL = 'TEST_TOOL3_HOST_LOCAL'
TEST_TOOL_HOST = 'TEST_TOOL_HOST_RESOURCE_GLOBAL'
TEST_TOOL_HOST_LOCAL = 'TEST_TOOL_HOST_LOCAL'
TEST_TOOL_TARGET = 'TEST_TOOL_TARGET_RESOURCE_GLOBAL'
TEST_TOOL_TARGET_LOCAL = 'TEST_TOOL_TARGET_LOCAL'
XCODE_TOOLS_RESOURCE = 'XCODE_TOOLS_ROOT_RESOURCE_GLOBAL'
WINE_TOOL = 'WINE_TOOL_RESOURCE_GLOBAL'
WINE32_TOOL = 'WINE32_TOOL_RESOURCE_GLOBAL'
class Enum(object):
@classmethod
def enumerate(cls):
return [v for k, v in cls.__dict__.items() if not k.startswith("_")]
class TestRequirements(Enum):
Container = 'container'
Cpu = 'cpu'
DiskUsage = 'disk_usage'
Dns = 'dns'
Kvm = 'kvm'
Network = 'network'
Ram = 'ram'
RamDisk = 'ram_disk'
SbVault = 'sb_vault'
YavSecret = 'yav'
class TestRequirementsConstants(Enum):
All = 'all'
AllCpuValue = 50
AllRamDiskValue = 50
MinCpu = 1
MinRam = 1
MinRamDisk = 0
@classmethod
def is_all_cpu(cls, value):
return value == cls.All
@classmethod
def get_cpu_value(cls, value):
return cls.AllCpuValue if cls.is_all_cpu(value) else value
@classmethod
def is_all_ram_disk(cls, value):
return value == cls.All
@classmethod
def get_ram_disk_value(cls, value):
return cls.AllRamDiskValue if cls.is_all_ram_disk(value) else value
class TestSize(Enum):
Small = 'small'
Medium = 'medium'
Large = 'large'
DefaultTimeouts = {
Small: 60,
Medium: 600,
Large: 3600,
}
DefaultPriorities = {
Small: -1,
Medium: -2,
Large: -3,
}
DefaultRequirements = {
Small: {
TestRequirements.Cpu: 1,
TestRequirements.Ram: 8,
# TestRequirements.Ram: 2,
TestRequirements.RamDisk: 0,
},
Medium: {
TestRequirements.Cpu: 1,
TestRequirements.Ram: 8,
# TestRequirements.Ram: 4,
TestRequirements.RamDisk: 0,
},
Large: {
TestRequirements.Cpu: 1,
TestRequirements.Ram: 8,
# TestRequirements.Ram: 8,
TestRequirements.RamDisk: 0,
},
}
MaxRequirements = {
Small: {
TestRequirements.Cpu: 4,
TestRequirements.Ram: 32,
# TestRequirements.Ram: 4,
TestRequirements.RamDisk: 32,
},
Medium: {
TestRequirements.Cpu: 4,
# TestRequirements.Cpu: 8,
TestRequirements.Ram: 32,
# TestRequirements.Ram: 16,
TestRequirements.RamDisk: 32,
},
Large: {
TestRequirements.Cpu: 4,
TestRequirements.Ram: 32,
TestRequirements.RamDisk: 32,
},
}
LargeMarker = "TL"
MediumMarker = "TM"
SmallMarker = "TS"
SizeMarkers = (LargeMarker, MediumMarker, SmallMarker)
SizeShorthandMap = {
Large: LargeMarker,
Medium: MediumMarker,
Small: SmallMarker,
}
@classmethod
def sizes(cls):
return cls.DefaultTimeouts.keys()
@classmethod
def get_shorthand(cls, size):
return cls.SizeShorthandMap[size]
@classmethod
def is_test_shorthand(cls, name):
return name in cls.SizeMarkers
@classmethod
def get_default_timeout(cls, size):
if size in cls.DefaultTimeouts:
return cls.DefaultTimeouts[size]
raise Exception("Unknown test size '{}'".format(size))
@classmethod
def get_default_priorities(cls, size):
if size in cls.DefaultPriorities:
return cls.DefaultPriorities[size]
raise Exception("Unknown test size '{}'".format(size))
@classmethod
def get_default_requirements(cls, size):
if size in cls.DefaultRequirements:
return cls.DefaultRequirements[size]
raise Exception("Unknown test size '{}'".format(size))
@classmethod
def get_max_requirements(cls, size):
if size in cls.MaxRequirements:
return cls.MaxRequirements[size]
raise Exception("Unknown test size '{}'".format(size))
class TestRunExitCode(Enum):
Skipped = 2
Failed = 3
TimeOut = 10
InfrastructureError = 12
class YaTestTags(Enum):
AlwaysMinimize = "ya:always_minimize"
Dirty = "ya:dirty"
DumpNodeEnvironment = "ya:dump_node_env"
DumpTestEnvironment = "ya:dump_test_env"
ExoticPlatform = "ya:exotic_platform"
External = "ya:external"
Fat = "ya:fat"
ForceDistbuild = "ya:force_distbuild"
ForceSandbox = "ya:force_sandbox"
GoNoSubtestReport = "ya:go_no_subtest_report"
GoTotalReport = "ya:go_total_report"
HugeLogs = "ya:huge_logs"
Manual = "ya:manual"
MapRootUser = "ya:map_root_user"
NoFuse = "ya:nofuse"
NoGracefulShutdown = "ya:no_graceful_shutdown"
Norestart = "ya:norestart"
Noretries = "ya:noretries"
NotAutocheck = "ya:not_autocheck"
Notags = "ya:notags"
PerfTest = "ya:perftest"
Privileged = "ya:privileged"
ReportChunks = "ya:report_chunks"
RunWithAsserts = "ya:relwithdebinfo"
SandboxCoverage = "ya:sandbox_coverage"
SequentialRun = "ya:sequential_run"
TraceOutput = "ya:trace_output"
YtRunner = "ya:yt"
CopyData = "ya:copydata"
CopyDataRO = "ya:copydataro"
class ServiceTags(Enum):
AnyTag = "ya:anytag"
class Status(object):
GOOD, XFAIL, FAIL, XPASS, MISSING, CRASHED, TIMEOUT = range(1, 8)
SKIPPED = -100
NOT_LAUNCHED = -200
CANON_DIFF = -300
DESELECTED = -400
INTERNAL = -int(2**31 - 1) # maxint
FLAKY = -50
# XFAILDIFF is internal status and should be replaced
# with XFAIL or XPASS during verification stage of canon data
XFAILDIFF = -90
BY_NAME = {
'crashed': CRASHED,
'deselected': DESELECTED,
'diff': CANON_DIFF,
'fail': FAIL,
'flaky': FLAKY,
'good': GOOD,
'internal': INTERNAL,
'missing': MISSING,
'not_launched': NOT_LAUNCHED,
'skipped': SKIPPED,
'timeout': TIMEOUT,
'xfail': XFAIL,
'xfaildiff': XFAILDIFF,
'xpass': XPASS,
}
TO_STR = {
CANON_DIFF: 'diff',
CRASHED: 'crashed',
DESELECTED: 'deselected',
FAIL: 'fail',
FLAKY: 'flaky',
GOOD: 'good',
INTERNAL: 'internal',
MISSING: 'missing',
NOT_LAUNCHED: 'not_launched',
SKIPPED: 'skipped',
TIMEOUT: 'timeout',
XFAIL: 'xfail',
XFAILDIFF: 'xfaildiff',
XPASS: 'xpass',
}
class _Colors(object):
_NAMES = [
"blue",
"cyan",
"default",
"green",
"grey",
"magenta",
"red",
"white",
"yellow",
]
_PREFIXES = ["", "light", "dark"]
def __init__(self):
self._table = {}
for prefix in self._PREFIXES:
for value in self._NAMES:
name = value
if prefix:
name = "{}_{}".format(prefix, value)
value = "{}-{}".format(prefix, value)
self.__add_color(name.upper(), value)
def __add_color(self, name, value):
self._table[name] = value
self.__setattr__(name, value)
Colors = _Colors()
class _Highlight(object):
_MARKERS = {
# special
"RESET": "rst",
"IMPORTANT": "imp",
"UNIMPORTANT": "unimp",
"BAD": "bad",
"WARNING": "warn",
"GOOD": "good",
"PATH": "path",
"ALTERNATIVE1": "alt1",
"ALTERNATIVE2": "alt2",
"ALTERNATIVE3": "alt3",
}
def __init__(self):
# setting attributes because __getattr__ is much slower
for attr, value in self._MARKERS.items():
self.__setattr__(attr, value)
Highlight = _Highlight()
class _StatusColorMap(object):
# There should be no XFAILDIFF, because it's internal status.
# It should be replaced with XFAIL or XPASS during verification of canon data.
_MAP = {
'crashed': Highlight.WARNING,
'deselected': Highlight.UNIMPORTANT,
'diff': Highlight.BAD,
'fail': Highlight.BAD,
'flaky': Highlight.ALTERNATIVE3,
'good': Highlight.GOOD,
'internal': Highlight.BAD,
'missing': Highlight.ALTERNATIVE1,
'not_launched': Highlight.BAD,
'skipped': Highlight.UNIMPORTANT,
'timeout': Highlight.BAD,
'xfail': Highlight.WARNING,
'xpass': Highlight.WARNING,
}
def __getitem__(self, item):
return self._MAP[item]
StatusColorMap = _StatusColorMap()
|