Step 2: Move test folder to root
[integration/test.git] / csit / libraries / NicKeywords.robot
1 *** Settings ***
2 Library           SSHLibrary
3 Library           String
4 Library           DateTime
5 Library           Collections
6 Library           json
7 Library           RequestsLibrary
8 Variables         ../variables/Variables.py
9 Resource          ./Utils.robot
10 Resource          Scalability.robot
11
12 *** Variables ***
13 ${switches}       2
14 ${REST_CONTEXT_INTENT}    restconf/config/intent:intents/intent
15 ${INTENTS}        restconf/config/intent:intents
16 ${VTN_INVENTORY}    restconf/operational/vtn-inventory:vtn-nodes
17 ${INTENT_ID}      b9a13232-525e-4d8c-be21-cd65e3436033
18
19 *** Keywords ***
20 Start NIC VTN Renderer Suite
21     [Documentation]    Start Nic VTN Renderer Init Test Suite
22     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
23     BuiltIn.Wait_Until_Keyword_Succeeds    30    3    Fetch Intent List
24
25 Stop NIC VTN Renderer Suite
26     [Documentation]    Stop Nic VTN Renderer Test Suite
27     Delete All Sessions
28
29 Start NIC VTN Rest Test Suite
30     [Documentation]    Start Nic VTN Renderer Rest Test Suite
31     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
32     Clean Mininet System
33     Start Mininet Linear    ${switches}
34
35 Stop NIC VTN Rest Test Suite
36     [Documentation]    Stop Nic VTN Renderer Test Suite
37     Stop Mininet    ${mininet_conn_id}
38
39 Fetch Intent List
40     [Documentation]    Check if VTN Renderer feature is installed.
41     ${resp}=    RequestsLibrary.Get    session    ${INTENTS}
42     Should Be Equal As Strings    ${resp.status_code}    200
43
44 Add Intent Using RestConf
45     [Arguments]    ${intent_id}    ${intent_data}
46     [Documentation]    Create a intent with specified parameters.
47     ${resp}=    RequestsLibrary.put    session    ${REST_CONTEXT_INTENT}/${intent_id}    data=${intent_data}
48     Should Be Equal As Strings    ${resp.status_code}    200
49
50 Verify Intent Using RestConf
51     [Arguments]    ${intent_id}
52     [Documentation]    Verify If intent is created.
53     ${resp}=    RequestsLibrary.Get    session    ${REST_CONTEXT_INTENT}/${intent_id}
54     Should Be Equal As Strings    ${resp.status_code}    200
55
56 Update Intent Using RestConf
57     [Arguments]    ${intent_id}    ${intent_data}
58     [Documentation]    Update a intent with specified parameters.
59     ${resp}=    RequestsLibrary.put    session    ${REST_CONTEXT_INTENT}/${intent_id}    data=${intent_data}
60     Should Be Equal As Strings    ${resp.status_code}    200
61
62 Delete Intent Using RestConf
63     [Arguments]    ${intent_id}
64     [Documentation]    Delete a intent with specified parameters.
65     ${resp}=    RequestsLibrary.Delete    session    ${REST_CONTEXT_INTENT}/${intent_id}
66     Should Be Equal As Strings    ${resp.status_code}    200
67
68 Add Intent From Karaf Console
69     [Arguments]    ${intent_from}    ${intent_to}    ${intent_permission}
70     [Documentation]    Adds an intent to the controller, and returns the id of the intent created.
71     ${output}=    Issue Command On Karaf Console    intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
72     Should Contain    ${output}    Intent created
73     ${output}=    Fetch From Left    ${output}    )
74     ${output_split}=    Split String    ${output}    ${SPACE}
75     ${id}=    Get From List    ${output_split}    3
76     [Return]    ${id}
77
78 Remove Intent From Karaf Console
79     [Arguments]    ${id}
80     [Documentation]    Removes an intent from the controller via the provided intent id.
81     ${output}=    Issue Command On Karaf Console    intent:remove ${id}
82     Should Contain    ${output}    Intent successfully removed
83     ${output}=    Issue Command On Karaf Console    log:display |grep "Removed VTN configuration associated with the deleted Intent: "
84     Should Contain    ${output}    Removed VTN configuration associated with the deleted Intent    ${id}
85
86 Mininet Ping Should Succeed
87     [Arguments]    ${host1}    ${host2}
88     [Timeout]    2 minute
89     Write    ${host1} ping -c 10 ${host2}
90     ${result}    Read Until    mininet>
91     Should Contain    ${result}    64 bytes
92
93 Mininet Ping Should Not Succeed
94     [Arguments]    ${host1}    ${host2}
95     [Timeout]    2 minute
96     Write    ${host1} ping -c 10 ${host2}
97     ${result}    Read Until    mininet>
98     Should Not Contain    ${result}    64 bytes