Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rerun TestE2ESDNTrace::test_020_run_sdntrace_fail_missing_flow #328

Open
viniarck opened this issue Oct 15, 2024 · 1 comment
Open

rerun TestE2ESDNTrace::test_020_run_sdntrace_fail_missing_flow #328

viniarck opened this issue Oct 15, 2024 · 1 comment
Assignees
Labels
epic_e2e_tests_coverage Increase end-to-end test coverage

Comments

@viniarck
Copy link
Member

Rerun on 2024-10-14

rerun: 0
tests/test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_020_run_sdntrace_fail_missing_flow: 2024-10-14,06:55:31.533146 - 2024-10-14,06:56:14.978133
self = <tests.test_e2e_40_sdntrace.TestE2ESDNTrace object at 0x7fe282275a10>

    def test_020_run_sdntrace_fail_missing_flow(self):
        """Run SDNTrace-CP with a failure due to missing flows:
        - delete flow from intermediate switch
        - make sure sdntrace_cp detects the failure
        - make sure sdntrace detects the failure
        - redeploy evc and make sure sdntrace / sdntrace_cp works
        """
        # 1. delete flow
        delete_flow = {
            "flows": [
                {
                    'cookie': int("0xaa%s" % self.circuit['id'], 16),
                    'cookie_mask': 0xffffffffffffffff,
                }
            ]
        }

        api_url = KYTOS_API + '/kytos/flow_manager/v2/flows/00:00:00:00:00:00:00:05'
        response = requests.delete(api_url, json=delete_flow)
        assert response.status_code == 202, response.text
        time.sleep(10)

        # 2. sdntrace control plane - Trace from UNI_A
        payload_1 = {
            "trace": {
                "switch": {"dpid": "00:00:00:00:00:00:00:01", "in_port": 1},
                "eth": {"dl_type": 33024, "dl_vlan": 400}
            }
        }
        api_url = KYTOS_API + '/amlight/sdntrace_cp/v1/trace'
        response = requests.put(api_url, json=payload_1)
        data = response.json()
        # only 4 steps are expected: starting, 1->2, 2->3, 3->4
        assert len(data["result"]) == 4, str(data)

        full_path = [
            (
                l['endpoint_b']['switch'],
                l['endpoint_b']['port_number'],
                l['metadata']['s_vlan']['value']
            )
            for l in self.circuit['current_path']
        ]

        actual = [
            (step['dpid'], step['port'], step['vlan'])
            for step in data["result"][1:]
        ]

        assert full_path != actual, f"Full path {full_path}. Actual: {actual}"
        assert full_path[:3] == actual, f"Expected {full_path[:3]}. Actual: {actual}"

        # 3. sdntrace data plane - Trace from UNI_A
        payload_2 = {
            "trace": {
                "switch": {
                    "dpid": "00:00:00:00:00:00:00:01",
                    "in_port": 1
                },
                "eth": {
                    "dl_vlan": 400,
                    "dl_vlan_pcp": 4,
                    "dl_type": 2048
                },
                "ip": {
                    "nw_src": "0.0.0.1",
                    "nw_dst": "0.0.0.2",
                    "nw_tos": 5,
                    "nw_proto": 17
                },
                "tp": {
                    "tp_src": 33948,
                    "tp_dst": 53
                }
            }
        }

        api_url = KYTOS_API + '/amlight/sdntrace/v1/trace'
        response = requests.put(api_url, json=payload_2)
        assert response.status_code == 200, response.text
        data = response.json()
        result = self.wait_sdntrace_result(data["result"]["trace_id"])

        full_path = [
            (
                l['endpoint_b']['switch'],
                l['endpoint_b']['port_number'],
            )
            for l in self.circuit['current_path']
        ]

        actual = [
            (step['dpid'], step['port']) for step in result[1:-1]
        ]

        assert full_path != actual, f"Full path {full_path}. Actual: {actual}"
        assert full_path[:4] == actual, f"Expected {full_path[:4]}. Actual: {actual}"

        # 4. redeploy evc and check again
        circuit_id = self.circuit['id']
        api_url = KYTOS_API + '/kytos/mef_eline/v2/evc'
        response = requests.patch(f"{api_url}/{circuit_id}/redeploy")
        assert response.status_code == 202, response.text
        time.sleep(10)
        self.circuit = self.wait_until_evc_is_active(circuit_id)

        api_url = KYTOS_API + '/amlight/sdntrace_cp/v1/trace'
        response = requests.put(api_url, json=payload_1)
        data = response.json()
        assert len(data["result"]) == 10, data
        expected = [
            (
                l['endpoint_b']['switch'],
                l['endpoint_b']['port_number'],
                l['metadata']['s_vlan']['value']
            )
            for l in self.circuit['current_path']
        ]
        actual = [
            (step['dpid'], step['port'], step['vlan'])
            for step in data["result"][1:]
        ]
        assert expected == actual, f"Expected {expected}. Actual: {actual}"

        api_url = KYTOS_API + '/amlight/sdntrace/v1/trace'
        response = requests.put(api_url, json=payload_2)
        assert response.status_code == 200, response.text
        data = response.json()
>       result = self.wait_sdntrace_result(data["result"]["trace_id"])

tests/test_e2e_40_sdntrace.py:386:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_e2e_40_sdntrace.TestE2ESDNTrace object at 0x7fe282275a10>
trace_id = 30002, timeout = 10

    def wait_sdntrace_result(self, trace_id, timeout=10):
        """Wait until sdntrace finishes."""
        wait_count = 0
        while wait_count < timeout:
            try:
                api_url = KYTOS_API + '/amlight/sdntrace/v1/trace'
                response = requests.get(f"{api_url}/{trace_id}")
                data = response.json()
                assert data["result"][-1]["reason"] == "done"
                break
            except:
                time.sleep(1)
                wait_count += 1
        else:
            msg = 'Timeout while waiting from sdntrace result.'
>           raise Exception(msg)
E           Exception: Timeout while waiting from sdntrace result.

tests/test_e2e_40_sdntrace.py:159: Exception
=========================== rerun test summary info ============================
RERUN tests/test_e2e_40_sdntrace.py::TestE2ESDNTrace::test_020_run_sdntrace_fail_missing_flow
@viniarck viniarck added the epic_e2e_tests_coverage Increase end-to-end test coverage label Oct 15, 2024
@jab1982
Copy link

jab1982 commented Oct 15, 2024

@Alopalao , can you please take a look?

@Alopalao Alopalao self-assigned this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic_e2e_tests_coverage Increase end-to-end test coverage
Projects
None yet
Development

No branches or pull requests

3 participants