Step 2: Move test folder to root
[integration/test.git] / csit / suites / nic / cli / console.robot
1 *** Settings ***
2 Documentation     Basic Tests for NIC Console Commands.
3 ...
4 ...               Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 Suite Setup       Setup NIC Console Environment
10 Library           SSHLibrary
11 Library           Collections
12 Library           OperatingSystem
13 Library           ../../../libraries/Common.py
14 Resource          ../../../libraries/KarafKeywords.robot
15 Resource          ../../../libraries/Utils.robot
16 Variables         ../../../variables/Variables.py
17
18 *** Variables ***
19 @{intent1}        10.0.0.5    10.0.0.2,10.0.0.3    ALLOW
20 @{intent2}        10.0.0.5    10.0.0.2,10.0.0.10    BLOCK
21 @{intent3}        10.0.0.1,10.0.0.4    10.0.0.2    ALLOW
22 @{all_intents}    ${intent1}    ${intent2}    ${intent3}
23 @{all_intents_ids}
24 ${intent_validation1}    from [10.0.0.1, 10.0.0.4] to [10.0.0.2] apply ALLOW
25 ${intent_validation2}    from [10.0.0.5] to [10.0.0.2] apply BLOCK
26 ${intent_validation3}    from [10.0.0.5] to [10.0.0.3] apply ALLOW
27 ${intent_validation4}    from [10.0.0.5] to [10.0.0.10] apply BLOCK
28 @{all_intent_validations}    ${intent_validation1}    ${intent_validation2}    ${intent_validation3}    ${intent_validation4}
29
30 *** Test Cases ***
31 Verify NIC Command Add and Remove
32     [Documentation]    Verification of NIC Console command add and remove. It first creates the intents
33     ...    and stores the intent ids, then verifies that the intents were added. Finally, it compiles the intents
34     ...    to verify that intents were properly merged and also validates intents were removed at the end per the cleanup procedure.
35     [Tags]    NIC
36     : FOR    ${intent}    IN    @{all_intents}
37     \    ${id}=    Add Intent    @{intent}
38     \    Append To List    ${all_intents_ids}    ${id}
39     ${size}=    Get Length    ${all_intents}
40     : FOR    ${index}    IN RANGE    ${size}
41     \    ${intent}=    Get From List    ${all_intents}    ${index}
42     \    ${intent_id}=    Get From List    ${all_intents_ids}    ${index}
43     \    Verify Intent Added    ${intent_id}    ${intent}
44     ${output}=    Issue Command On Karaf Console    intent:compile
45     : FOR    ${valid_intent}    IN    @{all_intent_validations}
46     \    Should Contain    ${output}    ${valid_intent}
47     : FOR    ${intent_id}    IN    @{all_intents_ids}
48     \    Remove Intent    ${intent_id}
49     ${output}=    Issue Command On Karaf Console    intent:list -c
50     : FOR    ${intent_id}    IN    @{all_intents_ids}
51     \    Should Not Contain    ${output}    ${id}
52
53 *** Keywords ***
54 Setup NIC Console Environment
55     [Documentation]    Installing NIC Console related features (odl-nic-core, odl-nic-console)
56     Install a Feature    odl-nic-core
57     Install a Feature    odl-nic-console
58     Start Suite
59     Verify Feature Is Installed    odl-nic-core
60     Verify Feature Is Installed    odl-nic-console
61
62 Add Intent
63     [Arguments]    ${intent_from}    ${intent_to}    ${intent_permission}
64     [Documentation]    Adds an intent to the controller, and returns the id of the intent created.
65     ${output}=    Issue Command On Karaf Console    intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
66     Should Contain    ${output}    Intent created
67     ${output}=    Fetch From Left    ${output}    )
68     ${output_split}=    Split String    ${output}    ${SPACE}
69     ${id}=    Get From List    ${output_split}    3
70     [Return]    ${id}
71
72 Verify Intent Added
73     [Arguments]    ${id}    ${intent}
74     [Documentation]    This will check if the id exists via intent:list -c, then compares intent details with arguments passed in with Add Intent
75     ${output}=    Issue Command On Karaf Console    intent:list -c
76     Should Contain    ${output}    ${id}
77     ${output}=    Issue Command On Karaf Console    intent:show ${id}
78     ${out}=    Get Lines Containing String    ${output}    Value:
79     ${out_intent_from}=    Get Line    ${out}    0
80     ${out_intent_to}=    Get Line    ${out}    1
81     ${out_intent_permission}=    Get Line    ${out}    2
82     ${intent_from}=    Get From List    ${intent}    0
83     ${intent_to}=    Get From List    ${intent}    1
84     ${intent_permission}=    Get From List    ${intent}    2
85     Should Contain    ${out_intent_from}    ${intent_from}
86     Should Contain    ${out_intent_to}    ${intent_to}
87     Should Contain    ${out_intent_permission}    ${intent_permission}
88
89 Remove Intent
90     [Arguments]    ${id}
91     [Documentation]    Removes an intent from the controller via the provided intent id.
92     ${output}=    Issue Command On Karaf Console    intent:remove ${id}
93     Should Contain    ${output}    Intent successfully removed