Closed HeriLFIU closed 4 months ago
@viniarck I don't know if this is necessarily what I had to do, but the e2e tests can now also detect the bug, so they have increased coverage.
I just rewrote the 4 unit tests into e2e tests, so I don't know if that is fine for this case.
@viniarck I just removed it and replaced it with datetime.utcnow()
@viniarck I just removed it and replaced it with datetime.utcnow()
Much appreciated.
@HeriLFIU, the new tests cases are failing though, can you double check if the link id you used is correct?
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------------------------------- start/stop times -------------------------------
rerun: 0
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering: 2024-02-29,17:44:31.646229 - 2024-02-29,17:44:55.036919
self = <tests.test_e2e_50_maintenance.TestE2EMaintenance object at 0x7f3d0a8804f0>
def test_125_multiple_payload_item_filtering(self):
self.net.start_controller(clean_config=True, enable_all=True)
self.net.wait_switches_connect()
time.sleep(10)
start = datetime.now(pytz.utc) + timedelta(days=1)
end = start + timedelta(hours=2)
payload = {
"start": start.strftime(TIME_FMT),
"end": end.strftime(TIME_FMT),
"switches": ["00:00:00:00:00:00:00:02", "00:00:00:00:00:00:00:03"],
"interfaces": ["00:00:00:00:00:00:00:03:3", "00:00:00:00:00:00:00:02:1"],
"links": [
"cf0f4071be[426](https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/jobs/59329#L426)b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260",
"4d42dc0852278accac7d9df15418f6d921db160b13d674029a87cef1b5f67f30",
],
}
api_url = KYTOS_API + '/maintenance/v1'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
data = response.json()
> assert response.status_code == 201, data
E AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
E assert 400 == 201
E + where 400 = <Response [400]>.status_code
tests/test_e2e_50_maintenance.py:1248: AssertionError
rerun: 1
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering: 2024-02-29,17:44:55.393942 - 2024-02-29,17:45:30.252966
self = <tests.test_e2e_50_maintenance.TestE2EMaintenance object at 0x7f3d0a8804f0>
def test_125_multiple_payload_item_filtering(self):
self.net.start_controller(clean_config=True, enable_all=True)
self.net.wait_switches_connect()
time.sleep(10)
start = datetime.now(pytz.utc) + timedelta(days=1)
end = start + timedelta(hours=2)
payload = {
"start": start.strftime(TIME_FMT),
"end": end.strftime(TIME_FMT),
"switches": ["00:00:00:00:00:00:00:02", "00:00:00:00:00:00:00:03"],
"interfaces": ["00:00:00:00:00:00:00:03:3", "00:00:00:00:00:00:00:02:1"],
"links": [
"cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260",
"4d42dc0852278accac7d9df15418f6d921db160b13d674029a87cef1b5f67f30",
],
}
api_url = KYTOS_API + '/maintenance/v1'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
data = response.json()
> assert response.status_code == 201, data
E AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
E assert 400 == 201
E + where 400 = <Response [400]>.status_code
tests/test_e2e_50_maintenance.py:1248: AssertionError
rerun: 0
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering: 2024-02-29,17:47:05.767004 - 2024-02-29,17:47:40.052241
self = <tests.test_e2e_50_maintenance.TestE2EMaintenance object at 0x7f3d0a880100>
def test_140_link_payload_filtering(self):
self.net.start_controller(clean_config=True, enable_all=True)
self.net.wait_switches_connect()
time.sleep(10)
start = datetime.now(pytz.utc) + timedelta(days=1)
end = start + timedelta(hours=2)
payload = {
"start": start.strftime(TIME_FMT),
"end": end.strftime(TIME_FMT),
"links": [
"cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260",
],
}
api_url = KYTOS_API + '/maintenance/v1'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
data = response.json()
> assert response.status_code == 201, data
E AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
E assert 400 == 201
E + where 400 = <Response [400]>.status_code
tests/test_e2e_50_maintenance.py:1341: AssertionError
rerun: 1
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering: 2024-02-29,17:48:28.200069 - 2024-02-29,17:48:52.695713
self = <tests.test_e2e_50_maintenance.TestE2EMaintenance object at 0x7f3d0a880100>
def test_140_link_payload_filtering(self):
self.net.start_controller(clean_config=True, enable_all=True)
self.net.wait_switches_connect()
time.sleep(10)
start = datetime.now(pytz.utc) + timedelta(days=1)
end = start + timedelta(hours=2)
payload = {
"start": start.strftime(TIME_FMT),
"end": end.strftime(TIME_FMT),
"links": [
"cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260",
],
}
api_url = KYTOS_API + '/maintenance/v1'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
data = response.json()
> assert response.status_code == 201, data
E AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f745027f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
E assert 400 == 201
E + where 400 = <Response [400]>.status_code
tests/test_e2e_50_maintenance.py:1341: AssertionError
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering: 2024-02-29,17:45:30.[436](https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/jobs/59329#L436)958 - 2024-02-29,17:46:05.720633
tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering: 2024-02-29,17:49:41.767493 - 2024-02-29,17:50:06.348797
=========================== rerun test summary info ============================
RERUN tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering
RERUN tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering
RERUN tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering
RERUN tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering
=========================== short test summary info ============================
FAILED tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering - AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f7[450](https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/jobs/59329#L450)27f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
assert 400 == 201
+ where 400 = <Response [400]>.status_code
FAILED tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering - AssertionError: {'code': 400, 'description': "Window contains non-existant items: {'switches': [], 'interfaces': [], 'links': ['cf0f4071be426b3f74[502](https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/jobs/59329#L502)7f5d22bc61f8312ae86293c9b28e7e66015607a9260']}"}
assert 400 == 201
+ where 400 = <Response [400]>.status_code
= 2 failed, 235 passed, 8 skipped, 9 xfailed, 7 xpassed, 1211 warnings, 4 rerun in 13[523](https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/jobs/59329#L523).79s (3:45:23) =
@viniarck Should be fixed. Mb, I hadn't run the local tests with the bug fix implemented to make sure everything was running properly. For some reason the topology generated during the tests have different link IDs from the topologys generated locally.
(kn) root@heriberto-VirtualBox:/home/heriberto/kytos-project/kytos-end-to-end-tests# python3 -m pytest tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_140_link_payload_filtering
======================================================================== test session starts ========================================================================
platform linux -- Python 3.9.18, pytest-7.2.1, pluggy-1.3.0
rootdir: /home/heriberto/kytos-project/kytos-end-to-end-tests
plugins: timeout-2.2.0, asyncio-0.20.3, cov-4.0.0, anyio-3.6.2, rerunfailures-13.0
asyncio: mode=strict
collected 1 item
tests/test_e2e_50_maintenance.py . [100%]
========================================================================= warnings summary ==========================================================================
tests/test_e2e_50_maintenance.py: 17 warnings
/home/heriberto/kytos-project/kn/lib/python3.9/site-packages/mininet/node.py:1106: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
return ( StrictVersion( cls.OVSVersion ) <
tests/test_e2e_50_maintenance.py: 17 warnings
/home/heriberto/kytos-project/kn/lib/python3.9/site-packages/mininet/node.py:1107: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
StrictVersion( '1.10' ) )
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------------------------------------------------------------------------- start/stop times --------------------------------------------------------------------------
================================================================== 1 passed, 34 warnings in 51.62s ==================================================================
Test 125 is also now passing.
(kn) root@heriberto-VirtualBox:/home/heriberto/kytos-project/kytos-end-to-end-tests# python3 -m pytest tests/test_e2e_50_maintenance.py::TestE2EMaintenance::test_125_multiple_payload_item_filtering
======================================================================== test session starts ========================================================================
platform linux -- Python 3.9.18, pytest-7.2.1, pluggy-1.3.0
rootdir: /home/heriberto/kytos-project/kytos-end-to-end-tests
plugins: timeout-2.2.0, asyncio-0.20.3, cov-4.0.0, anyio-3.6.2, rerunfailures-13.0
asyncio: mode=strict
collected 1 item
tests/test_e2e_50_maintenance.py . [100%]
========================================================================= warnings summary ==========================================================================
tests/test_e2e_50_maintenance.py: 17 warnings
/home/heriberto/kytos-project/kn/lib/python3.9/site-packages/mininet/node.py:1106: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
return ( StrictVersion( cls.OVSVersion ) <
tests/test_e2e_50_maintenance.py: 17 warnings
/home/heriberto/kytos-project/kn/lib/python3.9/site-packages/mininet/node.py:1107: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
StrictVersion( '1.10' ) )
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------------------------------------------------------------------------- start/stop times --------------------------------------------------------------------------
================================================================== 1 passed, 34 warnings in 51.74s ==================================================================
Cool. Let's ship this @HeriLFIU, nicely done.
Summary
There was an issue with the filtering of interfaces in maintenance that was not caught by the unit tests nor the e2e tests. With these new added tests similar issues/bugs should be caught by the e2e tests as well.
Local Tests
I just rewrote the unit test code so that it worked as an e2e test.
End-to-End Tests
The new test seems to function properly and detects the previous bug.