-
Notifications
You must be signed in to change notification settings - Fork 48
Description
How to reproduce
python3 -m acto --config data/percona-server-mongodb-operator/config.json --learn
It will crash with this log message:
CRITICAL, MainThread, error_handler.py:55, An exception occured: <class 'TypeError'>: Argument `schema` of function <function stateful_set_update_strategy_tests at 0x7f553ed792d0> got type <class 'acto.schema.object.ObjectSchema'> but expected type <class 'acto.schema.string.StringSchema'>.
Causes
-
For this operator,
updateStrategy
is a string (not an object like in the native schema). -
At this stage of Acto code:
acto/acto/input/test_generators/generator.py
Lines 241 to 246 in 92fb7c3
# sort by priority generator_candidates.sort(key=lambda x: x.priority, reverse=True) if len(generator_candidates) > 0: test_cases.append( (schema.path, generator_candidates[0].func(schema)), ) generator_candidates
in fact has two elements: one is the exact match forupdateStrategy
; the second is for typeString
. But Acto only uses the first candidate with the highest priority and fails type check later here.
Possible solutions
The quoted code snippet seems to have certain design that allows a few alternative generators (e.g. it sorts the whole candidate list instead of directly picking up the max or min) but ends up with trying only one. Maybe we can add some try
-except
statement there.
To work around it in my 523 homework, I used the following
if len(generator_candidates) > 0:
if (schema.path == ['spec', 'updateStrategy']):
test_cases.append(
(schema.path, generator_candidates[1].func(schema)),
)
else:
test_cases.append(
(schema.path, generator_candidates[0].func(schema)),
)