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