Tests for vhost-user interface configuration
[csit.git] / resources / libraries / robot / honeycomb / vhost_user.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.InterfaceUtil
16 | ...     | WITH NAME | interfaceCLI
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ...     | WITH NAME | InterfaceAPI
19 | Documentation | Keywords used to manipulate vhost-user unterfaces.
20
21 *** Keywords ***
22 | Honeycomb creates vhost-user interface
23 | | [Documentation] | Create a vhost-user interface using Honeycomb API.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - interface - name of an interface on the specified node. Type: string
28 | | ... | - settings - Configuration data for vhost-user interface.\
29 | | ... | Type: dictionary
30 | | ...
31 | | ... | *Example:*
32 | | ... | \| Honeycomb creates vhost-user interface\
33 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
34 | | ...
35 | | [Arguments] | ${node} | ${interface} | ${settings}
36 | | interfaceAPI.Create vhost user interface | ${node} | ${interface}
37 | | ... | &{settings}
38
39 | Honeycomb removes vhost-user interface
40 | | [Documentation] | Remove a vhost-user interface using Honeycomb API.
41 | | ...
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - interface - name of an interface on the specified node. Type: string
45 | | ...
46 | | ... | *Example:*
47 | | ... | \| Honeycomb removes vhost-user interface\
48 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
49 | | ...
50 | | [Arguments] | ${node} | ${interface}
51 | | interfaceAPI.Delete interface | ${node} | ${interface}
52
53 | Honeycomb configures vhost-user interface
54 | | [Documentation] | Configure a vhost-user interface using Honeycomb API.
55 | | ...
56 | | ... | *Arguments:*
57 | | ... | - node - information about a DUT node. Type: dictionary
58 | | ... | - interface - name of an interface on the specified node. Type: string
59 | | ... | - settings - Configuration data for vhost-user interface.\
60 | | ... | Type: dictionary
61 | | ...
62 | | ... | *Example:*
63 | | ... | \| Honeycomb configures vhost-user interface\
64 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${new_vhost_user_settings} \|
65 | | ...
66 | | [Arguments] | ${node} | ${interface} | ${settings}
67 | | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
68 | | ... | &{settings}
69
70 | Vhost-user configuration from Honeycomb should be
71 | | [Documentation] | Retrieves interface vhost-user configuration through\
72 | | ... | Honeycomb and compares it with settings supplied in argument.
73 | | ...
74 | | ... | *Arguments:*
75 | | ... | - node - information about a DUT node. Type: dictionary
76 | | ... | - interface - name of an interface on the specified node. Type: string
77 | | ... | - settings - Configuration data for vhost-user interface.\
78 | | ... | Type: dictionary
79 | | ...
80 | | ... | *Example:*
81 | | ... | \| Vhost-user configuration from Honeycomb should be\
82 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
83 | | ...
84 | | [Arguments] | ${node} | ${interface} | ${settings}
85 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
86 | | ${api_vhost}= | Set Variable | ${api_data['v3po:vhost-user']}
87 | | :FOR | ${key} | IN | @{settings.keys()}
88 | | | Should be equal | ${api_vhost['${key}']} | ${settings['${key}']}
89
90 | Vhost-user configuration from VAT should be
91 | | [Documentation] | Retrieves interface vhost-user configuration through VAT\
92 | | ... | and compares it with settings supplied in argument.
93 | | ...
94 | | ... | *Arguments:*
95 | | ... | - node - information about a DUT node. Type: dictionary
96 | | ... | - settings - Configuration data for vhost-user interface.\
97 | | ... | Type: dictionary
98 | | ...
99 | | ... | *Example:*
100 | | ... | \| Vhost-user configuration from VAT should be\
101 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
102 | | ...
103 | | ... | *Note:*
104 | | ... | Due to the difficulty of identifying newly created interfaces by name\
105 | | ... | or by sw_index, this keyword assumes there is only one vhost-user\
106 | | ... | interface present on the specified node.
107 | | ...
108 | | [Arguments] | ${node} | ${settings}
109 | | &{translate}= | Create dictionary | server=1 | client=0
110 | | ${vat_data}= | vhost user Dump | ${node}
111 | | ${vat_data}= | Set Variable | ${vat_data[0]}
112 | | Should be equal | ${vat_data['sock_filename']} | ${settings['socket']}
113 | | should be equal as strings | ${vat_data['is_server']}
114 | | ... | ${translate['${settings['role']}']}
115
116 | Vhost-user configuration from Honeycomb should be empty
117 | | [Documentation] | Attempts to retrieve interface vhost-user configuration\
118 | | ... | through Honeycomb and expects to recieve an empty dictionary.
119 | | ...
120 | | ... | *Arguments:*
121 | | ... | - node - information about a DUT node. Type: dictionary
122 | | ... | - interface - name of an interface on the specified node. Type: string
123 | | ...
124 | | ... | *Example:*
125 | | ... | \| Vhost-user configuration from Honeycomb should be empty\
126 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
127 | | ...
128 | | [Arguments] | ${node} | ${interface}
129 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
130 | | Run keyword and expect error | *KeyError: 'v3po:vhost-user'
131 | | ... | Should be empty | ${api_data['v3po:vhost-user']}
132
133 | Vhost-user configuration from VAT should be empty
134 | | [Documentation] | Attempts to retrieve interface vhost-user configuration\
135 | | ... | through VAT and expects a "no data" error.
136 | | ...
137 | | ... | *Arguments:*
138 | | ... | - node - information about a DUT node. Type: dictionary
139 | | ...
140 | | ... | *Example:*
141 | | ... | \| Vhost-user configuration from VAT should be empty\
142 | | ... | \| ${nodes['DUT1']} \|
143 | | ...
144 | | [Arguments] | ${node}
145 | | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
146 | | ... | vhost user Dump | ${node}
147
148 | Honeycomb fails setting vhost-user on different interface type
149 | | [Documentation] | Attempts to set vhost-user settings on an ethernet\
150 | | ... | type interface and expects to fail.
151 | | ...
152 | | ... | *Arguments:*
153 | | ... | - node - information about a DUT node. Type: dictionary
154 | | ... | - interface - name of an interface on the specified node. Type: string
155 | | ... | - settings - Configuration data for vhost-user. Type: dictionary
156 | | ...
157 | | ... | *Example:*
158 | | ... | \| Honeycomb fails setting vhost-user on different interface type\
159 | | ... | \| ${nodes['DUT1']} \| ${interface} \| ${vhost_user_settings} \|
160 | | ...
161 | | [Arguments] | ${node} | ${interface} | ${settings}
162 | | Run Keyword And Expect Error | HoneycombError: * Status code: 500.
163 | | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
164 | | ... | &{settings}
165
166 | Honeycomb fails setting invalid vhost-user configuration
167 | | [Documentation] | Attempts to create a vhost-user interface with invalid\
168 | | ... | configuration and expects to fail.
169 | | ...
170 | | ... | *Arguments:*
171 | | ... | - node - information about a DUT node. Type: dictionary
172 | | ... | - interface - name of an interface on the specified node. Type: string
173 | | ... | - settings_list - Bad configuration data for vhost-user. Type: list
174 | | ...
175 | | ... | *Example:*
176 | | ... | \| Honeycomb fails setting invalid vhost-user configuration\
177 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
178 | | ...
179 | | [Arguments] | ${node} | ${interface} | ${settings}
180 | | Run Keyword And Expect Error | HoneycombError: * Status code: 400.
181 | | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface} |
182 | | ... | &{settings}