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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
69 changes: 69 additions & 0 deletions tests/test_05_l2vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,72 @@ 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.1.1/24 dev vlan101')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gretel, can you please update the IP address assigned to VLAN 101 to something different? Example: 10.1.2.1/24

h8.cmd('ip link add link %s name vlan100 type vlan id 101' % (h8.intfNames()[0]))
h8.cmd('ip link set up vlan101')
h8.cmd('ip addr add 10.1.1.8/24 dev vlan101')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


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.1.1/24 dev vlan102')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here regarding the IP address

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.1.8/24 dev vlan102')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here regarding the IP address


# test connectivity after create 3 L2VPN
result = h1.cmd('ping -c4 10.1.1.8')
assert ', 0% packet loss,' in result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend that the assert goes in the end, to allow the VLAN interfaces be removed before actually checking for the results (and possibly failing, leaving the clean up incomplete).


h1.cmd('ip link del vlan102')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave this to the end


# wait a few seconds for convergency
time.sleep(30)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I understood the convergency here. From the previous commands, there was no links going down

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, the comment is confusing. This is some time after removing a link.


# test connectivity again
result = h1.cmd('ping -c4 10.1.1.8')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to have different variables to store the ping result from each VLAN:

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')

assert ', 0% packet loss,' in result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing all the connectivity, I suggest you to remove all the interfaces from h1 and h8:

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')

Loading