diff options
Diffstat (limited to 'cmso-robot/robot/resources/test_templates')
3 files changed, 345 insertions, 0 deletions
diff --git a/cmso-robot/robot/resources/test_templates/change_management.robot b/cmso-robot/robot/resources/test_templates/change_management.robot new file mode 100644 index 0000000..0584cce --- /dev/null +++ b/cmso-robot/robot/resources/test_templates/change_management.robot @@ -0,0 +1,166 @@ +*** Settings *** +Documentation Creates VID VNF Instance +Library StringTemplater +Library String +Library OperatingSystem +Library UUID +Library Collections +Library HttpLibrary.HTTP +Library DateTime +Resource ../scheduler_common.robot +Resource ../json_templater.robot +Resource ../files.robot +Resource ../scheduler_requests/create_schedule.robot +Resource ../scheduler_requests/approval_requests.robot +*** Variables **** +#Variable can only be assigned String variables initially +${status_list}= +${expected_status_list_immediate}= "Scheduled","Notifications Initiated" +${expected_status_list}= "Pending Schedule","Pending Approval","Scheduled","Notifications Initiated","Optimization in Progress" +*** Keywords *** +#GENERAL NOTES about Robot Framework +# Keywords are effectively equivalent to functions/methods +# ${} denotes a scalar variable @{} denotes a list variable and &{} denotes a Dictionary +# Only scalar variables should be passed to a function. Even if your function calls for a list it is easier to pass the list in as a scalar ${} +# To do this simply declare your non-scalar normally (@{}&{}), then when passing the non-scalar into a function pass it as a ${} +# +Change Management Template + [Arguments] ${request_file} ${expected_status_code} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} #Sends the POST request to create schedule. Result stored in ${resp} resp is an object that comes from the RequestLibrary + Wait Until Keyword Succeeds 120s 5s Wait For Pending Approval ${uuid} #Runs Wait For Pending Approval every 5s for 120s or until it passes + Should Be Equal as Strings ${resp.status_code} ${expected_status_code} #This will fail if an unexpected result is received from Scheduler + Send Tier2 Approval ${uuid} jf9860 Accepted + ${resp}= Get Change Management auth schedules/${uuid} #GETs the schedule from Scheduler. The result is stored in $resp + Wait Until Keyword Succeeds 120s 5s Wait For All VNFs Reach Status Completed ${uuid} #Makes sure VNF(s) is(are) completed in the schedule + Wait Until Keyword Succeeds 120s 5s Wait for Schedule to Complete Completed ${uuid} #Makes sure Schedule is marked completed + ${reps}= Delete Change Management auth schedules/${uuid} #sends DELETE request to scheduler this may have to be changed for 1802 US to change Delete Schedule to Cancel Schedule + +Change Management Rejection Template + [Arguments] ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${expected_status_code}= Convert to String 202 #Variables in keywords section have to be assigned keywords. So ${expected_status_code}= 202 + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + Wait Until Keyword Succeeds 120s 5s Wait For Pending Approval ${uuid} + Should Be Equal as Strings ${resp.status_code} ${expected_status_code} + Send Tier2 Approval ${uuid} jf9860 Rejected #Sends and checks Approval POST request + +Change Management Failure Template + [Documentation] Sends a post request expecting a failure. expected_status_code should be whatever code is expected for this call + [Arguments] ${request_file} ${expected_status_code} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + Should Be Equal as Strings ${resp.status_code} ${expected_status_code} + Return from Keyword If '${resp.status_code}' == '202' + #List of possible reasons that the request should fail - we should look for exact message..... + @{status_list}= Create List Scheduler.INVALID_ATTRIBUTE Scheduler.MISSING_REQUIRED_ATTRIBUTE Scheduler.NODE_LIST_CONTAINS_EMTPY_NODE Scheduler.INVALID_CHANGE_WINDOW + Validate Json Error ${resp.json()} ${status_list} + +Change Management Immediate Template + [Arguments] ${request_file} ${expected_status_code} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} #Immediate schedules do not need approval so there is no wait for pending approval or send approval + Should Be Equal as Strings ${resp.status_code} ${expected_status_code} + Wait Until Keyword Succeeds 120s 5s Wait For All VNFs Reach Status Completed ${uuid} + Wait Until Keyword Succeeds 120s 5s Wait for Schedule to Complete Completed ${uuid} + ${reps}= Delete Change Management auth schedules/${uuid} +Change Management Already Exists Immediate Template + [Arguments] ${request_file} ${template_folder} + ${uuid}= Convert to String 46969fb7-0d4c-4e78-80ca-e20759628be5 #This value was taken from DEV env Scheduler DB. To actually automate may want to make SQL query Keyword to get an existing scheduleId + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + Should Be Equal as Strings ${resp.status_code} 409 +Record Status Immediate Template + [Arguments] ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + Set Global Variable ${status_list} ${EMPTY} #$EMPTY is a empty string variable defined by ROBOT. This makes sure the global variable is cleared each run + Wait Until Keyword Succeeds 120s 5s Add to Status List Completed ${uuid} + ${reps}= Delete Change Management auth schedules/${uuid} + Compare Status List ${expected_status_list_immediate} ${status_list} + Log ${status_list} +Record Status Template + [Documentation] This test checks statuses for future schedules. It tends to fail due to scheduled status being missed. + [Arguments] ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + Set Global Variable ${status_list} ${EMPTY} + Wait Until Keyword Succeeds 120s 5s Add to Status List Pending Approval ${uuid} + Send Tier2 Approval ${uuid} jf9860 Accepted + ${resp}= Get Change Management auth schedules/${uuid} + Wait Until Keyword Succeeds 300s 5s Wait For All VNFs Reach Status and Add to Status Completed ${uuid} + ${reps}= Delete Change Management auth schedules/${uuid} + Compare Status List ${expected_status_list} ${status_list} + Log ${status_list} +#Check Status Template +# [Arguments] ${request_file} ${template_folder} +# ${uuid}= Generate UUID +# ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} +# Check Schedule Status Pending Schedule ${uuid} + +Get Schedule Test Template + [Documentation] This function reads scheduleIds and the expected values from a text file (see robot/assets/get_schedule_UUIDs.txt for the format) then runs a get on them to confirm the GET schedule functionality #this could be enhanced with SQL query to db + [Arguments] ${existing_uuid_file} + ${uuid_file}= OperatingSystem.Get File ${existing_uuid_file} #this file works with the dev server as of 11/9/2017 + @{file_lines}= Split to Lines ${uuid_file} + &{uuid_dictionary}= Create Dictionary + :For ${line} in @{file_lines} + \ @{line_array}= Split String ${line} + \ log ${line_array[1]} + \ Set To Dictionary ${uuid_dictionary} @{line_array}[0] @{line_array}[1] #You can pass singular list items as scalar variables + \ + Log ${uuid_dictionary} + @{resp_list}= Create List + :For ${uuid} in @{uuid_dictionary.keys()} + \ ${resp}= Get Change Management auth schedules/${uuid} + \ ${actual_status}= Get from dictionary ${uuid_dictionary} ${uuid} + \ Should be equal as Strings ${actual_status} ${resp.status_code} + \ Run Keyword If ${resp.status_code} == 200 Dictionary should contain key ${resp.json()} status ELSE Dictionary Should Contain Key ${resp.json()['requestError']} messageId #${resp.json()['requestError']} this is a scalar reference to a singular item from a dictionary. + \ Append to List ${resp_list} ${resp.json()} + Log ${resp_list} +Wait For All VNFs Reach Status + [Documentation] Checks the status of the VNFs in a schedule. + [Arguments] ${status} ${uuid} + ${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid} + : for ${vnf} in @{resp.json()} + \ Dictionary Should Contain Item ${vnf} status Completed +Wait For All VNFs Reach Status and Add to Status + [Documentation] This records the status of the vnf in the global status list + [Arguments] ${status} ${uuid} + ${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid} + : for ${vnf} in @{resp.json()} + \ Dictionary Should Contain Item ${vnf} status Completed + Add to Status List Completed ${uuid} #This only runs if there are no failures in Dictionary should Contain Item for loop previously +Wait for Schedule to Complete + [Documentation] This is used in wait for keyword to succeed generally it checks if the status of the schedule returned by a GET request is Complete + [Arguments] ${status} ${uuid} + ${resp}= Get Change Management auth schedules/${uuid} + Dictionary Should Contain Item ${resp.json()} status Completed +#Check Schedule Status +# [Arguments] ${status} ${uuid} +# ${resp}= Get Change Management auth schedules/${uuid} +# Dictionary Should Contain Item ${resp.json()} status ${status} +Add To Status List + [Documentation] Takes List and Schedule ID and changes global list of Statuses #A global list was used because Wait for Keyword to Succeed only seems to return pass or fail + [Arguments] ${end_status} ${uuid} + ${resp}= Get Change Management auth schedules/${uuid} + ${json}= Stringify Json ${resp.json()} + ${status}= Get Json Value ${json} /status + ${temp_list}= Catenate ${status_list} ${status}, + ${temp_list}= Replace String ${temp_list} ${SPACE}" ${EMPTY}" + Set Global Variable ${status_list} ${temp_list} + Should Contain ${status} ${end_status} +Compare Status List + [Arguments] ${expected} ${actual} + @{expected_list}= Split String ${expected} , + @{actual_list}= Split String ${actual} , + :For ${current} in @{expected_list} + \ Should Contain ${actual_list} ${current} + +Change Management DB Failover Template + [Arguments] ${request_file} ${template_folder} ${uuid1} ${uuid2} + Set Global Variable ${NODES} ${uuid1} + Run Keyword If '${uuid2}' != 'None' Delete Change Management auth schedules/${uuid2} #Sends and checks Approval POST request + ${expected_status_code}= Convert to String 202 #Variables in keywords section have to be assigned keywords. So ${expected_status_code}= 202 + ${resp}= Create Schedule ${uuid1} ${request_file} ${template_folder} + Wait Until Keyword Succeeds 120s 5s Wait For Pending Approval ${uuid1} Optimization Failed + Should Be Equal as Strings ${resp.status_code} ${expected_status_code} diff --git a/cmso-robot/robot/resources/test_templates/change_management_ete.robot b/cmso-robot/robot/resources/test_templates/change_management_ete.robot new file mode 100644 index 0000000..74dfdc2 --- /dev/null +++ b/cmso-robot/robot/resources/test_templates/change_management_ete.robot @@ -0,0 +1,84 @@ +*** Settings *** +Documentation Creates VID VNF Instance + +Library StringTemplater +Library UUID +Library Collections +Library SSHLibrary + +Resource ../scheduler_common.robot +Resource ../json_templater.robot +Resource ../scheduler_requests/create_schedule.robot +Resource ../scheduler_requests/approval_requests.robot + +*** Variables **** +${TEMPLATES} robot/assets/templates + +*** Keywords *** +Change Management Template + [Arguments] ${request_file} ${workflow} ${minutesFromNow}=1 + ${template_folder}= Catenate ${TEMPLATES}/changemanagement + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} workflow=${workflow} minutesFromNow=${minutesFromNow} + Should Be Equal as Strings ${resp.status_code} 202 + Validate Acknowledgment Response Headers ${resp} + Wait Until Keyword Succeeds 600s 30s Wait For Pending Approval ${uuid} + Send Tier2 Approval ${uuid} jf9860 Accepted + ${resp}= Get Change Management auth schedules/${uuid} + Wait Until Keyword Succeeds 120s 30s Wait For All VNFs Reach Status Completed ${uuid} + Wait Until Keyword Succeeds 120s 30s Wait for Schedule to Complete Completed ${uuid} + ${reps}= Delete Change Management auth schedules/${uuid} + +Change Management Immediate Template + [Arguments] ${request_file} ${workflow} + ${template_folder}= Catenate ${TEMPLATES}/changemanagement + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} workflow=${workflow} + Should Be Equal as Strings ${resp.status_code} 202 + Validate Acknowledgment Response Headers ${resp} + Wait Until Keyword Succeeds 120s 30s Wait For All VNFs Reach Status Completed ${uuid} + Wait Until Keyword Succeeds 120s 30s Wait for Schedule to Complete Completed ${uuid} + ${reps}= Delete Change Management auth schedules/${uuid} + +Wait For All VNFs Reach Status + [Arguments] ${status} ${uuid} + ${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid} + : for ${vnf} in @{resp.json()} + \ Dictionary Should Contain Item ${vnf} status Completed + +Wait for Schedule to Complete + [Arguments] ${status} ${uuid} + ${resp}= Get Change Management auth schedules/${uuid} + Dictionary Should Contain Item ${resp.json()} status Completed + +Create and Approve + [Arguments] ${request_file} ${workflow} ${minutesFromNow}=5 + ${template_folder}= Catenate ${TEMPLATES}/changemanagement + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} workflow=${workflow} minutesFromNow=${minutesFromNow} + Should Be Equal as Strings ${resp.status_code} 202 + Validate Acknowledgment Response Headers ${resp} + Wait Until Keyword Succeeds 300s 5s Wait For Pending Approval ${uuid} + Send Tier2 Approval ${uuid} jf9860 Accepted + +Change Management Cancel Template + [Arguments] ${request_file} ${workflow} ${minutesFromNow}=5 + ${template_folder}= Catenate ${TEMPLATES}/changemanagement + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} workflow=${workflow} minutesFromNow=${minutesFromNow} + Should Be Equal as Strings ${resp.status_code} 202 + Validate Acknowledgment Response Headers ${resp} + Wait Until Keyword Succeeds 600s 5s Wait For Pending Approval ${uuid} + Send Tier2 Approval ${uuid} jf9860 Accepted + ${resp}= Delete Change Management auth schedules/${uuid} + Should Be Equal as Strings ${resp.status_code} 204 + Log ${resp.headers} + +Validate Acknowledgment Response Headers + [Arguments] ${Response} + Log ${Response.headers} + ${act_headers_keys} = Get Dictionary Keys ${Response.headers} + Dictionary Should Contain Key ${Response.headers} X-LatestVersion + Dictionary Should Contain Key ${Response.headers} X-MinorVersion + Dictionary Should Contain Key ${Response.headers} X-PatchVersion +
\ No newline at end of file diff --git a/cmso-robot/robot/resources/test_templates/check_logs.robot b/cmso-robot/robot/resources/test_templates/check_logs.robot new file mode 100644 index 0000000..5926caa --- /dev/null +++ b/cmso-robot/robot/resources/test_templates/check_logs.robot @@ -0,0 +1,95 @@ +*** Settings *** +Documentation Tests for checking ECOMP Scheduler Logs + +Library UUID +Library SSHLibrary +Library String + + +Resource ../files.robot +Resource ../scheduler_requests/create_schedule.robot +Resource ../scheduler_requests/approval_requests.robot +Resource ../json_templater.robot +*** Variables **** +${log_location}= /opt/app/ecomp-scheduler/logs/ +${debug_log_location}= /opt/app/ecomp-scheduler/debug-logs/ +${date_time_regex}= ((([0-9]{2,4}-?){3}.([0-9]{2}:?){3}.*)) +${uuid_regex}= [0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12} + +*** Keywords *** +#GENERAL Notes this +Check Audit Logs + [Documentation] This test runs Create, Get, and Delete Schedule then checks logs in the server for the result + [Arguments] ${user-id} ${user-pass} ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + ${resp}= Get Change Management auth schedules/${uuid} + ${resp}= Delete Change Management auth schedules/${uuid} + ${server}= Convert to String mtanjv9sdlg10 #This should not be hardcoded. From test_properties.py replace this with some modification of GLOBAL_SCHEDULER_HOST + ${log_level}= Convert to String (INFO|WARN|ERROR|FATAL) + ${log_msg}= Convert to String (Accepted|No Content|OK) + ${status_codes}= Convert to String (204|202|200) + ${audit_regex}= Convert to String \\|UNKNOWN\\|.*\\|ecomp-scheduler\\|.*\\|COMPLETE\\|${status codes}\\|${log_msg}\\|${uuid_regex}\\|${log_level}\\|.*\\|[0-9]{1,}\\|${server}\\|.* + #THis regex string follows the current expected audit.log structure logging guidelines as of 1710 here https://wiki.web.att.com/pages/viewpage.action?pageId=545861390 + Open Connection ${GLOBAL_SCHEDULER_HOST} port=22 + Login ${user-id} ${user-pass} #This may only work with dev server should investigate using Pageant with Robot + ${result}= Grep Local File -E '${date_time_regex}{2}\\|${uuid}${audit_regex}CREATE_SCHEDULE_REQUEST' ${log_location}audit.log + @{create_grep_result}= Split to Lines ${result} + ${result}= Grep Local File -E '${date_time_regex}{2}\\|${uuid}${audit_regex}GET_SCHEDULE_REQUEST' ${log_location}audit.log + @{get_grep_result}= Split to Lines ${result} + ${result}= Grep Local File -E '${date_time_regex}{2}\\|${uuid}${audit_regex}DELETE_SCHEDULE_REQUEST' ${log_location}audit.log + @{delete_grep_result}= Split to Lines ${result} + Close Connection + Log many ${create_grep_result} ${get_grep_result} ${delete_grep_result} + Should Contain ${create_grep_result}[1] Accepted #This is only present in logs for create schedule + Should Contain ${get_grep_result}[1] OK #This is only present in logs for get schedule + Should Contain ${delete_grep_result}[1] No Content #This is only present in logs for delete + + +Check Debug Logs + [Arguments] ${user-id} ${user-pass} ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + ${resp}= Get Change Management auth schedules/${uuid} + ${resp}= Delete Change Management auth schedules/${uuid} + Open Connection ${GLOBAL_SCHEDULER_HOST} port=22 + Login ${user-id} ${user-pass} + ${result}= Grep Local File -E '${date_time_regex}\\|${uuid}' /opt/app/ecomp-scheduler/debug-logs/debug.log + #THis regex string follows the current expected debug.log structure logging guidelines as of 1710 here https://wiki.web.att.com/pages/viewpage.action?pageId=545861390 + Close Connection + Should not be Empty ${result} + +Check Metric Logs + [Arguments] ${user-id} ${user-pass} ${request_file} ${template_folder} + ${uuid}= Generate UUID + ${resp}= Create Schedule ${uuid} ${request_file} ${template_folder} + ${resp}= Get Change Management auth schedules/${uuid} + ${resp}= Delete Change Management auth schedules/${uuid} + ${server}= Convert to String mtanjv9sdlg10 + ${log_level}= Convert to String (INFO|WARN|ERROR|FATAL) + ${log_msg}= Convert to String (Accepted|No Content|OK|[a-zA-Z]+) + ${status_codes}= Convert to String (204|202|200) + ${regex}= Convert To String \\|UNKNOWN\\|.*\\|ecomp-scheduler\\|.*\\|http://([a-zA-Z]*\.){2,}(:[0-9]{1,5})?\\|(.*/?){1,}\\|COMPLETE\\|${status codes}\\|${log_msg}\\|${uuid_regex}\\|${log_level}\\|.*\\|[0-9]{1,}\\|${server}\\|.* + #THis regex string follows the current expected metric.log structure logging guidelines as of 1710 here https://wiki.web.att.com/pages/viewpage.action?pageId=545861390 + Open Connection ${GLOBAL_SCHEDULER_HOST} port=22 + Login ${user-id} ${user-pass} + ${result}= Grep Local File '${date_time_regex}{2}\\|${uuid}${regex}' ${log_location}metrics.log + @{grep_result}= Split to Lines ${result} + Close Connection + Should Not be Empty ${grep_result} + Log ${grep_result} + + +Check Error Logs + [Arguments] ${user-id} ${user-pass} ${request_file} ${template_folder} + + Open Connection ${GLOBAL_SCHEDULER_HOST} port=22 + Login ${user-id} ${user-pass} + ${result}= Grep Local File '${date_time_regex}\\|${uuid_regex}\\|.*\\|ecomp-scheduler\\|.*\\|.*(WARN|ERROR|FATAL).*\\|.*\\|' ${log_location}error.log + #THis regex string follows the current expected error.log structure logging guidelines as of 1710 here https://wiki.web.att.com/pages/viewpage.action?pageId=545861390 + #It is difficult to generate errors that would be logged in error.log. so this only tests that any error in the log matches the expected format + @{grep_result}= Split to Lines ${result} + Close Connection + Should Not be Empty ${grep_result} + Log ${grep_result} +
\ No newline at end of file |