blob: 49bc2920c9664a9da84a38f62514987b1c850003 [file] [log] [blame]
Eric Debeau9045a1e2018-04-24 17:22:41 +00001*** Settings ***
Eric Debeauca1b9c82018-04-24 20:41:02 +00002Documentation The main interface for interacting with OOF: SNIRO and Homing Service
Eric Debeau9045a1e2018-04-24 17:22:41 +00003Library RequestsLibrary
Jerry Flood124bd572019-04-09 18:34:22 -04004Library UUID
5Library String
6Library DateTime
7Library Collections
8Library JSONUtils
Eric Debeau9045a1e2018-04-24 17:22:41 +00009Resource global_properties.robot
Jerry Flood124bd572019-04-09 18:34:22 -040010Resource json_templater.robot
Eric Debeau9045a1e2018-04-24 17:22:41 +000011
12*** Variables ***
Eric Debeauca1b9c82018-04-24 20:41:02 +000013${OOF_HOMING_HEALTH_CHECK_PATH} /v1/plans/healthcheck
14${OOF_SNIRO_HEALTH_CHECK_PATH} /api/oof/v1/healthcheck
Jerry Flood124bd572019-04-09 18:34:22 -040015${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
Ruoyu Yingc014e922019-04-11 02:31:44 +080019${OOF_HOMING_PLAN_FOLDER} robot/assets/templates/optf-has
vrvarma4ecc3a72019-04-29 12:13:45 -040020${OOF_OSDF_TEMPLATE_FOLDER} robot/assets/templates/optf-osdf
Eric Debeau9045a1e2018-04-24 17:22:41 +000021
Gary Wu251aa682018-07-30 15:22:20 -070022${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 Flood0c3270c2018-11-01 12:46:55 -040024${OOF_CMSO_ENDPOINT} ${GLOBAL_OOF_CMSO_PROTOCOL}://${GLOBAL_INJECTED_OOF_CMSO_IP_ADDR}:${GLOBAL_OOF_CMSO_SERVER_PORT}
Eric Debeau9045a1e2018-04-24 17:22:41 +000025
Ruoyu Yingc014e922019-04-11 02:31:44 +080026${OOF_HOMING_AUTH} Basic YWRtaW4xOnBsYW4uMTU=
27
Eric Debeau9045a1e2018-04-24 17:22:41 +000028*** Keywords ***
Eric Debeauca1b9c82018-04-24 20:41:02 +000029Run OOF-Homing Health Check
30 [Documentation] Runs OOF-Homing Health check
31 ${resp}= Run OOF-Homing Get Request ${OOF_HOMING_HEALTH_CHECK_PATH}
Eric Debeau9045a1e2018-04-24 17:22:41 +000032 Should Be Equal As Integers ${resp.status_code} 200
33
Eric Debeauca1b9c82018-04-24 20:41:02 +000034Run OOF-Homing Get Request
35 [Documentation] Runs OOF-Homing Get request
Eric Debeau9045a1e2018-04-24 17:22:41 +000036 [Arguments] ${data_path}
Eric Debeauca1b9c82018-04-24 20:41:02 +000037 ${session}= Create Session session ${OOF_HOMING_ENDPOINT}
Eric Debeau9045a1e2018-04-24 17:22:41 +000038 ${resp}= Get Request session ${data_path}
39 Should Be Equal As Integers ${resp.status_code} 200
Eric Debeauca1b9c82018-04-24 20:41:02 +000040 Log Received response from OOF-Homing ${resp.text}
41 [Return] ${resp}
Jerry Flood124bd572019-04-09 18:34:22 -040042
Ruoyu Yingc014e922019-04-11 02:31:44 +080043RUN 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}
DR695Hb1112912019-05-03 15:55:40 -040052 ${generatedPlanId}= Convert To String ${${resp.json()['id']}['id']}
Ruoyu Yingc014e922019-04-11 02:31:44 +080053 Set Global Variable ${generatedPlanId}
54 Log generatedPlanId = ${generatedPlanId}
55 Should Be Equal As Integers ${resp.status_code} 201
56 Sleep 10s Wait Plan Resolution
57
Eric Debeauca1b9c82018-04-24 20:41:02 +000058Run OOF-SNIRO Health Check
59 [Documentation] Runs OOF-SNIRO Health check
60 ${resp}= Run OOF-SNIRO Get Request ${OOF_SNIRO_HEALTH_CHECK_PATH}
61 Should Be Equal As Integers ${resp.status_code} 200
62
63Run OOF-SNIRO Get Request
64 [Documentation] Runs OOF-SNIRO Get request
65 [Arguments] ${data_path}
66 ${session}= Create Session session ${OOF_SNIRO_ENDPOINT}
67 ${resp}= Get Request session ${data_path}
68 Should Be Equal As Integers ${resp.status_code} 200
69 Log Received response from OOF-SNIRO ${resp.text}
Eric Debeau9045a1e2018-04-24 17:22:41 +000070 [Return] ${resp}
Jerry Flood0c3270c2018-11-01 12:46:55 -040071
72
73Run OOF-CMSO Health Check
74 [Documentation] Runs OOF-CMSO Health check
75 ${resp}= Run OOF-CMSO Get Request ${OOF_CMSO_HEALTH_CHECK_PATH}
76 Should Be Equal As Integers ${resp.status_code} 200
77
78Run OOF-CMSO Get Request
79 [Documentation] Runs OOF-CMSO Get request
80 [Arguments] ${data_path}
81 ${auth}= Create List ${GLOBAL_OOF_CMSO_USERNAME} ${GLOBAL_OOF_CMSO_PASSWORD}
82 ${session}= Create Session session ${OOF_CMSO_ENDPOINT} auth=${auth}
83 ${resp}= Get Request session ${data_path}
84 Should Be Equal As Integers ${resp.status_code} 200
85 Log Received response from OOF-CMSO ${resp.text}
86 [Return] ${resp}
Jerry Flood124bd572019-04-09 18:34:22 -040087
88Run OOF-CMSO Post Scheduler
89 [Documentation] Runs a scheduler POST request
90 [Arguments] ${data_path} ${data}={}
91 ${auth}= Create List ${GLOBAL_OOF_CMSO_USERNAME} ${GLOBAL_OOF_CMSO_PASSWORD}
92 ${session}= Create Session session ${OOF_CMSO_ENDPOINT} auth=${auth}
93 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
94 ${resp}= Post Request session ${data_path} headers=${headers} data=${data}
95 Log Received response from scheduler ${resp.text}
96 [Return] ${resp}
97
98Run OOF-CMSO Future Schedule
99 [Documentation] Runs CMSO Future Schedule ETE test. One VNF, One Change Window
100 [Arguments] ${request_file}=OneVnfOneChangeWindow.json.template ${workflow}=Replace ${minutesFromNow}=3
101 ${uuid}= Generate UUID
102 ${resp}= OOF-CMSO Create Schedule ${uuid} ${request_file} workflow=${workflow} minutesFromNow=${minutesFromNow}
103 Should Be Equal as Strings ${resp.status_code} 202
104 Wait Until Keyword Succeeds 600s 30s OOF-CMSO Wait For Pending Approval ${uuid}
105 OOF-CMSO Send Tier2 Approval ${uuid} jf9860 Accepted
106 Wait Until Keyword Succeeds 600s 30s OOF-CMSO Wait for Schedule to Complete Completed ${uuid}
107
108
109OOF-CMSO Create Schedule
110 [Documentation] Creates a CMSO future schedule request for the passed template.
111 [Arguments] ${uuid} ${request_file} ${workflow} ${minutesFromNow}=5
112 ${testid}= Catenate ${uuid}
113 ${testid}= Get Substring ${testid} -4
114 ${dict}= Create Dictionary serviceInstanceId=${uuid} parent_service_model_name=${uuid}
115 ${map}= Create Dictionary uuid=${uuid} callbackUrl=http://localhost:8080 testid=${testid} workflow=${workflow} userId=oof@oof.onap.org
116 ${nodelist}= Create List node1 node2 node3 node4
117 ${nn}= Catenate 1
118 # Support up to 4 ChangeWindows
119 : For ${i} IN RANGE 1 4
120 \ ${today}= Evaluate ((${i}-1)*1440)+${minutesFromNow}
121 \ ${tomorrow} Evaluate ${today}+1440
122 \ ${last_time} Evaluate ${today}+30
123 \ ${start_time}= Get Current Date UTC + ${today} minutes result_format=${OOF_CMSO_UTC}
124 \ ${end_time}= Get Current Date UTC + ${tomorrow} minutes result_format=${OOF_CMSO_UTC}
125 \ Set To Dictionary ${map} start_time${i}=${start_time} end_time${i}=${end_time}
126 ${requestList}= Create List
127 : For ${vnf} IN @{nodelist}
128 \ Set To Dictionary ${map} node${nn} ${vnf}
129 \ ${nn}= Evaluate ${nn}+1
130 \ Set To DIctionary ${dict} vnfName=${vnf}
131 \ ${requestInfo}= Fill JSON Template File ${OOF_CMSO_TEMPLATE_FOLDER}/VidCallbackData.json.template ${dict}
132 \ Append To List ${requestList} ${requestInfo}
133 ${callBackDataMap}= Create Dictionary requestType=Update requestDetails=${requestList}
134 ${callbackDataString}= OOF-CMSO Json Escape ${callbackDataMap}
135 Set To Dictionary ${map} callbackData=${callbackDataString}
136 ${data}= Fill JSON Template File ${OOF_CMSO_TEMPLATE_FOLDER}/${request_file} ${map}
137 ${resp}= Run OOF-CMSO Post Scheduler cmso/v1/schedules/${uuid} data=${data}
138 [Return] ${resp}
139
140
141
142OOF-CMSO Wait For Pending Approval
143 [Documentation] Gets the schedule identified by the uuid and checks if it is in the Pending Approval state
144 [Arguments] ${uuid} ${status}=Pending Approval
145 ${resp}= Run OOF-CMSO Get Request cmso/v1/schedules/${uuid}
146 ${json}= Catenate ${resp.json()}
147 Dictionary Should Contain Item ${resp.json()} status ${status}
148
149OOF-CMSO Send Tier2 Approval
150 [Documentation] Sends an approval post request for the given schedule using the UUID and User given and checks that request worked
151 [Arguments] ${uuid} ${user} ${status}
152 ${approval}= Create Dictionary approvalUserId=${user} approvalType=Tier 2 approvalStatus=${status}
153 ${resp}= Run OOF-CMSO Post Scheduler cmso/v1/schedules/${uuid}/approvals data=${approval}
154 Should Be Equal As Strings ${resp.status_code} 204
155
156OOF-CMSO Wait for Schedule to Complete
157 [Arguments] ${status} ${uuid}
158 ${resp}= Run OOF-CMSO Get Request cmso/v1/schedules/${uuid}
159 Dictionary Should Contain Item ${resp.json()} status Completed
160
161OOF-CMSO Json Escape
162 [Arguments] ${json}
163 ${json_string}= Evaluate json.dumps(${json}) json
164 ${escaped}= Replace String ${json_string} " \\"
Ruoyu Yingc014e922019-04-11 02:31:44 +0800165 [Return] ${escaped}
vrvarma4ecc3a72019-04-29 12:13:45 -0400166
167Run OOF-OSDF Post Request
168 [Documentation] Runs a scheduler POST request
169 [Arguments] ${data_path} ${data}={} ${auth}
170
171 ${session}= Create Session session ${OOF_OSDF_ENDPOINT} auth=${auth}
172 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
173 ${resp}= Post Request session ${data_path} headers=${headers} data=${data}
174 Log Received response from osdf ${resp.text}
175 [Return] ${resp}
176
177
178Run OOF-OSDF Post Homing
179 [Documentation] Runs a osdf homing request
180 ${auth}= Create List ${GLOBAL_OOF_OSDF_USERNAME} ${GLOBAL_OOF_OSDF_PASSWORD}
181 ${data}= Get Binary File ${OOF_OSDF_TEMPLATE_FOLDER}${/}placement_request.json
182 ${resp}= Run OOF-OSDF Post Request /api/oof/placement/v1 data=${data} auth=${auth}
183 Should Be Equal As Strings ${resp.status_code} 204
184
185Run OOF-OSDF Post PCI-OPT
186 [Documentation] Runs a osdf PCI-OPT request
187 ${auth}= Create List ${GLOBAL_OOF_PCI_USERNAME} ${GLOBAL_OOF_PCI_PASSWORD}
188 ${data}= Get Binary File ${OOF_OSDF_TEMPLATE_FOLDER}${/}pci-opt-request.json
189 ${resp}= Run OOF-OSDF Post Request /api/oof/pci/v1 data=${data} auth=${auth}
190 Should Be Equal As Strings ${resp.status_code} 204