blob: dd68ede82914cc7d3edc6af589ff4b6662cdf967 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with VID. It handles low level stuff like managing the selenium request library and VID required steps
DR695H910097e2019-05-08 13:55:32 -04003Library SeleniumLibrary
DR695Hccff30b2017-02-17 18:44:24 -05004Library Collections
5Library String
6Library RequestsLibrary
Jerry Floodf67ce0e2017-03-20 16:59:23 -04007Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05008Resource ../global_properties.robot
9Resource ../browser_setup.robot
10
11*** Variables ***
12${VID_ENV} /vid
DR695Hbf5a3a32017-06-30 13:09:57 -040013${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
Sonsino, Ofir (os0695)36a5fb02018-04-09 14:15:05 +030015${VID_HEALTHCHECK_PATH} ${VID_ENV}/healthCheck
DR695Hbf5a3a32017-06-30 13:09:57 -040016${VID_HOME_URL} ${VID_ENDPOINT}${VID_ENV}/welcome.htm
17${VID_SERVICE_MODELS_URL} ${VID_ENDPOINT}${VID_ENV}/serviceModels.htm#/models/services
DR695Hccff30b2017-02-17 18:44:24 -050018
19*** Keywords ***
20Run 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
Brian Freeman0acaa242019-03-06 16:52:26 -050024 Should Be String ${resp.json()['detailedMsg']}
DR695Hccff30b2017-02-17 18:44:24 -050025
26Run 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}
DR695Hbf5a3a32017-06-30 13:09:57 -040030 Log Creating session ${VID_ENDPOINT}
31 ${session}= Create Session vid ${VID_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050032 ${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 Floodf67ce0e2017-03-20 16:59:23 -040036 [Return] ${resp}
37
DR695Hccff30b2017-02-17 18:44:24 -050038Login 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}
Jerry Flood80ff9852017-08-11 06:47:14 -040043 #Maximize Browser Window
DR695Hccff30b2017-02-17 18:44:24 -050044 Set Selenium Speed ${GLOBAL_SELENIUM_DELAY}
45 Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
DR695Hbf5a3a32017-06-30 13:09:57 -040046 Log Logging in to ${VID_ENDPOINT}${VID_ENV}
DR695Hccff30b2017-02-17 18:44:24 -050047 Handle Proxy Warning
Jerry Floodedbeafb2017-06-01 17:05:42 -040048 Title Should Be Login
49 Input Text xpath=//input[@id='loginId'] ${GLOBAL_VID_USERNAME}
50 Input Password xpath=//input[@id='password'] ${GLOBAL_VID_PASSWORD}
DR695Hccff30b2017-02-17 18:44:24 -050051 Click Button xpath=//input[@id='loginBtn']
Jerry Floodedbeafb2017-06-01 17:05:42 -040052 Wait Until Page Contains Welcome to VID ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
Brian Freeman796b9eb2018-10-08 08:23:20 -050053 Select From List By Label //select[@id='selectTestApi'] VNF_API (old)
DR695Hbf5a3a32017-06-30 13:09:57 -040054 Log Logged in to ${VID_ENDPOINT}${VID_ENV}
DR695Hccff30b2017-02-17 18:44:24 -050055
56Go To VID HOME
57 [Documentation] Naviage to VID Home
58 Go To ${VID_HOME_URL}
Jerry Floodedbeafb2017-06-01 17:05:42 -040059 Wait Until Page Contains Welcome to VID ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
60
61Go To VID Browse Service Models
62 [Documentation] Naviage to VID Browse Service Models
63 Go To ${VID_SERVICE_MODELS_URL}
64 Wait Until Page Contains Browse SDC Service Models ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040065
DR695Hccff30b2017-02-17 18:44:24 -050066Click On Button When Enabled
Jerry Floodf67ce0e2017-03-20 16:59:23 -040067 [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050068 Wait Until Page Contains Element xpath=${xpath} ${timeout}
69 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
70 Click Button xpath=${xpath}
71
DR695Hccff30b2017-02-17 18:44:24 -050072Click On Element When Visible
Jerry Floodf67ce0e2017-03-20 16:59:23 -040073 [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050074 Wait Until Page Contains Element xpath=${xpath} ${timeout}
75 Wait Until Element Is Visible xpath=${xpath} ${timeout}
76 Click Element xpath=${xpath}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040077
DR695Hccff30b2017-02-17 18:44:24 -050078Select From List When Enabled
Jerry Floodf67ce0e2017-03-20 16:59:23 -040079 [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050080 Wait Until Page Contains Element xpath=${xpath} ${timeout}
81 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040082 Select From List xpath=${xpath} ${value}
83
84Input Text When Enabled
85 [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050086 Wait Until Page Contains Element xpath=${xpath} ${timeout}
87 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
88 Input Text xpath=${xpath} ${value}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040089
DR695Hccff30b2017-02-17 18:44:24 -050090Parse Request Id
Jerry Floodf67ce0e2017-03-20 16:59:23 -040091 [Arguments] ${mso_response_text}
DR695Hccff30b2017-02-17 18:44:24 -050092 ${request_list}= Split String ${mso_response_text} 202)\n 1
Jerry Floodf67ce0e2017-03-20 16:59:23 -040093 ${clean_string}= Replace String ${request_list[1]} \n ${empty}
94 ${json}= To Json ${clean_string}
DR695Hccff30b2017-02-17 18:44:24 -050095 ${request_id}= Catenate ${json['requestReferences']['requestId']}
96 [Return] ${request_id}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040097
DR695Hccff30b2017-02-17 18:44:24 -050098Parse Instance Id
Jerry Floodf67ce0e2017-03-20 16:59:23 -040099 [Arguments] ${mso_response_text}
DR695Hccff30b2017-02-17 18:44:24 -0500100 ${request_list}= Split String ${mso_response_text} 202)\n 1
Jerry Floodf67ce0e2017-03-20 16:59:23 -0400101 ${json}= To Json ${request_list[1]}
DR695Hccff30b2017-02-17 18:44:24 -0500102 ${request_id}= Catenate ${json['requestReferences']['instanceId']}
DR695Hbf5a3a32017-06-30 13:09:57 -0400103 [Return] ${request_id}
Bin Yang326219a2018-05-31 05:35:33 +0000104
DR695Hbf5a3a32017-06-30 13:09:57 -0400105Get Model UUID from VID
106 [Documentation] Must use UI since rest call get redirect to portal and get DNS error
107 ... Search all services and match on the invariantUUID
108 [Arguments] ${invariantUUID}
109 Go To ${VID_ENDPOINT}${VID_ENV}/rest/models/services
110 ${resp}= Get Text xpath=//body/pre
111 ${json}= To Json ${resp}
Bin Yang326219a2018-05-31 05:35:33 +0000112 ${services}= Get From Dictionary ${json} services
DR695H910097e2019-05-08 13:55:32 -0400113 :FOR ${dict} IN @{services}
DR695Hbf5a3a32017-06-30 13:09:57 -0400114 \ ${uuid}= Get From DIctionary ${dict} uuid
115 \ ${inv}= Get From DIctionary ${dict} invariantUUID
116 \ Return From Keyword If "${invariantUUID}" == "${inv}" ${uuid}
117 [Return] ""
118
119
120Get Module Names from VID
121 [Documentation] Must use UI since rest call get redirect to portal and get DNS error
122 ... Given the invariantUUID of the model, mock up the vf_modules list passed to Preload VNF
123 [Arguments] ${invariantUUID}
124 ${id}= Get Model UUID from VID ${invariantUUID}
125 Go To ${VID_ENDPOINT}${VID_ENV}/rest/models/services/${id}
126 ${resp}= Get Text xpath=//body/pre
127 ${json}= To Json ${resp}
128 ${modules}= Create List
129 ${vnfs}= Get From Dictionary ${json} vnfs
130 ${keys}= Get Dictionary Keys ${vnfs}
DR695H910097e2019-05-08 13:55:32 -0400131 :FOR ${key} IN @{keys}
DR695Hbf5a3a32017-06-30 13:09:57 -0400132 \ Add VFModule ${vnfs['${key}']} ${modules}
133 [Return] ${modules}
134
135Add VFModule
136 [Documentation] Dig the vf module names from the VID service model
137 [Arguments] ${vnf} ${modules}
138 ${vfModules}= Get From Dictionary ${vnf} vfModules
139 ${keys}= Get Dictionary Keys ${vfModules}
DR695H910097e2019-05-08 13:55:32 -0400140 :FOR ${key} IN @{keys}
DR695Hbf5a3a32017-06-30 13:09:57 -0400141 \ ${module}= Get From Dictionary ${vfModules} ${key}
142 \ ${dict}= Create Dictionary name=${module['name']}
143 \ Append to List ${modules} ${dict}