613356e83cf2f70e3123e04df489dc417b84fd47
[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://${CONTROLLER}:${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
10 *** Variables ***
11 ${THE_FIRST_IRD_RESOURCE_ID}    hello
12 ${THE_SECOND_IRD_RESOURCE_ID}    world
13 ${RESOURCE_IN_FIRST_IRD}    test-model-networkmap
14 ${RESOURCE_IN_SECOND_IRD}    test-model-filtered-costmap
15 ${BASE_URL}
16 ${RANDOM_CONTEXT_ID}
17
18 *** Test Cases ***
19 Check the simple IRD information
20     [Documentation]    Get the default IRD information
21     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${ALTO_SIMPLE_IRD_INFO}
22     ${resp}    RequestsLibrary.Get Request    session    /${ALTO_SIMPLE_IRD_INFO}
23     ${context_id}    ${BASE_URL}    Get Basic Info    ${resp.content}
24     Set Suite Variable    ${BASE_URL}
25     Set Suite Variable    ${RANDOM_CONTEXT_ID}    ${context_id}
26     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${RESOURCE_POOL_BASE}/${context_id}
27
28 Create two IRDs
29     [Documentation]    Create two IRDs and verify their existence
30     Create An IRD    ${DEFAULT_CONTEXT_ID}    ${THE_FIRST_IRD_RESOURCE_ID}
31     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${ALTO_OPERATIONAL_IRD_INSTANCE}/${THE_FIRST_IRD_RESOURCE_ID}
32     Create An IRD    ${DEFAULT_CONTEXT_ID}    ${THE_SECOND_IRD_RESOURCE_ID}
33     Wait Until Keyword Succeeds    5s    1s    Check GET Response Code Equals 200    /${ALTO_OPERATIONAL_IRD_INSTANCE}/${THE_SECOND_IRD_RESOURCE_ID}
34
35 Add one IRD configuration entry in one IRD instance
36     [Documentation]    Add one IRD configuration entry in an IRD whose name is hello. Link IRD entry to one existed resource.
37     Wait Until Keyword Succeeds    5s    1s    Add An IRD Configuration Entry    ${THE_FIRST_IRD_RESOURCE_ID}    ${DEFAULT_CONTEXT_ID}    ${RESOURCE_IN_FIRST_IRD}    ${BASE_URL}
38     Wait Until Keyword Succeeds    5s    1s    Add An IRD Configuration Entry    ${THE_SECOND_IRD_RESOURCE_ID}    ${DEFAULT_CONTEXT_ID}    ${RESOURCE_IN_SECOND_IRD}    ${BASE_URL}
39
40 *** Keywords ***
41 Check GET Response Code Equals 200
42     [Arguments]    ${uri_without_ip_port}
43     ${resp}    RequestsLibrary.Get Request   session    ${uri_without_ip_port}
44     Should Be Equal As Strings    ${resp.status_code}    200
45
46 Create An IRD
47     [Arguments]    ${context_id}    ${IRD_id}
48     ${body}    Set Variable    {"ird-instance-configuration":{"entry-context":"/alto-resourcepool:context[alto-resourcepool:context-id='${context_id}']","instance-id":"${IRD_id}"}}
49     ${resp}    RequestsLibrary.Put Request    session    /${ALTO_CONFIG_IRD_INSTANCE_CONFIG}/${IRD_id}    data=${body}
50     Should Be Equal As Strings    ${resp.status_code}    200
51
52 Add An IRD Configuration Entry
53     [Arguments]    ${IRD_id}    ${context_id}    ${resource_id}    ${base_url}
54     ${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}"}}
55     ${resp}    RequestsLibrary.Put Request     session    /${ALTO_CONFIG_IRD_INSTANCE_CONFIG}/${IRD_id}/ird-configuration-entry/${resource_id}    data=${body}
56     should Be Equal As Strings    ${resp.status_code}    200