DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 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 RequestsLibrary |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 7 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 8 | Resource ../global_properties.robot |
| 9 | Resource ../browser_setup.robot |
| 10 | |
| 11 | *** Variables *** |
| 12 | ${VID_ENV} /vid |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 13 | ${VID_ENDPOINT} ${GLOBAL_VID_SERVER_PROTOCOL}://${GLOBAL_INJECTED_VID_IP_ADDR}:${GLOBAL_VID_SERVER_PORT} |
| 14 | ${VID_LOGIN_URL} ${VID_ENDPOINT}${VID_ENV}/login.htm |
Jerry Flood | 5db693b | 2017-05-24 08:52:39 -0400 | [diff] [blame] | 15 | ${VID_HEALTHCHECK_PATH} ${VID_ENV}/api/v2/users |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 16 | ${VID_HOME_URL} ${VID_ENDPOINT}${VID_ENV}/welcome.htm |
| 17 | ${VID_SERVICE_MODELS_URL} ${VID_ENDPOINT}${VID_ENV}/serviceModels.htm#/models/services |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 18 | |
| 19 | *** Keywords *** |
| 20 | Run VID Health Check |
| 21 | [Documentation] Logs in to VID GUI |
| 22 | ${resp}= Run VID Get Request ${VID_HEALTHCHECK_PATH} |
| 23 | Should Be Equal As Strings ${resp.status_code} 200 |
| 24 | Should Be String ${resp.json()[0]['loginId']} |
| 25 | |
| 26 | Run VID Get Request |
| 27 | [Documentation] Runs an VID get request |
| 28 | [Arguments] ${data_path} |
| 29 | ${auth}= Create List ${GLOBAL_VID_HEALTH_USERNAME} ${GLOBAL_VID_HEALTH_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 30 | Log Creating session ${VID_ENDPOINT} |
| 31 | ${session}= Create Session vid ${VID_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 32 | ${uuid}= Generate UUID |
| 33 | ${headers}= Create Dictionary username=${GLOBAL_VID_HEALTH_USERNAME} password=${GLOBAL_VID_HEALTH_PASSWORD} Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 34 | ${resp}= Get Request vid ${data_path} headers=${headers} |
| 35 | Log Received response from vid ${resp.text} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 36 | [Return] ${resp} |
| 37 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 38 | Login To VID GUI |
| 39 | [Documentation] Logs in to VID GUI |
| 40 | # Setup Browser Now being managed by test case |
| 41 | ##Setup Browser |
| 42 | Go To ${VID_LOGIN_URL} |
| 43 | Maximize Browser Window |
| 44 | Set Selenium Speed ${GLOBAL_SELENIUM_DELAY} |
| 45 | Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 46 | Log Logging in to ${VID_ENDPOINT}${VID_ENV} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 47 | Handle Proxy Warning |
Jerry Flood | edbeafb | 2017-06-01 17:05:42 -0400 | [diff] [blame] | 48 | Title Should Be Login |
| 49 | Input Text xpath=//input[@id='loginId'] ${GLOBAL_VID_USERNAME} |
| 50 | Input Password xpath=//input[@id='password'] ${GLOBAL_VID_PASSWORD} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 51 | Click Button xpath=//input[@id='loginBtn'] |
Jerry Flood | edbeafb | 2017-06-01 17:05:42 -0400 | [diff] [blame] | 52 | Wait Until Page Contains Welcome to VID ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 53 | Log Logged in to ${VID_ENDPOINT}${VID_ENV} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 54 | |
| 55 | Go To VID HOME |
| 56 | [Documentation] Naviage to VID Home |
| 57 | Go To ${VID_HOME_URL} |
Jerry Flood | edbeafb | 2017-06-01 17:05:42 -0400 | [diff] [blame] | 58 | Wait Until Page Contains Welcome to VID ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT} |
| 59 | |
| 60 | Go To VID Browse Service Models |
| 61 | [Documentation] Naviage to VID Browse Service Models |
| 62 | Go To ${VID_SERVICE_MODELS_URL} |
| 63 | Wait Until Page Contains Browse SDC Service Models ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 64 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 65 | Click On Button When Enabled |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 66 | [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 67 | Wait Until Page Contains Element xpath=${xpath} ${timeout} |
| 68 | Wait Until Element Is Enabled xpath=${xpath} ${timeout} |
| 69 | Click Button xpath=${xpath} |
| 70 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 71 | Click On Element When Visible |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 72 | [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 73 | Wait Until Page Contains Element xpath=${xpath} ${timeout} |
| 74 | Wait Until Element Is Visible xpath=${xpath} ${timeout} |
| 75 | Click Element xpath=${xpath} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 76 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 77 | Select From List When Enabled |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 78 | [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 79 | Wait Until Page Contains Element xpath=${xpath} ${timeout} |
| 80 | Wait Until Element Is Enabled xpath=${xpath} ${timeout} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 81 | Select From List xpath=${xpath} ${value} |
| 82 | |
| 83 | Input Text When Enabled |
| 84 | [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 85 | Wait Until Page Contains Element xpath=${xpath} ${timeout} |
| 86 | Wait Until Element Is Enabled xpath=${xpath} ${timeout} |
| 87 | Input Text xpath=${xpath} ${value} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 88 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 89 | Parse Request Id |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 90 | [Arguments] ${mso_response_text} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 91 | ${request_list}= Split String ${mso_response_text} 202)\n 1 |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 92 | ${clean_string}= Replace String ${request_list[1]} \n ${empty} |
| 93 | ${json}= To Json ${clean_string} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 94 | ${request_id}= Catenate ${json['requestReferences']['requestId']} |
| 95 | [Return] ${request_id} |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 96 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 97 | Parse Instance Id |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 98 | [Arguments] ${mso_response_text} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 99 | ${request_list}= Split String ${mso_response_text} 202)\n 1 |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 100 | ${json}= To Json ${request_list[1]} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 101 | ${request_id}= Catenate ${json['requestReferences']['instanceId']} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame^] | 102 | [Return] ${request_id} |
| 103 | |
| 104 | Get Model UUID from VID |
| 105 | [Documentation] Must use UI since rest call get redirect to portal and get DNS error |
| 106 | ... Search all services and match on the invariantUUID |
| 107 | [Arguments] ${invariantUUID} |
| 108 | Go To ${VID_ENDPOINT}${VID_ENV}/rest/models/services |
| 109 | ${resp}= Get Text xpath=//body/pre |
| 110 | ${json}= To Json ${resp} |
| 111 | :for ${dict} in @{json} |
| 112 | \ ${uuid}= Get From DIctionary ${dict} uuid |
| 113 | \ ${inv}= Get From DIctionary ${dict} invariantUUID |
| 114 | \ Return From Keyword If "${invariantUUID}" == "${inv}" ${uuid} |
| 115 | [Return] "" |
| 116 | |
| 117 | |
| 118 | Get Module Names from VID |
| 119 | [Documentation] Must use UI since rest call get redirect to portal and get DNS error |
| 120 | ... Given the invariantUUID of the model, mock up the vf_modules list passed to Preload VNF |
| 121 | [Arguments] ${invariantUUID} |
| 122 | ${id}= Get Model UUID from VID ${invariantUUID} |
| 123 | Go To ${VID_ENDPOINT}${VID_ENV}/rest/models/services/${id} |
| 124 | ${resp}= Get Text xpath=//body/pre |
| 125 | ${json}= To Json ${resp} |
| 126 | ${modules}= Create List |
| 127 | ${vnfs}= Get From Dictionary ${json} vnfs |
| 128 | ${keys}= Get Dictionary Keys ${vnfs} |
| 129 | :for ${key} in @{keys} |
| 130 | \ Add VFModule ${vnfs['${key}']} ${modules} |
| 131 | [Return] ${modules} |
| 132 | |
| 133 | Add VFModule |
| 134 | [Documentation] Dig the vf module names from the VID service model |
| 135 | [Arguments] ${vnf} ${modules} |
| 136 | ${vfModules}= Get From Dictionary ${vnf} vfModules |
| 137 | ${keys}= Get Dictionary Keys ${vfModules} |
| 138 | :for ${key} in @{keys} |
| 139 | \ ${module}= Get From Dictionary ${vfModules} ${key} |
| 140 | \ ${dict}= Create Dictionary name=${module['name']} |
| 141 | \ Append to List ${modules} ${dict} |