Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 1 | *** Settings *** |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 2 | Documentation The main interface for interacting with OOF: SNIRO and Homing Service |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 3 | Library RequestsLibrary |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 4 | Library ONAPLibrary.Utilities |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 5 | Library OperatingSystem |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 6 | Library String |
| 7 | Library DateTime |
| 8 | Library Collections |
DR695H | 7aca1a4 | 2019-06-03 17:08:34 -0400 | [diff] [blame] | 9 | Library ONAPLibrary.JSON |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 10 | Resource global_properties.robot |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 11 | Resource json_templater.robot |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 12 | |
| 13 | *** Variables *** |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 14 | ${OOF_HOMING_HEALTH_CHECK_PATH} /v1/plans/healthcheck |
| 15 | ${OOF_SNIRO_HEALTH_CHECK_PATH} /api/oof/v1/healthcheck |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 16 | ${OOF_CMSO_HEALTH_CHECK_PATH} /cmso/v1/health?checkInterfaces=true |
| 17 | |
| 18 | ${OOF_CMSO_TEMPLATE_FOLDER} robot/assets/templates/cmso |
| 19 | ${OOF_CMSO_UTC} %Y-%m-%dT%H:%M:%SZ |
Ruoyu Ying | c014e92 | 2019-04-11 02:31:44 +0800 | [diff] [blame] | 20 | ${OOF_HOMING_PLAN_FOLDER} robot/assets/templates/optf-has |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 21 | ${OOF_OSDF_TEMPLATE_FOLDER} robot/assets/templates/optf-osdf |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 22 | |
Gary Wu | 251aa68 | 2018-07-30 15:22:20 -0700 | [diff] [blame] | 23 | ${OOF_HOMING_ENDPOINT} ${GLOBAL_OOF_SERVER_PROTOCOL}://${GLOBAL_INJECTED_OOF_HOMING_IP_ADDR}:${GLOBAL_OOF_HOMING_SERVER_PORT} |
| 24 | ${OOF_SNIRO_ENDPOINT} ${GLOBAL_OOF_SERVER_PROTOCOL}://${GLOBAL_INJECTED_OOF_SNIRO_IP_ADDR}:${GLOBAL_OOF_SNIRO_SERVER_PORT} |
Jerry Flood | 0c3270c | 2018-11-01 12:46:55 -0400 | [diff] [blame] | 25 | ${OOF_CMSO_ENDPOINT} ${GLOBAL_OOF_CMSO_PROTOCOL}://${GLOBAL_INJECTED_OOF_CMSO_IP_ADDR}:${GLOBAL_OOF_CMSO_SERVER_PORT} |
DR695H | a868f7c | 2019-06-17 12:16:21 -0400 | [diff] [blame^] | 26 | ${OOF_OSDF_ENDPOINT} ${GLOBAL_OOF_SERVER_PROTOCOL}://${GLOBAL_INJECTED_OOF_HOMING_IP_ADDR}:${GLOBAL_OOF_HOMING_SERVER_PORT} |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 27 | |
Ruoyu Ying | c014e92 | 2019-04-11 02:31:44 +0800 | [diff] [blame] | 28 | ${OOF_HOMING_AUTH} Basic YWRtaW4xOnBsYW4uMTU= |
| 29 | |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 30 | *** Keywords *** |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 31 | Run OOF-Homing Health Check |
| 32 | [Documentation] Runs OOF-Homing Health check |
| 33 | ${resp}= Run OOF-Homing Get Request ${OOF_HOMING_HEALTH_CHECK_PATH} |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 34 | Should Be Equal As Integers ${resp.status_code} 200 |
| 35 | |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 36 | Run OOF-Homing Get Request |
| 37 | [Documentation] Runs OOF-Homing Get request |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 38 | [Arguments] ${data_path} |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 39 | ${session}= Create Session session ${OOF_HOMING_ENDPOINT} |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 40 | ${resp}= Get Request session ${data_path} |
| 41 | Should Be Equal As Integers ${resp.status_code} 200 |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 42 | Log Received response from OOF-Homing ${resp.text} |
| 43 | [Return] ${resp} |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 44 | |
Ruoyu Ying | c014e92 | 2019-04-11 02:31:44 +0800 | [diff] [blame] | 45 | RUN OOF-Homing SendPlanWithWrongVersion |
| 46 | [Documentation] It sends a POST request to conductor |
| 47 | ${session}= Create Session optf-cond ${OOF_HOMING_ENDPOINT} |
| 48 | ${data}= Get Binary File ${OOF_HOMING_PLAN_FOLDER}${/}plan_with_wrong_version.json |
| 49 | &{headers}= Create Dictionary Authorization=${OOF_HOMING_Auth} Content-Type=application/json Accept=application/json |
| 50 | ${resp}= Post Request optf-cond /v1/plans data=${data} headers=${headers} |
| 51 | Log ********************* |
| 52 | Log response = ${resp} |
| 53 | Log body = ${resp.text} |
DR695H | 315b7e7 | 2019-05-03 16:49:19 -0400 | [diff] [blame] | 54 | ${generatedPlanId}= Convert To String ${resp.json()['id']} |
Ruoyu Ying | c014e92 | 2019-04-11 02:31:44 +0800 | [diff] [blame] | 55 | Set Global Variable ${generatedPlanId} |
| 56 | Log generatedPlanId = ${generatedPlanId} |
| 57 | Should Be Equal As Integers ${resp.status_code} 201 |
| 58 | Sleep 10s Wait Plan Resolution |
| 59 | |
Eric Debeau | ca1b9c8 | 2018-04-24 20:41:02 +0000 | [diff] [blame] | 60 | Run OOF-SNIRO Health Check |
| 61 | [Documentation] Runs OOF-SNIRO Health check |
| 62 | ${resp}= Run OOF-SNIRO Get Request ${OOF_SNIRO_HEALTH_CHECK_PATH} |
| 63 | Should Be Equal As Integers ${resp.status_code} 200 |
| 64 | |
| 65 | Run OOF-SNIRO Get Request |
| 66 | [Documentation] Runs OOF-SNIRO Get request |
| 67 | [Arguments] ${data_path} |
| 68 | ${session}= Create Session session ${OOF_SNIRO_ENDPOINT} |
| 69 | ${resp}= Get Request session ${data_path} |
| 70 | Should Be Equal As Integers ${resp.status_code} 200 |
| 71 | Log Received response from OOF-SNIRO ${resp.text} |
Eric Debeau | 9045a1e | 2018-04-24 17:22:41 +0000 | [diff] [blame] | 72 | [Return] ${resp} |
Jerry Flood | 0c3270c | 2018-11-01 12:46:55 -0400 | [diff] [blame] | 73 | |
| 74 | |
| 75 | Run OOF-CMSO Health Check |
| 76 | [Documentation] Runs OOF-CMSO Health check |
| 77 | ${resp}= Run OOF-CMSO Get Request ${OOF_CMSO_HEALTH_CHECK_PATH} |
| 78 | Should Be Equal As Integers ${resp.status_code} 200 |
| 79 | |
| 80 | Run OOF-CMSO Get Request |
| 81 | [Documentation] Runs OOF-CMSO Get request |
| 82 | [Arguments] ${data_path} |
| 83 | ${auth}= Create List ${GLOBAL_OOF_CMSO_USERNAME} ${GLOBAL_OOF_CMSO_PASSWORD} |
| 84 | ${session}= Create Session session ${OOF_CMSO_ENDPOINT} auth=${auth} |
| 85 | ${resp}= Get Request session ${data_path} |
| 86 | Should Be Equal As Integers ${resp.status_code} 200 |
| 87 | Log Received response from OOF-CMSO ${resp.text} |
| 88 | [Return] ${resp} |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 89 | |
| 90 | Run OOF-CMSO Post Scheduler |
| 91 | [Documentation] Runs a scheduler POST request |
| 92 | [Arguments] ${data_path} ${data}={} |
| 93 | ${auth}= Create List ${GLOBAL_OOF_CMSO_USERNAME} ${GLOBAL_OOF_CMSO_PASSWORD} |
| 94 | ${session}= Create Session session ${OOF_CMSO_ENDPOINT} auth=${auth} |
| 95 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 96 | ${resp}= Post Request session ${data_path} headers=${headers} data=${data} |
| 97 | Log Received response from scheduler ${resp.text} |
| 98 | [Return] ${resp} |
| 99 | |
| 100 | Run OOF-CMSO Future Schedule |
| 101 | [Documentation] Runs CMSO Future Schedule ETE test. One VNF, One Change Window |
| 102 | [Arguments] ${request_file}=OneVnfOneChangeWindow.json.template ${workflow}=Replace ${minutesFromNow}=3 |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 103 | ${uuid}= Generate UUID4 |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 104 | ${resp}= OOF-CMSO Create Schedule ${uuid} ${request_file} workflow=${workflow} minutesFromNow=${minutesFromNow} |
| 105 | Should Be Equal as Strings ${resp.status_code} 202 |
| 106 | Wait Until Keyword Succeeds 600s 30s OOF-CMSO Wait For Pending Approval ${uuid} |
| 107 | OOF-CMSO Send Tier2 Approval ${uuid} jf9860 Accepted |
| 108 | Wait Until Keyword Succeeds 600s 30s OOF-CMSO Wait for Schedule to Complete Completed ${uuid} |
| 109 | |
| 110 | |
| 111 | OOF-CMSO Create Schedule |
| 112 | [Documentation] Creates a CMSO future schedule request for the passed template. |
| 113 | [Arguments] ${uuid} ${request_file} ${workflow} ${minutesFromNow}=5 |
| 114 | ${testid}= Catenate ${uuid} |
| 115 | ${testid}= Get Substring ${testid} -4 |
| 116 | ${dict}= Create Dictionary serviceInstanceId=${uuid} parent_service_model_name=${uuid} |
| 117 | ${map}= Create Dictionary uuid=${uuid} callbackUrl=http://localhost:8080 testid=${testid} workflow=${workflow} userId=oof@oof.onap.org |
| 118 | ${nodelist}= Create List node1 node2 node3 node4 |
| 119 | ${nn}= Catenate 1 |
| 120 | # Support up to 4 ChangeWindows |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 121 | :FOR ${i} IN RANGE 1 4 |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 122 | \ ${today}= Evaluate ((${i}-1)*1440)+${minutesFromNow} |
| 123 | \ ${tomorrow} Evaluate ${today}+1440 |
| 124 | \ ${last_time} Evaluate ${today}+30 |
| 125 | \ ${start_time}= Get Current Date UTC + ${today} minutes result_format=${OOF_CMSO_UTC} |
| 126 | \ ${end_time}= Get Current Date UTC + ${tomorrow} minutes result_format=${OOF_CMSO_UTC} |
| 127 | \ Set To Dictionary ${map} start_time${i}=${start_time} end_time${i}=${end_time} |
| 128 | ${requestList}= Create List |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 129 | :FOR ${vnf} IN @{nodelist} |
Jerry Flood | 124bd57 | 2019-04-09 18:34:22 -0400 | [diff] [blame] | 130 | \ Set To Dictionary ${map} node${nn} ${vnf} |
| 131 | \ ${nn}= Evaluate ${nn}+1 |
| 132 | \ Set To DIctionary ${dict} vnfName=${vnf} |
| 133 | \ ${requestInfo}= Fill JSON Template File ${OOF_CMSO_TEMPLATE_FOLDER}/VidCallbackData.json.template ${dict} |
| 134 | \ Append To List ${requestList} ${requestInfo} |
| 135 | ${callBackDataMap}= Create Dictionary requestType=Update requestDetails=${requestList} |
| 136 | ${callbackDataString}= OOF-CMSO Json Escape ${callbackDataMap} |
| 137 | Set To Dictionary ${map} callbackData=${callbackDataString} |
| 138 | ${data}= Fill JSON Template File ${OOF_CMSO_TEMPLATE_FOLDER}/${request_file} ${map} |
| 139 | ${resp}= Run OOF-CMSO Post Scheduler cmso/v1/schedules/${uuid} data=${data} |
| 140 | [Return] ${resp} |
| 141 | |
| 142 | |
| 143 | |
| 144 | OOF-CMSO Wait For Pending Approval |
| 145 | [Documentation] Gets the schedule identified by the uuid and checks if it is in the Pending Approval state |
| 146 | [Arguments] ${uuid} ${status}=Pending Approval |
| 147 | ${resp}= Run OOF-CMSO Get Request cmso/v1/schedules/${uuid} |
| 148 | ${json}= Catenate ${resp.json()} |
| 149 | Dictionary Should Contain Item ${resp.json()} status ${status} |
| 150 | |
| 151 | OOF-CMSO Send Tier2 Approval |
| 152 | [Documentation] Sends an approval post request for the given schedule using the UUID and User given and checks that request worked |
| 153 | [Arguments] ${uuid} ${user} ${status} |
| 154 | ${approval}= Create Dictionary approvalUserId=${user} approvalType=Tier 2 approvalStatus=${status} |
| 155 | ${resp}= Run OOF-CMSO Post Scheduler cmso/v1/schedules/${uuid}/approvals data=${approval} |
| 156 | Should Be Equal As Strings ${resp.status_code} 204 |
| 157 | |
| 158 | OOF-CMSO Wait for Schedule to Complete |
| 159 | [Arguments] ${status} ${uuid} |
| 160 | ${resp}= Run OOF-CMSO Get Request cmso/v1/schedules/${uuid} |
| 161 | Dictionary Should Contain Item ${resp.json()} status Completed |
| 162 | |
| 163 | OOF-CMSO Json Escape |
| 164 | [Arguments] ${json} |
| 165 | ${json_string}= Evaluate json.dumps(${json}) json |
| 166 | ${escaped}= Replace String ${json_string} " \\" |
Ruoyu Ying | c014e92 | 2019-04-11 02:31:44 +0800 | [diff] [blame] | 167 | [Return] ${escaped} |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 168 | |
| 169 | Run OOF-OSDF Post Request |
| 170 | [Documentation] Runs a scheduler POST request |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 171 | [Arguments] ${data_path} ${auth} ${data}={} |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 172 | |
| 173 | ${session}= Create Session session ${OOF_OSDF_ENDPOINT} auth=${auth} |
| 174 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 175 | ${resp}= Post Request session ${data_path} headers=${headers} data=${data} |
| 176 | Log Received response from osdf ${resp.text} |
| 177 | [Return] ${resp} |
| 178 | |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 179 | Run OOF-OSDF Post Homing |
| 180 | [Documentation] Runs a osdf homing request |
| 181 | ${auth}= Create List ${GLOBAL_OOF_OSDF_USERNAME} ${GLOBAL_OOF_OSDF_PASSWORD} |
| 182 | ${data}= Get Binary File ${OOF_OSDF_TEMPLATE_FOLDER}${/}placement_request.json |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 183 | ${resp}= Run OOF-OSDF Post Request /api/oof/placement/v1 auth=${auth} data=${data} |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 184 | Should Be Equal As Strings ${resp.status_code} 204 |
| 185 | |
| 186 | Run OOF-OSDF Post PCI-OPT |
| 187 | [Documentation] Runs a osdf PCI-OPT request |
| 188 | ${auth}= Create List ${GLOBAL_OOF_PCI_USERNAME} ${GLOBAL_OOF_PCI_PASSWORD} |
| 189 | ${data}= Get Binary File ${OOF_OSDF_TEMPLATE_FOLDER}${/}pci-opt-request.json |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 190 | ${resp}= Run OOF-OSDF Post Request /api/oof/pci/v1 auth=${auth} data=${data} |
vrvarma | 4ecc3a7 | 2019-04-29 12:13:45 -0400 | [diff] [blame] | 191 | Should Be Equal As Strings ${resp.status_code} 204 |