a23f93898c6d6e7757014a5160de3a35dd33cfd3
[integration/test.git] / csit / suites / alto / basic / 020_simple_IRD.robot
1 *** Settings ***
2 Documentation     Test suite for ALTO simple IRD (Information Resource Dictionary)
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           RequestsLibrary
6 Library           ../../../libraries/ALTO/AltoParser.py
7 Variables         ../../../variables/Variables.py
8 Variables         ../../../variables/alto/Variables.py
9 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
10
11 *** Variables ***
12 ${THE_FIRST_IRD_RESOURCE_ID}    hello
13 ${THE_SECOND_IRD_RESOURCE_ID}    world
14 ${RESOURCE_IN_FIRST_IRD}    test-model-networkmap
15 ${RESOURCE_IN_SECOND_IRD}    test-model-filtered-costmap
16 ${BASE_URL}       ${EMPTY}
17 ${RANDOM_CONTEXT_ID}    ${EMPTY}
18
19 *** Test Cases ***
20 Check the simple IRD information
21     [Documentation]    Get the default IRD information
22     Wait Until Keyword Succeeds    20s    2s    Check GET Response Code Equals 200    /${ALTO_SIMPLE_IRD_INFO}
23     ${resp}    RequestsLibrary.Get Request    session    /${ALTO_SIMPLE_IRD_INFO}
24     ${context_id}    ${BASE_URL}    Get Basic Info    ${resp.content}
25     Set Suite Variable    ${BASE_URL}
26     Set Suite Variable    ${RANDOM_CONTEXT_ID}    ${context_id}
27     Wait Until Keyword Succeeds    20s    2s    Check GET Response Code Equals 200    /${RESOURCE_POOL_BASE}/${context_id}
28
29 Create two IRDs
30     [Documentation]    Create two IRDs and verify their existence
31     Create An IRD    ${DEFAULT_CONTEXT_ID}    ${THE_FIRST_IRD_RESOURCE_ID}
32     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${ALTO_OPERATIONAL_IRD_INSTANCE}/${THE_FIRST_IRD_RESOURCE_ID}
33     Create An IRD    ${DEFAULT_CONTEXT_ID}    ${THE_SECOND_IRD_RESOURCE_ID}
34     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${ALTO_OPERATIONAL_IRD_INSTANCE}/${THE_SECOND_IRD_RESOURCE_ID}
35
36 Add one IRD configuration entry in one IRD instance
37     [Documentation]    Add one IRD configuration entry in an IRD whose name is hello. Link IRD entry to one existed resource.
38     Wait Until Keyword Succeeds    5s    1s    Add An IRD Configuration Entry    ${THE_FIRST_IRD_RESOURCE_ID}    ${DEFAULT_CONTEXT_ID}    ${RESOURCE_IN_FIRST_IRD}
39     ...    ${BASE_URL}
40     Wait Until Keyword Succeeds    5s    1s    Add An IRD Configuration Entry    ${THE_SECOND_IRD_RESOURCE_ID}    ${DEFAULT_CONTEXT_ID}    ${RESOURCE_IN_SECOND_IRD}
41     ...    ${BASE_URL}
42
43 *** Keywords ***
44 Check GET Response Code Equals 200
45     [Arguments]    ${uri_without_ip_port}
46     ${resp}    RequestsLibrary.Get Request    session    ${uri_without_ip_port}
47     Should Be True    ${resp.status_code}==200
48
49 Create An IRD
50     [Arguments]    ${context_id}    ${IRD_id}
51     ${body}    Set Variable    {"ird-instance-configuration":{"entry-context":"/alto-resourcepool:context[alto-resourcepool:context-id='${context_id}']","instance-id":"${IRD_id}"}}
52     ${resp}    RequestsLibrary.Put Request    session    /${ALTO_CONFIG_IRD_INSTANCE_CONFIG}/${IRD_id}    data=${body}
53     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
54
55 Add An IRD Configuration Entry
56     [Arguments]    ${IRD_id}    ${context_id}    ${resource_id}    ${base_url}
57     ${body}    Set Variable    {"ird-configuration-entry":{"entry-id":"${resource_id}","instance":"/alto-resourcepool:context[alto-resourcepool:context-id='${context_id}']/alto-resourcepool:resource[alto-resourcepool:resource-id='${resource_id}']","path":"${base_url}/${resource_id}"}}
58     ${resp}    RequestsLibrary.Put Request    session    /${ALTO_CONFIG_IRD_INSTANCE_CONFIG}/${IRD_id}/ird-configuration-entry/${resource_id}    data=${body}
59     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}