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

New test to create l2vpns and check connectivity #8

Merged
merged 14 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 97 additions & 8 deletions tests/test_05_l2vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_020_create_l2vpn_successfully(self):
{
"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50",
"vlan": "300",
},
],
}
]
}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text
Expand Down Expand Up @@ -101,8 +101,8 @@ def test_030_create_l2vpn_with_any_vlan(self):
{
"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50",
"vlan": "any",
},
],
}
]
}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text
Expand Down Expand Up @@ -169,8 +169,8 @@ def test_040_edit_vlan_l2vpn_successfully(self):
{
"port_id": current_data["endpoints"][1]["port_id"],
"vlan": "100",
},
],
}
]
}
response = requests.patch(f"{api_url}/{key}", json=payload)
assert response.status_code == 201, response.text
Expand Down Expand Up @@ -225,8 +225,8 @@ def test_045_edit_port_l2vpn_successfully(self):
},
{
"port_id": "urn:sdx:port:sax.net:Sax01:40",
},
],
}
]
}
response = requests.patch(f"{api_url}/{key}", json=payload)
assert response.status_code == 201, response.text
Expand Down Expand Up @@ -267,3 +267,92 @@ def test_050_delete_l2vpn_successfully(self):
## -> tenet
response = requests.get("http://tenet:8181/api/kytos/mef_eline/v2/evc/")
assert len(response.json()) == 0, response.text

def test_060_link_convergency_with_l2vpn_with_alternative_paths(self):
"""
Test a simple link convergency with L2VPNs that have alternative paths:
- Create 3 L2VPN,
- test connectivity,
- set one link to down,
- wait a few seconds for convergency,
- test connectivity again
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'

payload = {"name": "Text",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath1:50", "vlan": "100"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "100"}
]
}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text
h1, h8 = self.net.net.get('h1', 'h8')
h1.cmd('ip link add link %s name vlan100 type vlan id 100' % (h1.intfNames()[0]))
h1.cmd('ip link set up vlan100')
h1.cmd('ip addr add 10.1.1.1/24 dev vlan100')
h8.cmd('ip link add link %s name vlan100 type vlan id 100' % (h8.intfNames()[0]))
h8.cmd('ip link set up vlan100')
h8.cmd('ip addr add 10.1.1.8/24 dev vlan100')

payload = {"name": "Text",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath1:50", "vlan": "101"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "101"}
]
}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text
h1.cmd('ip link add link %s name vlan101 type vlan id 101' % (h1.intfNames()[0]))
h1.cmd('ip link set up vlan101')
h1.cmd('ip addr add 10.1.2.1/24 dev vlan101')
h8.cmd('ip link add link %s name vlan101 type vlan id 101' % (h8.intfNames()[0]))
h8.cmd('ip link set up vlan101')
h8.cmd('ip addr add 10.1.2.8/24 dev vlan101')

payload = {"name": "Text",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath1:50", "vlan": "102"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "102"}
]
}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text
h1.cmd('ip link add link %s name vlan102 type vlan id 102' % (h1.intfNames()[0]))
h1.cmd('ip link set up vlan102')
h1.cmd('ip addr add 10.1.3.1/24 dev vlan102')
h8.cmd('ip link add link %s name vlan102 type vlan id 102' % (h8.intfNames()[0]))
h8.cmd('ip link set up vlan102')
h8.cmd('ip addr add 10.1.3.8/24 dev vlan102')

# test connectivity
result_100 = h1.cmd('ping -c4 10.1.1.8')
result_101 = h1.cmd('ping -c4 10.1.2.8')
result_102 = h1.cmd('ping -c4 10.1.3.8')

# set one link to down
self.net.net.configLinkStatus('Ampath1', 'Sax01', 'down')

# wait a few seconds for convergency
time.sleep(15)

# test connectivity again
result_100_2 = h1.cmd('ping -c4 10.1.1.8')
result_101_2 = h1.cmd('ping -c4 10.1.2.8')
result_102_2 = h1.cmd('ping -c4 10.1.3.8')

# clean up
h1.cmd('ip link del vlan100')
h1.cmd('ip link del vlan101')
h1.cmd('ip link del vlan102')
h8.cmd('ip link del vlan100')
h8.cmd('ip link del vlan101')
h8.cmd('ip link del vlan102')

assert ', 0% packet loss,' in result_100
assert ', 0% packet loss,' in result_101
assert ', 0% packet loss,' in result_102

assert ', 0% packet loss,' in result_100_2
#assert ', 0% packet loss,' in result_101_2
#assert ', 0% packet loss,' in result_102_2
Loading