af24d56e375665df4b8b1dd0e237c44bbc964976
[csit.git] / resources / libraries / robot / honeycomb / nat.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.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
16 | Library | resources.libraries.python.honeycomb.NAT.NATKeywords
17 | Library | resources.libraries.python.NAT.NATUtil
18 | Documentation | Keywords used to test Honeycomb NAT node.
19
20 *** Keywords ***
21 | NAT configuration from Honeycomb should be empty
22 | | [Documentation] | Uses Honeycomb API to retrieve NAT operational data\
23 | | ... | and expects to find only default values.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - default_settings - NAT default settings. Type: dictionary
28 | | ...
29 | | ... | *Example:*
30 | | ...
31 | | ... | \| NAT configuration from Honeycomb should be empty \
32 | | ... | \| ${nodes['DUT1']} \| ${default_settings} \|
33 | | [Arguments] | ${node} | ${default_settings}
34 | | ${data}= | Get NAT Oper data | ${node}
35 | | Compare data structures | ${data} | ${default_settings}
36
37 | Honeycomb configures NAT entry
38 | | [Documentation] | Uses Honeycomb API to configure a static NAT entry.
39 | | ...
40 | | ... | *Arguments:*
41 | | ... | - node - information about a DUT node. Type: dictionary
42 | | ... | - data - NAT entry to configure. Type: dictionary
43 | | ... | - instance - NAT instance on VPP node. Type: integer
44 | | ... | - index - Index of NAT entry. Type: integer
45 | | ...
46 | | ... | *Example:*
47 | | ...
48 | | ... | \| Honeycomb configures NAT entry \| ${nodes['DUT1']} \| ${data} \
49 | | ... | \| ${0} \| ${1} \|
50 | | [Arguments] | ${node} | ${data} | ${instance}=0 | ${index}=1
51 | | Configure NAT entries | ${node} | ${data} | ${instance} | ${index}
52
53 | NAT entries from Honeycomb should be
54 | | [Documentation] | Uses Honeycomb API to retrieve NAT operational data\
55 | | ... | and compares against expected settings.
56 | | ...
57 | | ... | *Arguments:*
58 | | ... | - node - information about a DUT node. Type: dictionary
59 | | ... | - settings - NAT entry to expect. Type: dictionary
60 | | ... | - instance - NAT instance on VPP node. Type: integer
61 | | ...
62 | | ... | *Example:*
63 | | ...
64 | | ... | \| NAT entries from Honeycomb should be \| ${nodes['DUT1']} \
65 | | ... | \| ${settings} \| ${0} \|
66 | | [Arguments] | ${node} | ${settings} | ${instance}=0
67 | | ${data}= | Get NAT Oper data | ${node}
68 | | ${data}= | Set Variable
69 | | ... | ${data['nat-instances']['nat-instance'][${instance}]['mapping-table']}
70 | | Compare data structures | ${data} | ${settings}
71
72 | NAT entries from VAT should be
73 | | [Documentation] | Uses VPP test API to retrieve NAT entries\
74 | | ... | and compares against expected settings.
75 | | ...
76 | | ... | *Arguments:*
77 | | ... | - node - information about a DUT node. Type: dictionary
78 | | ... | - settings - NAT entry to expect. Type: dictionary
79 | | ...
80 | | ... | *Example:*
81 | | ...
82 | | ... | \| NAT entries from VAT should be \| ${nodes['DUT1']} \
83 | | ... | \| ${settings} \|
84 | | [Arguments] | ${node} | ${settings}
85 | | ${data}= | VPP get NAT static mappings | ${node}
86 | | Compare data structures | ${data} | ${settings}
87
88 | Honeycomb configures NAT on interface
89 | | [Documentation] | Uses Honeycomb API to configure NAT on an interface.
90 | | ...
91 | | ... | *Arguments:*
92 | | ... | - node - information about a DUT node. Type: dictionary
93 | | ... | - interface - name of an interface on the node. Type: string
94 | | ... | - direction - NAT direction parameter, inbound or outbound.\
95 | | ... | Type: string
96 | | ...
97 | | ... | *Example:*
98 | | ...
99 | | ... | \| Honeycomb configures NAT on interface \| ${nodes['DUT1']} \
100 | | ... | \| GigabitEthernet0/8/0 \| outbound \|
101 | | [Arguments] | ${node} | ${interface} | ${direction}
102 | | Configure NAT on interface
103 | | ... | ${node} | ${interface} | ${direction}
104
105 | Honeycomb removes NAT interface configuration
106 | | [Documentation] | Uses Honeycomb API to remove an existing NAT interface\
107 | | ... | configuration.
108 | | ...
109 | | ... | *Arguments:*
110 | | ... | - node - information about a DUT node. Type: dictionary
111 | | ... | - interface - name of an interface on the node. Type: string
112 | | ... | - direction - NAT direction parameter, inbound or outbound.\
113 | | ... | Type: string
114 | | ...
115 | | ... | *Example:*
116 | | ...
117 | | ... | \| Honeycomb removes NAT interface configuration \| ${nodes['DUT1']} \
118 | | ... | \| GigabitEthernet0/8/0 \| outbound \|
119 | | [Arguments] | ${node} | ${interface} | ${direction}
120 | | Configure NAT on interface
121 | | ... | ${node} | ${interface} | ${direction} | ${True}
122
123 | NAT interface configuration from Honeycomb should be
124 | | [Documentation] | Uses Honeycomb API to retrieve interface operational data\
125 | | ... | and compares the NAT section against expected settings.
126 | | ...
127 | | ... | *Arguments:*
128 | | ... | - node - information about a DUT node. Type: dictionary
129 | | ... | - interface - name of an interface on the node. Type: string
130 | | ... | - direction - NAT direction parameter, inbound or outbound.\
131 | | ... | Type: string
132 | | ...
133 | | ... | *Example:*
134 | | ...
135 | | ... | \| NAT interface configuration from Honeycomb should be \
136 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| outbound \|
137 | | [Arguments] | ${node} | ${interface} | ${direction}
138 | | ${data}= | Get interface oper data | ${node} | ${interface}
139 | | Variable should exist | ${data['interface-nat:nat']['${direction}']}
140
141 | NAT interface configuration from Honeycomb should be empty
142 | | [Documentation] | Uses Honeycomb API to retrieve interface operational data\
143 | | ... | and expects to find no data for the given direction.
144 | | ...
145 | | ... | *Arguments:*
146 | | ... | - node - information about a DUT node. Type: dictionary
147 | | ... | - interface - name of an interface on the node. Type: string
148 | | ... | - direction - NAT direction parameter, inbound or outbound.\
149 | | ... | Type: string
150 | | ...
151 | | ... | *Example:*
152 | | ...
153 | | ... | \| NAT interface configuration from Honeycomb should be empty \
154 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| outbound \|
155 | | [Arguments] | ${node} | ${interface} | ${direction}
156 | | ${data}= | Get interface oper data | ${node} | ${interface}
157 | | Variable should not exist | ${data['interface-nat:nat']['${direction}']}
158
159 | NAT interface configuration from VAT should be
160 | | [Documentation] | Uses Honeycomb API to retrieve NAT configured interfaces\
161 | | ... | and compares with expected settings.
162 | | ...
163 | | ... | *Arguments:*
164 | | ... | - node - information about a DUT node. Type: dictionary
165 | | ... | - settings - settings to expect. Type: dictionary
166 | | ... | Type: string
167 | | ...
168 | | ... | *Example:*
169 | | ...
170 | | ... | \| NAT interface configuration from VAT should be \
171 | | ... | \| ${nodes['DUT1']} \| ${settings} \|
172 | | [Arguments] | ${node} | ${settings}
173 | | ${data}= | VPP get NAT interfaces | ${node}
174 | | Compare data structures | ${data[0]} | ${settings}