-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the way to go if you expect the connection to devices in the testbed file to fail? #233
Comments
Ahh and im on the current version: You are currently running pyATS version: 24.2 Package Version genie 24.2 |
Hello @JanisFalkenhagenWork , Kindly give some time. will check and update you. |
Hey, for now i used this workaround:
It makes the code less concise but seems to work. Also we modifiy the testbed in place, what might have sideeffects for other scripts, as i dont think that they are cloned for each testscript. I am still curious about your solution or recommended/endorsed way of solving this problem. Have a nice day. :D |
Hi, thanks for the info. Kindly give me some time to check on this with my team. |
Hi, the |
I disagree. The connect does not fail on my machine at least. As i've written above, it prints a log message but does not throw an error. This means that the setup step would not fail, the subsequent tests would thus be executed. However, you are right that the connect stops any further execution. So even if i somehow catch the device that is not connectable, any devices afterwards are not connected, meaning, those tests would unneccessarily fail. Also i am sorry but this does not really answer my question because i asked on how i would handle this issue, if i expect devices not to be connectable. From what i am understanding from your answer, i would guess that i cannot use the testbed.connect() shortcut. But what would be the standard way of doing the connection then if i wanted to implement it by the book? Or is this case just not covered because it usually points to a critically failing network anyways? And yeah issue #226 is closed and tbh i don't recall why i mentioned it. I think because it complains about Exceptions being thrown which are not anymore. Maybe the fix mentioned in that issue by @SohanTirpude was to remove the exceptions being propagated to the user, i.e. the testscript, which now makes my life more difficult. Thanks for the response. |
Hi, Kindly try with updated pyats as issue #226 is resolved and in this, @SohanTirpude did not removes the exceptions but only showing exceptions for devices which are unable to connect and for other devices are able to connect. So, kindly try. |
Hi, thanks for your answer. I'll try as soon as i get to it. My timetable is pretty full though atm. So please give me some time to test this out. The device.is_connected() method is a good hint though. Thank you. Have a nice rest of your week |
But just out of curiosity? Why is the device.is_connected() method not listed here? https://pubhub.devnetcloud.com/media/pyats/docs/topology/concept.html |
Hello Janis, Thanks for your update, take your time to try this. Once you did, kindly update the status. |
Hello Janis, Kindly let us know the update on this issue. |
Hi, i am currently on vacation. Please give me some more time to test this and let me come back to you then. Thank you in advance. |
Hello , Kindly let us know, when you will come back from vacation. |
Hello @JanisFalkenhagenWork , Is any update on this issue, kindly let us know. |
Hey, i just tried it on the newest version available to me. This is the output of the
The same behaviour as i described above is still happening: I created a testbed containing three devices:
Then i used the following code to check my hypothethis:
This then prints the following to the console:
This looks like an exception but it is not an exception that is propagated to the user context, i.e., my context. This is only printed to an output stream.
As expected this scripts prints the stuff from the script above plus the last string. We can therefore conclude that the tb.connect() does NOT throw an exception. This means, that we cannot recognize from the user code if specific devices have failed to connect without iterating over them once again. This effectively makes the Additionally, the execution of the connect function just halts, as soon, as one device is encountered that is not connectable, increasing the negative impact of this behaviour. This means that simply removing not connected devices from the testbed via the That is why i asked, if this is by design and if there is a workaround that does not lead to reimplementing the tb.connect() function. The latter obviously works, as i demonstrated here:
I hope this clarifies my problem and shows that i tested it thoroughly enough as you requested. :) Have a nice day |
Hello @JanisFalkenhagenWork , Can you let me know, how many devices are in yaml and which one is not connectable second device of third device. Is that same thing happened in internal aswell. |
as i wrote above the testbed contains three devices. The first and third (when read from the top) are reachable and connectable via ssh The second device is not present in the network, the connection thus times out:
All devices are cisco Catalyst 2960L. Do i understand you correctly that the I am not sure what you mean by
Also the meaning of this sentence is not clear to me. Could you please elaborate on those two?
|
Ok, i tested again. I used the same testbed as above with the following code:
As you can see, the device which is not present is not removed. Also contrary to what i saw in my last tests, this time the third device is connected. This, i did not expect, so i tested with two of our large production testbeds again. It did also not show the behaviour where the connection establishment is aborted once one device fails. I am not sure what changed since then but this means, that the This means that stable test operation would require this code for each connect, as long as one cannot gurantee that all devices are reachabel, right?
But if this is practically required for each testcase, why not implement it in the Also it would be very much bad practice if the testbed object passed to me in my testcase's setup method, was modified, i.e., if i removed not connected devices from it because all subsequent testcases would be handed the modified testbed. So the better solution would be to have the And my main question remains: Is this just bad test design on my part, i.e., should testbeds only contain devices that are guranteed to connect successfully? |
Hello @JanisFalkenhagenWork , If devices are not connectable, OR You can set empty list, and add devices in that list if devices are connectable
|
Hello @JanisFalkenhagenWork , |
Hello, your code example is simply copied from my answer. It does not do what your caption says it does. You still didn't answer the question i have: Are testbeds containing devices that are not connectable bad style/bad practice? Also i find it a bit rude to change your previous answers after the fact without marking changes. |
Hello , Yes, it is a bad practice but , if devices are not connectable you have to remove those devices in testbed or make sure those devices are reachable if not you have to do above code block.
I had forgot to mentioned you that previous change i made.
|
Ok. Thank you for the answer, I have no further questions. |
Thanks for confirmation. Will be closing this issue. Neeraja |
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.
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
The text was updated successfully, but these errors were encountered: