kytos-ng / pathfinder

Kytos main path finder Network Application (NApp)
https://kytos-ng.github.io/api/pathfinder.html
MIT License
0 stars 7 forks source link

fix: removed support for `desired_links` and fixed `undesired_links` to filter upfront as a subgraph #47

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

Closes #37 Closes #46

(before this get merged, mef_eline also needs to update the endpoint to /v3 and fix this issue)

Summary

See updated changelog file.

Local Tests

{
    "source": "00:00:00:00:00:00:00:01:1",
    "destination": "00:00:00:00:00:00:00:03:1"
}

{
    "paths": [
        {
            "hops": [
                "00:00:00:00:00:00:00:01:1",
                "00:00:00:00:00:00:00:01",
                "00:00:00:00:00:00:00:01:4",
                "00:00:00:00:00:00:00:03:3",
                "00:00:00:00:00:00:00:03",
                "00:00:00:00:00:00:00:03:1"
            ],
            "cost": 5
        },
        {
            "hops": [
                "00:00:00:00:00:00:00:01:1",
                "00:00:00:00:00:00:00:01",
                "00:00:00:00:00:00:00:01:3",
                "00:00:00:00:00:00:00:02:2",
                "00:00:00:00:00:00:00:02",
                "00:00:00:00:00:00:00:02:3",
                "00:00:00:00:00:00:00:03:2",
                "00:00:00:00:00:00:00:03",
                "00:00:00:00:00:00:00:03:1"
            ],
            "cost": 8
        }
    ]
}
{
    "source": "00:00:00:00:00:00:00:01:1",
    "destination": "00:00:00:00:00:00:00:03:1",
    "undesired_links": ["{{linkid}}"]
}
{
    "paths": [
        {
            "hops": [
                "00:00:00:00:00:00:00:01:1",
                "00:00:00:00:00:00:00:01",
                "00:00:00:00:00:00:00:01:3",
                "00:00:00:00:00:00:00:02:2",
                "00:00:00:00:00:00:00:02",
                "00:00:00:00:00:00:00:02:3",
                "00:00:00:00:00:00:00:03:2",
                "00:00:00:00:00:00:00:03",
                "00:00:00:00:00:00:00:03:1"
            ],
            "cost": 8
        }
    ]
}

20230509_183019

20230509_183723

❯ curl -s -X POST -H 'Content-type: application/json' http://127.0.0.1:8181/api/kytos/pathfinder/v3/ -d '{"source": "00:00:00:00:00:00:00:21:60", "destination":  "00:00:00:00:00:00:00:15:54", "spf_max_paths": 2, "undesired_links": ["3956ad11df6336618b11ba3da67c855f895310509d61d9f520b712e4b140320a"]}' | jq -r
{
  "paths": [
    {
      "hops": [
        "00:00:00:00:00:00:00:21:60",
        "00:00:00:00:00:00:00:21",
        "00:00:00:00:00:00:00:21:15",
        "00:00:00:00:00:00:00:19:15",
        "00:00:00:00:00:00:00:19",
        "00:00:00:00:00:00:00:19:12",
        "00:00:00:00:00:00:00:12:12",
        "00:00:00:00:00:00:00:12",
        "00:00:00:00:00:00:00:12:4",
        "00:00:00:00:00:00:00:15:4",
        "00:00:00:00:00:00:00:15",
        "00:00:00:00:00:00:00:15:54"
      ],
      "cost": 11
    },
    {
      "hops": [
        "00:00:00:00:00:00:00:21:60",
        "00:00:00:00:00:00:00:21",
        "00:00:00:00:00:00:00:21:14",
        "00:00:00:00:00:00:00:18:14",
        "00:00:00:00:00:00:00:18",
        "00:00:00:00:00:00:00:18:11",
        "00:00:00:00:00:00:00:11:11",
        "00:00:00:00:00:00:00:11",
        "00:00:00:00:00:00:00:11:1",
        "00:00:00:00:00:00:00:12:1",
        "00:00:00:00:00:00:00:12",
        "00:00:00:00:00:00:00:12:4",
        "00:00:00:00:00:00:00:15:4",
        "00:00:00:00:00:00:00:15",
        "00:00:00:00:00:00:00:15:54"
      ],
      "cost": 14
    }
  ]
}

