blob: d8bd55363d61da7da849b6877d0c288ba8a0794a [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
Jerry Flood5db693b2017-05-24 08:52:39 -040015${VID_HEALTHCHECK_PATH} ${VID_ENV}/api/v2/users
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
24 Should Be String ${resp.json()[0]['loginId']}
25
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}
103
104Get 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
118Get 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
133Add 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}