49557757c0ce987c64cbe107982190071fa7168b
[integration/test.git] / csit / suites / openflowplugin / Reconciliation / 010_Group_Flows.robot
1 *** Settings ***
2 Documentation     Test reconciliation of chained groups and flows after switch is restart.
3 Suite Setup       Initialization Phase
4 Suite Teardown    Final Phase
5 Library           XML
6 Library           OperatingSystem
7 Library           RequestsLibrary
8 Resource          ../../../libraries/MininetKeywords.robot
9 Resource          ../../../libraries/FlowLib.robot
10 Resource          ../../../libraries/Utils.robot
11 Variables         ../../../variables/Variables.py
12
13 *** Variables ***
14 ${XmlsDir}        ${CURDIR}/../../../variables/xmls
15 ${groupfile1}     g4.xml
16 ${groupfile2}     g5.xml
17 ${flowfile}       f50.xml
18
19 *** Test Cases ***
20 Add Group 1 And Verify In Config Datastore
21     [Documentation]    Add a group and verify.
22     ${body}=    OperatingSystem.Get File    ${XmlsDir}/${groupfile1}
23     FlowLib.Add Group To Controller And Verify    ${body}    openflow:1    1
24
25 Verify After Adding Group 1 In Operational DataStore
26     [Documentation]    Get the group stats in operational.
27     ${elements}=    BuiltIn.Create List    group-statistics    ref-count    packet-count    byte-count    buckets
28     ...    weight    group-select
29     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/group/1    ${elements}
30
31 Add Group 2 And Verify In Config Datastore
32     [Documentation]    Add a group and verify.
33     ${body}=    OperatingSystem.Get File    ${XmlsDir}/${groupfile2}
34     FlowLib.Add Group To Controller And Verify    ${body}    openflow:1    2
35
36 Verify After Adding Group 2 In Operational DataStore
37     [Documentation]    Get the group stats in operational.
38     ${elements}=    BuiltIn.Create List    group-statistics    ref-count    packet-count    byte-count    buckets
39     ...    watch_group    watch_port    group-ff
40     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/group/2    ${elements}
41
42 Add Flow And Verify In Config Datastore
43     [Documentation]    Add a flow pointing to the group and verify.
44     ${body}    OperatingSystem.Get File    ${XmlsDir}/${flowfile}
45     FlowLib.Add Flow To Controller And Verify    ${body}    openflow:1    0    1
46
47 Verify After Adding Flow In Operational DataStore
48     [Documentation]    Get the flow stats in operational.
49     ${elements}=    BuiltIn.Create List    group-action    group-id
50     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/table/0/flow/1    ${elements}
51
52 Restart Mininet
53     [Documentation]    Restart Mininet and verify.
54     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
55     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller
56     BuiltIn.Set Suite Variable    ${mininet_conn_id}
57     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Are Switches Connected Topo
58
59 Verify Group 1 In Operational DataStore
60     [Documentation]    Get the group stats in operational.
61     ${elements}=    BuiltIn.Create List    group-statistics    ref-count    packet-count    byte-count    buckets
62     ...    weight    group-select
63     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/group/1    ${elements}
64
65 Verify Group 2 In Operational DataStore
66     [Documentation]    Get the group stats in operational.
67     ${elements}=    BuiltIn.Create List    group-statistics    ref-count    packet-count    byte-count    buckets
68     ...    watch_group    watch_port    group-ff
69     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/group/2    ${elements}
70
71 Verify Flow In Operational DataStore
72     [Documentation]    Get the flow stats in operational.
73     ${elements}=    BuiltIn.Create List    group-action    group-id
74     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.Check For Elements At URI    ${OPERATIONAL_NODES_API}/node/openflow:1/table/0/flow/1    ${elements}
75
76 Remove Flow And Verify In Config Datastore
77     [Documentation]    Remove the flow and verify.
78     FlowLib.Remove Flow From Controller And Verify    openflow:1    0    1
79
80 Verify After Removing Flow In Operational DataStore
81     [Documentation]    Get the flow stats in operational.
82     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.No Content From URI    session    ${OPERATIONAL_NODES_API}/node/openflow:1/table/0/flow/1
83
84 Remove Group 2 And Verify In Config Datastore
85     [Documentation]    Remove the group and verify.
86     FlowLib.Remove Group From Controller And Verify    openflow:1    2
87
88 Verify After Removing Group 2 In Operational DataStore
89     [Documentation]    Get the group stats in operational.
90     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.No Content From URI    session    ${OPERATIONAL_NODES_API}/node/openflow:1/group/2
91
92 Remove Group 1 And Verify In Config Datastore
93     [Documentation]    Remove the group and verify.
94     FlowLib.Remove Group From Controller And Verify    openflow:1    1
95
96 Verify After Removing Group 1 In Operational DataStore
97     [Documentation]    Get the group stats in operational.
98     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Utils.No Content From URI    session    ${OPERATIONAL_NODES_API}/node/openflow:1/group/1
99
100 *** Keywords ***
101 Initialization Phase
102     [Documentation]    Starts mininet and verify if topology is in operational datastore.
103     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
104     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller
105     BuiltIn.Set Suite Variable    ${mininet_conn_id}
106     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Are Switches Connected Topo
107
108 Final Phase
109     [Documentation]    Stops mininet.
110     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
111     RequestsLibrary.Delete All Sessions
112
113 Are Switches Connected Topo
114     [Documentation]    Checks wheather switches are connected to controller
115     ${resp}=    RequestsLibrary.Get Request    session    ${OPERATIONAL_TOPO_API}/topology/flow:1    headers=${ACCEPT_XML}
116     Log    ${resp.content}
117     ${count}=    XML.Get Element Count    ${resp.content}    xpath=node
118     Should Be Equal As Numbers    ${count}    1