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

Added e2e tests for untagged and any new EVCs #210

Merged
merged 3 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
118 changes: 118 additions & 0 deletions tests/test_e2e_10_mef_eline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,121 @@ def test_155_removing_evc_metadata_persistent(self):
data = response.json()
assert my_key not in data['metadata']
assert len(data['metadata']) > 0

def test_160_create_untagged_evc(self):
viniarck marked this conversation as resolved.
Show resolved Hide resolved
payload = {
"name": "evc1",
"dynamic_backup_path": True,
"enabled": True,
"uni_a": {
"tag": {"tag_type": 1, "value": "untagged"},
"interface_id": "00:00:00:00:00:00:00:01:1"
},
"uni_z": {
"tag": {"tag_type": 1, "value": "untagged"},
"interface_id": "00:00:00:00:00:00:00:02:1"
}
}
api_url = KYTOS_API + '/mef_eline/v2/evc/'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
assert response.status_code == 201, response.text
data = response.json()
assert 'circuit_id' in data
time.sleep(20)

h11, h2 = self.net.net.get('h11', 'h2')
h11.cmd('ip addr add 104.0.0.11/24 dev %s' % (h11.intfNames()[0]))
h2.cmd('ip addr add 104.0.0.2/24 dev %s' % (h2.intfNames()[0]))
result = h11.cmd('ping -c1 104.0.0.2')
assert ', 0% packet loss,' in result

def test_165_create_any_evc(self):
payload = {
"name": "evc1",
"dynamic_backup_path": True,
"enabled": True,
"uni_a": {
"tag": {"tag_type": 1, "value": "any"},
"interface_id": "00:00:00:00:00:00:00:01:1"
},
"uni_z": {
"tag": {"tag_type": 1, "value": "any"},
"interface_id": "00:00:00:00:00:00:00:02:1"
}
}
api_url = KYTOS_API + '/mef_eline/v2/evc/'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
assert response.status_code == 201, response.text
data = response.json()
assert 'circuit_id' in data
time.sleep(10)

