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

E2e tests #9

Merged
merged 7 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions tests/test_05_l2vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,4 @@ def test_060_link_convergency_with_l2vpn_with_alternative_paths(self):
time.sleep(30)
result = h1.cmd('ping -c4 10.1.1.8')
assert ', 100% packet loss,' in result

317 changes: 317 additions & 0 deletions tests/test_06_l2vpn_return_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
import json
import re
import time
from datetime import datetime, timedelta
import uuid

import pytest
from random import randrange
import requests

from tests.helpers import NetworkTest

SDX_CONTROLLER = 'http://sdx-controller:8080/SDX-Controller'

class TestE2EReturnCodes:
net = None

@classmethod
def setup_class(cls):
cls.net = NetworkTest(["ampath", "sax", "tenet"])
cls.net.wait_switches_connect()
cls.net.run_setup_topo()

@classmethod
def teardown_class(cls):
cls.net.stop()

def test_010_code201(self):
italovalcy marked this conversation as resolved.
Show resolved Hide resolved
"""
Test the return code for creating a SDX L2VPN
201: L2VPN Service Created
P2P with VLAN translation
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/100 and TENET/150",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "100",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "150",},
italovalcy marked this conversation as resolved.
Show resolved Hide resolved
],}
italovalcy marked this conversation as resolved.
Show resolved Hide resolved
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

def test_011_code201(self):
italovalcy marked this conversation as resolved.
Show resolved Hide resolved
"""
Test the return code for creating a SDX L2VPN
201: L2VPN Service Created
P2P with option "any"
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/300 and TENET/any",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "300",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "any",},
],}
italovalcy marked this conversation as resolved.
Show resolved Hide resolved
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

@pytest.mark.xfail(reason="return status 400: PCE error: Can't find a valid vlan breakdown solution")
def test_012_code201(self):
"""
Test the return code for creating a SDX L2VPN
201: L2VPN Service Created
P2P with VLAN range
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLANs 10-99 between AMPATH and SAX",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "10-99",},
{"port_id": "urn:sdx:port:sax.net:Sax01:50","vlan": "10-99",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

@pytest.mark.xfail(reason="return status 400: PCE error: Can't find a valid vlan breakdown solution")
def test_013_code201(self):
"""
Test the return code for creating a SDX L2VPN
201: L2VPN Service Created
P2P with "untagged" and a VLAN ID
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/400 and SAX/untagged",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "400",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "untagged",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

def test_014_code201(self):
"""
Test the return code for creating a SDX L2VPN
201: L2VPN Service Created
Example with optional attributes
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/700 and TENET/700",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "700",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "700",},
],
"description": "Example to demonstrate a L2VPN with optional attributes",
"scheduling": {
"end_time": "2025-12-31T12:00:00Z"},
"qos_metrics": {
"min_bw": {"value": 5,"strict": False},
"max_delay": {"value": 150,"strict": True},
"max_number_oxps": {"value": 3}},
"notifications": [
{"email": "[email protected]"},
{"email": "[email protected]"}
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

def test_020_code400(self):
"""
Test the return code for creating a SDX L2VPN
400: Request does not have a valid JSON or body is incomplete/incorrect
-> Wrong vlan: vlan is not a string
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "Test L2VPN request",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": 100,},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "any",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 400, response.text

def test_021_code400(self):
"""
Test the return code for creating a SDX L2VPN
400: Request does not have a valid JSON or body is incomplete/incorrect
-> Wrong vlan: vlan is out of range 1-4095
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "Test L2VPN request",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "5000",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "any",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 400, response.text

def test_022_code400(self):
"""
Test the return code for creating a SDX L2VPN
400: Request does not have a valid JSON or body is incomplete/incorrect
-> Wrong vlan: since one endpoint has the "all" option, all endpoints must have the same value
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "Test L2VPN request",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "all",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "any",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 400, response.text

@pytest.mark.xfail(reason="return status 200: Connection published -- same behavior as vlan = 'any'")
def test_023_code400(self):
"""
Test the return code for creating a SDX L2VPN
400: Request does not have a valid JSON or body is incomplete/incorrect
-> Body incomplete: vlan attribute is missing on an endpoint
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "Test L2VPN request",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "500",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50"},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 400, response.text

@pytest.mark.xfail(reason="return status 402: Could not generate a traffic matrix")
def test_024_code400(self):
"""
Test the return code for creating a SDX L2VPN
400: Request does not have a valid JSON or body is incomplete/incorrect
-> Body incorrect: port_id
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "Test L2VPN request",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath","vlan": "600",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "600",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 400, response.text

@pytest.mark.xfail(reason="return status 500: Internal Server Error")
def test_030_code402(self):
"""
Test the return code for creating a SDX L2VPN
402: Request not compatible (For instance, when a L2VPN P2MP is requested but only L2VPN P2P is supported)
P2MP
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN ID 200 at AMPATH, TENET, at SAX",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50", "vlan": "200"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "200"},
{"port_id": "urn:sdx:port:sax.net:Sax01:50","vlan": "200",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 402, response.text

@pytest.mark.xfail(reason="return status 400: PCE error: Can't find a valid vlan breakdown solution")
def test_040_code409(self):
"""
Test the return code for creating a SDX L2VPN
409: L2VPN Service already exists
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between TENET/1000 and SAX/1000",
"endpoints": [
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "1000"},
{"port_id": "urn:sdx:port:sax.net:Sax01:50","vlan": "1000",},
],}
response = requests.post(api_url, json=payload)
assert response.status_code == 201, response.text

time.sleep(30)

response = requests.post(api_url, json=payload)
assert response.status_code == 409, response.text

def test_050_code410(self):
"""
Test the return code for creating a SDX L2VPN
410: Can't fulfill the strict QoS requirements
Case: min_bw out of range (value must be in [0-100])
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/2000 and TENET/2000",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "2000",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "2000",},
],
"qos_metrics": {
"min_bw": {"value": 101}}
}
response = requests.post(api_url, json=payload)
assert response.status_code == 410, response.text

@pytest.mark.xfail(reason="return status 201: Connection published")
def test_051_code410(self):
"""
Test the return code for creating a SDX L2VPN
410: Can't fulfill the strict QoS requirements
Case: max_delay out of range (value must be in [0-1000])
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/2010 and TENET/2010",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "2010",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "2010",},
],
"qos_metrics": {
"max_delay": {"value": 1001}}}
response = requests.post(api_url, json=payload)
assert response.status_code == 410, response.text

@pytest.mark.xfail(reason="return status 201: Connection published")
def test_052_code410(self):
"""
Test the return code for creating a SDX L2VPN
410: Can't fulfill the strict QoS requirements
Case: max_number_oxps out of range (value must be in [0-100])
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/2020 and TENET/2020",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "2020",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "2020",},
],
"qos_metrics": {
"max_number_oxps": {"value": 101}}}
response = requests.post(api_url, json=payload)
assert response.status_code == 410, response.text

@pytest.mark.xfail(reason="return status 201: Connection published")
def test_060_code411(self):
"""
Test the return code for creating a SDX L2VPN
411: Scheduling not possible
end_time before current date
"""
api_url = SDX_CONTROLLER + '/l2vpn/1.0'
payload = {
"name": "VLAN between AMPATH/2030 and TENET/2030",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50","vlan": "2030",},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50","vlan": "2030",},
],
"scheduling": {
"end_time": "2023-12-30"}
}
response = requests.post(api_url, json=payload)
assert response.status_code == 411, response.text