Closed NoUmlautsAllowed closed 3 years ago
I can (somewhat) reproduce this issue, it is a problem with keep_alive
mode it seems. The problem is that the order of machine instance teardown is not reflecting dependencies between instances. Essentially, we're just tearing down in the order of requests right now.
The proper solution is to find a way to perform teardown in an order where any dependencies are dealt with after their dependents. I'll have to experiment a bit to see which method is the most robust one for doing this. I will post an update here once I have a solution available.
BTW, instead of doing
with tbot.Context(keep_alive=True, reset_on_error_by_default=True) as ctx:
if os.environ.get('CI') == 'true':
ctx.register(tbot.selectable.LocalLabHost, [tbot.role.LabHost])
else:
my_remote_lab.register_machines(ctx)
you can use add_defaults
which is probably more elegant and future proof:
with tbot.Context(keep_alive=True, reset_on_error_by_default=True, add_defaults=True) as ctx:
if os.environ.get('CI') != 'true':
my_remote_lab.register_machines(ctx)
I commented on the #59. The changes introduced with c488841c37d089df6a0455fe559b032a1e1e6daa fix the problem for me.
BTW, instead of doing
with tbot.Context(keep_alive=True, reset_on_error_by_default=True) as ctx: if os.environ.get('CI') == 'true': ctx.register(tbot.selectable.LocalLabHost, [tbot.role.LabHost]) else: my_remote_lab.register_machines(ctx)
you can use
add_defaults
which is probably more elegant and future proof:with tbot.Context(keep_alive=True, reset_on_error_by_default=True, add_defaults=True) as ctx: if os.environ.get('CI') != 'true': my_remote_lab.register_machines(ctx)
Thanks for the suggestion with the defaults :)
Hi,
I am using tbot together with pytest. I recently experienced some strange behavior in tbot when it comes to requesting roles from the
tbot.Context
.The
tbot.Context
is configured inconftest.py
with the following settings:Since I am running the tests in a Gitlab Pipeline, I use the environment variable
CI
to determine, if the local host should be used asLabHost
or if I need to connect to a remote lab. This is done intbot_context()
.When writing tests, I noticed different behavior if I was running the tests in the CI pipeline (i.e. using the local host as
LabHost
) and on my development machine using theSSHConnector
to connect to the same machine used for the tests in the CI pipeline.So I tracked down the problem with the following two tests where I request either the
LabHost
or theBoardLinux
first:I can run the tests with these commands directly on the lab host:
The
test_lnx_first.py
works fine, with thetest_lh_first.py
I get the following error:When I run the tests from my development machine and use the
SSHConnector
to connect to theLabHost
I can run thetest_lh_first.py
test without any errors.So I wonder if the order in which roles are requested from the context matter when the teardown of the tests is executed and the roles are de-initialized.
My current workaround is to request the
BoardLinux
role first and theLabHost
afterwards, but this means I have to wait until the board is powered up before I can use theLabHost
which can be impractical in some cases where configuration needs to be done on theLabHost
before the board is requested and powered up.Am I missing something here so tbot should be used in a different way like I do?
Best regards NoU