Check cluster status after rejoin
[integration/test.git] / csit / suites / genius / 02_ID_manager.robot
1 *** Settings ***
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
7 Library           String
8 Library           RequestsLibrary
9 Library           Collections
10 Library           re
11 Variables         ../../variables/Variables.py
12 Variables         ../../variables/genius/Modules.py
13 Resource          ../../libraries/DataModels.robot
14 Resource          ../../libraries/Utils.robot
15
16 *** Variables ***
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
23
24 *** Test Cases ***
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}
32
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]}
37     log    ${body}
38     Post Elements To URI    ${OPERATIONS_API}/id-manager:allocateIdRange    ${body}
39     get Id pool
40
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]}
47     log    ${body}
48     ${resp}    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/id-manager:allocateIdRange    data=${body}
49     Log    ${resp.content}
50     should be equal as strings    ${resp.status_code}    500
51
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
57     log    ${body}
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
61     Log    ${respjson}
62     Should Contain    ${get_resp.content}    17
63     Should Be Equal As Strings    ${get_resp.status_code}    200
64
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
68     log    ${body}
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
73     Log    ${respjson}
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
79     log    ${respjson}
80     Should Be Equal As Strings    ${get_releasedIds.status_code}    200
81     @{released_ids}    re.findall    <id>[0-9]+    ${get_releasedIds.content}
82     log    ${released_ids}
83
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}
88     log    ${body}
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}/
91
92 *** Keywords ***
93 get Id pool
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
97     Log    ${respjson}
98     Should Contain    ${get_resp.content}    14
99     Should Be Equal As Strings    ${get_resp.status_code}    200