dda330bb1cda03ab7e2802a25598d86a3534b99f
[integration/test.git] / csit / suites / groupbasedpolicy / GBPSXP / ep_provider_register_part.robot
1 *** Settings ***
2 Documentation     Test suite for Group Based Policy, sxp-ep-provider component.
3 Suite Setup       Suite_Startup
4 Suite Teardown    Suite_Cleanup
5 Test Setup        GbpSxp.Prepare_Ssh_Tooling
6 Test Teardown     Wipe_Clean_Ep_Templates_And_Sxp_Node
7 Library           OperatingSystem    WITH NAME    os
8 Library           RequestsLibrary
9 Library           SSHLibrary
10 Library           ../../../libraries/GbpSxp.py    WITH NAME    gbpsxp
11 Resource          ../../../variables/Variables.robot
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/TemplatedRequests.robot
14 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
15 Resource          ../../../libraries/GbpSxp.robot
16
17 *** Variables ***
18 ${EP_PROVIDER_TEMPLATES_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-ep-provider-templates
19 ${SXP_NODE_CONFIG_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-node.json
20 ${SXP_NODE_ADD_ENTRY_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-node-add-entry.json
21 ${GBP_RPC_UNREGISTER_ENDPOINT_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-rpc-unregister-endpoint.json
22 ${GBP_EXPECTED_ENDPOINTS_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-endpoint
23 ${ISE_MOCK_SERVER_API_FOLDER}    mock-server-tc010
24 ${CONFIGURE_ISE_SOURCE_FILE}    ${CURDIR}/../../../variables/gbp/gbpsxp-ise-source.json
25 ${SXP_NODE_NAME}    1.1.1.1
26
27 *** Test Cases ***
28 Register_EP_Using_Manual_Inputs
29     [Documentation]    Elicit endpoint registration by providing ep-policy-template, ep-forwarding-template and ip-sgt binding
30     Utils.Add_Elements_To_URI_From_File    ${SXP_EP_PROVIDER_CONFIG_URI}    ${EP_PROVIDER_TEMPLATES_FILE}-2.1.json
31     Create_sxp_node    session    ${SXP_NODE_CONFIG_FILE}    1.1.1.1
32     Utils.Post_Elements_To_URI_From_File    ${SXP_NODE_RPC_ADD_ENTRY_URI}    ${SXP_NODE_ADD_ENTRY_FILE}
33     ${expected_endpoints}    os.Get_File    ${GBP_EXPECTED_ENDPOINTS_FILE}-2.1.json
34     Wait_For_Endpoint_And_Check    session    ${expected_endpoints}
35
36 Register_EP_Using_Manual_Inputs_And_Ise
37     [Documentation]    Elicit endpoint registration by providing ep-forwarding-template and ip-sgt binding (ep-policy-template will loaded from ise-API)
38     Utils.Add_Elements_To_URI_From_File    ${SXP_EP_PROVIDER_CONFIG_URI}    ${EP_PROVIDER_TEMPLATES_FILE}-2.2.json
39     gbpsxp.Deploy_Ise_Mock_Server    ${ISE_MOCK_SERVER_API_FOLDER}    ${ISE_REST_PORT}
40     ${ise_harvest_status_json}    gbpsxp.Configure_Ise_Source_And_Gain_Harvest_Status    session    ${CONFIGURE_ISE_SOURCE_FILE}    http://${TOOLS_SYSTEM_IP}:${ISE_REST_PORT}
41     gbpsxp.Check_Ise_Harvest_Status    ${ise_harvest_status_json}    5
42     Create_sxp_node    session    ${SXP_NODE_CONFIG_FILE}    ${SXP_NODE_NAME}
43     Utils.Post_Elements_To_URI_From_File    ${SXP_NODE_RPC_ADD_ENTRY_URI}    ${SXP_NODE_ADD_ENTRY_FILE}
44     ${expected_endpoints}    os.Get_File    ${GBP_EXPECTED_ENDPOINTS_FILE}-2.2.json
45     Wait_For_Endpoint_And_Check    session    ${expected_endpoints}
46     gbpsxp.Clean_ise_source_config
47     gbpsxp.Teardown_Ise_Mock_Server    ${ISE_MOCK_SERVER_API_FOLDER}
48
49 *** Keywords ***
50 Suite_Startup
51     [Documentation]    Setup session and set karaf log levels
52     RequestsLibrary.Create_Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
53     KarafKeywords.Setup_Karaf_Keywords
54     ${karaf_debug_enabled}    BuiltIn.Get_Variable_Value    ${KARAF_DEBUG}    ${False}
55     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.sxp
56     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.groupbasedpolicy.renderer
57     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.groupbasedpolicy.sxp
58     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.groupbasedpolicy.sxp_ep_provider
59
60 Suite_Cleanup
61     [Documentation]    Cleanup session and set karaf log levels to default
62     ${karaf_debug_enabled}    BuiltIn.Get_Variable_Value    ${KARAF_DEBUG}    ${False}
63     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set INFO org.opendaylight.sxp
64     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set INFO org.opendaylight.groupbasedpolicy.renderer
65     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set INFO org.opendaylight.groupbasedpolicy.sxp
66     BuiltIn.run_keyword_if    ${karaf_debug_enabled}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set INFO org.opendaylight.groupbasedpolicy.sxp_ep_provider
67     RequestsLibrary.Delete_All_Sessions
68
69 Wipe_Clean_Ep_Templates_And_Sxp_Node
70     [Documentation]    Delete sxp-ep-provider templates and sxp node
71     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Remove_All_Elements_If_Exist    ${SXP_EP_PROVIDER_CONFIG_URI}
72     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Remove_All_Elements_If_Exist    ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${SXP_NODE_NAME}
73     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Remove_All_Elements_If_Exist    ${GBP_TENANT_CONFIG_URI}
74     Utils.Post_Elements_To_URI_From_File    ${GBP_RPC_UNREGISTER_ENDPOINT_URI}    ${GBP_RPC_UNREGISTER_ENDPOINT_FILE}
75     BuiltIn.Wait_Until_Keyword_Succeeds    5    1    Check_For_Clean_Endpoints    session
76     gbpsxp.Teardown_Ssh_Tooling
77
78 Check_For_Clean_Endpoints
79     [Arguments]    ${session_arg}
80     [Documentation]    Ensure that there are no endpoints in the system
81     ${actual_endpoints}    Utils.Get_Data_From_URI    ${session_arg}    ${GBP_ENDPOINTS_URI}
82     ${actual_endpoints_json}    Utils.Json_Parse_From_String    ${actual_endpoints}
83     BuiltIn.Should_Be_Empty    ${actual_endpoints_json['endpoints']['address-endpoints']}
84
85 Wait_For_Endpoint_And_Check
86     [Arguments]    ${session_arg}    ${expected_endpoints}
87     [Documentation]    Wait for endpoint to appear in DS/operational and compare to expected endpoint
88     ${actual_endpoints_no_timestamp}    BuiltIn.Wait_Until_Keyword_Succeeds    5    1    Get_Endpoints_And_Clean_Timestamp    ${session_arg}
89     TemplatedRequests.Normalize_Jsons_And_Compare    ${expected_endpoints}    ${actual_endpoints_no_timestamp}
90
91 Get_Endpoints_And_Clean_Timestamp
92     [Arguments]    ${session_arg}
93     [Documentation]    Read endpoints from DS/operational and clean timestamp for simple comparison
94     ${actual_endpoints}    Utils.Get_Data_From_URI    ${session_arg}    ${GBP_ENDPOINTS_URI}
95     ${actual_endpoints_json}    Utils.Json_Parse_From_String    ${actual_endpoints}
96     ${actual_endpoints_no_timestamp}    gbpsxp.Remove_Endpoint_Timestamp    ${actual_endpoints_json}
97     [Return]    ${actual_endpoints_no_timestamp}
98
99 Create_sxp_node
100     [Arguments]    ${session_arg}    ${sxp_node_config_file}    ${sxp_node_id}
101     [Documentation]    Create sxp node and wait till it appears in DS/operational
102     ${previous_topology_config}    BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Get_Data_From_URI    ${session_arg}    ${SXP_TOPOLOGY_NODE_CONFIG_URI}
103     BuiltIn.Log    ${previous_topology_config}
104     Utils.Add_Elements_To_URI_From_File_And_Verify    ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${sxp_node_id}    ${sxp_node_config_file}
105     ${sxp_node_config_readback}    Utils.Get_Data_From_URI    ${session_arg}    ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${sxp_node_id}
106     BuiltIn.Wait_Until_Keyword_Succeeds    20    2    Check_If_Sxp_Node_Is_Enabled    ${session_arg}    ${SXP_TOPOLOGY_NODE_OPERATIONAL_URI}/node/${sxp_node_id}
107
108 Check_If_Sxp_Node_Is_Enabled
109     [Arguments]    ${session_arg}    ${node_uri}
110     [Documentation]    Read node enabled leaf and check if it is true
111     ${sxp_node}    Utils.Get_Data_From_URI    ${session_arg}    ${node_uri}
112     ${sxp_node_json}    Utils.Json_Parse_From_String    ${sxp_node}
113     ${sxp_node_enabled}    gbpsxp.Resolve_sxp_node_is_enabled    ${sxp_node_json}
114     BuiltIn.Should_Be_Equal_As_Strings    True    ${sxp_node_enabled}