blob: 355227935c3215201c36a8c66325262d7518c0b7 [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
3Library ExtendedSelenium2Library
4Library 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
Sonsino, Ofir (os0695)36a5fb02018-04-09 14:15:05 +030024 Should Be String ${resp.json()['message']}
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}
DR695Hbf5a3a32017-06-30 13:09:57 -040053 Log Logged in to ${VID_ENDPOINT}${VID_ENV}
DR695Hccff30b2017-02-17 18:44:24 -050054
55Go To VID HOME
56 [Documentation] Naviage to VID Home
57 Go To ${VID_HOME_URL}
Jerry Floodedbeafb2017-06-01 17:05:42 -040058 Wait Until Page Contains Welcome to VID ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
59
60Go 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 Floodf67ce0e2017-03-20 16:59:23 -040064
DR695Hccff30b2017-02-17 18:44:24 -050065Click On Button When Enabled
Jerry Floodf67ce0e2017-03-20 16:59:23 -040066 [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050067 Wait Until Page Contains Element xpath=${xpath} ${timeout}
68 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
69 Click Button xpath=${xpath}
70
DR695Hccff30b2017-02-17 18:44:24 -050071Click On Element When Visible
Jerry Floodf67ce0e2017-03-20 16:59:23 -040072 [Arguments] ${xpath} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050073 Wait Until Page Contains Element xpath=${xpath} ${timeout}
74 Wait Until Element Is Visible xpath=${xpath} ${timeout}
75 Click Element xpath=${xpath}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040076
DR695Hccff30b2017-02-17 18:44:24 -050077Select From List When Enabled
Jerry Floodf67ce0e2017-03-20 16:59:23 -040078 [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050079 Wait Until Page Contains Element xpath=${xpath} ${timeout}
80 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040081 Select From List xpath=${xpath} ${value}
82
83Input Text When Enabled
84 [Arguments] ${xpath} ${value} ${timeout}=${GLOBAL_VID_UI_TIMEOUT_MEDIUM}
DR695Hccff30b2017-02-17 18:44:24 -050085 Wait Until Page Contains Element xpath=${xpath} ${timeout}
86 Wait Until Element Is Enabled xpath=${xpath} ${timeout}
87 Input Text xpath=${xpath} ${value}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040088
DR695Hccff30b2017-02-17 18:44:24 -050089Parse Request Id
Jerry Floodf67ce0e2017-03-20 16:59:23 -040090 [Arguments] ${mso_response_text}
DR695Hccff30b2017-02-17 18:44:24 -050091 ${request_list}= Split String ${mso_response_text} 202)\n 1
Jerry Floodf67ce0e2017-03-20 16:59:23 -040092 ${clean_string}= Replace String ${request_list[1]} \n ${empty}
93 ${json}= To Json ${clean_string}
DR695Hccff30b2017-02-17 18:44:24 -050094 ${request_id}= Catenate ${json['requestReferences']['requestId']}
95 [Return] ${request_id}
Jerry Floodf67ce0e2017-03-20 16:59:23 -040096
DR695Hccff30b2017-02-17 18:44:24 -050097Parse Instance Id
Jerry Floodf67ce0e2017-03-20 16:59:23 -040098 [Arguments] ${mso_response_text}
DR695Hccff30b2017-02-17 18:44:24 -050099 ${request_list}= Split String ${mso_response_text} 202)\n 1
Jerry Floodf67ce0e2017-03-20 16:59:23 -0400100 ${json}= To Json ${request_list[1]}
DR695Hccff30b2017-02-17 18:44:24 -0500101 ${request_id}= Catenate ${json['requestReferences']['instanceId']}
DR695Hbf5a3a32017-06-30 13:09:57 -0400102 [Return] ${request_id}
Bin Yang326219a2018-05-31 05:35:33 +0000103
DR695Hbf5a3a32017-06-30 13:09:57 -0400104Get 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}
Bin Yang326219a2018-05-31 05:35:33 +0000111 ${services}= Get From Dictionary ${json} services
112 :for ${dict} in @{services}
DR695Hbf5a3a32017-06-30 13:09:57 -0400113 \ ${uuid}= Get From DIctionary ${dict} uuid
114 \ ${inv}= Get From DIctionary ${dict} invariantUUID
115 \ Return From Keyword If "${invariantUUID}" == "${inv}" ${uuid}
116 [Return] ""
117
118
119Get Module Names from VID
120 [Documentation] Must use UI since rest call get redirect to portal and get DNS error
121 ... Given the invariantUUID of the model, mock up the vf_modules list passed to Preload VNF
122 [Arguments] ${invariantUUID}
123 ${id}= Get Model UUID from VID ${invariantUUID}
124 Go To ${VID_ENDPOINT}${VID_ENV}/rest/models/services/${id}
125 ${resp}= Get Text xpath=//body/pre
126 ${json}= To Json ${resp}
127 ${modules}= Create List
128 ${vnfs}= Get From Dictionary ${json} vnfs
129 ${keys}= Get Dictionary Keys ${vnfs}
130 :for ${key} in @{keys}
131 \ Add VFModule ${vnfs['${key}']} ${modules}
132 [Return] ${modules}
133
134Add VFModule
135 [Documentation] Dig the vf module names from the VID service model
136 [Arguments] ${vnf} ${modules}
137 ${vfModules}= Get From Dictionary ${vnf} vfModules
138 ${keys}= Get Dictionary Keys ${vfModules}
139 :for ${key} in @{keys}
140 \ ${module}= Get From Dictionary ${vfModules} ${key}
141 \ ${dict}= Create Dictionary name=${module['name']}
142 \ Append to List ${modules} ${dict}