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