def test_rtc9778_tc_arc_008_delete_after_archive_complete(stream): """ Create a recording with copy type as UNIQUE and delete it after archival completes """ recording = None web_service_obj = None try: 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(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.COMPLETE) response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ARCHIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error response = a8.delete_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error is_valid, error = validate_recordings.validate_recording_deletion( recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9734_tc_er_010_playback_redirect_mode(stream, name, copy_type): """ Playback of Active and Archive recording(UNIQUE and COMMON) with DO(Dash Origin) redirect enabled """ recording = None web_service_obj = None try: 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(StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error if copy_type == RecordingAttribute.COPY_TYPE_UNIQUE: archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.IN_PROGRESS) response = rio.find_recording(recording_id).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_recordings.validate_playback( recording_id) 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_rtc9752_tc_rec_004_past_start_time_current_end_time(stream): """ Create a recording with past start time and current end time """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * -120, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.get_url() LOGGER.debug("Recording instance created=%s", recording.serialize()) response = a8.create_recording(recording) minimum_start_time = datetime.datetime.utcnow() + datetime.timedelta(0, constants.MINIMUM_SEGMENT_TIME_DIFF) is_valid, error = validate_common.validate_http_response_status_code(response, requests.codes.no_content) assert is_valid, error is_valid, status = validate_recordings.validate_recording(recording_id, web_service_obj, minimum_start_time) assert is_valid, status if status == constants.RecordingStatus.COMPLETE: is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9757_tc_rec_011_delete_before_recording_start(stream): """ Create a recording and delete it before it starts """ start_time = utils.get_formatted_time(constants.SECONDS * 120, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 240, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=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 time.sleep(constants.SECONDS * 60) response = a8.delete_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error recording_id = recording.get_entry(0).RecordingId is_valid, error = validate_recordings.validate_recording_deletion( recording_id) assert is_valid, error
def test_rtc9818_tc_rec_029_end_time_before_start_time(stream): """ Create a unique copy recording with end time before start time """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * 60, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert not is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def delete_recordings(del_ct, rec_list, rec_dict): """ Delete the list of Recording from recording list :param del_ct: deleting count :param rec_list: list of recording idenitifers to delete :param rec_dict: recording details of recording :return: (rec_list, rec_dict) - recording identifiers list, recording details list """ rec_list_len = len(rec_list) print "[INFO: ] rec_list_len ", rec_list_len if del_ct <= rec_list_len: counts = del_ct else: counts = rec_list_len for inx in range(counts): rec_id = rec_list[inx] recording = recording_model.Recording(RecordingId=rec_id) print "[DEBUG: ] deletion on recid ", rec_id response = a8.delete_recording(recording) is_valid, error = validate_common.validate_http_response_status_code(response, requests.codes.no_content) assert is_valid, error rec_list.remove(rec_id) rec_dict['items'].pop(rec_id) return rec_list, rec_dict
def test_rtc9762_tc_rec_016_multiple_unique(stream): """ Create multiple recordings with copy type as UNIQUE """ total_recordings = 3 web_service_objs = [] recording_pool = None recording = 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, 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 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_recordings) for i in range(total_recordings): recording_pool.apply_async(validate_recordings.validate_recording, (recording.get_entry(i).RecordingId, web_service_objs[i]), callback=queue.put) for i in range(total_recordings): is_valid, error = queue.get() assert is_valid, error for i in range(total_recordings): 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, i) assert is_valid, error for i in range(total_recordings): recording_pool.apply_async(validate_recordings.validate_playback, (recording.get_entry(i).RecordingId,), callback=queue.put) for i in range(total_recordings): 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_objs: 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_create_3hr_recording_ipdvrtests_64(channel, name, copy_type): """ JIRA_URL : https://jira01.engit.synamedia.com/browse/IPDVRTESTS-64 DESCRIPTION : Create 3 hr recording #Partially automated Skipped step(s) : Step 3 - No errors seen in MA/SR pods """ stream = channel web_service_obj = None recording = None stream_name = nsa.get_stream(stream).json()[0][constants.STREAM_NAME] try: #STEP 1 - Create UC and CC recording with longer duration ~3hr start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 10830, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 #STEP 2 - Verify recording state is complete is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) assert is_valid, error #Find recording LOGGER.info("Find recording in rio") response = rio.find_recording(recording_id).json() if not response: return False, ValidationError.RECORDING_RESPONSE_EMPTY.format(recording_id) print "[INFO: ] Recording status in rio : ",response[0]['Status'] #Playback and Validate Playback LOGGER.info("Playback Recording") print "\nPlayback Recording" print "Recording ID :",recording.get_entry(0).RecordingId is_valid, error = validate_recordings.validate_playback(recording.get_entry(0).RecordingId) print "[INFO: ] ",is_valid assert is_valid, error #STEP 4 - memsql table has correct info for UC and CC LOGGER.info("Find recording in rio") response = rio.find_recording(recording_id).json() if not response: return False, ValidationError.RECORDING_RESPONSE_EMPTY.format(recording_id) print "[INFO: ] Recording status in rio : \n" pprint (response, width=1) 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_rtc9816_tc_rec_007_update_stream_id_before_recording_start(stream): """ Create a recording and update the stream ID before the recording starts """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * 120, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 150, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 time.sleep(constants.SECONDS * 60) stream_list_rem = [x for x in STREAM_ID_LIST if x != stream] assert stream_list_rem, ValidationError.STREAM_NOT_CONFIGURED recording.get_entry(0).StreamId = stream_list_rem[0] # Update the previously created recording with the new stream ID response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error is_valid, error = validate_streams.validate_stream_id( recording_id, stream_list_rem[0]) assert is_valid, error is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_tc_des_016_vmr_ntp_out_of_sync(): LOGGER.info("vmr_ntp_out_of_sync test case...") recording = None web_service_obj = None timeout = int(os.environ.get(STREAM_ID)) ntp_server_v2pc = CONFIG_INFO[Component.V2PC][Component.NTP] india_ntp = '1.in.pool.ntp.org' ntp_synchronization_time = 300 # Initiate the recording try: start_time = utils.get_formatted_time((constants.SECONDS * 30) + timeout, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time((constants.SECONDS * 90) + timeout, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=STREAM_ID) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 time.sleep(40) # Configure to the right ntp server in VMR cmd = "sed -i -E 's/" + ntp_server_v2pc + "/" + india_ntp + "/g' /etc/ntp.conf" update_vmr_ntp_server(cmd) time.sleep(ntp_synchronization_time) # Validate recording is incomplete is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) LOGGER.info(is_valid) LOGGER.info(error) assert is_valid, error response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage(response, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: # revert back the ntp to the original value in vmr cmd = "sed -i -E 's/" + india_ntp + "/" + ntp_server_v2pc + "/g' /etc/ntp.conf" update_vmr_ntp_server(cmd) time.sleep(ntp_synchronization_time) web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code) # Check whether all the components are synchronized. times_are_synchronized, error = test_setup.are_times_synchronized() if not times_are_synchronized: pytest.fail(error)
def test_rtc9737_tc_er_013_vertical_grouping(stream, name, copy_type): """ Vertical Grouping - Enable vertical grouping on all profiles in MA. """ web_service_obj = None recording = None service_name = V2pc.MANIFEST_AGENT stream_name = nsa.get_stream(stream).json()[0][constants.STREAM_NAME] profile_data = v2pc.get_all_stream_profile_data(stream_name) assert len(profile_data)>=3, "Vertical grouping required minimum 3 profile for a stream" try: #Taking backup of v2pc pod config info and editing the config and then restarting the services is_valid, error = cleanup(redeploy_config_map, service_name, revert=True) assert is_valid, error is_valid, error = v2pc_edit_manifest_config(V2pc.MANIFEST_AGENT, vertical_grouping="*") assert is_valid, error 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(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) assert is_valid, error is_valid, error = verify_vertical_grouping(recording_id) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: #Revert back the v2pc config changes is_valid, error = cleanup(redeploy_config_map, service_name, revert=True) assert is_valid, error 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_rtc9750_tc_rec_002_future_start_time_future_end_time_common(stream): """ Create a recording with future start time, future end time and COMMON copy type """ recording = None web_service_obj = None try: 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) copy_type = RecordingAttribute.COPY_TYPE_COMMON recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_NOT_STORED, 1) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_deleted_recording_cannot_be_played_back_ipdvrtests_166( common_lib, stream): """ JIRA ID : IPDVRTESTS-166 JIRA LINK : https://jira01.engit.synamedia.com/browse/IPDVRTESTS-166 """ recording = None web_service_obj = None try: # Step1: Create a 30 minute recording recording, web_service_obj = common_lib.create_recording( stream, rec_duration=Component.LARGE_REC_LEN_IN_SEC) recording_id = recording.get_entry(0).RecordingId is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error # Step2: Delete the recording response = a8.delete_recording(recording) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error is_valid, error = validate_recordings.validate_recording_deletion( recording_id) assert is_valid, error # Step 3: Validating playback is_valid, error = validate_recordings.validate_playback_using_vle( recording_id) assert not is_valid, ValidationError.DELETED_RECORDING_PLAYED_BACK.format( recording_id) 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_tc10367_restart_channel_when_recording(channel): """ JIRA ID : IPDVRTESTS-58 JIRA Link : https://jira01.engit.synamedia.com/browse/IPDVRTESTS-58 TC10367: Restart the channel during recording and then playback """ stream = channel recording = None web_service_obj = None try: rec_buffer_time = utils.get_rec_duration( dur_confg_key=Component.REC_BUFFER_LEN_IN_SEC) rec_duration = utils.get_rec_duration() start_time = utils.get_formatted_time( (constants.SECONDS * rec_buffer_time), TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time( (constants.SECONDS * (rec_buffer_time + rec_duration)), TimeFormat.TIME_FORMAT_MS, stream) copy_type = RecordingAttribute.COPY_TYPE_UNIQUE LOGGER.debug("Stream Id : %s", stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId LOGGER.info("Recording Id :%s", recording_id) web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 LOGGER.info("Restart Channel : %s", stream) # Restart the stream is_valid, error = v2pc.restart_stream(stream, count=3) assert is_valid, error is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error finally: if web_service_obj: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9744_tc_er_018_private_copy(stream, name, copy_type): """ Private copy - Archive/Pre-gen """ web_service_obj = None recording = None stream = str(private_copy_stream) try: start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 80, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error # wait for georbage collect archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.COMPLETE) response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ARCHIVE_STORAGE, Cos.RECORDING_STORED) 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_rtc9773_tc_arc_003_common(stream): """ Create a recording with copy type as COMMON and check whether archival is happening or not """ recording = None web_service_obj = None try: 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) copy_type = RecordingAttribute.COPY_TYPE_COMMON recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.IN_PROGRESS) response = rio.find_recording(recording_id).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_recordings.validate_playback(recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9775_tc_arc_005_playback_archive_in_progress(stream): """ Create a recording with copy type as UNIQUE and play it back when archival is in progress """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 90, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) assert is_valid, error archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.IN_PROGRESS) response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage(response, Cos.ARCHIVE_STORAGE, [Cos.RECORDING_STORED, Cos.RECORDING_PARTIALLY_STORED]) assert is_valid, error is_valid, error = validate_recordings.validate_playback_using_vle(recording_id) assert is_valid, error # If we playback recording when archival is INPROGRESS, There is a chance of few segments being played from # Active storage. This means that only part of the segments would move from archive to recon. # The rest will move from active to archive. So both PARTIALLY_STORED and STORED are valid is_valid, error = validate_storage.validate_recording_in_storage(response, Cos.RECON_STORAGE, [Cos.RECORDING_STORED, Cos.RECORDING_PARTIALLY_STORED]) assert is_valid, ValidationError.SEGMENT_NOT_MOVED.format(Cos.RECON_STORAGE, recording_id) finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9756_tc_rec_010_recording_stop_after_recording_start(stream): """ Create a recording and once it starts, stop it by setting the end time as the current time """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 150, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 response = rio.find_recording(recording_id).json() LOGGER.debug("Response=%s", response) start_time = utils.get_parsed_time(response[0][RecordingAttribute.START_TIME][:-1]) current_time = datetime.datetime.utcnow() # wait till the recording start time if current_time < start_time: utils.wait(start_time - current_time, constants.TIME_DELTA) is_valid, error = validate_recordings.validate_notification(web_service_obj, constants.RecordingStatus.STARTED) assert is_valid, error time.sleep(constants.SECONDS * 60) recording.get_entry(0).EndTime = utils.get_formatted_time(constants.SECONDS * 0, TimeFormat.TIME_FORMAT_MS, stream) response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code(response, requests.codes.no_content) assert is_valid, error time.sleep(constants.SECONDS * 4) is_valid, error = validate_recordings.validate_recording_end_state(recording_id, [RecordingStatus.COMPLETE], web_service_obj=web_service_obj) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_sanity_hybrid_copy(stream, name, copy_type): """ Schedule UNIQUE and COMMON copy on same channel and verify the recording and playback. """ recording = None web_service_obj = None try: start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 80, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream, copyType=copy_type) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.COMPLETE) response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_NOT_STORED) assert is_valid, error is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ARCHIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_tc_ply_lang(name, stream, audio_lang): """ Playback recording using different audio languages like eng, fre and spa and validate playback """ recording = None web_service_obj = None try: 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) copy_type = RecordingAttribute.COPY_TYPE_UNIQUE recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error vle_request_params = {} LOGGER.debug( "Configuring vle to playback with clients=%s and audio language=%s", 1, audio_lang) vle_request_params[Vle.CLIENTS_NUM_MAX] = 1 vle_request_params[Vle.AUDIO_LANGUAGE] = audio_lang is_valid, error = validate_recordings.validate_playback( recording_id, VLE_REQUEST_PARAMS=vle_request_params) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_sanity_rtc10065_private_copy(stream): """ Schedule Private copy and verify the recording and playback. """ recording = None web_service_obj = None stream = str(private_copy_stream) try: start_time = utils.get_formatted_time(constants.SECONDS * 30, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time(constants.SECONDS * 80, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error response = rio.find_recording(recording_id).json() is_valid, error = validate_storage.validate_recording_in_storage( response, Cos.ACTIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) 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_ply_stream_style(name, stream, stream_style): """ Playback vle using multiple/single bit rates and using different stream styles """ recording = None web_service_obj = None try: 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) copy_type = RecordingAttribute.COPY_TYPE_UNIQUE recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) assert is_valid, error vle_request_params = {} LOGGER.debug("Configuring vle to playback with clients=%s and stream style=%s", 1, stream_style) vle_request_params[Vle.CLIENTS_NUM_MAX] = 1 vle_request_params[Vle.STREAM_STYLE] = stream_style if Vle.STREAM_STYLE_DEFAULT == stream_style: is_valid, msg = utils.get_video_profiles_from_m3u8(recording_id) assert is_valid, msg # If Valid, msg will contain the list of video profiles assert msg, ValidationError.VIDEO_PROFILES_NOT_FOUND.format(recording_id) vle_request_params[Vle.DOWNLOAD_BITRATE] = msg[0] is_valid, error = validate_recordings.validate_playback(recording_id, VLE_REQUEST_PARAMS=vle_request_params) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9771_tc_ply_009_playback_subtitles(stream): """ Playback recording with subtitles and validate playback in Direct Mode """ recording = None web_service_obj = None try: 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(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error vle_request_params = {} LOGGER.debug( "Configuring vle to playback with subtitle in VMR direct mode") vle_request_params[Vle.VLE_CALL_FLOW_KEY] = Vle.VLE_CALL_FLOW_SUBTITLE is_valid, error = validate_recordings.validate_playback( recording_id, VLE_REQUEST_PARAMS=vle_request_params) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9753_tc_rec_006_current_start_time_future_end_time(stream): """ Create a recording with current start time and future end time """ recording = None web_service_obj = None try: end_time = utils.get_formatted_time(constants.SECONDS * 60, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object( recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 is_valid, status = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, status if status == constants.RecordingStatus.COMPLETE: is_valid, error = validate_recordings.validate_playback( recording_id) assert is_valid, error finally: web_service_obj.stop_server() response = a8.delete_recording(recording) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_tc_arc_(name, stream, event): """ test_tc_arc_[009_multiple_playback_one_unique-ARCHIVE --> Create multiple recordings with copy type as UNIQUE, wait for them to get archived, playback one of the them and verify if the recording is present both in the ARCHIVE_STORAGE AND RECON_STORAGE test_tc_arc_[011_multiple_playback_one_re_archive_unique-RE_ARCHIVE --> Create multiple recordings with copy type as UNIQUE, wait for them to get archived, playback one, and wait till it gets re-archived """ LOGGER.info("#####################################################################") LOGGER.info("Starting test_tc_arc_%s", name) total_recordings = 3 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, 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 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_id = recording.get_entry(0).RecordingId recording_pool = mp_pool.ThreadPool(processes=total_recordings) for i in range(total_recordings): recording_pool.apply_async(validate_recordings.validate_recording, (recording.get_entry(i).RecordingId, web_service_objs[i]), callback=queue.put) for i in range(total_recordings): is_valid, error = queue.get() assert is_valid, error archive_helper.wait_for_archival(stream, recording_id, Archive.ARCHIVE, Archive.COMPLETE) for i in range(total_recordings): 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_NOT_STORED, i) assert is_valid, error 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 is_valid, error = validate_recordings.validate_playback_using_vle(recording_id) assert is_valid, error response = rio.find_recording(recording.get_entry(0).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_recording_in_storage(response, Cos.RECON_STORAGE, Cos.RECORDING_STORED) assert is_valid, error if event == Archive.RE_ARCHIVE: archive_helper.wait_for_archival(stream, recording_id, Archive.RE_ARCHIVE, Archive.COMPLETE) is_valid, error = validate_storage.validate_recording_in_storage(response, Cos.RECON_STORAGE, Cos.RECORDING_NOT_STORED) assert is_valid, error is_valid, error = validate_storage.validate_recording_in_storage(response, Cos.ARCHIVE_STORAGE, Cos.RECORDING_STORED) assert is_valid, error for i in range(total_recordings): recording_pool.apply_async(validate_recordings.validate_playback, (recording.get_entry(i).RecordingId,), callback=queue.put) for i in range(total_recordings): 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_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_033_015_(total_recording, stream, name, copy_type): """ Create multiple recordings with copy type as COMMON """ web_service_objects = [] recording_pool = None recording = 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_recording, StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId 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): 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 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_filter_video_based_on_rank_ipdvrtests_235(channel): """ JIRA ID : IPDVRTESTS-235 JIRA Link : https://jira01.engit.synamedia.com/browse/IPDVRTESTS-235 Description: DASH-Confirm MPE publish template to filter video based on rank """ stream = channel recording = None metadata = None web_service_obj = None try: source_xml = utils.get_source_mpd_content(stream) bit_res = utils.get_bitrates_resolutions(source_xml) bitrates = bit_res.keys() assert len(bitrates) >= 2, "Not enough video profiles in the selected stream to filter" # Step1: Configure Variants in MPE publish template to filter video based on rank push_payload = { "name": "default", "order": "rank", "selectivePublish": "true", "profileOrdering": [ { "rank": "1" }, { "rank": "2" } ] } generic_config = utils.get_spec_config() key_profile = generic_config[Component.WORK_FLOW][Component.KEY_PROFILE_DASH_WIDEVINE] response, published_template_data, template_name = v2pc_helper.get_publish_template_by_format(template_format=V2pc.DASH_TEMPLATE_PACKAGE_FORMAT, key_profile=key_profile) assert response, "Cannot find the template data for the given format/key profile" LOGGER.debug("Published Template Data : %s", published_template_data) keys_to_be_removed = V2pc.OTHER_KEYS metadata = dict([(key, value) for key, value in published_template_data.items() if key not in keys_to_be_removed]) LOGGER.debug("Modified metadata : %s", metadata) metadata_modified = metadata.copy() metadata_modified['properties']["variants"] = [push_payload, ] LOGGER.debug("modified publish template : %s", metadata_modified) update_template = v2pc.put_publish_template(metadata_modified, template=template_name) assert update_template, "Unable to update the published template with renamed segment" result, response = v2pc.restart_media_workflow(generic_config[Component.WORK_FLOW][Component.WORKFLOW_NAME]) assert result, response result, response = v2pc_helper.waits_till_workflow_active(generic_config[Component.WORK_FLOW][Component.WORKFLOW_NAME], 120) assert result, response # Step2: Create 30 minute recording LOGGER.info("Creating Recording") rec_buffer_time = utils.get_rec_duration(dur_confg_key=Component.REC_BUFFER_LEN_IN_SEC) rec_duration = utils.get_rec_duration(dur_confg_key=Component.LARGE_REC_LEN_IN_SEC) start_time = utils.get_formatted_time((constants.SECONDS * rec_buffer_time), TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time((constants.SECONDS * (rec_buffer_time + rec_duration)), TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(StartTime=start_time, EndTime=end_time, StreamId=stream) recording_id = recording.get_entry(0).RecordingId web_service_obj = notification_utils.get_web_service_object(recording_id) recording.get_entry(0).UpdateUrl = web_service_obj.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 playback_url = utils.get_mpe_playback_url(recording_id, PlaybackTypes.DASH_WV) is_valid, error = validate_recordings.validate_recording(recording_id, web_service_obj) assert is_valid, error # step3: Check for manifest for the variants using curl mpd_res = requests.get(playback_url) res_bitrates = [] result_dict = utils.xml_dict(mpd_res.content) for repre in result_dict['MPD']['Period'][0]['AdaptationSet']: if repre.has_key("Representation") and repre.has_key("contentType") and repre["contentType"] == 'video': for rate in repre["Representation"]: if "video" in rate['id'] and int(rate['bandwidth']) not in res_bitrates: res_bitrates.append(int(rate['bandwidth'])) strip_value = len(push_payload["profileOrdering"]) - len(bitrates) if strip_value != 0: assert sorted(bitrates)[::-1][0:strip_value] == res_bitrates, "Video bitrates are not filtered based on rank given in publish template" else: assert sorted(bitrates)[::-1] == res_bitrates, "Video bitrates are not filtered based on rank given in publish template" finally: if metadata: LOGGER.info("Reverting the publish template changes") update_template = v2pc.put_publish_template(metadata, template=template_name) assert update_template, "Unable to update the publish template" result, response = v2pc.restart_media_workflow(generic_config[Component.WORK_FLOW][Component.WORKFLOW_NAME]) assert result, response result, response = v2pc_helper.waits_till_workflow_active(generic_config[Component.WORK_FLOW][Component.WORKFLOW_NAME],120) assert result, response 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_rtc9763_tc_rec_027_multiple_delete_playback_unique(stream): """ Create multiple recordings with copy type as UNIQUE, delete one and playback the rest """ total_recordings = 3 web_service_objs = [] playback_pool = None recording = 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, 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 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_id_0 = recording.get_entry(0).RecordingId recording_pool = mp_pool.ThreadPool(processes=total_recordings) for i in range(total_recordings): recording_pool.apply_async( validate_recordings.validate_recording, (recording.get_entry(i).RecordingId, web_service_objs[i]), callback=queue.put) for i in range(total_recordings): is_valid, error = queue.get() assert is_valid, error for i in range(total_recordings): response = rio.find_recording( recording.get_entry(i).RecordingId).json() is_valid, error = validate_storage.validate_copy_count( response, Cos.ACTIVE_STORAGE, total_recordings) assert is_valid, error recording_to_delete = copy.deepcopy(recording) del recording_to_delete.get_entries()[1:] del recording.get_entries()[:1] # to clean up recordings later response = a8.delete_recording(recording_to_delete) is_valid, error = validate_common.validate_http_response_status_code( response, requests.codes.no_content) assert is_valid, error is_valid, error = validate_recordings.validate_recording_deletion( recording_id_0) assert is_valid, error is_valid, error = validate_recordings.validate_playback_using_vle( recording_id_0) assert not is_valid, ValidationError.DELETED_RECORDING_PLAYED_BACK.format( recording_id_0) playback_pool = mp_pool.ThreadPool( processes=len(recording.get_entries())) for recording_entry in recording.get_entries(): playback_pool.apply_async( validate_recordings.validate_playback_using_vle, (recording_entry.RecordingId, ), callback=queue.put) for i in range(len(recording.get_entries())): is_valid, error = queue.get() assert is_valid, error finally: if playback_pool: playback_pool.close() playback_pool.join() for web_service_obj in web_service_objs: 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_rtc9804_tc_des_011_mce_ni_packet_latency(): """ Introduce the latency on each packet on the outgoing MCE Interface, trigger a recording and verify if the recording is successful """ ssh_client = None response = None web_service_obj = None start_duration = 30 try: rev_cmds = {} mce_nodes = v2pc.get_app_worker_nodes(MCE_INSTANCE, COMPONENT_NAME) for mce_node in mce_nodes: mce_data_out = mce_node[Interface.DATA_OUT] mce_ip = mce_node[Component.IP] ssh_client = utils.get_ssh_client(COMPONENT_NAME, COMPONENT_USERNAME, component_ip=mce_ip) # deleting the previously scheduled jobs by other test cases, in order not to tamper with the current test case destructive_utils.delete_scheduled_job(COMPONENT_NAME, ssh_client, mce_ip, destructive.MCE_JOB_IDS) rev_cmds[mce_ip] = destructive_utils.schedule_rev_cmd( ssh_client, mce_data_out, mce_ip, destructive.MCE_JOB_IDS, constants.MINUTES * 10) des_cmd = DestructiveTesting.PACKET_LATENCY_OUTGOING_INTERFACE.format( mce_data_out, DestructiveTesting.PACKET_LATENCY) des_cmd = destructive_utils.get_outgoing_tc_cmd( mce_data_out, des_cmd) # expected outcome after the destructive commands are run expected_result = { DestructiveTesting.DELAY: DestructiveTesting.PACKET_LATENCY, DestructiveTesting.DST: DestructiveTesting.NETWORK } is_des_effective, error = destructive_utils.exec_des_cmd( ssh_client, mce_data_out, des_cmd, expected_result) assert is_des_effective, error start_time = utils.get_formatted_time( constants.SECONDS * start_duration, TimeFormat.TIME_FORMAT_MS, STREAM_ID) end_time = utils.get_formatted_time(constants.SECONDS * 90, TimeFormat.TIME_FORMAT_MS, STREAM_ID) response = destructive_utils.create_recording_des(start_time, end_time) web_service_obj = response[RecordingAttribute.WEB_SERVICE_OBJECT] recording_id = response[RecordingAttribute.RECORDING_ID] is_valid, error = validate_recordings.validate_recording( recording_id, web_service_obj) assert is_valid, error is_valid, error = validate_recordings.validate_playback(recording_id) assert is_valid, error # executing the revert command to undo the destructive commands for mce_node in mce_nodes: mce_ip = mce_node[Component.IP] mce_data_out = mce_node[Interface.DATA_OUT] ssh_client = utils.get_ssh_client(COMPONENT_NAME, COMPONENT_USERNAME, component_ip=mce_ip) if rev_cmds[mce_ip]: rev_effective, error = destructive_utils.exec_rev_cmd( COMPONENT_NAME, ssh_client, mce_ip, rev_cmds[mce_ip], mce_data_out, destructive.MCE_JOB_IDS) else: rev_effective, error = destructive_utils.is_rev_effective( ssh_client, mce_data_out) assert rev_effective, error # running sanity test to check if the setup is back to normal after reverting the commands test_rtc9723_tc_rec_001_future_start_time_future_end_time(STREAM_ID) finally: if ssh_client: ssh_client.close() if web_service_obj: web_service_obj.stop_server() if response: response = a8.delete_recording( response[RecordingAttribute.RECORDING]) LOGGER.debug("Recording clean up status code=%s", response.status_code)
def test_rtc9726_tc_er_018_private_copy(stream, name, copy_type): """ Schedule UNIQUE copy recording (20 - 10 same start/end time, 10 different start/end times), batch size 4. """ web_service_objects = [] recording_pool = None recording = None total_recording = 20 diff_start_time_recordings = 10 same_start_time_recordings = 10 try: #Taking backup of v2pc pod config info, editing the config and then restarting the services is_valid, error = cleanup(redeploy_config_map, V2pc.MANIFEST_AGENT, revert=True) assert is_valid, error is_valid, error = v2pc_edit_manifest_config(V2pc.MANIFEST_AGENT, batch_size='4') assert is_valid, error is_valid, error = verify_batch_size_update(V2pc.MANIFEST_AGENT, Component.VMR, "4") assert is_valid, error 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 * 80, TimeFormat.TIME_FORMAT_MS, stream) recording = recording_model.Recording(total_recordings=same_start_time_recordings, StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) for i in range(diff_start_time_recordings, same_start_time_recordings+diff_start_time_recordings): start_time = utils.get_formatted_time((constants.SECONDS * 30)+i, TimeFormat.TIME_FORMAT_MS, stream) end_time = utils.get_formatted_time((constants.SECONDS * 80)+i, TimeFormat.TIME_FORMAT_MS, stream) rec_with_diff_time = recording_model.Recording(total_recordings=1, StartTime=start_time, EndTime=end_time, copyType=copy_type, StreamId=stream) rec_with_diff_time.Entries[0].RecordingId = RecordingAttribute.RECORDING_ID_PREFIX + \ rec_with_diff_time.RequestId + '_' + str(i) recording.Entries.append(rec_with_diff_time.get_entry(0)) last_recording_id = rec_with_diff_time.Entries[0].RecordingId for i in range(total_recording): recording_id = recording.get_entry(i).RecordingId 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()) #Sending recording request to create recording response = a8.create_recording(recording) is_valid, error = validate_common.validate_http_response_status_code(response, requests.codes.no_content) assert is_valid, error response = rio.find_recording(last_recording_id).json() if not response: return False, ValidationError.RECORDING_RESPONSE_EMPTY.format(last_recording_id) start_time = utils.get_parsed_time(response[0][RecordingAttribute.START_TIME][:-1]) current_time = datetime.datetime.utcnow() wait_time = utils.add_time_to_secs((start_time - current_time), constants.SECONDS) if wait_time < 0: wait_time = 0 #Verifying recording is started or not recording_pool = mp_pool.ThreadPool() for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_notification, (web_service_objects[i], constants.RecordingStatus.STARTED, wait_time), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error #Verifying playback of recording in progress for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_playback_using_vle, (recording.get_entry(i).RecordingId,), dict(in_progress = True), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_playback_using_hls_checker, (recording.get_entry(i).RecordingId,), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error end_time = utils.get_parsed_time(response[0][RecordingAttribute.END_TIME][:-1]) current_time = datetime.datetime.utcnow() wait_time = utils.add_time_to_secs((end_time - current_time), constants.SECONDS) if wait_time < 0: wait_time = 0 #Verifying recording is completed or not recording_pool = mp_pool.ThreadPool() for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_notification, (web_service_objects[i], constants.RecordingStatus.COMPLETE, wait_time), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error #Playback verification after recording completed for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_playback_using_vle, (recording.get_entry(i).RecordingId,), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error for i in range(total_recording): recording_pool.apply_async(validate_recordings.validate_playback_using_hls_checker, (recording.get_entry(i).RecordingId,), callback=queue.put) for i in range(total_recording): is_valid, error = queue.get() assert is_valid, error finally: #Revert back the v2pc config changes is_valid, error = cleanup(redeploy_config_map, V2pc.MANIFEST_AGENT, revert=True) assert is_valid, error if recording_pool: recording_pool.close() recording_pool.join() for web_service_obj in web_service_objects: 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)