aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2016-05-16 18:20:30 +0200
committerMatej Klotton <mklotton@cisco.com>2016-05-20 11:30:44 +0000
commit95bf11e637855dc91e490f526406fa7538a21ac6 (patch)
tree26602cc2fc8baf7fd9bdcf5928c2ee7efb61c1a9
parentc2f8b62e978c4f5f29fa3ad3ccba6683a9f3ea85 (diff)
Tests for vhost-user interface configuration
JIRA: CSIT-76 - add tests for vhost-user interface manipulation: - create, modify, delete - add negative tests: - wrong interface type - wrong configuration Change-Id: I09239ef099a6f9672895f9540762e5044123f7ec Signed-off-by: Tibor Frank <tifrank@cisco.com>
-rw-r--r--resources/libraries/python/InterfaceUtil.py15
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwInterfaces.py1
-rw-r--r--resources/libraries/robot/honeycomb/vhost_user.robot182
-rw-r--r--resources/templates/vat/vhost_user_dump.vat1
-rw-r--r--tests/suites/honeycomb/5 - interface_vhost_user.robot167
5 files changed, 366 insertions, 0 deletions
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index 94250fba28..1c1ada8f6c 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -529,6 +529,21 @@ class InterfaceUtil(object):
return response[0]
@staticmethod
+ def vhost_user_dump(node):
+ """Get vhost-user data for the given node.
+
+ :param node: VPP node to get interface data from.
+ :type node: dict
+ :return: List of dictionaries with all vhost-user interfaces.
+ :rtype: list
+ """
+ with VatTerminal(node) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ "vhost_user_dump.vat")
+
+ return response[0]
+
+ @staticmethod
def create_subinterface(node, interface, sub_id, outer_vlan_id,
inner_vlan_id, type_subif):
"""Create sub-interface on node.
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
index 04800a24b5..3f9e9d16a5 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
@@ -25,6 +25,7 @@ from resources.libraries.python.honeycomb.HoneycombUtil \
import HoneycombUtil as HcUtil
+# pylint: disable=too-many-public-methods
class InterfaceKeywords(object):
"""Keywords for Interface manipulation.
diff --git a/resources/libraries/robot/honeycomb/vhost_user.robot b/resources/libraries/robot/honeycomb/vhost_user.robot
new file mode 100644
index 0000000000..1d585041a4
--- /dev/null
+++ b/resources/libraries/robot/honeycomb/vhost_user.robot
@@ -0,0 +1,182 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+| Library | resources.libraries.python.InterfaceUtil
+| ... | WITH NAME | interfaceCLI
+| Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
+| ... | WITH NAME | InterfaceAPI
+| Documentation | Keywords used to manipulate vhost-user unterfaces.
+
+*** Keywords ***
+| Honeycomb creates vhost-user interface
+| | [Documentation] | Create a vhost-user interface using Honeycomb API.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ... | - settings - Configuration data for vhost-user interface.\
+| | ... | Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Honeycomb creates vhost-user interface\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${settings}
+| | interfaceAPI.Create vhost user interface | ${node} | ${interface}
+| | ... | &{settings}
+
+| Honeycomb removes vhost-user interface
+| | [Documentation] | Remove a vhost-user interface using Honeycomb API.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ...
+| | ... | *Example:*
+| | ... | \| Honeycomb removes vhost-user interface\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \|
+| | ...
+| | [Arguments] | ${node} | ${interface}
+| | interfaceAPI.Delete interface | ${node} | ${interface}
+
+| Honeycomb configures vhost-user interface
+| | [Documentation] | Configure a vhost-user interface using Honeycomb API.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ... | - settings - Configuration data for vhost-user interface.\
+| | ... | Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Honeycomb configures vhost-user interface\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \| ${new_vhost_user_settings} \|
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${settings}
+| | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
+| | ... | &{settings}
+
+| Vhost-user configuration from Honeycomb should be
+| | [Documentation] | Retrieves interface vhost-user configuration through\
+| | ... | Honeycomb and compares it with settings supplied in argument.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ... | - settings - Configuration data for vhost-user interface.\
+| | ... | Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Vhost-user configuration from Honeycomb should be\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${settings}
+| | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
+| | ${api_vhost}= | Set Variable | ${api_data['v3po:vhost-user']}
+| | :FOR | ${key} | IN | @{settings.keys()}
+| | | Should be equal | ${api_vhost['${key}']} | ${settings['${key}']}
+
+| Vhost-user configuration from VAT should be
+| | [Documentation] | Retrieves interface vhost-user configuration through VAT\
+| | ... | and compares it with settings supplied in argument.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - settings - Configuration data for vhost-user interface.\
+| | ... | Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Vhost-user configuration from VAT should be\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \|
+| | ...
+| | ... | *Note:*
+| | ... | Due to the difficulty of identifying newly created interfaces by name\
+| | ... | or by sw_index, this keyword assumes there is only one vhost-user\
+| | ... | interface present on the specified node.
+| | ...
+| | [Arguments] | ${node} | ${settings}
+| | &{translate}= | Create dictionary | server=1 | client=0
+| | ${vat_data}= | vhost user Dump | ${node}
+| | ${vat_data}= | Set Variable | ${vat_data[0]}
+| | Should be equal | ${vat_data['sock_filename']} | ${settings['socket']}
+| | should be equal as strings | ${vat_data['is_server']}
+| | ... | ${translate['${settings['role']}']}
+
+| Vhost-user configuration from Honeycomb should be empty
+| | [Documentation] | Attempts to retrieve interface vhost-user configuration\
+| | ... | through Honeycomb and expects to recieve an empty dictionary.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ...
+| | ... | *Example:*
+| | ... | \| Vhost-user configuration from Honeycomb should be empty\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \|
+| | ...
+| | [Arguments] | ${node} | ${interface}
+| | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
+| | Run keyword and expect error | *KeyError: 'v3po:vhost-user'
+| | ... | Should be empty | ${api_data['v3po:vhost-user']}
+
+| Vhost-user configuration from VAT should be empty
+| | [Documentation] | Attempts to retrieve interface vhost-user configuration\
+| | ... | through VAT and expects a "no data" error.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Vhost-user configuration from VAT should be empty\
+| | ... | \| ${nodes['DUT1']} \|
+| | ...
+| | [Arguments] | ${node}
+| | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
+| | ... | vhost user Dump | ${node}
+
+| Honeycomb fails setting vhost-user on different interface type
+| | [Documentation] | Attempts to set vhost-user settings on an ethernet\
+| | ... | type interface and expects to fail.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ... | - settings - Configuration data for vhost-user. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ... | \| Honeycomb fails setting vhost-user on different interface type\
+| | ... | \| ${nodes['DUT1']} \| ${interface} \| ${vhost_user_settings} \|
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${settings}
+| | Run Keyword And Expect Error | HoneycombError: * Status code: 500.
+| | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
+| | ... | &{settings}
+
+| Honeycomb fails setting invalid vhost-user configuration
+| | [Documentation] | Attempts to create a vhost-user interface with invalid\
+| | ... | configuration and expects to fail.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of an interface on the specified node. Type: string
+| | ... | - settings_list - Bad configuration data for vhost-user. Type: list
+| | ...
+| | ... | *Example:*
+| | ... | \| Honeycomb fails setting invalid vhost-user configuration\
+| | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${settings}
+| | Run Keyword And Expect Error | HoneycombError: * Status code: 400.
+| | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface} |
+| | ... | &{settings}
diff --git a/resources/templates/vat/vhost_user_dump.vat b/resources/templates/vat/vhost_user_dump.vat
new file mode 100644
index 0000000000..6a3d7a5130
--- /dev/null
+++ b/resources/templates/vat/vhost_user_dump.vat
@@ -0,0 +1 @@
+sw_interface_vhost_user_dump \ No newline at end of file
diff --git a/tests/suites/honeycomb/5 - interface_vhost_user.robot b/tests/suites/honeycomb/5 - interface_vhost_user.robot
new file mode 100644
index 0000000000..505eb8929b
--- /dev/null
+++ b/tests/suites/honeycomb/5 - interface_vhost_user.robot
@@ -0,0 +1,167 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Variables ***
+| ${node}= | ${nodes['DUT1']}
+| ${interface}= | ${node['interfaces']['port1']['name']}
+| ${vhost_interface}= | test_vhost
+| &{vhost_user_server}= | socket=soc1 | role=server
+| &{vhost_user_server_edit_1}= | socket=soc12 | role=server
+| &{vhost_user_server_edit_2}= | socket=soc12 | role=client
+| &{vhost_user_client}= | socket=soc2 | role=client
+| &{vhost_user_client_edit_1}= | socket=soc22 | role=client
+| &{vhost_user_client_edit_2}= | socket=soc22 | role=server
+| &{vhost_user_wrong}= | socket=soc2 | role=wrong
+
+*** Settings ***
+| Resource | resources/libraries/robot/default.robot
+| Resource | resources/libraries/robot/honeycomb/vhost_user.robot
+| Documentation | *Honeycomb vhost-user interface management test suite.*
+| ...
+| ... | This test suite tests if it is posible to create, modify and\
+| ... | delete a vhost-user interface.
+
+*** Test Cases ***
+| Honycomb creates vhost-user interface - server
+| | [Documentation] | Check if Honeycomb creates a vhost-user interface, role:\
+| | ... | server.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | When Honeycomb creates vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_server}
+
+| Honycomb modifies vhost-user interface - server
+| | [Documentation] | Check if Honeycomb can modify properties of existing\
+| | ... | vhost-user interface, role: server.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server_edit_1}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server_edit_1}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_server_edit_1}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server_edit_2}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server_edit_2}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_server_edit_2}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_server}
+
+| Honycomb deletes vhost-user interface - server
+| | [Documentation] | Check if Honeycomb can delete an existing vhost-user\
+| | ... | interface, role: server.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_server}
+| | When Honeycomb removes vhost-user interface
+| | ... | ${node} | ${vhost_interface}
+| | Then vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | And vhost-user configuration from VAT should be empty
+| | ... | ${node}
+
+| Honycomb creates vhost-user interface - client
+| | [Documentation] | Check if Honeycomb creates a vhost-user interface, role:\
+| | ... | client.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | When Honeycomb creates vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_client}
+
+| Honycomb modifies vhost-user interface - client
+| | [Documentation] | Check if Honeycomb can modify properties of existing\
+| | ... | vhost-user interface, role: client.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client_edit_1}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client_edit_1}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_client_edit_1}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client_edit_2}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client_edit_2}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_client_edit_2}
+| | When Honeycomb configures vhost-user interface
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | Then vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | And vhost-user configuration from VAT should be
+| | ... | ${node} | ${vhost_user_client}
+
+| Honycomb deletes vhost-user interface - client
+| | [Documentation] | Check if Honeycomb can delete an existing vhost-user\
+| | ... | interface, role: client.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_client}
+| | When Honeycomb removes vhost-user interface
+| | ... | ${node} | ${vhost_interface}
+| | Then vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | And vhost-user configuration from VAT should be empty
+| | ... | ${node}
+
+| Honeycomb does not set vhost-user configuration on another interface type
+| | [Documentation] | Check if Honeycomb refuses to set vhost-user\
+| | ... | configuration for interface which is not v3po:vhost-user type.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | When Honeycomb fails setting vhost-user on different interface type
+| | ... | ${node} | ${interface} | ${vhost_user_server}
+| | Then vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${interface}
+| | And vhost-user configuration from VAT should be empty
+| | ... | ${node}
+
+| Honeycomb does not set invalid vhost-user configuration
+| | [Documentation] | Check if Honeycomb refuses to set invalid parameters to\
+| | ... | vhost-user interface.
+| | [Tags] | honeycomb_sanity
+| | ...
+| | Given vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | When Honeycomb fails setting invalid vhost-user configuration
+| | ... | ${node} | ${vhost_interface} | ${vhost_user_wrong}
+| | Then vhost-user configuration from Honeycomb should be empty
+| | ... | ${node} | ${vhost_interface}
+| | And vhost-user configuration from VAT should be empty
+| | ... | ${node}