def test_rtc9788_bulk_update_end_time_during_recording_inprogress_unique( total_recording, stream, name, copy_type): """ TC9788 : Bulk update of recording requests of end time during recording(20 requests ) unique copy """ recording = None web_service_objects = [] recording_pool = None recording_id_list = [] try: queue = Queue.Queue() start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 180, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(total_recordings=total_recording, StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId recording_id_list.append(recording_id) web_service_objects.append( notification_utils.get_web_service_object(recording_id)) recording.get_entry(i).UpdateUrl = web_service_objects[i].get_url() LOGGER.debug("Recording instance created=%s", recording.serialize()) response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error recording_pool = mp_pool.ThreadPool(processes=total_recording) start_wait = constants.RECORDING_DELAY + 30 sleep_time = utils.get_sleep_time(start_wait, stream) print "[INFO: ] Waiting %d seconds for recording to start" % sleep_time LOGGER.debug("Waiting %d seconds for recording to start", sleep_time) time.sleep(sleep_time) for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() LOGGER.debug("Response=%s", response) end_time = response[0][RecordingAttribute.END_TIME][:-1] LOGGER.debug("Scheduled end time of recording=%s is %s", recording_id_list[i], end_time) recording.get_entry(i).EndTime = utils.get_formatted_time( constants.SECONDS * 70, TimeFormat.TIME_FORMAT_MS, stream) LOGGER.debug("Updated end time of recording=%s to %s", recording_id_list[i], recording.get_entry(i).EndTime) # Update the recording with the updated end time response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error # Validating whether the updated end time was populated or not for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() LOGGER.debug("Response=%s", response) is_valid, error = validate_recordings.validate_time( response, recording.get_entry(i).EndTime, RecordingAttribute.END_TIME) assert is_valid, error for i in range(total_recording): recording_pool.apply_async( validate_recordings.validate_recording, (recording.get_entry(i).RecordingId, web_service_objects[i]), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error finally: if recording_pool: recording_pool.close() recording_pool.join() if len(web_service_objects): for web_service_obj in web_service_objects: web_service_obj.stop_server() if recording: response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_update_recording_ipdvrtests_48(common_lib, stream): """ JIRA_URL : https://jira01.engit.synamedia.com/browse/IPDVRTESTS-48 DESCRIPTION : "Update Recording" """ recording = None web_service_obj = None try: #step 1:Create a recording and update the end time. Alternatively update start time if original start time is in future ##creating a recording recording, web_service_obj = common_lib.create_recording(stream) ##change the start time of the recording start_time_new = utils.get_formatted_time(constants.SECONDS * 80, TimeFormat.TIME_FORMAT_MS, stream) recording.get_entry(0).StartTime = start_time_new ##change the end time of the recording end_time_new = utils.get_formatted_time(constants.SECONDS * 110, TimeFormat.TIME_FORMAT_MS, stream) recording.get_entry(0).EndTime = end_time_new response = a8.create_recording(recording) recording_id = recording.get_entry(0).RecordingId is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error ##verify the recording complete is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error #step 2:Verify memsql table is updated with new time using RIO API response = rio.find_recording(recording_id) resp = json.loads(response.content) is_valid, error = validate_recordings.validate_time( resp, start_time_new, RecordingAttribute.START_TIME) assert is_valid, error is_valid, error = validate_recordings.validate_time( resp, end_time_new, RecordingAttribute.END_TIME) assert is_valid, error #step 3:Check cos logs to see segments are written using COS API is_valid, error = validate_storage.validate_recording_in_storage( resp, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error #step 4:Check MA/SR pod logs for any errors while recording s_time = utils.get_parsed_time(str(start_time_new)[:-1]) e_time = utils.get_parsed_time(str(end_time_new)[:-1]) is_valid, error = vmr_helper.verify_error_logs_in_vmr( stream, 'manifest-agent', 'vmr', search_string="ERROR", start_time=s_time, end_time=e_time) assert is_valid, error is_valid, error = vmr_helper.verify_error_logs_in_vmr( stream, 'segment-recorder', 'vmr', search_string="ERROR", start_time=s_time, end_time=e_time) assert is_valid, error #step 5:Check no discontinuity errors in MA is_valid, error = vmr_helper.verify_error_logs_in_vmr( stream, 'manifest-agent', 'vmr', search_string="discontinuity", start_time=s_time, end_time=e_time) assert is_valid, error finally: if web_service_obj: web_service_obj.stop_server() if recording: response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_tc_rec(name, stream, copy_type): """ Updating end time of shorter unique copy recording after shorter recording completed, and longer recording in progress. """ total_recordings = 2 validate_rec_wait_time = 240 recording = None web_service_objs = [] recording_pool = None try: queue = Queue.Queue() start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 60, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording( total_recordings=total_recordings, StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) for i in range(total_recordings): recording_id = recording.get_entry(i).RecordingId web_service_objs.append( notification_utils.get_web_service_object(recording_id)) recording.get_entry(i).UpdateUrl = web_service_objs[i].get_url() LOGGER.debug("Recording=%s, UpdateURL=%s", recording_id, web_service_objs[i].get_url()) recording.get_entry(1).EndTime = utils.get_formatted_time( constants.SECONDS * 80, TimeFormat.TIME_FORMAT_MS, stream) LOGGER.debug("Recording instance created=%s", recording.serialize()) response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error # Validating longer recording parallel recording_id_1 = recording.get_entry(1).RecordingId # recording_pool = mp_pool.ThreadPool(processes=2) recording_pool = mp_pool.ThreadPool() recording_pool.apply_async(validate_recordings.validate_recording, (recording_id_1, web_service_objs[1]), callback=queue.put) # Validating shorter recording to complete recording_id_0 = recording.get_entry(0).RecordingId is_valid, error = validate_recordings.validate_recording( recording_id_0, web_service_objs[0]) assert is_valid, error shorter_recording_res = rio.find_recording(recording_id_0).json() # Validate the copy count for unique/common copy if RecordingAttribute.COPY_TYPE_UNIQUE == copy_type: is_valid, error = validate_storage.validate_copy_count( shorter_recording_res, Cos.ACTIVE_STORAGE, 2) elif RecordingAttribute.COPY_TYPE_COMMON == copy_type: is_valid, error = validate_storage.validate_copy_count( shorter_recording_res, Cos.ACTIVE_STORAGE, 1) assert is_valid, error LOGGER.debug(copy_type + " copy validation success") # Try to update the end time after shorter recording completes response = rio.find_recording(recording_id_0).json() print "[INFO: ] response json ", response updated_end_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) recording.get_entry(0).EndTime = updated_end_time shorter_recording_res = a8.create_recording(recording, recording_id_0) response = rio.find_recording(recording_id_0).json() print "[INFO: ] response json ", response is_valid, error = validate_common.validate_http_response_status_code( shorter_recording_res, requests.codes.bad_request) print "[INFO: ] update end time after recording complete message ", error # assert is_valid, "CSCvc21524: - "+error # Validating the updated end time in response, it should not be equal response = rio.find_recording(recording_id_0).json() is_valid, error = validate_recordings.validate_time( response, updated_end_time, RecordingAttribute.END_TIME) assert not is_valid, error print "[INFO: ] Validating the updated end time in response, it should not be equal " print "[INFO: ] async validate recording wait time ", time.sleep( validate_rec_wait_time) print "[INFO: ] queue list empty ", queue.empty() # Validating the longer recording is_valid, error = queue.get(timeout=7) print "[INFO: ] queue value 1 ", is_valid assert is_valid, error print "[INFO: ] Validating the longer recording " # Playback all recordings for i in range(total_recordings): recording_pool.apply_async(validate_recordings.validate_playback, (recording.get_entry(i).RecordingId, ), callback=queue.put) print "[INFO: ] Playback all recordings " # Validate playback recordings for i in range(total_recordings): is_valid, error = queue.get() print "[INFO: ] queue value 2 ", is_valid assert is_valid, error print "[INFO: ] Validate playback recordings" finally: if recording_pool: recording_pool.close() recording_pool.join() for web_service_obj in web_service_objs: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_tc_rec_009_036_(total_recording, stream, name, copy_type): """ Update the end time of a recording before it starts """ recording = None web_service_objects = [] recording_pool = None recording_id_list = [] try: queue = Queue.Queue() start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 70, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(total_recordings=total_recording, StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId recording_id_list.append(recording_id) web_service_objects.append( notification_utils.get_web_service_object(recording_id)) recording.get_entry(i).UpdateUrl = web_service_objects[i].get_url() LOGGER.debug("Recording instance created=%s", recording.serialize()) response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error recording_pool = mp_pool.ThreadPool(processes=total_recording) for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() LOGGER.debug("Response=%s", response) end_time = response[0][RecordingAttribute.END_TIME][:-1] LOGGER.debug("Scheduled end time of recording=%s is %s", recording_id, end_time) recording.get_entry(i).EndTime = utils.get_formatted_time( constants.SECONDS * 60, TimeFormat.TIME_FORMAT_MS, stream) LOGGER.debug("Updated end time of recording=%s to %s", recording_id, recording.get_entry(i).EndTime) # Update the recording with the updated end time response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error # Validating whether the updated end time was populated or not for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() LOGGER.debug("Response=%s", response) is_valid, error = validate_recordings.validate_time( response, recording.get_entry(i).EndTime, RecordingAttribute.END_TIME) assert is_valid, error for i in range(total_recording): recording_pool.apply_async( validate_recordings.validate_recording, (recording.get_entry(i).RecordingId, web_service_objects[i]), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error for i in range(total_recording): response = rio.find_recording( recording.get_entry(i).RecordingId).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error if copy_type == RecordingAttribute.COPY_TYPE_COMMON: is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_NOT_STORED, 1) assert is_valid, error if copy_type == RecordingAttribute.COPY_TYPE_UNIQUE: archive_helper.wait_for_archival( stream, recording.get_entry(0).RecordingId, Archive.ARCHIVE, Archive.COMPLETE) for i in range(total_recording): response = rio.find_recording( recording.get_entry(i).RecordingId).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ARCHIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_storage.validate_copy_count( response, Cos.ARCHIVE_STORAGE) assert is_valid, error for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_playback, (recording.get_entry(i).RecordingId, ), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error finally: if recording_pool: recording_pool.close() recording_pool.join() for web_service_obj in web_service_objects: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9768_bulk_update_start_time_during_recording_inprogress_common( total_recording, stream, name, copy_type): """ TC9768: Bulk update of recording requests of start time during recording (20 requests) common copy 1, Send a bulk request for 20 common copy recordings. 2, Change the start time for all the recordings during the recording is in-progress. Verify that bulk update of start time during recording gets failed. """ recording = None web_service_objects = [] recording_pool = None recording_id_list = [] try: # Set 30 second length, starting 30 seconds in future start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 60, TimeFormat.TIME_FORMAT_MS, stream) # Create recording request LOGGER.info("CREATE RECORDING OBJECT INSTANCE") recording = recording_model.Recording(total_recordings=total_recording, StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId recording_id_list.append(recording_id) web_service_objects.append( notification_utils.get_web_service_object(recording_id)) recording.get_entry(i).UpdateUrl = web_service_objects[i].get_url() LOGGER.debug("Recording instance created=%s", recording.serialize()) # Send recording request to a8 LOGGER.info("SEND ORIGINAL RECORDING REQUESTS TO A8") response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) LOGGER.info("Requested recordings from a8 - valid: %s, error: %s", is_valid, error) assert is_valid, error # Wait for all recordings to start LOGGER.info("WAIT FOR RECORDINGS TO START") for i in range(total_recording): is_valid, error = validate_recordings.validate_notification( web_service_objects[i], constants.RecordingStatus.STARTED) assert is_valid, error # Change the start times in the recording object instance LOGGER.info("UPDATE START TIMES IN RECORDING OBJECT INSTANCE") original_start_times = [] for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() # Save original start times for verification step later original_start_times.append( response[0][RecordingAttribute.START_TIME]) # Change start time +10 seconds recording.get_entry(i).StartTime = utils.get_formatted_time( constants.SECONDS * 10, TimeFormat.TIME_FORMAT_MS, stream) LOGGER.info("%s start times - original=%s, updated=%s", recording_id_list[i], original_start_times[i], recording.get_entry(i).StartTime) # Attempt to update the recording start times LOGGER.info("SEND UPDATED RECORDING REQUESTS TO A8") response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) LOGGER.info("Requested updated recordings in a8 valid=%s, error=%s", is_valid, error) assert is_valid, error # Verify that the updated start time was NOT populated LOGGER.info("VERIFY UNCHANGED START TIMES FOR RECORDINGS") for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() is_valid, error = validate_recordings.validate_time( response, original_start_times[i], RecordingAttribute.START_TIME) assert is_valid, error # Let the recordings complete LOGGER.info("VERIFY RECORDING COMPLETION") queue = Queue.Queue() recording_pool = mp_pool.ThreadPool(processes=total_recording) for i in range(total_recording): recording_pool.apply_async( validate_recordings.validate_notification, (web_service_objects[i], constants.RecordingStatus.COMPLETE, 60), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() LOGGER.info("Recording %s complete valid=%s, error=%s", recording_id_list[i], is_valid, error) assert is_valid, error finally: # Clean up if recording_pool: recording_pool.close() recording_pool.join() if len(web_service_objects): for web_service_obj in web_service_objects: web_service_obj.stop_server() if recording: response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9787_bulk_update_end_time_prior_to_current_time_during_recording_inprogress_unique( total_recording, stream, name, copy_type): """ TC9787: Bulk update of recording requests of end time prior to current time during recording in progress (20 requests) unique copy 1. Send a bulk request for 20 unique copy recordings. 2. Change the end time for all the recordings during the recording is in-progress. Verify that bulk update of end time during recording gets failed. UPDATED 06/14/2019 to look for success in changing end time - From VMR development team: "RM on getting /a8/record request - updates the end time if the recording has not already ended and if end time in the request is in valid ISO8601 format. It returns success response." """ recording = None web_service_objects = [] recording_pool = None recording_id_list = [] try: # Set 120 second length, starting 5 seconds in future. start_time = utils.get_formatted_time(constants.SECONDS * 5, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 125, TimeFormat.TIME_FORMAT_MS, stream) # Create recording request LOGGER.info("CREATE RECORDING OBJECT INSTANCE") recording = recording_model.Recording(total_recordings=total_recording, StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId recording_id_list.append(recording_id) web_service_objects.append( notification_utils.get_web_service_object(recording_id)) recording.get_entry(i).UpdateUrl = web_service_objects[i].get_url() LOGGER.debug("Recording instance created=%s", recording.serialize()) # Send recording request to a8 LOGGER.info("SEND ORIGINAL RECORDING REQUESTS TO A8") response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) LOGGER.info("Requested recordings from a8 - valid: %s, error: %s", is_valid, error) assert is_valid, error # Wait for all recordings to start LOGGER.info("WAIT FOR RECORDINGS TO START") for i in range(total_recording): is_valid, error = validate_recordings.validate_notification( web_service_objects[i], constants.RecordingStatus.STARTED) assert is_valid, error LOGGER.info("Current time=%s", datetime.datetime.utcnow()) # Change the end times in the recording object instance to one second prior to current time new_end_time = utils.get_formatted_time(constants.SECONDS * -1, TimeFormat.TIME_FORMAT_MS, stream) LOGGER.info("UPDATE END TIMES IN RECORDING OBJECT INSTANCE") for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() original_end_time = response[0][RecordingAttribute.END_TIME] recording.get_entry(i).EndTime = new_end_time LOGGER.info("%s end time - original=%s, updated=%s", recording_id_list[i], original_end_time, new_end_time) # Send a8 request to update the recording end times LOGGER.info("SEND UPDATED RECORDING REQUESTS TO A8") response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) LOGGER.info("Requested updated recordings in a8 valid=%s, error=%s", is_valid, error) assert is_valid, error # Verify that the updated end time was populated LOGGER.info("VERIFY CHANGED END TIMES FOR RECORDINGS") for i in range(total_recording): response = rio.find_recording(recording_id_list[i]).json() is_valid, error = validate_recordings.validate_time( response, recording.get_entry(i).EndTime, RecordingAttribute.END_TIME) assert is_valid, error # The recordings should end after the end time changed LOGGER.info("VERIFY RECORDING COMPLETION") queue = Queue.Queue() recording_pool = mp_pool.ThreadPool(processes=total_recording) for i in range(total_recording): recording_pool.apply_async( validate_recordings.validate_notification, (web_service_objects[i], constants.RecordingStatus.COMPLETE, 30), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() LOGGER.info("Recording %s complete valid=%s, error=%s", recording_id_list[i], is_valid, error) assert is_valid, error finally: if recording_pool: recording_pool.close() recording_pool.join() if len(web_service_objects): for web_service_obj in web_service_objects: web_service_obj.stop_server() if recording: response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)