Remove trailing spaces in robot scripts
[testsuite.git] / robot / resources / vid / teardown_vid.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with VID. It handles low level stuff like managing the selenium request library and VID required steps
3 Library             SeleniumLibrary
4 Library         Collections
5 Library         String
6 Library        ONAPLibrary.SO    WITH NAME     SO
7 Resource        vid_interface.robot
8 Resource        create_vid_vnf.robot
9 Resource        create_service_instance.robot
10 Resource        ../heatbridge.robot
11
12 *** Variables ***
13 ${VID_ENV}            /vid
14 ${VID_SERVICE_MODELS_SEARCH_URL}  ${GLOBAL_VID_SERVER_PROTOCOL}://${GLOBAL_INJECTED_VID_IP_ADDR}:${GLOBAL_VID_SERVER_PORT}${VID_ENV}/serviceModels.htm#/instances/services
15
16 *** Keywords ***
17 Teardown VID
18     [Documentation]   Teardown the VID This assumes that the any runnign stacks have been torn down
19     [Arguments]    ${service_instance_id}    ${lcp_region}    ${tenant}   ${customer}    ${uris_to_delete}
20     Return From Keyword If   len('${service_instance_id}') == 0
21     # Keep going to the VID service instance until we get the pop-up alert that there is no service instance
22     ${status}    Catenate    FAIL
23     ${status}    ${vfmodule}=    Wait Until Keyword Succeeds    300s    1s    Delete VID    ${service_instance_id}    ${lcp_region}    ${tenant}   ${customer}    ${uris_to_delete}
24     Return From Keyword If   '${status}' == 'PASS'
25     Fail   ${status}
26
27
28 Delete VID
29     [Documentation]    Teardown the next VID entity that has a Remove icon.
30     [Arguments]    ${service_instance_id}    ${lcp_region}    ${tenant}   ${customer}    ${uris_to_delete}
31     # For vLB closed loop, we may have 2 vf modules and the vDNS one needs to be removed first.
32     ${remove_order}=    Create List    vDNS_Ete   vPKG   Vfmodule_Ete
33
34     # FAIL status is returned in ${vfmodule} because FAIL are ignored during teardown
35     ${status}    ${vfmodule}=   Run Keyword and Ignore Error   Delete Next VID Entity    ${service_instance_id}    ${lcp_region}    ${tenant}   ${remove_order}   ${customer}
36     Return From Keyword If    '${status}' == 'FAIL'    ${status}    ${vfmodule}
37     Return From Keyword If    '${vfmodule}' == 'FAIL'    ${status}    ${vfmodule}
38     # After tearing down a VF module, execute the reverse HB for it to remove the references from A&AI
39     Run Keyword If   'Vfmodule_Ete' in '${vfmodule}'    Execute Reverse Heatbridge    ${uris_to_delete}
40     Fail    Continue with Next Remove
41
42 Delete Next VID Entity
43     [Documentation]    Teardown the next VID entity that has a Remove icon.
44     [Arguments]    ${service_instance_id}    ${lcp_region}    ${tenant}   ${remove_order}   ${customer}
45     ${vfmodule}=    Catenate
46     Go To    ${VID_SERVICE_MODELS_SEARCH_URL}
47     Wait Until Page Contains    Please search by    timeout=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
48     Wait Until Page Contains Element    xpath=//div[@class='statusLine aaiHidden']    timeout=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
49     Wait Until Element Is Not Visible    xpath=//div[@class='statusLine aaiHidden']    timeout=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
50
51     # If we don't wait for this control to be enabled, the submit results in a 'not found' pop-up (UnexpectedAlertPresentException)
52     Select From List By Label    //select[@ng-model='selectedCustomer']    ${customer}
53     Click On Button When Enabled    //button[contains(text(),'Submit')]
54     # When Handle VID Alert detects a pop-up. it will return FAIL and we are done
55     # Return from Keyword is required because FAIL is inored during teardown
56     ${teardown_status}=   Catenate    PASS
57     ${status}   ${value}   Run Keyword And Ignore Error    Handle VID Alert
58     Return From Keyword If   '${status}' == 'FAIL'   ${status}
59     ${status}   ${value}   Run Keyword And Ignore Error    Wait Until Page Contains Element    link=View/Edit    timeout=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
60     Return From Keyword If   '${status}' == 'FAIL'   ${status}
61     ${teardown_status}=   Catenate    FAIL
62
63     Click Element     link=View/Edit
64     Wait Until Page Contains    View/Edit Service Instance     timeout=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
65     Wait Until Element Is Visible    xpath=//a/span[@class='glyphicon glyphicon-remove']    timeout=${GLOBAL_VID_UI_TIMEOUT_LONG}
66
67     :FOR   ${remove_first}    IN    @{remove_order}
68     \    ${remove_xpath}=    Set Variable   //li/div[contains(.,'${remove_first}')]/a/span[@class='glyphicon glyphicon-remove']
69     \    ${status}    ${data}=   Run Keyword And Ignore Error    Page Should Contain Element     xpath=${remove_xpath}
70     \    Exit For Loop If    '${status}' == 'PASS'
71     \   ${remove_xpath}=    Set Variable   //li/div/a/span[@class='glyphicon glyphicon-remove']
72     Click On Element When Visible    xpath=${remove_xpath}
73
74     ${status}   ${value}=   Run Keyword and Ignore Error   Wait Until Page Contains Element     xpath=//select[@parameter-id='lcpRegion']
75     Run Keyword If   '${status}'=='PASS'   Select From List By Label    xpath=//select[@parameter-id='lcpRegion']    ${lcp_region}
76     Run Keyword If   '${status}'=='PASS'   Select From List By Label    xpath=//select[@parameter-id='tenant']    ${tenant}
77     ${status}   ${vfmodule}=    Run Keyword And Ignore Error    Get Text    xpath=//td[contains(text(), 'Vf Module Name')]/../td[2]
78     Click Element    xpath=//div[@class='buttonRow']/button[@ngx-enabled='true']
79     #//*[@id="mContent"]/div/div/div/div/table/tbody/tr/td/div/div[2]/div/div[1]/div[5]/button[1]
80     Wait Until Page Contains    100 %     300s
81     ${response text}=    Get Text    xpath=//div[@ng-controller='deletionDialogController']//div[@ng-controller= 'msoCommitController']/pre[@class = 'log ng-binding']
82     ${request_id}=    Parse Request Id     ${response text}
83     Click Element    xpath=//div[@class='ng-scope']/div[@class = 'buttonRow']/button[text() = 'Close']
84     ${auth}=    Create List  ${GLOBAL_SO_USERNAME}    ${GLOBAL_SO_PASSWORD}
85     ${resp}=    SO.Run Polling Get Request    ${GLOBAL_SO_ENDPOINT}    ${GLOBAL_SO_STATUS_PATH}${request_id}    auth=${auth}
86     [Return]   ${teardown_status}    ${vfmodule}
87
88 Handle VID Alert
89     [Documentation]   When service instance has been deleted, an alert will be triggered on the search to end the loop
90     ...   The various Alert keywords did not prevent the alert exception on the Click ELement, hence this roundabout way of handling the alert
91     Run Keyword And Ignore Error        Click On Button When Enabled    //button[contains(text(),'Submit')]
92     ${status}   ${t}=    Run Keyword And Ignore Error    Handle Alert
93     Return From Keyword If   '${status}' == 'FAIL'
94     Fail    ${t}