for each item in the directory, and then do a product to generate
a result list with all combinations (A Product).
- For a directory with a magic '$' file, we generate a list of all
- items that we will randomly choose from.
+ For a directory with a magic '$' file, or for a directory whose name
+ ends in '$', we generate a list of all items that we will randomly
+ choose from.
The final description (after recursion) for each item will look
like a relative path. If there was a % product, that path
if submat is not None:
submats.append(submat)
return matrix.Concat(item, submats)
+ elif path.endswith('$') or '$' in files:
+ # pick a random item -- make sure we don't pick any magic files
+ if '$' in files:
+ files.remove('$')
+ if '%' in files:
+ files.remove('%')
+ submats = []
+ for fn in sorted(files):
+ submat = _build_matrix(
+ os.path.join(path, fn),
+ mincyclicity,
+ fn)
+ if submat is not None:
+ submats.append(submat)
+ return matrix.PickRandom(item, submats)
elif '%' in files:
# convolve items
files.remove('%')
(mincyclicity + mat.cyclicity() - 1) / mat.cyclicity(), mat
)
return mat
- elif '$' in files:
- # pick a random item
- files.remove('$')
- submats = []
- for fn in sorted(files):
- submat = _build_matrix(
- os.path.join(path, fn),
- mincyclicity,
- fn)
- if submat is not None:
- submats.append(submat)
- return matrix.PickRandom(item, submats)
else:
# list items
submats = []
},
},
}
- self.start_patchers(fake_fs)
- result = build_matrix.build_matrix('d0_0')
- assert len(result) == 1
+ fake_fs1 = {
+ 'd0_0$': {
+ 'd1_0': {
+ 'd1_0_0.yaml': None,
+ 'd1_0_1.yaml': None,
+ },
+ 'd1_1': {
+ 'd1_1_0.yaml': None,
+ 'd1_1_1.yaml': None,
+ },
+ 'd1_2': {
+ 'd1_2_0.yaml': None,
+ 'd1_2_1.yaml': None,
+ 'd1_2_2.yaml': None,
+ },
+ },
+ }
+ for info in [(fake_fs,'d0_0'), (fake_fs1,'d0_0$')]:
+ fsv = info[0]
+ dval = info[1]
+ self.start_patchers(fsv)
+ result = build_matrix.build_matrix(dval)
+ assert len(result) == 1
def test_random_dollar_sign_with_concat(self):
fake_fs = {
},
},
}
- self.start_patchers(fake_fs)
- result = build_matrix.build_matrix('d0_0')
- assert len(result) == 1
- if result[0][0][1:].startswith('d1_2'):
- for i in result:
- assert 'd0_0/d1_2/d1_2_0.yaml' in i[1]
- assert 'd0_0/d1_2/d1_2_1.yaml' in i[1]
- assert 'd0_0/d1_2/d1_2_2.yaml' in i[1]
- assert 'd0_0/d1_2/d1_2_3.yaml' in i[1]
+ fake_fs1 = {
+ 'd0_0$': {
+ 'd1_0': {
+ 'd1_0_0.yaml': None,
+ },
+ 'd1_1': {
+ 'd1_1_0.yaml': None,
+ 'd1_1_1.yaml': None,
+ },
+ 'd1_2': {
+ '+': None,
+ 'd1_2_0.yaml': None,
+ 'd1_2_1.yaml': None,
+ 'd1_2_2.yaml': None,
+ 'd1_2_3.yaml': None,
+ },
+ },
+ }
+ for info in [(fake_fs,'d0_0'), (fake_fs1,'d0_0$')]:
+ fsv = info[0]
+ dval = info[1]
+ self.start_patchers(fsv)
+ result = build_matrix.build_matrix(dval)
+ assert len(result) == 1
+ if result[0][0][1:].startswith('d1_2'):
+ for i in result:
+ assert 'd0_0/d1_2/d1_2_0.yaml' in i[1]
+ assert 'd0_0/d1_2/d1_2_1.yaml' in i[1]
+ assert 'd0_0/d1_2/d1_2_2.yaml' in i[1]
+ assert 'd0_0/d1_2/d1_2_3.yaml' in i[1]
def test_random_dollar_sign_with_convolve(self):
fake_fs = {
},
},
}
- self.start_patchers(fake_fs)
- result = build_matrix.build_matrix('d0_0')
- assert len(result) == 4
+ fake_fs1 = {
+ 'd0_0': {
+ '%': None,
+ 'd1_0': {
+ 'd1_0_0.yaml': None,
+ 'd1_0_1.yaml': None,
+ },
+ 'd1_1': {
+ 'd1_1_0.yaml': None,
+ 'd1_1_1.yaml': None,
+ },
+ 'd1_2$': {
+ 'd1_2_0.yaml': None,
+ 'd1_2_1.yaml': None,
+ 'd1_2_2.yaml': None,
+ },
+ },
+ }
+ for fsv in [fake_fs, fake_fs1]:
+ self.start_patchers(fsv)
+ result = build_matrix.build_matrix('d0_0')
+ assert len(result) == 4
def test_emulate_teuthology_noceph(self):
fake_fs = {