Sample integration test
[integration/test.git] / test / csit / suites / controller / AD_SAL_Apps_OF10 / 010__host_tracker.txt
1 *** Settings ***
2 Documentation     Test suite for Host Tracker
3 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTPORT}    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 ${name}           10.0.1.4
12 ${key}            hostConfig
13 ${REST_CONTEXT}    /controller/nb/v2/hosttracker
14 ${REST_CONTEXT_ST}    /controller/nb/v2/statistics
15 ${FLOW}           "10.0.1.4"
16
17 *** Test Cases ***
18 Add a host
19     [Documentation]    Add a host, list to validate the result.
20     [Tags]    apps
21     ${body}    Create Dictionary    nodeType    OF    dataLayerAddress    5e:bf:79:84:10:a6    vlan
22     ...    1    nodeId    00:00:00:00:00:00:00:03    nodeConnectorId    2    networkAddress
23     ...    10.0.1.4    staticHost    ${True}    nodeConnectorType    OF
24     ${resp}    RequestsLibrary.Put    session    ${REST_CONTEXT}/${CONTAINER}/address/${name}    data=${body}
25     Should Be Equal As Strings    ${resp.status_code}    201
26     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/${CONTAINER}/hosts/active
27     Should Be Equal As Strings    ${resp.status_code}    200
28     ${result}    To JSON    ${resp.content}
29     ${content}    Get From Dictionary    ${result}    ${key}
30     List Should Contain Value    ${content}    ${body}
31
32 Check flow in flow stats
33     [Documentation]    Show flow stats and validate result
34     [Tags]    apps
35     Sleep    30
36     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_ST}/${CONTAINER}/flow
37     Should Be Equal As Strings    ${resp.status_code}    200
38     Log    ${resp.content}
39     Should Contain X Times    ${resp.content}    ${FLOW}    3
40
41 Remove a host
42     [Documentation]    Remove a host, list to validate the result.
43     [Tags]    apps
44     ${body}    Create Dictionary    nodeType    OF    dataLayerAddress    5e:bf:79:84:10:a6    vlan
45     ...    1    nodeId    00:00:00:00:00:00:00:03    nodeConnectorId    2    networkAddress
46     ...    10.0.1.4    staticHost    ${True}    nodeConnectorType    OF
47     ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT}/${CONTAINER}/address/${name}
48     Should Be Equal As Strings    ${resp.status_code}    204
49     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/${CONTAINER}/hosts/inactive
50     Should Be Equal As Strings    ${resp.status_code}    200
51     ${result}    To JSON    ${resp.content}
52     ${content}    Get From Dictionary    ${result}    ${key}
53     List Should Not Contain Value    ${content}    ${body}
54
55 Check flow is not in flow stats
56     [Documentation]    Show flow stats and validate result
57     [Tags]    apps
58     Sleep    30
59     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_ST}/${CONTAINER}/flow
60     Should Be Equal As Strings    ${resp.status_code}    200
61     Log    ${resp.content}
62     Should Not Contain    ${resp.content}    ${FLOW}