2 Documentation Test Suite for IdManager
3 Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
4 Suite Teardown Delete All Sessions
5 Test Teardown Get Model Dump ${ODL_SYSTEM_IP} ${idmanager_data_models}
6 Library OperatingSystem
8 Library RequestsLibrary
11 Variables ../../variables/Variables.py
12 Variables ../../variables/genius/Modules.py
13 Resource ../../libraries/DataModels.robot
14 Resource ../../libraries/Utils.robot
17 ${genius_config_dir} ${CURDIR}/../../variables/genius
18 ${pool-name} test-pool
19 @{test_keys} test-key1 test-key2 test-key3
20 ${create_json} createIdpool.json
21 ${allocaterange_json} allocateIdRange.json
22 ${OPERATIONS_API} /restconf/operations
25 Create ID pool in range 10:20
26 [Documentation] This testcase creates Id pool in range 10 to 20.
27 Post Elements To URI From File ${OPERATIONS_API}/id-manager:createIdPool ${genius_config_dir}/${create_json}
28 @{poolrange} create list ${pool-name} 10 20
29 Check For Elements At URI ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/ ${poolrange}
30 @{availiable_pool} create List 10 20 10
31 Check For Elements At URI ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/ ${availiable_pool}
33 Allocate Ids from pool created within size as 5
34 [Documentation] This testcase allocated IDs of specified size for the pool created in 1st testcase.
35 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
36 ${body} replace string ${body} test-key ${test_keys[0]}
38 Post Elements To URI ${OPERATIONS_API}/id-manager:allocateIdRange ${body}
41 Neg_Allocate ids of size 10 from the same pool
42 [Documentation] This is a Negative testcase where when trying to allocate Id range out of the availiable IDs we have, the IDs are not allocated.
43 ${pool-name} Set Variable test-pool
44 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
45 ${body} Replace String ${body} 5 6
46 ${body} Replace String ${body} test-key ${test_keys[1]}
48 ${resp} RequestsLibrary.Post Request session ${OPERATIONS_API}/id-manager:allocateIdRange data=${body}
50 should be equal as strings ${resp.status_code} 500
52 Allocate IDs of size 3 from the pool
53 [Documentation] This testcase allocates 3 Ids from the created pool in test case 1
54 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
55 ${body} replace string ${body} test-key ${test_keys[2]}
56 ${body} replace string ${body} 5 3
58 Post Elements To URI ${OPERATIONS_API}/id-manager:allocateIdRange ${body}
59 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/
60 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
62 Should Contain ${get_resp.content} 17
63 Should Be Equal As Strings ${get_resp.status_code} 200
65 Release a block of IDs allocated using releaseIds RPC
66 [Documentation] This testcase Releases the block of Ids by using the key which is sent in json.
67 ${body} OperatingSystem.Get File ${genius_config_dir}/releaseIds.json
69 ${body} replace string ${body} test-key ${test_keys[2]}
70 Post Elements To URI ${OPERATIONS_API}/id-manager:releaseId ${body}
71 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/
72 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
74 Should Be Equal As Strings ${get_resp.status_code} 200
75 ${child-pool-name} Should Match Regexp ${get_resp.content} ${pool-name}\.[0-9]+
76 log ${child-pool-name}
77 ${get_releasedIds} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${child-pool-name}/released-ids-holder/
78 ${respjson} RequestsLibrary.To Json ${get_releasedIds.content} pretty_print=True
80 Should Be Equal As Strings ${get_releasedIds.status_code} 200
81 @{released_ids} re.findall <id>[0-9]+ ${get_releasedIds.content}
84 Delete the ID Pool using deleteIdPool RPC
85 [Documentation] This testcase deletes the ID pool craeted in the 1st testcase.
86 ${body} OperatingSystem.Get File ${genius_config_dir}/deleteIdPool.json
87 ${body} replace string ${body} poolname ${pool-name}
89 Post Elements To URI ${OPERATIONS_API}/id-manager:deleteIdPool ${body}
90 No Content From URI session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/
94 [Documentation] This keyword checks the created ID pool by doing GET.
95 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/
96 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
98 Should Contain ${get_resp.content} 14
99 Should Be Equal As Strings ${get_resp.status_code} 200