bde238f279798bda90a6275f8eed9cc5e967f486
[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]
25 ${intent_validation2}    from [10.0.0.5] to [10.0.0.2]
26 ${intent_validation3}    from [10.0.0.5] to [10.0.0.3]
27 ${intent_validation4}    from [10.0.0.5] to [10.0.0.10]
28 ${intent_validation_policy1}    ALLOW
29 ${intent_validation_policy2}    BLOCK
30 ${intent_validation_policy3}    ALLOW
31 ${intent_validation_policy4}    BLOCK
32 @{all_intent_validations}    ${intent_validation1}    ${intent_validation2}    ${intent_validation3}    ${intent_validation4}
33 @{all_intent_validations_policies}    ${intent_validation_policy1}    ${intent_validation_policy2}    ${intent_validation_policy3}    ${intent_validation_policy4}
34
35 *** Test Cases ***
36 Verify NIC Command Add and Remove
37     [Documentation]    Verification of NIC Console command add and remove. It first creates the intents
38     ...    and stores the intent ids, then verifies that the intents were added. Finally, it compiles the intents
39     ...    to verify that intents were properly merged and also validates intents were removed at the end per the cleanup procedure.
40     ...    The command "Wait Until Keyword Succeeds" is used to poll for 10 minutes
41     ...    until the intent:add command is availible for the test case to be run.
42     [Tags]    NIC
43     Wait Until Keyword Succeeds    10 min    5 sec    Verify Intent:Add Command is Availible
44     : FOR    ${intent}    IN    @{all_intents}
45     \    ${id}=    Add Intent    @{intent}
46     \    Append To List    ${all_intents_ids}    ${id}
47     ${size}=    Get Length    ${all_intents}
48     : FOR    ${index}    IN RANGE    ${size}
49     \    ${intent}=    Get From List    ${all_intents}    ${index}
50     \    ${intent_id}=    Get From List    ${all_intents_ids}    ${index}
51     \    Verify Intent Added    ${intent_id}    ${intent}
52     ${output}=    Issue Command On Karaf Console    intent:compile
53     ${size}=    Get Length    ${all_intent_validations}
54     : FOR    ${index}    IN RANGE    ${size}
55     \    ${compiled_intent_validation}=    Get From List    ${all_intent_validations}    ${index}
56     \    ${intent_validation_line}=    Get Lines Containing String    ${output}    ${compiled_intent_validation}
57     \    ${policy}=    Get From List    ${all_intent_validations_policies}    ${index}
58     \    Should Contain    ${intent_validation_line}    ${policy}
59     : FOR    ${intent_id}    IN    @{all_intents_ids}
60     \    Remove Intent    ${intent_id}
61     ${output}=    Issue Command On Karaf Console    intent:list -c
62     : FOR    ${intent_id}    IN    @{all_intents_ids}
63     \    Should Not Contain    ${output}    ${id}
64
65 *** Keywords ***
66 Setup NIC Console Environment
67     [Documentation]    Installing NIC Console related features (odl-nic-core, odl-nic-console)
68     Install a Feature    odl-nic-core-service-mdsal
69     Install a Feature    odl-nic-core
70     Install a Feature    odl-nic-console
71     Start Suite
72     Verify Feature Is Installed    odl-nic-core
73     Verify Feature Is Installed    odl-nic-console
74
75 Add Intent
76     [Arguments]    ${intent_from}    ${intent_to}    ${intent_permission}
77     [Documentation]    Adds an intent to the controller, and returns the id of the intent created.
78     ${output}=    Issue Command On Karaf Console    intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
79     Should Contain    ${output}    Intent created
80     ${output}=    Fetch From Left    ${output}    )
81     ${output_split}=    Split String    ${output}    ${SPACE}
82     ${id}=    Get From List    ${output_split}    3
83     [Return]    ${id}
84
85 Verify Intent:Add Command is Availible
86     [Documentation]    Verifies that odl-nic-console is up and intent:add command is available to be used.
87     ...    Should be used with the command "Wait Until Keyword Succeeds" to poll until command is availible.
88     ${output}=    Issue Command On Karaf Console    intent:add
89     Should Not Contain    ${output}    Command not found
90
91 Verify Intent Added
92     [Arguments]    ${id}    ${intent}
93     [Documentation]    This will check if the id exists via intent:list -c, then compares intent details with arguments passed in with Add Intent
94     ${output}=    Issue Command On Karaf Console    intent:list -c
95     Should Contain    ${output}    ${id}
96     ${output}=    Issue Command On Karaf Console    intent:show ${id}
97     ${out}=    Get Lines Containing String    ${output}    Value:
98     ${out_intent_from}=    Get Line    ${out}    0
99     ${out_intent_to}=    Get Line    ${out}    1
100     ${out_intent_permission}=    Get Line    ${out}    2
101     ${intent_from}=    Get From List    ${intent}    0
102     ${intent_to}=    Get From List    ${intent}    1
103     ${intent_permission}=    Get From List    ${intent}    2
104     Should Contain    ${out_intent_from}    ${intent_from}
105     Should Contain    ${out_intent_to}    ${intent_to}
106     Should Contain    ${out_intent_permission}    ${intent_permission}
107
108 Remove Intent
109     [Arguments]    ${id}
110     [Documentation]    Removes an intent from the controller via the provided intent id.
111     ${output}=    Issue Command On Karaf Console    intent:remove ${id}
112     Should Contain    ${output}    Intent successfully removed