kytos-ng / sdntrace

Napp that traces OpenFlow paths in the dataplane
https://kytos-ng.github.io/api/sdntrace.html
GNU Lesser General Public License v3.0
0 stars 5 forks source link

Added tests for api requests #78

Closed Alopalao closed 1 month ago

Alopalao commented 1 month ago

Closes #38 Closes #46

Summary

Added tests for API request from main.py Assigned version 1.0.0 to requests

Local Tests

Made requests to test versioning

End-to-End Tests

Results from e2e PR

+ python3 -m pytest tests/test_e2e_40_sdntrace.py --reruns 2 -r fEr
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-8.1.1, pluggy-1.5.0
rootdir: /tests
plugins: rerunfailures-13.0, timeout-2.2.0, anyio-4.3.0
collected 14 items

tests/test_e2e_40_sdntrace.py ..............                             [100%]

=============================== warnings summary ===============================
viniarck commented 1 month ago

Also, UI client request endpoints need to be updated too (here's one line for example):

Alopalao commented 1 month ago

This exception in the tests:

tests/unit/tracing/test_trace_manager.py::TestTraceManager::test_is_entry_invalid_not_colored
  /home/scrutinizer/build/.tox/py311/lib/python3.11/site-packages/_pytest/unraisableexception.py:80: PytestUnraisableExceptionWarning: Exception ignored in thread started by: <bound method TraceManager._spawn_trace of <napps.amlight.sdntrace.tracing.trace_manager.TraceManager object at 0x7f9bee815990>>

  Traceback (most recent call last):
    File "/home/scrutinizer/build/.tox/py311/var/lib/kytos/napps/amlight/sdntrace/tracing/trace_manager.py", line 94, in _spawn_trace
      tracer = TracePath(self, trace_id, trace_entries)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/scrutinizer/build/.tox/py311/var/lib/kytos/napps/amlight/sdntrace/tracing/tracer.py", line 47, in __init__
      self.init_switch = self.get_init_switch()
                         ^^^^^^^^^^^^^^^^^^^^^^
    File "/home/scrutinizer/build/.tox/py311/var/lib/kytos/napps/amlight/sdntrace/tracing/tracer.py", line 56, in get_init_switch
      return Switches().get_switch(self.init_entries.dpid)
                                   ^^^^^^^^^^^^^^^^^^^^^^
  AttributeError: 'str' object has no attribute 'dpid'

It is caused because TestManager class creates a thread which is constantly running. It does not fail in the specified test test_is_entry_invalid_not_colored. Looks like it fails around the time that test is running. Changing the order of tests will change the shown test in this warning.