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