kytos-ng / kytos-end-to-end-tests

Kytos End-to-End Tests
0 stars 10 forks source link

Add e2e tests for `kytos_stats` #242

Closed gretelliz closed 1 year ago

gretelliz commented 1 year ago

Closes #235

Summary

Add e2e tests for kytos_stats endpoints including the new endpoint v1/table/stats to request tables.

Local Tests

N/A

End-to-end Tests

N/A

viniarck commented 1 year ago

Also, let's run the entire test suite with this branch for completeness before merging this PR.

gretelliz commented 1 year ago

@viniarck, Thank you! Sure, I am going to add that test now.

gretelliz commented 1 year ago

@viniarck, In the new e2e test to check activate_count as you suggested, I set a time with time.sleep(60). The field is not increasing, how long should I wait to see an increase?

viniarck commented 1 year ago

@viniarck, In the new e2e test to check activate_count as you suggested, I set a time with time.sleep(60). The field is not increasing, how long should I wait to see an increase?

@gretelliz of_lldp and coloring flows, right after the OF Handshake, and then of_lldp will keep sending packets every 3 secs, and table and flows table stats will be received slightly after the handshake and then every STATS_INTERVAL (7 secs). A 10 sec delay should suffice, here's an example:

❯ http localhost:8181/api/amlight/kytos_stats/v1/table/stats?table=0
HTTP/1.1 200 OK
content-length: 301
content-type: application/json
date: Fri, 16 Jun 2023 17:55:05 GMT
server: uvicorn

{
    "00:00:00:00:00:00:00:01": {
        "0": {
            "active_count": 3,
            "lookup_count": 74,
            "matched_count": 2,
            "table_id": 0
        }
    },
    "00:00:00:00:00:00:00:02": {
        "0": {
            "active_count": 3,
            "lookup_count": 68,
            "matched_count": 6,
            "table_id": 0
        }
    },
    "00:00:00:00:00:00:00:03": {
        "0": {
            "active_count": 3,
            "lookup_count": 66,
            "matched_count": 4,
            "table_id": 0
        }
    }
}

❯ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
 cookie=0xac00000000000001, duration=46.629s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=50000,dl_src=ee:ee:ee:ee:ee:02 actions=CONTROLLER:65535
 cookie=0xac00000000000001, duration=46.622s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=50000,dl_src=ee:ee:ee:ee:ee:03 actions=CONTROLLER:65535
 cookie=0xab00000000000001, duration=48.501s, table=0, n_packets=32, n_bytes=1344, send_flow_rem priority=1000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535

If it's not incrementing then there's something else wrong that you need to debug.

viniarck commented 1 year ago

This needs to land with https://github.com/amlight/kytos-docker/pull/30 (future reminder for whoever is merging)

Also, @gretelliz did you have the chance to run the test suite?

gretelliz commented 1 year ago

Yes, @viniarck. See:

+ python3 -m pytest --timeout=180 tests/test_e2e_70_kytos_stats.py
============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.0.0
rootdir: /tests
plugins: timeout-2.1.0, rerunfailures-10.2, anyio-3.6.2
timeout: 180.0s
timeout method: signal
timeout func_only: False
collected 7 items

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

=============================== warnings summary ===============================
test_e2e_70_kytos_stats.py: 17 warnings
  /usr/lib/python3/dist-packages/mininet/node.py:1121: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    return ( StrictVersion( cls.OVSVersion ) <

test_e2e_70_kytos_stats.py: 17 warnings
  /usr/lib/python3/dist-packages/mininet/node.py:1122: 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 -------------------------------
================== 7 passed, 34 warnings in 435.14s (0:07:15) ==================