Append 3 more punt path protection TCs
[integration/test.git] / csit / suites / genius / 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}    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
8 Library           String
9 Library           RequestsLibrary
10 Library           Collections
11 Library           re
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
17
18 *** Variables ***
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
25
26 *** Test Cases ***
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}
34
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]}
39     log    ${body}
40     Post Elements To URI    ${OPERATIONS_API}/id-manager:allocateIdRange    ${body}
41     get Id pool
42
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]}
49     log    ${body}
50     ${resp}    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/id-manager:allocateIdRange    data=${body}
51     Log    ${resp.content}
52     should be equal as strings    ${resp.status_code}    500
53
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
59     log    ${body}
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
63     Log    ${respjson}
64     Should Contain    ${get_resp.content}    17
65     Should Be Equal As Strings    ${get_resp.status_code}    200
66
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
70     log    ${body}
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
75     Log    ${respjson}
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
81     log    ${respjson}
82     Should Be Equal As Strings    ${get_releasedIds.status_code}    200
83     @{released_ids}    re.findall    <id>[0-9]+    ${get_releasedIds.content}
84     log    ${released_ids}
85
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}
90     log    ${body}
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}/
93
94 *** Keywords ***
95 get Id pool
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
99     Log    ${respjson}
100     Should Contain    ${get_resp.content}    14
101     Should Be Equal As Strings    ${get_resp.status_code}    200