blob: 24a234594bbc5405fa5f0493b27831f41fa031f6 [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
Eric Debeau9045a1e2018-04-24 17:22:41 +000019
Gary Wu251aa682018-07-30 15:22:20 -070020${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 Flood0c3270c2018-11-01 12:46:55 -040022${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 +000023
24*** Keywords ***
Eric Debeauca1b9c82018-04-24 20:41:02 +000025Run OOF-Homing Health Check
26 [Documentation] Runs OOF-Homing Health check
27 ${resp}= Run OOF-Homing Get Request ${OOF_HOMING_HEALTH_CHECK_PATH}
Eric Debeau9045a1e2018-04-24 17:22:41 +000028 Should Be Equal As Integers ${resp.status_code} 200
29
Eric Debeauca1b9c82018-04-24 20:41:02 +000030Run OOF-Homing Get Request
31 [Documentation] Runs OOF-Homing Get request
Eric Debeau9045a1e2018-04-24 17:22:41 +000032 [Arguments] ${data_path}
Eric Debeauca1b9c82018-04-24 20:41:02 +000033 ${session}= Create Session session ${OOF_HOMING_ENDPOINT}
Eric Debeau9045a1e2018-04-24 17:22:41 +000034 ${resp}= Get Request session ${data_path}
35 Should Be Equal As Integers ${resp.status_code} 200
Eric Debeauca1b9c82018-04-24 20:41:02 +000036 Log Received response from OOF-Homing ${resp.text}
37 [Return] ${resp}
Jerry Flood124bd572019-04-09 18:34:22 -040038
Eric Debeauca1b9c82018-04-24 20:41:02 +000039Run 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
44Run 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 Debeau9045a1e2018-04-24 17:22:41 +000051 [Return] ${resp}
Jerry Flood0c3270c2018-11-01 12:46:55 -040052
53
54Run 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
59Run 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 Flood124bd572019-04-09 18:34:22 -040068
69Run 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
79Run 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
90OOF-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
123OOF-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
130OOF-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
137OOF-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
142OOF-CMSO Json Escape
143 [Arguments] ${json}
144 ${json_string}= Evaluate json.dumps(${json}) json
145 ${escaped}= Replace String ${json_string} " \\"
146 [Return] ${escaped}