10 Commits

Author SHA1 Message Date
Riccardo Pittau
d5d62c8dbf Use unittest mock from standard library
Drop the third party mock library to use unittest mock from
standard library.

Change-Id: Ib64b661572e4869a24865c02a6c84a6603930394
2020-04-06 14:35:50 +02:00
Sam Betts
b536fbba61 [LLDP] Skip NICs that say they are ready but are unreadable.
While listening for LLDP packets, if one of the sockets marks itself as
ready to read then our code will try to read data from that socket, but
if something goes wrong while reading that data then it causes IPA to
raise out of the loop skipping any other of the other NICs which might
have worked. This patch adds code to catch and LOG any exception that is
raised while we are trying to read data from one of the sockets so that
we can proceed to process all the NICs.

Change-Id: I8546097f5ae23755a5fdb448902007a2d823b7bf
Closes-Bug: #1665025
2017-11-28 17:25:43 +00:00
Julian Edwards
f57cbccf8b Prevent tests' unmocked access to utils.execute()
This change introduces a new base test class that mocks out
utils.execute and forces an exception if it gets called.
This has rooted out many tests that were doing this as a side effect of
calling other functions, doing things like modprobe and running iscsi
on the host's actual machine.

The tests are all now appropriately patched in places where this was
happening, and the new base class permanently prevents this from
accidentally happening again.

If you really want to call utils.execute() then you need to re-mock it
in your unit test.

Change-Id: Idf87d09a9c01a6bfe2767f8becabe65c02983518
2017-05-15 10:48:43 +10:00
John L. Villalovos
1695cb18c2 Add missing 'autospec' argument to mock.patch
Add missing 'autospec' keyword argument to mock.patch and
mock.patch.object calls. Use 'autospec=True' except for a few cases
where it fails because the mocked function is a @classmethod and it
doesn't work. In that case explicity set it to 'autospec=False'

Change-Id: I620dce91abaa4440e1803aeefb3e93c0b65d1419
2017-03-19 10:04:19 -07:00
Derek Higgins
9f5f664080 Advertise the correct address when using IPv6
Parse the output of "ip route get $IP" taking
IPv6 into consideration. Also wrap the IP address
in square brackets if it is IPv6.

Change-Id: Ifc44e5aa3c5b814b6ceba04461bb68fe1d75c22b
Closes-Bug: #1650533
2017-01-11 11:00:56 +00:00
John L. Villalovos
13c9350699 Clarify test comment to minimize confusion
Wording was a little confusing. Try to make it more clear.

Change-Id: Iad280314bf4929b18b1493bd7e9a26fc58297ee1
2016-11-09 14:59:30 -08:00
Dmitry Tantsur
b864a8c566 Fix several errors in LLDP handling code
* Stop silencing exceptions in raw socket context manager
* Correctly handle receiving packages with odd size and too small ones
* Fix a unit test that was testing nothing due to bad mocking

Change-Id: Ic8626d10618f52d50667d2698f34a92f5dcac33e
Closes-Bug: #1640238
2016-11-09 15:02:54 +01:00
Robert Li
9e4b769055 Build socket list right before select call
This will make sure the socket list and the interface list are
always in sync, and the select call is on the right list of
sockets.

Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Closes-Bug: #1533892
Change-Id: Id6710f4648203b7d476a2a16ea647224baca1bb9
2016-08-17 16:35:07 +02:00
Sam Betts
95e1e4e35a Consolidate IPA configuration into a config module
This patch moves the IPA oslo configs out of the agent cmd into their
own module so that it is safe to import them from other places in the
application without causing circular imports.

Change-Id: I100792bd0d1f369763afaa6f93e144e9967c3048
2016-05-31 15:24:23 +01:00
Josh Gachnang
fb2790774d Add base for IPA functional tests
Starts up an agent in a thread and then runs functional tests against
it.

Add the first functional test of the API: a simple test of the
commands API.

Co-Authored-By: Mario Villaplana <mario.villaplana@gmail.com>
Change-Id: If4ad611929d388a2a9454224646cb296bd0ba0ce
2015-08-18 16:19:47 +00:00