2 Documentation Test Suite for IdManager
3 Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS} timeout=5
4 Suite Teardown Delete All Sessions
5 Test Setup Genius Test Setup
6 Test Teardown Get Model Dump ${ODL_SYSTEM_IP} ${idmanager_data_models}
7 Library OperatingSystem
9 Library RequestsLibrary
12 Variables ../../variables/genius/Modules.py
13 Resource ../../libraries/DataModels.robot
14 Resource ../../libraries/Utils.robot
15 Resource ../../libraries/Genius.robot
16 Resource ../../variables/Variables.robot
19 ${genius_config_dir} ${CURDIR}/../../variables/genius
20 ${pool-name} test-pool
21 @{test_keys} test-key1 test-key2 test-key3
22 ${create_json} createIdpool.json
23 ${allocaterange_json} allocateIdRange.json
24 ${OPERATIONS_API} /restconf/operations
27 Create ID pool in range 10:20
28 [Documentation] This testcase creates Id pool in range 10 to 20.
29 Post Elements To URI From File ${OPERATIONS_API}/id-manager:createIdPool ${genius_config_dir}/${create_json}
30 @{poolrange} create list ${pool-name} 10 20
31 Check For Elements At URI ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/ ${poolrange}
32 @{availiable_pool} create List 10 20 10
33 Check For Elements At URI ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/ ${availiable_pool}
35 Allocate Ids from pool created within size as 5
36 [Documentation] This testcase allocated IDs of specified size for the pool created in 1st testcase.
37 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
38 ${body} replace string ${body} test-key ${test_keys[0]}
40 Post Elements To URI ${OPERATIONS_API}/id-manager:allocateIdRange ${body}
43 Neg_Allocate ids of size 10 from the same pool
44 [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.
45 ${pool-name} Set Variable test-pool
46 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
47 ${body} Replace String ${body} 5 6
48 ${body} Replace String ${body} test-key ${test_keys[1]}
50 ${resp} RequestsLibrary.Post Request session ${OPERATIONS_API}/id-manager:allocateIdRange data=${body}
52 should be equal as strings ${resp.status_code} 500
54 Allocate IDs of size 3 from the pool
55 [Documentation] This testcase allocates 3 Ids from the created pool in test case 1
56 ${body} OperatingSystem.Get File ${genius_config_dir}/${allocaterange_json}
57 ${body} replace string ${body} test-key ${test_keys[2]}
58 ${body} replace string ${body} 5 3
60 Post Elements To URI ${OPERATIONS_API}/id-manager:allocateIdRange ${body}
61 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/
62 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
64 Should Contain ${get_resp.content} 17
65 Should Be Equal As Strings ${get_resp.status_code} 200
67 Release a block of IDs allocated using releaseIds RPC
68 [Documentation] This testcase Releases the block of Ids by using the key which is sent in json.
69 ${body} OperatingSystem.Get File ${genius_config_dir}/releaseIds.json
71 ${body} replace string ${body} test-key ${test_keys[2]}
72 Post Elements To URI ${OPERATIONS_API}/id-manager:releaseId ${body}
73 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/
74 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
76 Should Be Equal As Strings ${get_resp.status_code} 200
77 ${child-pool-name} Should Match Regexp ${get_resp.content} ${pool-name}\.[-]?[0-9]+
78 log ${child-pool-name}
79 ${get_releasedIds} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${child-pool-name}/released-ids-holder/
80 ${respjson} RequestsLibrary.To Json ${get_releasedIds.content} pretty_print=True
82 Should Be Equal As Strings ${get_releasedIds.status_code} 200
83 @{released_ids} re.findall <id>[0-9]+ ${get_releasedIds.content}
86 Delete the ID Pool using deleteIdPool RPC
87 [Documentation] This testcase deletes the ID pool craeted in the 1st testcase.
88 ${body} OperatingSystem.Get File ${genius_config_dir}/deleteIdPool.json
89 ${body} replace string ${body} poolname ${pool-name}
91 Post Elements To URI ${OPERATIONS_API}/id-manager:deleteIdPool ${body}
92 No Content From URI session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/
96 [Documentation] This keyword checks the created ID pool by doing GET.
97 ${get_resp} RequestsLibrary.Get Request session ${CONFIG_API}/id-manager:id-pools/id-pool/${pool-name}/available-ids-holder/
98 ${respjson} RequestsLibrary.To Json ${get_resp.content} pretty_print=True
100 Should Contain ${get_resp.content} 14
101 Should Be Equal As Strings ${get_resp.status_code} 200