2 Documentation Basic Tests for Persistence Test APP.
4 ... Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
8 Library ../../../libraries/UtilLibrary.py
9 Resource ../../../libraries/KarafKeywords.robot
10 Resource ../../../libraries/Utils.robot
11 Variables ../../../variables/Variables.py
13 Suite Setup Setup Persistence Test App Environment
14 Suite Teardown Cleanup Persistence Test Database
20 ${email_addr} user1@example.com
21 ${location1} BUILDING_1_FIRST_FLOOR
22 ${location2} BUILDING_2_FIRST_FLOOR
24 ${device1_ip} 10.1.1.10
26 ${device2_ip} 10.1.1.20
31 [Documentation] Verify the User functionality of the Persistence Test App
32 ... This test case performs the following:
34 ... 2. Verify user is created and can be fetched
35 ... 3. Verify user is created with correct user name and email address
36 ... 4. Verify unknown user cannot be authenticated
37 ... 5. Disable the user
38 ... 6. Verify disabled user can be fetched
39 [Tags] persistence testapp
40 Issue Command On Karaf Console user:sign-up ${username} ${password} ${email_addr}
41 ${output}= Issue Command On Karaf Console user:get-enabled
42 ${string}= Extract String To Validate ${output} User{username=Username{value= 0
43 Should Match ${string} ${username}
44 ${string}= Extract String To Validate ${output} email=Email{value= 2
45 Should Match ${string} ${email_addr}
46 ${unknown_user}= Set Variable random
47 ${output}= Issue Command On Karaf Console user:sign-in ${unknown_user} ${password}
48 Should Contain ${output} Error executing command:
49 Issue Command On Karaf Console user:disable ${username}
50 ${output}= Issue Command On Karaf Console user:get-disabled
51 ${user_dstate}= Set Variable isEnabled=false
52 ${data}= Find User State ${output}
53 Should Contain ${data} ${user_dstate}
55 Verify Network Device Test App
56 [Documentation] Verify the Network Device functionality of the Persistence Test App
57 ... This test case performs the following:
59 ... 2. Verify device can be discovered
60 ... 3. Assign a name to the device
61 ... 4. Verify device name
62 ... 5. Configure a location
63 ... 6. Verify device location
64 [Tags] persistence testapp
65 Issue Command On Karaf Console networkdevice:discover ${device1_ip}
66 ${output}= Issue Command On Karaf Console networkdevice:get-reachable
67 ${string}= Extract String To Validate ${output} ipAddress=IpAddress{value= 2
68 Should Match ${string} ${device1_ip}
69 ${device_id}= Find Device Id ${device1_ip}
70 Issue Command On Karaf Console networkdevice:set-friendly-name ${device_id} ${device1_name}
71 ${data}= Find Device Name ${device1_ip}
72 Should Match ${data} ${device1_name}
73 Issue Command On Karaf Console networkdevice:set-location ${device_id} ${location1}
74 ${data}= Find Device Location ${device1_ip} ${location1}
75 Should Match ${data} ${location1}
77 Verify Data Persistency
78 [Documentation] Verify that the data that is generated by Persistence Test App can be persisted
79 ... This test case performs the following:
81 ... 2. Add a device and configure name and location
82 ... 3. Restart the controller
83 ... 4. Verify user name, email address and state are persisted
84 ... 5. Verify device name and location are persisted
85 [Tags] persistence testapp
86 Issue Command On Karaf Console user:sign-up ${username} ${password} ${email_addr}
87 Issue Command On Karaf Console networkdevice:discover ${device2_ip}
88 ${device_id}= Find Device Id ${device2_ip}
89 Issue Command On Karaf Console networkdevice:set-location ${device_id} ${location2}
90 Issue Command On Karaf Console networkdevice:set-friendly-name ${device_id} ${device2_name}
91 Stop One Or More Controllers ${ODL_SYSTEM_IP}
92 Wait Until Keyword Succeeds 60s 3s Controller Down Check ${ODL_SYSTEM_IP}
93 Start One Or More Controllers ${ODL_SYSTEM_IP}
94 UtilLibrary.Wait For Controller Up ${ODL_SYSTEM_IP} ${RESTCONFPORT}
95 ${output}= Issue Command On Karaf Console user:get-enabled
96 ${string}= Extract String To Validate ${output} User{username=Username{value= 0
97 Should Match ${string} ${username}
98 ${string}= Extract String To Validate ${output} email=Email{value= 2
99 Should Match ${string} ${email_addr}
100 ${data}= Find User State ${output}
101 ${user_estate}= Set Variable isEnabled=true
102 Should Contain ${data} ${user_estate}
103 ${data}= Find Device Name ${device2_ip}
104 Should Match ${data} ${device2_name}
105 ${data}= Find Device Location ${device2_ip} ${location2}
106 Should Match ${data} ${location2}
110 Extract String To Validate
111 [Documentation] Take the output of a content, the string to be splitted and the
112 ... index of the data from the output, parse the strin and return the data that includes
113 ... user's name, user's email address, device's IP address
114 [Arguments] ${output} ${splitter} ${index}
115 ${output}= Split Value from String ${output} }
116 ${string}= Get From List ${output} ${index}
117 ${string}= Split Value from String ${string} ${splitter}
118 ${string}= Get From List ${string} 1
122 [Documentation] Take the output of networkdevice:get-reachable, find the line
123 ... with the give IP with the given IP address and return the line
124 [Arguments] ${device_ip}
125 ${output}= Issue Command On Karaf Console networkdevice:get-reachable
126 ${output}= Split To Lines ${output}
127 ${length}= Get Length ${output}
128 FOR ${INDEX} IN RANGE 0 ${length}
129 ${line}= Get From List ${output} ${INDEX}
130 ${data}= Fetch From Right ${line} ipAddress=IpAddress{value=
131 ${data}= Split String ${data} },
132 ${data}= Get From List ${data} 0
133 IF '${data}' == '${device_ip}' BREAK
138 [Documentation] Find the device ID using its IP address
139 [Arguments] ${device_ip}
140 ${line}= Find Line ${device_ip}
141 ${id}= Split String ${line} NetworkDevice{id=SerialNumber{value=
142 ${id}= Get From List ${id} 1
143 ${id}= Fetch from Left ${id} }
147 [Documentation] Find the device's name using its IP address
148 [Arguments] ${device_ip}
149 ${line}= Find Line ${device_ip}
150 ${line}= Split String ${line} ,
151 ${line}= Get From List ${line} -2
152 ${name}= Split String ${line} friendlyName=
153 ${name}= Get From List ${name} 1
157 [Documentation] Find the device's location using its IP address
158 [Arguments] ${device_ip} ${location}
159 ${line}= Find Line ${device_ip}
160 ${line}= Split String ${line} ,
161 ${line}= Get From List ${line} 3
162 ${name}= Split String ${line} location=
163 ${name}= Get From List ${name} 1
167 [Documentation] Find the user's state
168 [Arguments] ${output}
169 ${output}= Split Value from String ${output} ,
170 ${data}= Get From List ${output} 4
171 ${data}= Remove Space on String ${data}
172 ${data}= Split String ${data} }
175 Setup Persistence Test App Environment
176 [Documentation] Installing Persistence Related features
177 Install a Feature odl-persistence-all
178 Install a Feature odl-persistence-test-app
179 Verify Feature Is Installed odl-persistence-api
180 Verify Feature Is Installed odl-persistence-jpa-impl
181 Verify Feature Is Installed odl-persistence-test-app
183 Cleanup Persistence Test Database
184 [Documentation] Clear the database and uninstall Persistence Test App
185 Uninstall a Feature odl-persistence-api
186 Uninstall a Feature odl-persistence-jpa-impl
187 Uninstall a Feature odl-persistence-test-app
188 Verify Feature Is Not Installed odl-persistence-api
189 Verify Feature Is Not Installed odl-persistence-jpa-impl
190 Verify Feature Is Not Installed odl-persistence-test-app