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