9ef2a9447ad46373e9a8eda134963cffa46dc66d
[integration/test.git] / test / csit / suites / sp-of13 / 020__MD_SAL_NSF_OF13 / 030__restconf_topology.txt
1 *** Settings ***
2 Documentation     Test suite RESTCONF Topology 
3 Suite Setup       Create Session   session   http://${CONTROLLER}:${PORT}   auth=${AUTH}   headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           Collections
6 Library           ../../../libraries/RequestsLibrary.py
7 Library           ../../../libraries/Common.py
8 Variables         ../../../variables/Variables.py
9
10 *** Variables ***
11 ${topology1}    "flow:1"
12 ${node1}    "openflow:1"
13 ${node2}    "openflow:2"
14 ${node3}    "openflow:3"
15 ${key}       link
16 ${REST_CONTEXT_1}    /restconf/operational/network-topology:network-topology
17 ${REST_CONTEXT_2}    /restconf/operational/network-topology:network-topology/topology/flow:1
18 ${REST_CONTEXT_3}    /restconf/config/network-topology:network-topology/topology/flow:1/link/userlink
19
20 *** Test Cases ***
21 Get RESTCONF Topology
22     [Documentation]    Get RESTCONF Topology and validate the result.
23     [Tags]    get
24     ${resp}    Get    session    ${REST_CONTEXT_1}
25     Should Be Equal As Strings    ${resp.status_code}    200 
26     Log    ${resp.content}
27     Should Contain   ${resp.content}   ${topology1}  
28    
29 List all the links
30     [Documentation]    List all the links in the topology.
31     [Tags]    get
32     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:2
33     ${body2}    Create Dictionary    source-node=openflow:3    source-tp=openflow:3:3
34     ${link2}    Create Dictionary    link-id=openflow:3:3  destination=${body1}    source=${body2}
35     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:1
36     ${body2}    Create Dictionary    source-node=openflow:2    source-tp=openflow:2:3
37     ${link1}    Create Dictionary    link-id=openflow:2:3  destination=${body1}    source=${body2}
38     ${body1}    Create Dictionary    dest-node=openflow:3    dest-tp=openflow:3:3
39     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:2
40     ${link4}    Create Dictionary    link-id=openflow:1:2  destination=${body1}    source=${body2}
41     ${body1}    Create Dictionary    dest-node=openflow:2    dest-tp=openflow:2:3
42     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:1
43     ${link3}    Create Dictionary    link-id=openflow:1:1  destination=${body1}    source=${body2}
44     ${links}    Create List    ${link1}    ${link2}   ${link3}   ${link4}
45     ${resp}    Get    session    ${REST_CONTEXT_2}
46     Should Be Equal As Strings    ${resp.status_code}    200 
47     ${result}    To JSON    ${resp.content}
48     ${content}    Get From Dictionary    ${result}    topology
49     ${topology}    Get From List   ${content}    0
50     ${link}      Get From Dictionary    ${topology}    link
51     Sort List    ${link}
52     Lists Should be Equal    ${link}    ${links}
53
54 Add a link
55     [Documentation]    Add a link, list to validate the result.
56     [Tags]    add
57     ${body1}    Create Dictionary    dest-node=openflow:3    dest-tp=openflow:3:1 
58     ${body2}    Create Dictionary    source-node=openflow:2    source-tp=openflow:2:1 
59     ${body3}    Create Dictionary    link-id=userlink  destination=${body1}    source=${body2}
60     ${links}    Create List    ${body3}
61     ${body}    Create Dictionary    link=${links}
62     ${resp}    Put    session    ${REST_CONTEXT_3}   data=${body}
63     Should Be Equal As Strings    ${resp.status_code}    200
64     ${resp}    Get    session    ${REST_CONTEXT_3}
65     Should Be Equal As Strings    ${resp.status_code}    200
66     ${result}    To JSON    ${resp.content}
67     ${link}    Get From Dictionary    ${result}    link
68     Lists Should be Equal    ${link}    ${links}
69
70
71 Remove a link
72     [Documentation]    Remove a link, list to validate the result.
73     [Tags]    remove
74     ${resp}    Delete   session    ${REST_CONTEXT_3}  
75     Should Be Equal As Strings    ${resp.status_code}    200
76     ${resp}    Get    session    ${REST_CONTEXT_3}
77     Should Be Equal As Strings    ${resp.status_code}    404