kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
2 stars 7 forks source link

Added in rate limited KytosEventBuffers #412

Closed Ktmi closed 5 months ago

Ktmi commented 9 months ago

Closes #245.

Summary

This patch implements a rate limited KytosEventBuffer through the usage of the limits package.

Local Tests

I was trying to test writing many flows to stored_flows, however, at the moment, I get a pymongo error on the flow_manager side of things. Otherwise, normal tasks like creating EVCs seem to work well.

kytos $> data = create_flows('00:00:00:00:00:00:00:01', 50)                                                                                                                                      

kytos $> ev = KytosEvent('kytos.flow_manager.flows.install', content=data)                                                                                                                       

kytos $> controller.buffers.app.put(ev)                                                                                                                                                          

kytos $> 2023-09-11 15:47:31,016 - ERROR [kytos.core.helpers] (thread_pool_app_4) listen_to handler: <function Main.on_flows_install_delete at 0x7fa4583e1900>, args: (<Main(flow_manager, stopped 140342502299200)>, KytosEvent('kytos.flow_manager.flows.install', {'flow_dict': {'flow': [{'priority': 1, 'cookie': 1, 'match': {'in_port': 1, 'dl_vlan': 1}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 2, 'cookie': 2, 'match': {'in_port': 1, 'dl_vlan': 2}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 3, 'cookie': 3, 'match': {'in_port': 1, 'dl_vlan': 3}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 4, 'cookie': 4, 'match': {'in_port': 1, 'dl_vlan': 4}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 5, 'cookie': 5, 'match': {'in_port': 1, 'dl_vlan': 5}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 6, 'cookie': 6, 'match': {'in_port': 1, 'dl_vlan': 6}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 7, 'cookie': 7, 'match': {'in_port': 1, 'dl_vlan': 7}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 8, 'cookie': 8, 'match': {'in_port': 1, 'dl_vlan': 8}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 9, 'cookie': 9, 'match': {'in_port': 1, 'dl_vlan': 9}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 10, 'cookie': 10, 'match': {'in_port': 1, 'dl_vlan': 10}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 11, 'cookie': 11, 'match': {'in_port': 1, 'dl_vlan': 11}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 12, 'cookie': 12, 'match': {'in_port': 1, 'dl_vlan': 12}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 13, 'cookie': 13, 'match': {'in_port': 1, 'dl_vlan': 13}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 14, 'cookie': 14, 'match': {'in_port': 1, 'dl_vlan': 14}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 15, 'cookie': 15, 'match': {'in_port': 1, 'dl_vlan': 15}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 16, 'cookie': 16, 'match': {'in_port': 1, 'dl_vlan': 16}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 17, 'cookie': 17, 'match': {'in_port': 1, 'dl_vlan': 17}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 18, 'cookie': 18, 'match': {'in_port': 1, 'dl_vlan': 18}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 19, 'cookie': 19, 'match': {'in_port': 1, 'dl_vlan': 19}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 20, 'cookie': 20, 'match': {'in_port': 1, 'dl_vlan': 20}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 21, 'cookie': 21, 'match': {'in_port': 1, 'dl_vlan': 21}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 22, 'cookie': 22, 'match': {'in_port': 1, 'dl_vlan': 22}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 23, 'cookie': 23, 'match': {'in_port': 1, 'dl_vlan': 23}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 24, 'cookie': 24, 'match': {'in_port': 1, 'dl_vlan': 24}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 25, 'cookie': 25, 'match': {'in_port': 1, 'dl_vlan': 25}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 26, 'cookie': 26, 'match': {'in_port': 1, 'dl_vlan': 26}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 27, 'cookie': 27, 'match': {'in_port': 1, 'dl_vlan': 27}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 28, 'cookie': 28, 'match': {'in_port': 1, 'dl_vlan': 28}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 29, 'cookie': 29, 'match': {'in_port': 1, 'dl_vlan': 29}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 30, 'cookie': 30, 'match': {'in_port': 1, 'dl_vlan': 30}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 31, 'cookie': 31, 'match': {'in_port': 1, 'dl_vlan': 31}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 32, 'cookie': 32, 'match': {'in_port': 1, 'dl_vlan': 32}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 33, 'cookie': 33, 'match': {'in_port': 1, 'dl_vlan': 33}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 34, 'cookie': 34, 'match': {'in_port': 1, 'dl_vlan': 34}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 35, 'cookie': 35, 'match': {'in_port': 1, 'dl_vlan': 35}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 36, 'cookie': 36, 'match': {'in_port': 1, 'dl_vlan': 36}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 37, 'cookie': 37, 'match': {'in_port': 1, 'dl_vlan': 37}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 38, 'cookie': 38, 'match': {'in_port': 1, 'dl_vlan': 38}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 39, 'cookie': 39, 'match': {'in_port': 1, 'dl_vlan': 39}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 40, 'cookie': 40, 'match': {'in_port': 1, 'dl_vlan': 40}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 41, 'cookie': 41, 'match': {'in_port': 1, 'dl_vlan': 41}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 42, 'cookie': 42, 'match': {'in_port': 1, 'dl_vlan': 42}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 43, 'cookie': 43, 'match': {'in_port': 1, 'dl_vlan': 43}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 44, 'cookie': 44, 'match': {'in_port': 1, 'dl_vlan': 44}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 45, 'cookie': 45, 'match': {'in_port': 1, 'dl_vlan': 45}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 46, 'cookie': 46, 'match': {'in_port': 1, 'dl_vlan': 46}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 47, 'cookie': 47, 'match': {'in_port': 1, 'dl_vlan': 47}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 48, 'cookie': 48, 'match': {'in_port': 1, 'dl_vlan': 48}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 49, 'cookie': 49, 'match': {'in_port': 1, 'dl_vlan': 49}, 'actions': [{'action_type': 'output', 'port': 2}]}, {'priority': 50, 'cookie': 50, 'match': {'in_port': 1, 'dl_vlan': 50}, 'actions': [{'action_type': 'output', 'port': 2}]}]}, 'dpid': '00:00:00:00:00:00:00:01', 'force': True}, 0)) traceback: Traceback (most recent call last):,   File "/home/ktmi/kytos-project3/kytos/kytos/core/helpers.py", line 143, in handler_context,     result = handler(*args),   File "/home/ktmi/kytos-project3/kenv/var/lib/kytos/napps/kytos/flow_manager/main.py", line 538, in on_flows_install_delete,     self.handle_flows_install_delete(event),   File "/home/ktmi/kytos-project3/kenv/var/lib/kytos/napps/kytos/flow_manager/main.py", line 588, in handle_flows_install_delete,     self._install_flows(,   File "/home/ktmi/kytos-project3/kenv/var/lib/kytos/napps/kytos/flow_manager/main.py", line 765, in _install_flows,     self.flow_controller.upsert_flows(,   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/tenacity-8.0.1-py3.10.egg/tenacity/__init__.py", line 324, in wrapped_f,     return self(f, *args, **kw),   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/tenacity-8.0.1-py3.10.egg/tenacity/__init__.py", line 404, in __call__,     do = self.iter(retry_state=retry_state),   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/tenacity-8.0.1-py3.10.egg/tenacity/__init__.py", line 349, in iter,     return fut.result(),   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result,     return self.__get_result(),   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result,     raise self._exception,   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/tenacity-8.0.1-py3.10.egg/tenacity/__init__.py", line 407, in __call__,     result = fn(*args, **kwargs),   File "/home/ktmi/kytos-project3/kytos/kytos/core/retry.py", line 25, in decorated,     return func(*args, **kwargs),   File "/home/ktmi/kytos-project3/kenv/var/lib/kytos/napps/../napps/kytos/flow_manager/controllers/__init__.py", line 98, in upsert_flows,     return self.db.flows.bulk_write(ops).upserted_ids,   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/pymongo-4.1.0-py3.10-linux-x86_64.egg/pymongo/collection.py", line 514, in bulk_write,     bulk_api_result = blk.execute(write_concern, session),   File "/home/ktmi/kytos-project3/kenv/lib/python3.10/site-packages/pymongo-4.1.0-py3.10-linux-x86_64.egg/pymongo/bulk.py", line 495, in execute,     raise InvalidOperation("No operations to execute"), pymongo.errors.InvalidOperation: No operations to execute, 

End-To-End Tests

The following are the end to end test results:

kytos-end-to-end-tests-kytos-1  | Starting enhanced syslogd: rsyslogd.
kytos-end-to-end-tests-kytos-1  | /etc/openvswitch/conf.db does not exist ... (warning).
kytos-end-to-end-tests-kytos-1  | Creating empty database /etc/openvswitch/conf.db.
kytos-end-to-end-tests-kytos-1  | Starting ovsdb-server.
kytos-end-to-end-tests-kytos-1  | Configuring Open vSwitch system IDs.
kytos-end-to-end-tests-kytos-1  | Starting ovs-vswitchd.
kytos-end-to-end-tests-kytos-1  | Enabling remote OVSDB managers.
kytos-end-to-end-tests-kytos-1  | + sed -i 's/STATS_INTERVAL = 60/STATS_INTERVAL = 7/g' /var/lib/kytos/napps/kytos/of_core/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/CONSISTENCY_MIN_VERDICT_INTERVAL =.*/CONSISTENCY_MIN_VERDICT_INTERVAL = 60/g' /var/lib/kytos/napps/kytos/flow_manager/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/LINK_UP_TIMER = 10/LINK_UP_TIMER = 1/g' /var/lib/kytos/napps/kytos/topology/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/DEPLOY_EVCS_INTERVAL = 60/DEPLOY_EVCS_INTERVAL = 5/g' /var/lib/kytos/napps/kytos/mef_eline/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/LLDP_LOOP_ACTIONS = \["log"\]/LLDP_LOOP_ACTIONS = \["disable","log"\]/' /var/lib/kytos/napps/kytos/of_lldp/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/LLDP_IGNORED_LOOPS = {}/LLDP_IGNORED_LOOPS = {"00:00:00:00:00:00:00:01": \[\[4, 5\]\]}/' /var/lib/kytos/napps/kytos/of_lldp/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/CONSISTENCY_COOKIE_IGNORED_RANGE =.*/CONSISTENCY_COOKIE_IGNORED_RANGE = [(0xdd00000000000000, 0xdd00000000000009)]/g' /var/lib/kytos/napps/kytos/flow_manager/settings.py
kytos-end-to-end-tests-kytos-1  | + sed -i 's/LIVENESS_DEAD_MULTIPLIER =.*/LIVENESS_DEAD_MULTIPLIER = 3/g' /var/lib/kytos/napps/kytos/of_lldp/settings.py
kytos-end-to-end-tests-kytos-1  | + kytosd --help
kytos-end-to-end-tests-kytos-1  | + sed -i s/WARNING/INFO/g /etc/kytos/logging.ini
kytos-end-to-end-tests-kytos-1  | + test -z ''
kytos-end-to-end-tests-kytos-1  | + TESTS=tests/
kytos-end-to-end-tests-kytos-1  | + test -z ''
kytos-end-to-end-tests-kytos-1  | + RERUNS=2
kytos-end-to-end-tests-kytos-1  | + python3 scripts/wait_for_mongo.py
kytos-end-to-end-tests-kytos-1  | Trying to run hello command on MongoDB...
kytos-end-to-end-tests-kytos-1  | Trying to run 'hello' command on MongoDB...
kytos-end-to-end-tests-kytos-1  | Trying to run 'hello' command on MongoDB...
kytos-end-to-end-tests-kytos-1  | Ran 'hello' command on MongoDB successfully. It's ready!
kytos-end-to-end-tests-kytos-1  | + python3 -m pytest tests/ --reruns 2 -r fEr
kytos-end-to-end-tests-kytos-1  | ============================= test session starts ==============================
kytos-end-to-end-tests-kytos-1  | platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.2.0
kytos-end-to-end-tests-kytos-1  | rootdir: /tests
kytos-end-to-end-tests-kytos-1  | plugins: rerunfailures-10.2, timeout-2.1.0, anyio-3.6.2
kytos-end-to-end-tests-kytos-1  | collected 241 items
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_05_topology.py ..................                         [  8%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 24%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_11_mef_eline.py ......                                    [ 27%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 30%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_13_mef_eline.py .....xs.s......xs.s.XXxX.xxxx..X......... [ 47%]
kytos-end-to-end-tests-kytos-1  | ...                                                                      [ 48%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_14_mef_eline.py x                                         [ 49%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_15_mef_eline.py ..                                        [ 50%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_20_flow_manager.py .....................                  [ 58%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_21_flow_manager.py ...                                    [ 60%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_22_flow_manager.py ...............                        [ 66%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_23_flow_manager.py ..............                         [ 72%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_30_of_lldp.py ....                                        [ 73%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_31_of_lldp.py ...                                         [ 75%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_32_of_lldp.py ...                                         [ 76%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_40_sdntrace.py ............RRF                            [ 81%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_41_kytos_auth.py ........                                 [ 85%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_50_maintenance.py ........................                [ 95%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_60_of_multi_table.py .....                                [ 97%]
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_70_kytos_stats.py .......                                 [100%]
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | =================================== FAILURES ===================================
kytos-end-to-end-tests-kytos-1  | _____________ TestE2ESDNTrace.test_090_test_flows_with_instruction _____________
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | cls = <tests.test_e2e_40_sdntrace.TestE2ESDNTrace object at 0x7fdaae448160>
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  |     def test_090_test_flows_with_instruction(cls):
kytos-end-to-end-tests-kytos-1  |         "Test flows with instruction"
kytos-end-to-end-tests-kytos-1  |         payload_stored_flow = {
kytos-end-to-end-tests-kytos-1  |             "flows": [
kytos-end-to-end-tests-kytos-1  |                 {
kytos-end-to-end-tests-kytos-1  |                     "match": {
kytos-end-to-end-tests-kytos-1  |                         "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                         "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                     },
kytos-end-to-end-tests-kytos-1  |                     "instructions": [
kytos-end-to-end-tests-kytos-1  |                         {
kytos-end-to-end-tests-kytos-1  |                             "instruction_type": "apply_actions",
kytos-end-to-end-tests-kytos-1  |                             "actions": [
kytos-end-to-end-tests-kytos-1  |                                 {"action_type": "output", "port": 1}
kytos-end-to-end-tests-kytos-1  |                             ]
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     ]
kytos-end-to-end-tests-kytos-1  |                 }
kytos-end-to-end-tests-kytos-1  |             ]
kytos-end-to-end-tests-kytos-1  |         }
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/kytos/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
kytos-end-to-end-tests-kytos-1  |         response = requests.post(api_url, json = payload_stored_flow)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 202, response.text
kytos-end-to-end-tests-kytos-1  |         time.sleep(10)
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         payload = [
kytos-end-to-end-tests-kytos-1  |                     {
kytos-end-to-end-tests-kytos-1  |                         "trace": {
kytos-end-to-end-tests-kytos-1  |                             "switch": {
kytos-end-to-end-tests-kytos-1  |                                 "dpid": "00:00:00:00:00:00:00:01",
kytos-end-to-end-tests-kytos-1  |                                 "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                             },
kytos-end-to-end-tests-kytos-1  |                             "eth": {
kytos-end-to-end-tests-kytos-1  |                                 "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                             }
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     }
kytos-end-to-end-tests-kytos-1  |                 ]
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/amlight/sdntrace_cp/v1/traces'
kytos-end-to-end-tests-kytos-1  |         response = requests.put(api_url, json=payload)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 200, response.text
kytos-end-to-end-tests-kytos-1  | >       data = response.json()["result"][0][0]
kytos-end-to-end-tests-kytos-1  | E       IndexError: list index out of range
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_40_sdntrace.py:1037: IndexError
kytos-end-to-end-tests-kytos-1  | ---------------------------- Captured stdout setup -----------------------------
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | ---------------------------- Captured stdout setup -----------------------------
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | ---------------------------- Captured stdout setup -----------------------------
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | FAIL to stop kytos after 5 seconds -- Kytos pid still exists.. Force stop!
kytos-end-to-end-tests-kytos-1  | =============================== warnings summary ===============================
kytos-end-to-end-tests-kytos-1  | usr/local/lib/python3.9/dist-packages/kytos/core/config.py:187
kytos-end-to-end-tests-kytos-1  |   /usr/local/lib/python3.9/dist-packages/kytos/core/config.py:187: UserWarning: Unknown arguments: ['tests/', '--reruns', '2', '-r', 'fEr']
kytos-end-to-end-tests-kytos-1  |     warnings.warn(f"Unknown arguments: {unknown}")
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | test_e2e_01_kytos_startup.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_05_topology.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_10_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_11_mef_eline.py: 25 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_12_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_13_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_14_mef_eline.py: 76 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_15_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_20_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_21_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_22_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_23_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_30_of_lldp.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_31_of_lldp.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_32_of_lldp.py: 11 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_40_sdntrace.py: 147 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_41_kytos_auth.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_50_maintenance.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_60_of_multi_table.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_70_kytos_stats.py: 17 warnings
kytos-end-to-end-tests-kytos-1  |   /usr/lib/python3/dist-packages/mininet/node.py:1121: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
kytos-end-to-end-tests-kytos-1  |     return ( StrictVersion( cls.OVSVersion ) <
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | test_e2e_01_kytos_startup.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_05_topology.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_10_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_11_mef_eline.py: 25 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_12_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_13_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_14_mef_eline.py: 76 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_15_mef_eline.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_20_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_21_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_22_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_23_flow_manager.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_30_of_lldp.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_31_of_lldp.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_32_of_lldp.py: 11 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_40_sdntrace.py: 147 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_41_kytos_auth.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_50_maintenance.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_60_of_multi_table.py: 17 warnings
kytos-end-to-end-tests-kytos-1  | test_e2e_70_kytos_stats.py: 17 warnings
kytos-end-to-end-tests-kytos-1  |   /usr/lib/python3/dist-packages/mininet/node.py:1122: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
kytos-end-to-end-tests-kytos-1  |     StrictVersion( '1.10' ) )
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
kytos-end-to-end-tests-kytos-1  | ------------------------------- start/stop times -------------------------------
kytos-end-to-end-tests-kytos-1  | rerun: 0
kytos-end-to-end-tests-kytos-1  | test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction: 2023-09-08,23:02:28.393561 - 2023-09-08,23:02:38.438356
kytos-end-to-end-tests-kytos-1  | cls = <tests.test_e2e_40_sdntrace.TestE2ESDNTrace object at 0x7fdaae448160>
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  |     def test_090_test_flows_with_instruction(cls):
kytos-end-to-end-tests-kytos-1  |         "Test flows with instruction"
kytos-end-to-end-tests-kytos-1  |         payload_stored_flow = {
kytos-end-to-end-tests-kytos-1  |             "flows": [
kytos-end-to-end-tests-kytos-1  |                 {
kytos-end-to-end-tests-kytos-1  |                     "match": {
kytos-end-to-end-tests-kytos-1  |                         "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                         "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                     },
kytos-end-to-end-tests-kytos-1  |                     "instructions": [
kytos-end-to-end-tests-kytos-1  |                         {
kytos-end-to-end-tests-kytos-1  |                             "instruction_type": "apply_actions",
kytos-end-to-end-tests-kytos-1  |                             "actions": [
kytos-end-to-end-tests-kytos-1  |                                 {"action_type": "output", "port": 1}
kytos-end-to-end-tests-kytos-1  |                             ]
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     ]
kytos-end-to-end-tests-kytos-1  |                 }
kytos-end-to-end-tests-kytos-1  |             ]
kytos-end-to-end-tests-kytos-1  |         }
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/kytos/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
kytos-end-to-end-tests-kytos-1  |         response = requests.post(api_url, json = payload_stored_flow)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 202, response.text
kytos-end-to-end-tests-kytos-1  |         time.sleep(10)
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         payload = [
kytos-end-to-end-tests-kytos-1  |                     {
kytos-end-to-end-tests-kytos-1  |                         "trace": {
kytos-end-to-end-tests-kytos-1  |                             "switch": {
kytos-end-to-end-tests-kytos-1  |                                 "dpid": "00:00:00:00:00:00:00:01",
kytos-end-to-end-tests-kytos-1  |                                 "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                             },
kytos-end-to-end-tests-kytos-1  |                             "eth": {
kytos-end-to-end-tests-kytos-1  |                                 "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                             }
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     }
kytos-end-to-end-tests-kytos-1  |                 ]
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/amlight/sdntrace_cp/v1/traces'
kytos-end-to-end-tests-kytos-1  |         response = requests.put(api_url, json=payload)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 200, response.text
kytos-end-to-end-tests-kytos-1  | >       data = response.json()["result"][0][0]
kytos-end-to-end-tests-kytos-1  | E       IndexError: list index out of range
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_40_sdntrace.py:1037: IndexError
kytos-end-to-end-tests-kytos-1  | rerun: 1
kytos-end-to-end-tests-kytos-1  | test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction: 2023-09-08,23:03:43.125244 - 2023-09-08,23:03:53.172277
kytos-end-to-end-tests-kytos-1  | cls = <tests.test_e2e_40_sdntrace.TestE2ESDNTrace object at 0x7fdaae448160>
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  |     def test_090_test_flows_with_instruction(cls):
kytos-end-to-end-tests-kytos-1  |         "Test flows with instruction"
kytos-end-to-end-tests-kytos-1  |         payload_stored_flow = {
kytos-end-to-end-tests-kytos-1  |             "flows": [
kytos-end-to-end-tests-kytos-1  |                 {
kytos-end-to-end-tests-kytos-1  |                     "match": {
kytos-end-to-end-tests-kytos-1  |                         "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                         "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                     },
kytos-end-to-end-tests-kytos-1  |                     "instructions": [
kytos-end-to-end-tests-kytos-1  |                         {
kytos-end-to-end-tests-kytos-1  |                             "instruction_type": "apply_actions",
kytos-end-to-end-tests-kytos-1  |                             "actions": [
kytos-end-to-end-tests-kytos-1  |                                 {"action_type": "output", "port": 1}
kytos-end-to-end-tests-kytos-1  |                             ]
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     ]
kytos-end-to-end-tests-kytos-1  |                 }
kytos-end-to-end-tests-kytos-1  |             ]
kytos-end-to-end-tests-kytos-1  |         }
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/kytos/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
kytos-end-to-end-tests-kytos-1  |         response = requests.post(api_url, json = payload_stored_flow)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 202, response.text
kytos-end-to-end-tests-kytos-1  |         time.sleep(10)
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         payload = [
kytos-end-to-end-tests-kytos-1  |                     {
kytos-end-to-end-tests-kytos-1  |                         "trace": {
kytos-end-to-end-tests-kytos-1  |                             "switch": {
kytos-end-to-end-tests-kytos-1  |                                 "dpid": "00:00:00:00:00:00:00:01",
kytos-end-to-end-tests-kytos-1  |                                 "in_port": 2,
kytos-end-to-end-tests-kytos-1  |                             },
kytos-end-to-end-tests-kytos-1  |                             "eth": {
kytos-end-to-end-tests-kytos-1  |                                 "dl_vlan": 100
kytos-end-to-end-tests-kytos-1  |                             }
kytos-end-to-end-tests-kytos-1  |                         }
kytos-end-to-end-tests-kytos-1  |                     }
kytos-end-to-end-tests-kytos-1  |                 ]
kytos-end-to-end-tests-kytos-1  |     
kytos-end-to-end-tests-kytos-1  |         api_url = KYTOS_API + '/amlight/sdntrace_cp/v1/traces'
kytos-end-to-end-tests-kytos-1  |         response = requests.put(api_url, json=payload)
kytos-end-to-end-tests-kytos-1  |         assert response.status_code == 200, response.text
kytos-end-to-end-tests-kytos-1  | >       data = response.json()["result"][0][0]
kytos-end-to-end-tests-kytos-1  | E       IndexError: list index out of range
kytos-end-to-end-tests-kytos-1  | 
kytos-end-to-end-tests-kytos-1  | tests/test_e2e_40_sdntrace.py:1037: IndexError
kytos-end-to-end-tests-kytos-1  | test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction: 2023-09-08,23:04:59.179691 - 2023-09-08,23:05:09.224641
kytos-end-to-end-tests-kytos-1  | =========================== rerun test summary info ============================
kytos-end-to-end-tests-kytos-1  | RERUN test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction
kytos-end-to-end-tests-kytos-1  | RERUN test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction
kytos-end-to-end-tests-kytos-1  | =========================== short test summary info ============================
kytos-end-to-end-tests-kytos-1  | FAILED tests/test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_090_test_flows_with_instruction
kytos-end-to-end-tests-kytos-1  | = 1 failed, 218 passed, 6 skipped, 11 xfailed, 5 xpassed, 1063 warnings, 2 rerun in 11147.00s (3:05:47) =
Ktmi commented 9 months ago

Still getting the same error in the SDN trace e2e tests. Not sure why. Will rerun without this patch and see if the issue persists.

Ktmi commented 9 months ago

E2E tests on SDN trace fails whether I have this patch applied or not.

viniarck commented 9 months ago

E2E tests on SDN trace fails whether I have this patch applied or not.

@Ktmi the nightly e2e tests have been passing for more than 2 weeks. Maybe it might be a sleep that's impacting when executing on your laptop? Either way, if it's failing it might be worth mapping an issue for it if you haven't yet, just so it can be improved. It's also worth dispatching an execution on GitLab https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/pipelines with this branch here just so you can also have more information when opening the issue.

viniarck commented 9 months ago

E2E tests on SDN trace fails whether I have this patch applied or not.

@Ktmi the nightly e2e tests have been passing for more than 2 weeks. Maybe it might be a sleep that's impacting when executing on your laptop? Either way, if it's failing it might be worth mapping an issue for it if you haven't yet, just so it can be improved. It's also worth dispatching an execution on GitLab https://gitlab.ampath.net/amlight/kytos-end-to-end-tester/-/pipelines with this branch here just so you can also have more information when opening the issue.

If you set this env var ENV_VARS with this value --build-arg branch_kytos=feat/rate_limited_buffers and dispatch the GitLab pipeline it should run all the e2e tests with this branch.

viniarck commented 8 months ago

Other than that I also simulated a wrong configuration and it exited kytosd as expected:

Web update - Web UI was not updated
2023-10-17 15:18:27,786 - INFO [kytos.core.db] [db.py:152:db_conn_wait] (MainThread) Starting DB connection
2023-10-17 15:18:27,787 - INFO [kytos.core.db] [db.py:137:_mongo_conn_wait] (MainThread) Trying to run 'hello' command on MongoDB...
2023-10-17 15:18:27,795 - INFO [kytos.core.db] [db.py:139:_mongo_conn_wait] (MainThread) Ran 'hello' command on MongoDB successfully. It's ready!
2023-10-17 15:18:27,805 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/login/ - GET
2023-10-17 15:18:27,806 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/users/ - GET
2023-10-17 15:18:27,806 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/users/{username} - GET
2023-10-17 15:18:27,806 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/users/ - POST
Kytos couldn't start because of 'rate_limitedx' Traceback (most recent call last):
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 264, in start
    self.start_controller()
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 342, in start_controller
    self._buffers = KytosBuffers()
  File "/home/viniarck/repos/kytos/kytos/core/buffers/manager.py", line 60, in __init__
    setattr(self, name, buffer_from_config(name, config))
  File "/home/viniarck/repos/kytos/kytos/core/buffers/factory.py", line 89, in buffer_from_config
    processed_conf = buffer_conf_processors[buffer_type](config)
KeyError: 'rate_limitedx'

Task was destroyed but it is pending!
task: <Task pending name='Task-1' coro=<start_shell_async() running at /home/viniarck/repos/kytos/kytos/core/kytosd.py:120>>
2023-10-17 15:18:27,806 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/users/{username} - DELETE
2023-10-17 15:18:27,806 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/kytos/core/auth/users/{username} - PATCH
2023-10-17 15:18:27,806 - INFO [kytos.core.controller] [controller.py:282:create_pidfile] (MainThread) /home/viniarck/repos/kytos/.direnv/python-3.9/var/run/kytos
2023-10-17 15:18:27,807 - INFO [kytos.core.controller] [controller.py:340:start_controller] (MainThread) Starting Kytos - Kytos Controller
2023-10-17 15:18:27,810 - ERROR [kytos.core.controller] [kytosd.py:156:async_main] (MainThread) Kytos couldn't start because of 'rate_limitedx' Traceback (most recent call last):
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 264, in start
    self.start_controller()
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 342, in start_controller
    self._buffers = KytosBuffers()
  File "/home/viniarck/repos/kytos/kytos/core/buffers/manager.py", line 60, in __init__
    setattr(self, name, buffer_from_config(name, config))
  File "/home/viniarck/repos/kytos/kytos/core/buffers/factory.py", line 89, in buffer_from_config
    processed_conf = buffer_conf_processors[buffer_type](config)
KeyError: 'rate_limitedx'

/home/viniarck/repos/kytos/kytos/core/kytosd.py:98: RuntimeWarning: coroutine 'start_shell_async' was never awaited
  async_main(config)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2023-10-17 15:18:27,810 - INFO [kytos.core.controller] [kytosd.py:157:async_main] (MainThread) Shutting down Kytos...
Ktmi commented 5 months ago

Gonna close this one, and reopen a new PR, in order to integrate the changes from #438.