Skip to content

Commit 2008905

Browse files
committed
consistent mode: fix worker's vardir calculation
#330 describes a problem with searching a Lua module in the consistent mode: ``` ./test/test-run.py sql-tap/collation -j -1 ``` However, the same tests is working in the parallel mode with one worker process: ``` ./test/test-run.py sql-tap/collation -j 1 ``` First of all, the `sql-tap/collation` argument actually matches two tests: * `sql-tap/collation_unicode.test.lua` * `sql-tap/collation.test.lua` The latter is marked as fragile, while the former has no such mark. test-run places them in two different task groups, which are served by two different worker instances. However, the test suite object is shared between them. A worker's vardir is calculated as `suite's vardir + worker_name` and it is set back to the suite's vardir. This code is written in assumption that a test suite contains the main vardir before worker's initialization. This assumption works for the parallel mode, because of two facts: * The suite object is created with the main vardir as vardir. * The suite object is copied into a worker's process and so it is never changed twice. The latter property is not hold in the consistent mode. We create `001-sql-tap` worker for stable tests and then another `001-sql-tap` for fragile tests. And they're in the same process for the consistent mode. It results to worker's vardir like `/tmp/t/001-sql-tap/001-sql-tap`. However, the needed Lua module resides in `/tmp/t/001-sql-tap`. Let's just acquire the main vardir directly from arguments list. The problem was overlooked when a separate fragile test group was added. The consistent mode did assumption that one worker is created for one test suite, while it is not so anymore. This double initialization of the test suite's vardir is actually an effect of parallelization of test-run. A lot of code already exist before the parallelization was implemented and it was not carefully redesigned. Fixes #330
1 parent e19bb11 commit 2008905

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/worker.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,22 @@ def parse_reproduce_file(filepath):
4949
return reproduce
5050

5151

52+
def main_vardir():
53+
"""
54+
A 'var directory' term is used in two different meanings
55+
across test-run.
56+
57+
There is the --vardir option, VARDIR environment variable and
58+
/tmp/t default. Let's call this directory the 'main vardir'.
59+
60+
There are per worker subdirectories within the main vardir:
61+
'ddd-suite-name'. Let's call such a directory worker's vardir.
62+
"""
63+
return os.path.realpath(Options().args.vardir)
64+
65+
5266
def get_reproduce_file(worker_name):
53-
main_vardir = os.path.realpath(Options().args.vardir)
54-
reproduce_dir = os.path.join(main_vardir, 'reproduce')
67+
reproduce_dir = os.path.join(main_vardir(), 'reproduce')
5568
return os.path.join(reproduce_dir, '%s.list.yaml' % worker_name)
5669

5770

@@ -255,8 +268,7 @@ def __init__(self, suite, _id):
255268
self.suite = suite
256269
self.name = '%03d_%s' % (self.id, self.suite.suite_path)
257270

258-
main_vardir = self.suite.ini['vardir']
259-
self.suite.ini['vardir'] = os.path.join(main_vardir, self.name)
271+
self.suite.ini['vardir'] = os.path.join(main_vardir(), self.name)
260272

261273
self.reproduce_file = get_reproduce_file(self.name)
262274
safe_makedirs(os.path.dirname(self.reproduce_file))

0 commit comments

Comments
 (0)