Skip to content

What is the way to go if you expect the connection to devices in the testbed file to fail? #233

Description

@JanisFalkenhagenWork

Hey there,

i am currently developing some tests for my company's infrastructure and because it's a pretty much constantly changing network, failed connects are expected and do not indicate wrong behaviour.

If i then use a testbed which contains all devices, the typical testbed.connect() and further usage of the devices inside of that testbed fails.
See the example below for a quick demo.

[...]
class CommonSetup(aetest.CommonSetup):
    @aetest.subsection
    def connect_to_devs(self, testbed):
        testbed.connect() 
# Here a log message is written to the cli containing the traceback of an internal exception that happens when connection to the device. It 
#is NOT propagated to this context. Otherwise, i could remove the device dynamically from the testbed. It looks like the remaining 
#connections still don't get established. See also Issue #226.

class Testcase(aetest.Testcase):
    @aetest.setup
    def setup(self, testbed):
        self.results = testbed.parse("<sh something>")

# Now when i run this, i get an error:
#3299:  Caught an exception while executing section setup:
#3300:  Traceback (most recent call last):
#3301:    File "TESTSDIR/TEST_SCRIPT_NAME", line LineNo, in setup
#3302:      self.results = testbed.parse(f"<sh something>")
#3303:                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
#3304:    File "src/pyats/topology/testbed.py", line 816, in pyats.topology.testbed.Testbed.parse
#3305:   TypeError: 'NoneType' object is not iterable

    @aetest.test
    def test(self):
        [...]

Is there a way for me to have the testbed.parse command only operate on devices, that have been connected?
Is there a way to force connect to all devices, even though there are some devices that can't be connected to atm?
Is there a way for me to see if a device inside the testbed isn't connected successfully, so i can remove it dynamically?

Is this just bad test design on my part?

I'm looking forward to your answers and thank you for your time. :D

Have a nice day
Janis

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions