Fix bgp l2vpn evpn test
[integration/test.git] / csit / suites / iotdm / basic / 092_ResourceHierarchyAE_CNT_CIN.robot
1 *** Settings ***
2 Documentation     Test for hierarchy of resources: AE/CONTAINER/CONTENTINSTANCE
3 Suite Setup       IOTDM Basic Suite Setup    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}
4 Suite Teardown    Kill The Tree    ${ODL_SYSTEM_1_IP}    InCSE1    admin    admin
5 Resource          ../../../libraries/SubStrings.robot
6 Library           ../../../libraries/IoTDM/criotdm.py
7 Library           Collections
8 Resource          ../../../variables/Variables.robot
9 Resource          ../../../libraries/IoTDM/IoTDMKeywords.robot
10
11 *** Variables ***
12 ${rt_ae}          2
13 ${rt_container}    3
14 ${rt_contentInstance}    4
15
16 *** Test Cases ***
17 1.11 Valid Input for AE without name
18     [Documentation]    Valid Input for AE without name
19     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
20     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}
21     Response Is Correct    ${r}
22
23 1.12 Valid Input for AE with name
24     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL3"
25     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}
26     Response Is Correct    ${r}
27
28 1.13 Invalid Input for AE with name Already Exist, should return error
29     [Documentation]    Invalid Input for AE with name Already Exist, should return error
30     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL3"
31     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_ae}
32     ...    ${attr}
33     Should Start with    ${error}    Cannot create this resource [409]
34
35 1.14 Invalid Input for AE (AE cannot be created under AE)
36     [Documentation]    Invalid Input for AE (AE cannot be created under AE), expect error
37     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL4"
38     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/ODL3    ${rt_ae}
39     ...    ${attr}
40     Should Start with    ${error}    Cannot create this resource [405]
41     # -----------------    Update and Retrieve -------------
42
43 1.15 Valid Update AE's label
44     [Documentation]    Valid Update AE's label
45     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
46     ${r} =    Update Resource    ${iserver}    InCSE1/ODL3    ${rt_ae}    ${attr}
47     Response Is Correct    ${r}
48     # Retrieve and test the lbl
49     ${r} =    Retrieve Resource    ${iserver}    InCSE1/ODL3
50     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
51     #==================================================
52     #    Container Test
53     #==================================================
54
55 2.11 Create Container without name under AE
56     [Documentation]    Create Container under AE without name
57     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
58     Connect And Create Resource    InCSE1/ODL3    ${rt_container}    ${attr}
59
60 2.12 Create Container with name under AE
61     [Documentation]    Create Container Under AE with name containerUnderAE and retrieve it to check if it is created
62     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderAE"
63     ${r} =    Create Resource    ${iserver}    /InCSE1/ODL3    ${rt_container}    ${attr}
64     ${container} =    Location    ${r}
65     Response Is Correct    ${r}
66     # retrieve it
67     ${result} =    Retrieve Resource    ${iserver}    ${container}
68     Should Contain    ${result.text}    containerUnderAE
69
70 2.13 Invalid Input for Container Under AE with name (Already exist)
71     [Documentation]    Invalid Input for Container Under AE with name (Already exist)
72     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderAE"
73     ${error} =    Run Keyword And Expect Error    *    Connect And Create Resource    InCSE1/ODL3    ${rt_container}    ${attr}
74     Should Start with    ${error}    Cannot create this resource [409]
75
76 2.14 Update Container Label
77     [Documentation]    Update Label to ["aaa","bbb","ccc"]
78     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
79     ${r} =    Update Resource    ${iserver}    InCSE1/ODL3/containerUnderAE    ${rt_container}    ${attr}
80     Response Is Correct    ${r}
81     # Retrieve and test the lbl
82     ${r} =    Retrieve Resource    ${iserver}    InCSE1/ODL3/containerUnderAE
83     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
84     #----------------------------------------------------------------------
85
86 2.21 Create Container under InCSE1 without name
87     [Documentation]    Create Container under InCSE1 without name
88     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
89     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
90     Response Is Correct    ${r}
91
92 2.22 Create Container under CSE with name
93     [Documentation]    Create Container under CSE with name
94     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderCSE"
95     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
96     Response Is Correct    ${r}
97     # retrieve it
98     ${result} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE
99     Should Contain    ${result.text}    containerUnderCSE
100
101 2.23 Invalid Input for Container Under CSE with name (Already exist)
102     [Documentation]    Invalid Input for Container Under CSE with name (Already exist)
103     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderCSE"
104     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_container}
105     ...    ${attr}
106     Should Start with    ${error}    Cannot create this resource [409]
107
108 2.24 Update Container Label
109     [Documentation]    Update Container Label
110     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
111     ${r} =    Update Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
112     Response Is Correct    ${r}
113     # Retrieve and test the lbl
114     ${r} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE
115     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
116     #----------------------------------------------------------------------
117
118 2.31 Create Container under Container without name
119     [Documentation]    Create Container under Container without name
120     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
121     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
122     Response Is Correct    ${r}
123
124 2.32 Create Container under Container with name
125     [Documentation]    Create Container under Container with name
126     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderContainer"
127     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
128     ${container} =    Location    ${r}
129     Response Is Correct    ${r}
130     # retrieve it
131     ${result} =    Retrieve Resource    ${iserver}    ${container}
132     Should Contain    ${result.text}    containerUnderContainer
133
134 2.33 Invalid Input for Container Under Container with name (Already exist)
135     [Documentation]    Invalid Input for Container Under Container with name (Already exist)
136     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderContainer"
137     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}
138     ...    ${attr}
139     Should Start with    ${error}    Cannot create this resource [409]
140
141 2.34 Update Container Label
142     [Documentation]    Update Container Label to ["aaa","bbb","ccc"]
143     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
144     ${r} =    Update Resource    ${iserver}    InCSE1/containerUnderCSE/containerUnderContainer    ${rt_container}    ${attr}
145     Response Is Correct    ${r}
146     # Retrieve and test the lbl
147     ${r} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE/containerUnderContainer
148     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
149
150 2.41 Invalid Input for AE under container with name(mess up layer)
151     [Documentation]    Invalid Input for AE under container withoutname(mess up layer)
152     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL4"
153     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_ae}
154     ...    ${attr}
155     Should Start with    ${error}    Cannot create this resource [405]
156     Should Contain    ${error}    Cannot create AE under this resource type: 3
157     #==================================================
158     #    ContentInstance Test
159     #==================================================
160
161 3.11 Valid contentInstance under CSEBase/container without name
162     [Documentation]    Valid contentInstance under CSEBase/container without name
163     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
164     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_contentInstance}    ${attr}
165     Response Is Correct    ${r}
166
167 3.12 Valid contentInstance under CSEBase/container with name
168     [Documentation]    Valid contentInstance under CSEBase/container with name
169     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","rn":"conIn1"
170     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_contentInstance}    ${attr}
171     Response Is Correct    ${r}
172
173 3.13 Invalid contentInstance under CSEBase
174     [Documentation]    Invalid contentInstance under CSEBase
175     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
176     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_contentInstance}
177     ...    ${attr}
178     Should Start with    ${error}    Cannot create this resource [405]
179     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 5
180
181 3.14 Invalid contentInstance under AE
182     [Documentation]    Invalid contentInstance under AE
183     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
184     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/ODL3    ${rt_contentInstance}
185     ...    ${attr}
186     Should Start with    ${error}    Cannot create this resource [405]
187     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 2
188
189 3.15 Invalid contentInstance under contentInstance
190     [Documentation]    Invalid contentInstance under contentInstance
191     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
192     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/containerUnderCSE/conIn1    ${rt_contentInstance}
193     ...    ${attr}
194     Should Start with    ${error}    Cannot create this resource [405]
195     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 4
196
197 3.16 Invalid AE under contentInstance
198     [Documentation]    Invalid AE under contentInstance
199     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
200     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/containerUnderCSE/conIn1    ${rt_ae}
201     ...    ${attr}
202     Should Start with    ${error}    Cannot create this resource [405]
203     Should Contain    ${error}    Cannot create AE under this resource type: 4
204
205 3.17 Invalid container under contentInstance
206     [Documentation]    Invalid container under contentInstance
207     ${attr} =    Set Variable    "cr":null,"lbl":["aaa","bbb","ccc"]
208     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/containerUnderCSE/conIn1    ${rt_container}
209     ...    ${attr}
210     Should Start with    ${error}    Cannot create this resource [405]
211     Should Contain    ${error}    Cannot create Container under this resource type: 4
212     #==================================================
213     #    Delete Test
214     #==================================================
215
216 4.11 Delete AE without child resource
217     [Documentation]    Delete AE without child resource
218     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
219     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AeName"
220     ${ae} =    Location    ${r}
221     Response Is Correct    ${r}
222     ${deleteRes} =    Delete Resource    ${iserver}    ${ae}
223     ${status_code} =    Status Code    ${deleteRes}
224     Should Be Equal As Integers    ${status_code}    200
225     # Delete AE that does not exist/has been deleted should return error
226     ${error} =    Run Keyword And Expect Error    *    Delete Resource    ${iserver}    ${ae}
227     Should Start with    ${error}    Cannot delete this resource [404]
228
229 4.12 Delete Container without child resource
230     [Documentation]    Delete Container without child resource
231     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
232     ${r} =    Create Resource    ${iserver}    InCSE1/ODL3    ${rt_container}    ${attr}
233     ${container} =    Location    ${r}
234     Response Is Correct    ${r}
235     ${deleteRes} =    Delete Resource    ${iserver}    ${container}
236     ${status_code} =    Status Code    ${deleteRes}
237     Should Be Equal As Integers    ${status_code}    200
238     # Delete container that does not exist/has been deleted should return error
239     ${error} =    Run Keyword And Expect Error    *    Delete Resource    ${iserver}    ${container}
240     Should Start with    ${error}    Cannot delete this resource [404]
241
242 Delete the Container Under CSEBase
243     [Documentation]    Delete the Container and AE Under CSEBase
244     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/containerUnderCSE
245     ${status_code} =    Status Code    ${deleteRes}
246     Should Be Equal As Integers    ${status_code}    200
247     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/ODL3
248     ${status_code} =    Status Code    ${deleteRes}
249     Should Be Equal As Integers    ${status_code}    200
250
251 *** Keywords ***
252 Connect And Create Resource
253     [Arguments]    ${targetURI}    ${resoutceType}    ${attr}
254     ${iserver} =    Connect To Iotdm    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}    http
255     ${r} =    Create Resource    ${iserver}    ${targetURI}    ${resoutceType}    ${attr}
256     ${container} =    Resid    ${r}
257     ${status_code} =    Status Code    ${r}
258     Should Be Equal As Integers    ${status_code}    201
259
260 Response Is Correct
261     [Arguments]    ${r}
262     ${status_code} =    Status Code    ${r}
263     Should Be True    199 < ${status_code} < 299
264     ${text} =    Text    ${r}
265     LOG    ${text}
266     ${json} =    Json    ${r}
267     LOG    ${json}