4 Library SettingsLibrary.py
5 Resource DatastoreCRUD.robot
9 [Arguments] ${controller_ip} ${num_cars} ${timeout}=3s
10 [Documentation] Initializes shard and then adds the specified number of cars and performs a GET as a check.
11 ${resp} InitCar ${controller_ip} ${PORT}
12 Should Be Equal As Strings ${resp.status_code} 204
13 ${resp} AddCar ${controller_ip} ${RESTCONFPORT} ${num_cars} 204
14 Should Be Equal As Strings ${resp.status_code} 204
15 Wait Until Keyword Succeeds ${timeout} 1s Get Cars And Verify ${controller_ip} ${num_cars}
17 Add Cars And Verify Without Init
18 [Arguments] ${controller_ip} ${num_cars} ${timeout}=3s
19 [Documentation] Adds cars to an initialized cars shard then performs a GET as a check.
20 Comment First car add may return 409, but subsequent should be 204
21 ${resp} AddCar ${controller_ip} ${RESTCONFPORT} ${num_cars} 204 409
22 Should Be Equal As Strings ${resp.status_code} 204
23 Wait Until Keyword Succeeds ${timeout} 1s Get Cars And Verify ${controller_ip} ${num_cars}
26 [Arguments] ${controller_ip} ${num_cars}
27 [Documentation] Gets cars and verifies that the manufacturer is correct.
28 # TODO: Future enhanement: verify all fields.
29 ${resp} Getcars ${controller_ip} ${RESTCONFPORT} ${0}
30 Should Be Equal As Strings ${resp.status_code} 200
31 : FOR ${i} IN RANGE 1 ${num_cars}+1
32 \ Should Contain ${resp.content} manufacturer${i}
35 [Arguments] ${controller_ip} ${num_people} ${timeout}=3s
36 [Documentation] Note: The first AddPerson call passed with 0 posts directly to the data store to get
37 ... the people container created so the subsequent AddPerson RPC calls that put to the
38 ... person list will succeed.
39 ${resp} AddPerson ${controller_ip} ${RESTCONFPORT} ${0} 204
40 Should Be Equal As Strings ${resp.status_code} 204
41 Wait Until Keyword Succeeds ${timeout} 1s Get One Person And Verify ${controller_ip} ${0}
42 ${resp} AddPerson ${controller_ip} ${RESTCONFPORT} ${num_people} 200
43 Wait Until Keyword Succeeds ${timeout} 1s Get People And Verify ${controller_ip} ${num_people}
45 Add People And Verify Without Init
46 [Arguments] ${controller_ip} ${num_people} ${timeout}=3s
47 [Documentation] Adds people to an initialized people shard then performs a GET as a check.
48 ${resp} AddPerson ${controller_ip} ${RESTCONFPORT} ${num_people} 200
49 Should Be Equal As Strings ${resp.status_code} 200
50 Wait Until Keyword Succeeds ${timeout} 1s Get People And Verify ${controller_ip} ${num_people}
52 Get One Person And Verify
53 [Arguments] ${controller_ip} ${number}
54 [Documentation] Gets a person and verifies that the user ID is correct.
55 # TODO: Future enhanement: verify all fields.
56 ${resp} GetPersons ${controller_ip} ${RESTCONFPORT} ${0}
57 Should Be Equal As Strings ${resp.status_code} 200
58 Should Contain ${resp.content} user${number}
61 [Arguments] ${controller_ip} ${num_people}
62 [Documentation] Gets multiple people and verifies that the user IDs are correct.
63 # TODO: Future enhanement: verify all fields.
64 ${resp} GetPersons ${controller_ip} ${RESTCONFPORT} ${0}
65 Should Be Equal As Strings ${resp.status_code} 200
66 : FOR ${i} IN RANGE 1 ${num_people}+1
67 \ Should Contain ${resp.content} user${i}
69 Add Car Person And Verify
70 [Arguments] ${controller_ip} ${timeout}=3s
71 [Documentation] Add a car-person via the data store and get the car-person from Leader.
72 ... Note: This is done to get the car-people container created so subsequent
73 ... BuyCar RPC puts to the car-person list will succeed.
74 AddCarPerson ${controller_ip} ${RESTCONFPORT} ${0}
75 Wait Until Keyword Succeeds ${timeout} 1s Get One Car-Person Mapping And Verify ${controller_ip} ${0}
77 Get One Car-Person Mapping And Verify
78 [Arguments] ${controller_ip} ${number}
79 [Documentation] Gets a car person mapping and verifies that the user ID is correct.
80 ${resp} GetCarPersonMappings ${controller_ip} ${RESTCONFPORT} ${0}
81 Should Be Equal As Strings ${resp.status_code} 200
82 Should Contain ${resp.content} user${number}
84 Get Car-Person Mappings And Verify
85 [Arguments] ${controller_ip} ${num_entries}
86 ${resp} GetCarPersonMappings ${controller_ip} ${RESTCONFPORT} ${0}
87 Should Be Equal As Strings ${resp.status_code} 200
88 : FOR ${i} IN RANGE 1 ${num_entries}+1
89 \ Should Contain ${resp.content} user${i}
92 [Arguments] ${controller_ip} ${num_entries} ${start}=${0} ${timeout}=3s
93 BuyCar ${controller_ip} ${RESTCONFPORT} ${num_entries} ${start}
94 ${total_entries} Evaluate ${start}+${num_entries}
95 Wait Until Keyword Succeeds ${timeout} 1s Get Car-Person Mappings And Verify ${controller_ip} ${total_entries}
98 [Arguments] ${controller_ip}
99 ${resp} Getcars ${controller_ip} ${RESTCONFPORT} ${0}
100 Should Be Equal As Strings ${resp.status_code} 404
102 Delete All Cars And Verify
103 [Arguments] ${controller_ip} ${timeout}=3s
104 DeleteAllCars ${controller_ip} ${RESTCONFPORT} ${0}
105 Wait Until Keyword Succeeds ${timeout} 1s Check Cars Deleted ${controller_ip}
108 [Arguments] ${controller_ip}
109 ${resp} GetPersons ${controller_ip} ${RESTCONFPORT} ${0}
110 Should Be Equal As Strings ${resp.status_code} 404
112 Delete All People And Verify
113 [Arguments] ${controller_ip} ${timeout}=3s
114 DeleteAllPersons ${controller_ip} ${RESTCONFPORT} ${0}
115 Wait Until Keyword Succeeds ${timeout} 1s Check People Deleted ${controller_ip}
117 Check Cars-Persons Deleted
118 [Arguments] ${controller_ip}
119 ${resp} GetCarPersonMappings ${controller_ip} ${RESTCONFPORT} ${0}
120 Should Be Equal As Strings ${resp.status_code} 404
122 Delete All Cars-Persons And Verify
123 [Arguments] ${controller_ip} ${timeout}=3s
124 DeleteAllCarsPersons ${controller_ip} ${RESTCONFPORT} ${0}
125 Wait Until Keyword Succeeds ${timeout} 1s Check Cars-Persons Deleted ${controller_ip}
127 Delete All Entries From Shards
128 [Arguments] @{controllers}
129 [Documentation] Delete All Shards.
130 : FOR ${ip} IN @{controllers}
131 \ Delete All Cars And Verify ${ip}
132 : FOR ${ip} IN @{controllers}
133 \ Delete All People And Verify ${ip}
134 : FOR ${ip} IN @{controllers}
135 \ Delete All Cars-Persons And Verify ${ip}
138 [Arguments] ${controller_ip} ${nth_car}
139 [Documentation] Verifies that the first through nth car is present.
140 ${resp} Getcars ${controller_ip} ${RESTCONFPORT} ${0}
141 Should Be Equal As Strings ${resp.status_code} 200
142 : FOR ${INDEX} IN RANGE 1 ${nth_car}
143 \ ${counter}= Convert to String ${INDEX}
144 \ Log manufacturer${counter}
145 \ Should Contain ${resp.content} manufacturer${counter}
148 [Arguments] ${controller_ip} ${nth_person}
149 [Documentation] Verifies that the first through nth person is present.
150 ${resp} GetPersons ${controller_ip} ${RESTCONFPORT} ${0}
151 Should Be Equal As Strings ${resp.status_code} 200
152 : FOR ${INDEX} IN RANGE 1 ${nth_person}
153 \ ${counter}= Convert to String ${INDEX}
155 \ Should Contain ${resp.content} user${counter}
158 [Arguments] ${controller_ip} ${nth_carperson}
159 [Documentation] Verifies that the first through nth car-person is present.
160 ${resp} GetCarPersonMappings ${controller_ip} ${RESTCONFPORT} ${0}
161 Should Be Equal As Strings ${resp.status_code} 200
162 : FOR ${INDEX} IN RANGE 1 ${nth_carperson}
163 \ ${counter}= Convert to String ${INDEX}
165 \ Should Contain ${resp.content} user${counter}
167 Check Elements In Shards
168 [Arguments] ${controller_ip} ${nth}
169 [Documentation] Check all shards for nth elements
170 wait until keyword succeeds 3 1 Check Cars ${controller_ip} ${nth}
171 wait until keyword succeeds 3 1 Check People ${controller_ip} ${nth}
172 wait until keyword succeeds 3 1 Check CarPeople ${controller_ip} ${nth}
175 [Arguments] ${controller_ip} ${field bases}
176 [Documentation] Initializes the cars shard by creating a 0th car with POST then deleting it.
177 ... Field bases are a dictionary of datastore record field values onto which is appended
178 ... an incremental value to uniquely identify the record from which it came.
179 ... Typically, you will use the Create Dictionary keyword on arguments which look like this:
180 ... id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
181 ${node}= Set Variable ${EMPTY}
182 ${prefix}= Set Variable {"car:cars":{"car-entry":[{
183 ${postfix}= Set Variable }]}}
184 Create Records ${controller_ip} ${node} ${0} ${0} ${prefix} ${field bases}
186 ${node}= Set Variable car:cars/car-entry
187 Delete Records ${controller_ip} ${node} ${0} ${0}
190 [Arguments] ${controller_ip} ${first} ${last} ${field bases}
191 [Documentation] Creates cars with record IDs of specified range using POST.
192 ... If first and last are equal, only one record is updated.
193 ... Field bases are a dictionary of datastore record field values onto which is appended
194 ... an incremental value to uniquely identify the record from which it came.
195 ... Typically, you will use the Create Dictionary keyword on an argument which looks like this:
196 ... id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
197 ${node}= Set Variable car:cars
198 ${prefix}= Set Variable {"car-entry":[{
199 ${postfix}= Set Variable }]}
200 Create Records ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
204 [Arguments] ${controller_ip} ${first} ${last} ${field bases}
205 [Documentation] Updates cars with record IDs of the specified using PUT.
206 ... If first and last are equal, only one record is updated.
207 ... Field bases are a dictionary of datastore record field values onto which is appended
208 ... an incremental value to uniquely identify the record from which it came.
209 ... Typically, you will use the Create Dictionary keyword on arguments which look like this:
210 ... id=${EMPTY} category=coupe model=model manufacturer=mfg year=2
211 ${node}= Set Variable car:cars/car-entry
212 ${prefix}= Set Variable {"car-entry":[{
213 ${postfix}= Set Variable }]}
214 Update Records ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
218 [Arguments] ${controller_ip}
219 [Documentation] Returns all records from the cars shard in JSON format.
220 ${node}= Set Variable car:cars
221 ${result}= Read Records ${controller_ip} ${node}
225 [Arguments] ${controller_ip} ${id}
226 [Documentation] Returns the specified record from the cars shard in JSON format.
227 ${node}= Set Variable car:cars/car-entry/${id}
228 ${result}= Read Records ${controller_ip} ${node}
232 [Arguments] ${controller_ip}
233 [Documentation] Deletes all records from the cars shard.
234 ${node}= Set Variable car:cars
235 Delete All Records ${controller_ip} ${node}
238 [Arguments] ${controller_ip} ${first} ${last}
239 [Documentation] Deletes the specified range of records from the cars shard.
240 ${node}= Set Variable car:cars/car-entry
241 Delete Records ${controller_ip} ${node} ${first} ${last}