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