h11, h2 = self.net.net.get('h11', 'h2')
h11.cmd('ip link add link %s name vlan100 type vlan id 100' % (h11.intfNames()[0]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we are using the "any" VLAN here, what do you think about using a random value for the VLAN on the PING test? I suggest replacing the VLAN 100 with a random value chosen from a range from 1 to 4095. Let me know what you think.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, will do that.

Copy link
Author

Choose a reason for hiding this comment

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

I divided the PR, here is the correct one for mef_eline

h11.cmd('ip link set up vlan100')
h11.cmd('ip addr add 100.0.0.11/24 dev vlan100')
h2.cmd('ip link add link %s name vlan100 type vlan id 100' % (h2.intfNames()[0]))
h2.cmd('ip link set up vlan100')
h2.cmd('ip addr add 100.0.0.2/24 dev vlan100')
result = h11.cmd('ping -c1 100.0.0.2')
assert ', 0% packet loss,' in result

def test_170_create_any_100_evc(self):
payload = {
"name": "evc1",
"dynamic_backup_path": True,
"enabled": True,
"uni_a": {
"tag": {"tag_type": 1, "value": "any"},
"interface_id": "00:00:00:00:00:00:00:01:1"
},
"uni_z": {
"tag": {"tag_type": 1, "value": 100},
"interface_id": "00:00:00:00:00:00:00:02:1"
}
}
api_url = KYTOS_API + '/mef_eline/v2/evc/'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
assert response.status_code == 201, response.text
data = response.json()
assert 'circuit_id' in data
time.sleep(10)

h11, h2 = self.net.net.get('h11', 'h2')
h11.cmd('ip link add link %s name vlan100 type vlan id 100' % (h11.intfNames()[0]))
h11.cmd('ip link set up vlan100')
h11.cmd('ip addr add 100.0.0.11/24 dev vlan100')
h2.cmd('ip link add link %s name vlan100 type vlan id 100' % (h2.intfNames()[0]))
h2.cmd('ip link set up vlan100')
h2.cmd('ip addr add 100.0.0.2/24 dev vlan100')
Copy link
Member

Choose a reason for hiding this comment

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

symmetric hosts VLANs I think it's fair game to test this use case, but let's also assert the installed UNI flows on the switches based on your spreadsheet for completeness. @italovalcy let us know if you'd like to see this tested differently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe it is worth adding assertions on the flows besides doing the ping test. Especially since we don't have tests for asymmetric VLANs so far.

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Author

Choose a reason for hiding this comment

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

I divided the PR, here is the correct one for mef_eline

result = h11.cmd('ping -c1 100.0.0.2')
assert ', 0% packet loss,' in result

def test_185_create_100_untagged_evc(self):
payload = {
"name": "evc1",
"dynamic_backup_path": True,
"enabled": True,
"uni_a": {
"tag": {"tag_type": 1, "value": 100},
"interface_id": "00:00:00:00:00:00:00:01:1"
},
"uni_z": {
"tag": {"tag_type": 1, "value": "untagged"},
"interface_id": "00:00:00:00:00:00:00:02:1"
}
}
api_url = KYTOS_API + '/mef_eline/v2/evc/'
response = requests.post(api_url, data=json.dumps(payload), headers={'Content-type': 'application/json'})
assert response.status_code == 201, response.text
data = response.json()
assert 'circuit_id' in data
time.sleep(10)

h11, h2 = self.net.net.get('h11', 'h2')
h11.cmd('ip link add link %s name vlan104 type vlan id 100' % (h11.intfNames()[0]))
h11.cmd('ip link set up vlan104')
h11.cmd('ip addr add 104.0.0.11/24 dev vlan104')
h2.cmd('ip addr add 104.0.0.2/24 dev %s' % (h2.intfNames()[0]))
result = h11.cmd('ping -c1 104.0.0.2')
assert ', 0% packet loss,' in result
61 changes: 61 additions & 0 deletions tests/test_e2e_21_flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,64 @@ def test_031_on_switch_restart_kytos_should_recreate_flows(self):
flows_s1 = s1.dpctl('dump-flows')
assert len(flows_s1.split('\r\n ')) == BASIC_FLOWS + 1, flows_s1
assert 'dl_vlan=999' in flows_s1

def test_032_deserialization_by_restarting_kytos(self):
viniarck marked this conversation as resolved.
Show resolved Hide resolved
"""Test if, after kytos restart, deserialize properly"""

payload = {
"flows": [
{
"priority": 10,
"match": {
"in_port": 1,
"dl_vlan": "4096/4096"
},
"actions": [
{
"action_type": "output",
"port": 2
}
]
},
{
"priority": 10,
"match": {
"in_port": 1,
"dl_vlan": 0
viniarck marked this conversation as resolved.
Show resolved Hide resolved
},
"actions": [
{
"action_type": "output",
"port": 2
}
]
},
]
}

api_url = KYTOS_API + '/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
response = requests.post(api_url, data=json.dumps(payload),
headers={'Content-type': 'application/json'})
assert response.status_code == 202, response.text
data = response.json()
assert 'FlowMod Messages Sent' in data['response']

# wait for the flow to be installed
time.sleep(10)

# OVS does not have a way to actually restart the switch
# so to simulate that, we just delete all flows
s1 = self.net.net.get('s1')
s1.dpctl('del-flows')
# reconnect to trigger and speed up consistency check after the handshake
self.net.reconnect_switches()

# wait for the flow to be installed
time.sleep(10)

flows_s1 = s1.dpctl('dump-flows')
assert len(flows_s1.split('\r\n ')) == BASIC_FLOWS + 2, flows_s1
# 4096/4096
assert 'vlan_tci=0x1000/0x1000' in flows_s1
# 0
assert 'vlan_tci=0x0000/0x1fff' in flows_s1