Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / openflowplugin / Inventory_Scalability_OF10 / 010__restconf_inventory.robot
1 *** Settings ***
2 Documentation       Test suite for RESTCONF inventory
3
4 Library             Collections
5 Library             RequestsLibrary
6 Library             ../../../libraries/Common.py
7 Variables           ../../../variables/Variables.py
8 Resource            ../../../variables/openflowplugin/Variables.robot
9
10 Suite Setup         Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
11 Suite Teardown      Delete All Sessions
12
13
14 *** Test Cases ***
15 Get list of nodes
16     [Documentation]    Get the inventory
17     ${TOPO_TREE_DEPTH}    Convert To Integer    ${TOPO_TREE_DEPTH}
18     ${TOPO_TREE_FANOUT}    Convert To Integer    ${TOPO_TREE_FANOUT}
19     ${numnodes}    Num Of Nodes    ${TOPO_TREE_DEPTH}    ${TOPO_TREE_FANOUT}
20     Wait Until Keyword Succeeds    30s    2s    Check Every Nodes    ${numnodes}
21
22 Get nodeconnector for the root node
23     [Documentation]    Get the inventory for the root node
24     ${TOPO_TREE_FANOUT}    Convert To Integer    ${TOPO_TREE_FANOUT}
25     ${resp}    RequestsLibrary.GET On Session
26     ...    session
27     ...    url=${RFC8040_NODES_API}/node=openflow%3A1?${RFC8040_OPERATIONAL_CONTENT}
28     ...    expected_status=200
29     Log    ${resp.text}
30     Wait Until Keyword Succeeds    30s    2s    Check conn loop    ${TOPO_TREE_FANOUT}    1    ${resp.text}
31
32 Get nodeconnector for a node
33     [Documentation]    Get the inventory for a node
34     ${TOPO_TREE_DEPTH}    Convert To Integer    ${TOPO_TREE_DEPTH}
35     ${TOPO_TREE_FANOUT}    Convert To Integer    ${TOPO_TREE_FANOUT}
36     ${numnodes}    Num Of Nodes    ${TOPO_TREE_DEPTH}    ${TOPO_TREE_FANOUT}
37     Wait Until Keyword Succeeds    30s    2s    Check Every Nodes Nodeconnector    ${numnodes}
38
39 Get Stats for a node
40     [Documentation]    Get the stats for a node
41     ${TOPO_TREE_DEPTH}    Convert To Integer    ${TOPO_TREE_DEPTH}
42     ${TOPO_TREE_FANOUT}    Convert To Integer    ${TOPO_TREE_FANOUT}
43     ${numnodes}    Num Of Nodes    ${TOPO_TREE_DEPTH}    ${TOPO_TREE_FANOUT}
44     Wait Until Keyword Succeeds    120s    2s    Check Every Nodes Stats    ${numnodes}
45
46
47 *** Keywords ***
48 Check Every Nodes
49     [Arguments]    ${numnodes}
50     ${resp}    RequestsLibrary.GET On Session    session    url=${RFC8040_OPERATIONAL_NODES_API}    expected_status=200
51     FOR    ${IND}    IN RANGE    1    ${numnodes+1}
52         Should Contain    ${resp.text}    openflow:${IND}
53     END
54
55 Check Every Nodes Stats
56     [Arguments]    ${numnodes}
57     FOR    ${IND}    IN RANGE    1    ${numnodes+1}
58         ${resp}    RequestsLibrary.GET On Session
59         ...    session
60         ...    url=${RFC8040_NODES_API}/node=openflow%3A${IND}?${RFC8040_OPERATIONAL_CONTENT}
61         ...    expected_status=200
62         Log    ${resp.text}
63         Should Contain    ${resp.text}    flow-capable-node-connector-statistics
64         Should Contain    ${resp.text}    flow-table-statistics
65     END
66
67 Check Every Nodes Nodeconnector
68     [Arguments]    ${numnodes}
69     FOR    ${IND}    IN RANGE    2    ${numnodes+1}
70         ${resp}    RequestsLibrary.GET On Session
71         ...    session
72         ...    url=${RFC8040_NODES_API}/node=openflow%3A${IND}?${RFC8040_OPERATIONAL_CONTENT}
73         ...    expected_status=200
74         Log    ${resp.text}
75         Check conn loop    ${TOPO_TREE_FANOUT+1}    ${IND}    ${resp.text}
76     END
77
78 Check conn loop
79     [Arguments]    ${arg}    ${outerind}    ${content}
80     FOR    ${var}    IN RANGE    1    ${arg+1}
81         Should Contain    ${content}    openflow:${outerind}:${var}
82     END