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