- Excluding link b4bb0efae4ff2952171836a4c56dff63bae46a9a03ab3c3fdeec8bd66f23dad2 that belongs to 00:00:00:00:00:00:00:21:15 and 00:00:00:00:00:00:00:19:15

❯ curl -s -X POST -H 'Content-type: application/json' http://127.0.0.1:8181/api/kytos/pathfinder/v3/ -d '{"source": "00:00:00:00:00:00:00:21:60", "destination":  "00:00:00:00:00:00:00:15:54", "spf_max_paths": 2, "undesired_links": ["b4bb0efae4ff2952171836a4c56dff63bae46a9a03ab3c3fdeec8bd66f23dad2"]}' | jq -r
{
  "paths": [
    {
      "hops": [
        "00:00:00:00:00:00:00:21:60",
        "00:00:00:00:00:00:00:21",
        "00:00:00:00:00:00:00:21:14",
        "00:00:00:00:00:00:00:18:14",
        "00:00:00:00:00:00:00:18",
        "00:00:00:00:00:00:00:18:11",
        "00:00:00:00:00:00:00:11:11",
        "00:00:00:00:00:00:00:11",
        "00:00:00:00:00:00:00:11:1",
        "00:00:00:00:00:00:00:12:1",
        "00:00:00:00:00:00:00:12",
        "00:00:00:00:00:00:00:12:4",
        "00:00:00:00:00:00:00:15:4",
        "00:00:00:00:00:00:00:15",
        "00:00:00:00:00:00:00:15:54"
      ],
      "cost": 14
    },
    {
      "hops": [
        "00:00:00:00:00:00:00:21:60",
        "00:00:00:00:00:00:00:21",
        "00:00:00:00:00:00:00:21:14",
        "00:00:00:00:00:00:00:18:14",
        "00:00:00:00:00:00:00:18",
        "00:00:00:00:00:00:00:18:13",
        "00:00:00:00:00:00:00:19:13",
        "00:00:00:00:00:00:00:19",
        "00:00:00:00:00:00:00:19:12",
        "00:00:00:00:00:00:00:12:12",
        "00:00:00:00:00:00:00:12",
        "00:00:00:00:00:00:00:12:4",
        "00:00:00:00:00:00:00:15:4",
        "00:00:00:00:00:00:00:15",
        "00:00:00:00:00:00:00:15:54"
      ],
      "cost": 14
    }
  ]
}

End-to-End Tests

+ python3 -m pytest tests/ --reruns 2 -r fEr
============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.0.0
rootdir: /builds/amlight/kytos-end-to-end-tester/kytos-end-to-end-tests
plugins: rerunfailures-10.2, timeout-2.1.0, anyio-3.6.2
collected 227 items
tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
tests/test_e2e_05_topology.py ..................                         [  8%]
tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 26%]
tests/test_e2e_11_mef_eline.py ......                                    [ 29%]
tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 32%]
tests/test_e2e_13_mef_eline.py .....xs.s......xs.s.XXxX.xxxx..X......... [ 50%]
...                                                                      [ 51%]
tests/test_e2e_14_mef_eline.py x                                         [ 52%]
tests/test_e2e_15_mef_eline.py ..                                        [ 53%]
tests/test_e2e_20_flow_manager.py ......................                 [ 62%]
tests/test_e2e_21_flow_manager.py ...                                    [ 63%]
tests/test_e2e_22_flow_manager.py ...............                        [ 70%]
tests/test_e2e_23_flow_manager.py ..............                         [ 76%]
tests/test_e2e_30_of_lldp.py ....                                        [ 78%]
tests/test_e2e_31_of_lldp.py ...                                         [ 79%]
tests/test_e2e_32_of_lldp.py ...                                         [ 81%]
tests/test_e2e_40_sdntrace.py ...........                                [ 85%]
tests/test_e2e_41_kytos_auth.py ........                                 [ 89%]
tests/test_e2e_50_maintenance.py ........................                [100%]
=============================== warnings summary ===============================
= 205 passed, 6 skipped, 11 xfailed, 5 xpassed, 799 warnings in 10444.28s (2:54:04)