From fe30c71d4c1c824b4939e9b05d378228c7a1e76b Mon Sep 17 00:00:00 2001 From: Alon Kochba Date: Tue, 4 Apr 2017 16:51:50 +0300 Subject: [PATCH] Add CSIT for openstack-sfc releng/builder patch: https://git.opendaylight.org/gerrit/#/c/54312 Change-Id: I048b77d9ab5c841f027dcba30995ce83bf2b2615 Signed-off-by: Alon Kochba --- csit/libraries/OpenStackOperations.robot | 136 ++++++++++++++++++++ csit/suites/openstack/extensions/sfc.robot | 142 +++++++++++++++++++++ csit/testplans/netvirt-extensions-sfc.txt | 1 + 3 files changed, 279 insertions(+) create mode 100644 csit/suites/openstack/extensions/sfc.robot create mode 100644 csit/testplans/netvirt-extensions-sfc.txt diff --git a/csit/libraries/OpenStackOperations.robot b/csit/libraries/OpenStackOperations.robot index 182127865e..d095251e30 100644 --- a/csit/libraries/OpenStackOperations.robot +++ b/csit/libraries/OpenStackOperations.robot @@ -231,6 +231,25 @@ Create Vm Instances \ ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg} 30s \ Log ${output} +Create Vm Instance With Port + [Arguments] ${port_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default + [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node} + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${port_id}= Get Port Id ${port_name} ${devstack_conn_id} + ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg} 30s + Log ${output} + +Create Vm Instance With Ports + [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default + [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node} + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${port_id}= Get Port Id ${port_name} ${devstack_conn_id} + ${port2_id}= Get Port Id ${port2_name} ${devstack_conn_id} + ${output}= Write Commands Until Prompt nova boot --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-groups ${sg} 30s + Log ${output} + Create Vm Instance With Port On Compute Node [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=cirros-0.3.4-x86_64-uec ${flavor}=m1.nano ${sg}=default [Documentation] Create One VM instance using given ${port_name} and for given ${compute_node} @@ -858,3 +877,120 @@ Create And Configure Security Group Neutron Security Group Rule Create ${sg-name} direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0 Neutron Security Group Rule Create ${sg-name} direction=ingress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0 Neutron Security Group Rule Create ${sg-name} direction=egress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0 + +Create SFC Flow Classifier + [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port} + [Documentation] Create a flow classifier for SFC + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron flow-classifier-create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Created a new flow_classifier + [Return] ${output} + +Delete SFC Flow Classifier + [Arguments] ${name} + [Documentation] Delete a SFC flow classifier + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron flow-classifier-delete ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Deleted flow_classifier + [Return] ${output} + +Create SFC Port Pair + [Arguments] ${name} ${port_in} ${port_out} + [Documentation] Creates a neutron port pair for SFC + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Created a new port_pair + [Return] ${output} + +Delete SFC Port Pair + [Arguments] ${name} + [Documentation] Delete a SFC port pair + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-pair-delete ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Deleted port_pair + [Return] ${output} + +Create SFC Port Pair Group + [Arguments] ${name} ${port_pair} + [Documentation] Creates a port pair group with a single port pair for SFC + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair} ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Created a new port_pair_group + [Return] ${output} + +Create SFC Port Pair Group With Two Pairs + [Arguments] ${name} ${port_pair1} ${port_pair2} + [Documentation] Creates a port pair group with two port pairs for SFC + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Created a new port_pair_group + [Return] ${output} + +Delete SFC Port Pair Group + [Arguments] ${name} + [Documentation] Delete a SFC port pair group + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-pair-group-delete ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Deleted port_pair_group + [Return] ${output} + +Create SFC Port Chain + [Arguments] ${name} ${pg1} ${pg2} ${fc} + [Documentation] Creates a port pair chain with two port groups and a singel classifier. + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Created a new port_chain + [Return] ${output} + +Delete SFC Port Chain + [Arguments] ${name} + [Documentation] Delete a SFC port chain + ${devstack_conn_id}= Get ControlNode Connection + Switch Connection ${devstack_conn_id} + ${cmd}= Set Variable neutron port-chain-delete ${name} + Log ${cmd} + ${output}= Write Commands Until Prompt ${cmd} 30s + Log ${output} + Close Connection + Should Contain ${output} Deleted port_chain + [Return] ${output} diff --git a/csit/suites/openstack/extensions/sfc.robot b/csit/suites/openstack/extensions/sfc.robot new file mode 100644 index 0000000000..8f9fd9ff78 --- /dev/null +++ b/csit/suites/openstack/extensions/sfc.robot @@ -0,0 +1,142 @@ +*** Settings *** +Documentation Test suite to verify SFC configuration and packet flows. +Suite Setup BuiltIn.Run Keywords SetupUtils.Setup_Utils_For_Setup_And_Teardown +... AND DevstackUtils.Devstack Suite Setup +Suite Teardown Close All Connections +Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing +Test Teardown Get Test Teardown Debugs +Library SSHLibrary +Library OperatingSystem +Library RequestsLibrary +Resource ../../../libraries/DevstackUtils.robot +Resource ../../../libraries/OpenStackOperations.robot +Resource ../../../libraries/SetupUtils.robot +Resource ../../../libraries/Utils.robot +Resource ../../../libraries/KarafKeywords.robot + +*** Variables *** +@{NETWORKS_NAME} network_1 +@{SUBNETS_NAME} l2_subnet_1 +@{VM_INSTANCES} sf1 sf2 sf3 source_vm dest_vm +@{SUBNETS_RANGE} 30.0.0.0/24 +@{PORTS} p1in p1out p2in p2out p3in p3out source_vm_port +... dest_vm_port + +*** Test Cases *** +Create VXLAN Network (network_1) + [Documentation] Create Network with neutron request. + Create Network @{NETWORKS_NAME}[0] + +Create Subnets For network_1 + [Documentation] Create Sub Nets for the Networks with neutron request. + Create SubNet @{NETWORKS_NAME}[0] @{SUBNETS_NAME}[0] @{SUBNETS_RANGE}[0] + +Add Allow All Rules + [Documentation] Allow all packets for this suite + Neutron Security Group Create sg-sfc + Neutron Security Group Rule Create sg-sfc direction=ingress port_range_max=65535 port_range_min=1 protocol=tcp remote_ip_prefix=0.0.0.0/0 + Neutron Security Group Rule Create sg-sfc direction=egress port_range_max=65535 port_range_min=1 protocol=tcp remote_ip_prefix=0.0.0.0/0 + Neutron Security Group Rule Create sg-sfc direction=ingress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0 + Neutron Security Group Rule Create sg-sfc direction=egress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0 + Neutron Security Group Rule Create sg-sfc direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0 + Neutron Security Group Rule Create sg-sfc direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0 + +Create Neutron Ports + [Documentation] Precreate neutron ports to be used for SFC VMs + : FOR ${port} IN @{PORTS} + \ Create Port @{NETWORKS_NAME}[0] ${port} sg=sg-sfc + +Create Vm Instances + [Documentation] Create Four Vm instances using flavor and image names for a network. + Create Vm Instance With Ports p1in p1out sf1 sg=sg-sfc + Create Vm Instance With Ports p2in p2out sf2 sg=sg-sfc + Create Vm Instance With Ports p3in p3out sf3 sg=sg-sfc + Create Vm Instance With Port source_vm_port source_vm sg=sg-sfc + Create Vm Instance With Port dest_vm_port dest_vm sg=sg-sfc + +Check Vm Instances Have Ip Address + [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses. + ... We are polling first and longest on the last VM created assuming that if it's received it's address + ... already the other instances should have theirs already or at least shortly thereafter. + # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling + # for dhcp addresses + : FOR ${vm} IN @{VM_INSTANCES} + \ Wait Until Keyword Succeeds 15s 5s Verify VM Is ACTIVE ${vm} + ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 5s Collect VM IP Addresses + ... true @{VM_INSTANCES} + ${NET1_VM_IPS} ${NET1_DHCP_IP} Collect VM IP Addresses false @{VM_INSTANCES} + ${VM_INSTANCES}= Collections.Combine Lists ${VM_INSTANCES} + ${VM_IPS}= Collections.Combine Lists ${NET1_VM_IPS} + ${LOOP_COUNT} Get Length ${VM_INSTANCES} + : FOR ${index} IN RANGE 0 ${LOOP_COUNT} + \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None + \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt nova console-log @{VM_INSTANCES}[${index}] 30s + Set Suite Variable ${NET1_VM_IPS} + Should Not Contain ${NET1_VM_IPS} None + Should Not Contain ${NET1_DHCP_IP} None + [Teardown] Run Keywords Show Debugs @{VM_INSTANCES} + ... AND Get Test Teardown Debugs + +Create Flow Classifiers + [Documentation] Create SFC Flow Classifier for TCP traffic between source VM and destination VM + Create SFC Flow Classifier FC_http @{NET1_VM_IPS}[3] @{NET1_VM_IPS}[4] tcp 80 source_vm_port + +Create Port Pairs + [Documentation] Create SFC Port Pairs + Create SFC Port Pair PP1 p1in p1out + Create SFC Port Pair PP2 p2in p2out + Create SFC Port Pair PP3 p3in p3out + +Create Port Pair Groups + [Documentation] Create SFC Port Pair Groups + Create SFC Port Pair Group With Two Pairs PG1 PP1 PP2 + Create SFC Port Pair Group PG2 PP3 + +Create Port Chain + [Documentation] Create SFC Port Chain using two port groups an classifier created previously + Create SFC Port Chain PC1 PG1 PG2 FC_http + +Start Web Server On Destination VM + [Documentation] Start a simple web server on the destination VM + Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[4] while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $(hostname)" | sudo nc -l -p 80 ; done& + +Add Static Routing On Service Function VMs + [Documentation] Enable eth1 and add static routing between the ports on the SF VMs + : FOR ${INDEX} IN RANGE 0 2 + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces' + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces' + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo /etc/init.d/S40network restart + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward' + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[3] dev eth0 + \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[4] dev eth1 + +Connectivity Tests From Vm Instance1 In network_1 + [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance + # FIXME need to somehow verify it goes through SFs (flows?) + ${DEST_VM_LIST} Create List @{NET1_VM_IPS}[4] + Test Operations From Vm Instance network_1 @{NET1_VM_IPS}[3] ${DEST_VM_LIST} + Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[3] curl http://@{NET1_VM_IPS}[4] + +Delete Vm Instances In network_1 + [Documentation] Delete Vm instances using instance names in network_1. + : FOR ${VmElement} IN @{VM_INSTANCES} + \ Delete Vm Instance ${VmElement} + +Delete All SFC Objects + [Documentation] Delete all previously created SFC objects + Delete SFC Port Chain PC1 + Delete SFC Port Pair Group PG1 + Delete SFC Port Pair Group PG2 + Delete SFC Port Pair PP1 + Delete SFC Port Pair PP2 + Delete SFC Port Pair PP3 + Delete SFC Flow Classifier FC_http + +Delete Sub Networks In network_1 + [Documentation] Delete Sub Nets for the Networks with neutron request. + Delete SubNet l2_subnet_1 + +Delete Networks + [Documentation] Delete Networks with neutron request. + : FOR ${NetworkElement} IN @{NETWORKS_NAME} + \ Delete Network ${NetworkElement} diff --git a/csit/testplans/netvirt-extensions-sfc.txt b/csit/testplans/netvirt-extensions-sfc.txt new file mode 100644 index 0000000000..e34806bae7 --- /dev/null +++ b/csit/testplans/netvirt-extensions-sfc.txt @@ -0,0 +1 @@ +integration/test/csit/suites/openstack/extensions/sfc.robot -- 2.36.6