def doit_wrapper(cfg, printflg=False):
    message = ""
    status = 3
    test_id = "TC10140"
    tims_dict = {test_id: ["US78110", message, status]}
    print "%s: BRB - Dual VMR - Redirect request from All VMR to a VMR and from Specific " \
          "VMR to a VMR with different copy type.." % (test_id)

    try:
        # announce
        # abspath = os.path.abspath(__file__)
        scriptName = os.path.basename(__file__)
        (test, ext) = os.path.splitext(scriptName)
        print "Starting test " + test

        if "no_brb" in cfg["test-flags"]:
            message = "Testcase Skipped: Skipping the testcase since no_brb flag is enabled."
            print message
            tims_dict = update_tims_data(tims_dict, 2, message, [test_id])
            return tims_dict

        # Initialize the Variables
        timeout = 2
        serviceIdlist = []

        # set values based on config
        cmdc_hosts = [cfg['cmdc']['host']]
        pps_hosts = [cfg['pps']['host']]
        upm_hosts = [cfg['upm']['host']]
        cmdc_port = cfg['cmdc']['port']
        pps_port = cfg['pps']['port']
        catalogueId = cfg['catalogueId']
        protocol = cfg['protocol']
        region = cfg['region']

        # Handle if the there are less channels than the threshold.
        threshold_channels = 17
        channelfilter1 = []
        for channels in cfg['test_channels'].keys():
            if channels.startswith("GenericCh"):
                channelfilter1.append(channels)
        if len(channelfilter1) < threshold_channels:
            message = "Skipping this TC since number of channels are less than 17."
            print message
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
            return tims_dict

        # Hardcoded the channel due to UUID channel issue while routing and recording.
        route_channel = '5b89b327-920f-402c-900d-1fb1e1784310'  #UUID equivalet of cfg['test_channels']['GenericCh1']['ServiceId']
        testchannel1 = cfg['test_channels']['GenericCh1']['ServiceId']
        testchannel2 = cfg['test_channels']['GenericCh2']['ServiceId']

        serviceIdlist.append(unicode(testchannel1))
        serviceIdlist.append(unicode(testchannel2))

        prefix = cfg['basic_feature']['household_prefix']
        fetch_bookingcatalog_delay = cfg['pps']['fetch_bookingCatalog_delay']
        recordingstatecheck_timedelay = cfg['pps']['booked_to_recording_delay']
        householdid1 = prefix + '1'
        householdid2 = prefix + '2'
        householdid3 = prefix + '3'
        householdid4 = prefix + '4'
        householdid_list = [
            householdid1, householdid2, householdid3, householdid4
        ]
        hostlist = list(itertools.product(cmdc_hosts, pps_hosts, upm_hosts))
        recording_delay = 180

        source_region = cfg["recorderRegion"]
        srt_content_reset = [[source_region, "*", source_region, "NoChange"]]
        common_copy = "Common"
        unique_copy = "Unique"
        dest_region = cfg["recorderRegion2"]
        copy_type = unique_copy
        ingest_delay = 120
        vmr = cfg['vmr']
        aws_vmr = cfg['vmr2']
        region_index = 5

        srt_content = [["*", "*", dest_region, common_copy],
                       [source_region, testchannel2, dest_region, unique_copy]]

        # Do PPS Booking
        pps_headers = {
            'Content-Type': 'application/json',
            'Source-Type': 'WEB',
            'Source-ID': '127.0.0.1',
        }

        ###########################  USER DEFINED POST TIME IN UTC ############################
        start_delay = 5
        timeslotinminutes = cfg["test_channels"]["longProgramLength"]
        ingestion_time = get_utc_time_after_n_minutes(start_delay, True)
        start_time = datetime.datetime.strptime(ingestion_time,
                                                '%Y-%m-%dT%H:%M:%S')
        post_time = calendar.timegm(start_time.timetuple()) + 0.0001
        #######################################################################################

        print "### STEP1: Ingest an event on channel 1 & channel 2 with 5 minutes duration " \
              "and 5 minues post time. ###\n"
        ci_host = cfg['ci']['host']
        ci_port = cfg['ci']['port']
        ingest_minimum_delay = cfg['ci']['ingest_minimum_delay']
        ingest_delay_factor_per_minute = cfg['ci'][
            'ingest_delay_factor_per_minute']

        eventtitle1 = "TC10140" + str(random.randint(1, 499))

        channel1 = ChannelLineup(BoundaryInMinutes=0)
        channel1.add_to_lineup(serviceId=testchannel1,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel1.postXmlData(ci_host, ci_port, startTime=post_time)
        channel1.writeXmlFiles(startTime=post_time)

        print "channel1 : ", channel1

        channel2 = ChannelLineup(BoundaryInMinutes=0)
        channel2.add_to_lineup(serviceId=testchannel2,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel2.postXmlData(ci_host, ci_port, startTime=post_time)
        channel2.writeXmlFiles(startTime=post_time)

        print "channel2 : ", channel2

        print "Wait time for the catalog ingest to " \
              "get synced with the CI Host in seconds: " + str(ingest_delay)
        time.sleep(ingest_delay)

    except:
        message = "Testcase Failed: Error Occurred in Configuration " + PrintException(
            True)
        print message
        tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
        return tims_dict

    for (cmdc_host, pps_host, upm_host) in hostlist:
        try:
            print "### STEP2 : Ensure four household present in the system pointing to RR1 " \
                  "recording region. ###\n"
            for household in householdid_list:
                hh_region = get_household_region(cfg, upm_host, household,
                                                 timeout)
                assert hh_region == source_region, "Testcase Fail : Household %s not in the " \
                                                   "source region %s" % (household, source_region)

            print "### STEP3:  Modify the SRT in such a way, ###\n"
            print "### STEP 3.1. To record the contents on hh 1 (any region) and from any " \
                  "channel with common copy type in RR2 recording region. ###\n"
            print "### STEP 3.2. To record the contents on hh 2 (RR1 region) and from " \
                  "channel 2 with unique copy type in RR2 recording region.###\n"

            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content)

            # Cleaning up the household
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)

            gridservicelistresponse = fetch_gridRequest(catalogueId, protocol, cmdc_host, \
                                                        cmdc_port, serviceIdlist, region, timeout,
                                                        printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(gridservicelistresponse, \
                                                           eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            print "### STEP4. Perform booking on all four households for the ingested contents.##\n"
            print "## STEP 4.1. Perform the booking on channel 1 on hh 1##"
            content_ev1 = contentId_list[0][0]
            ev1_broadcast_start_time = contentId_list[0][1][0]
            payload_ev1 = """{
                            "scheduleInstanceId" : "%s",
                            "checkConflicts" : true,
                            "pvr":"nPVR"
                            }""" % (content_ev1)

            result = do_PPSbooking(pps_port, protocol, pps_host, householdid_list[0], \
                                   pps_headers, payload_ev1, content_ev1, timeout, printflg)
            if result != "PASS":
                message = "Testcase Failed:Unable to do pps booking of content ID " \
                          + str(content_ev1) + " in household " + str(householdid_list[0])
                print message
                tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

            print "## STEP 4.2. Perform the booking on channel 2 on hh 2##"
            content_ev2 = contentId_list[0][0]
            payload_ev2 = """{
                            "scheduleInstanceId" : "%s",
                            "checkConflicts" : true,
                            "pvr":"nPVR"
                            }""" % (content_ev2)

            result = do_PPSbooking(pps_port, protocol, pps_host, householdid_list[1], \
                                   pps_headers, payload_ev2, content_ev2, timeout, printflg)
            if result != "PASS":
                message = "Testcase Failed:Unable to do pps booking of content ID " \
                          + str(content_ev1) + " in household " + str(householdid_list[1])
                print message
                tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

            time.sleep(fetch_bookingcatalog_delay)
            print "About to start the event 1 booking\n"
            # Getting Catalog Response for the Booked Catalog
            catalogresult, catalogresponse = verify_booking(
                pps_port, protocol, pps_host, householdid_list[0], content_ev1,
                timeout)
            print "Booking response of Event 1:", catalogresult
            assert catalogresult == "PASS", "TestCase  Failed : Content ID " + str(content_ev1) \
                                            + " in household " + str(householdid) \
                                            + " is not in the BOOKED state"

            catalogresult, catalogresponse = verify_booking(
                pps_port, protocol, pps_host, householdid_list[1], content_ev2,
                timeout)
            print "Booking response of Event 2 :\n", catalogresult
            assert catalogresult == "PASS", "TestCase  Failed : Content ID " \
                                            + str(content_ev2) + " in household " \
                                            + str(householdid) + " is not in the BOOKED state"

            print "### STEP5. Wait for the program to start its recording on all four " \
                  "households.####\n"

            broadcasting_starttime = get_timedifference(
                ev1_broadcast_start_time, printflg)
            recordingstatechage = recordingstatecheck_timedelay + broadcasting_starttime
            print "Script will wait for ", recordingstatechage," seconds to check the event " \
                                                               "recording state"
            time.sleep(recordingstatechage)
            print "Waiting additional %s seconds to workaround the " \
                  "state change issue." % (recording_delay)
            time.sleep(recording_delay)

            recrding_res1, recrding_resp1 = verify_recording_state(
                pps_port, protocol, pps_host, householdid_list[0], content_ev1,
                timeout)
            if recrding_res1 != "PASS":
                message = "Testcase Failed: Content ID {0} in household {1} is " \
                          "not in the RECORDING state".format(content_ev1, householdid)
                assert False, message

            recrding_res2, recrding_resp2 = verify_recording_state(
                pps_port, protocol, pps_host, householdid_list[1], content_ev2,
                timeout)
            if recrding_res2 != "PASS":
                message = "Testcase Failed: Content ID {0} in household {1} is not in the " \
                          "RECORDING state".format(content_ev2, householdid)
                assert False, message

            print "### STEP 6. Confirm from VMR API response that recorded contents.###\n"

            print "## STEP 6.1. Content from channel 1 recorded on hh1 with Common copy type " \
                  "in RR2 recording region.##"
            cfg['vmr'] = vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list[0],
                                                       timeout)
            print "Playback URI list :", playbackuri_list
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            print "ContentId list :", contentidlist
            vmr_response_1 = get_vmr_response(cfg, contentidlist[0], timeout)
            riodev_recording_hh1 = json.loads(vmr_response_1.content)[0]
            region_hh1 = riodev_recording_hh1['A8UpdateURL'].split(
                '/')[region_index]
            hh1_copy_type = riodev_recording_hh1["CopyType"]

            print "riodev_recording_hh1 : ", riodev_recording_hh1

            print "region_hh1 : ", region_hh1

            assert hh1_copy_type == common_copy, \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 1 " % (content_ev1, copy_type)

            assert region_hh1 == dest_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 1 " % (content_ev1, dest_region)

            print "## STEP6.2. Content from channel 2 recorded on hh2 with Unique copy type " \
                  "in RR2 recording region.##"

            cfg['vmr'] = aws_vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list[2:4],
                                                       timeout)
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            vmr_response_2 = get_vmr_response(cfg, contentidlist[0], timeout)
            riodev_recording_hh2 = json.loads(vmr_response_2.content)[0]
            region_hh2 = riodev_recording_hh2['A8UpdateURL'].split(
                '/')[region_index]
            hh2_copy_type = riodev_recording_hh2["CopyType"]

            print "riodev_recording_hh2 : ", riodev_recording_hh2

            print "region_hh2 : ", region_hh2

            assert hh2_copy_type == unique_copy, \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 2." % (content_ev1, unique_copy)

            assert region_hh2 == dest_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 2." % (content_ev1, dest_region)

            message = "TestCase Passed : SRT is working as expected."
            tims_dict = update_tims_data(tims_dict, 0, message, [test_id])

        except AssertionError as ae:
            message = str(ae)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        except Exception as e:
            message = str(e)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        finally:
            print "### STEP7. Cleanup the households and srt table. ###\n"
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)
            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content_reset)
            print message
            return tims_dict
예제 #2
0
def doit_wrapper(cfg, printflg=False):
    message = ""
    status = 3
    test_id = "TC10124"
    tims_dict = {test_id: ["US78110", message, status]}
    print "%s: BRB - Dual VMR - Redirect recording from HH with invalid VMR before " \
          "scheduling from invalid VMR to valid VMR" % (test_id)

    try:
        # announce
        # abspath = os.path.abspath(__file__)
        scriptName = os.path.basename(__file__)
        (test, ext) = os.path.splitext(scriptName)
        print "Starting test " + test

        if "no_brb" in cfg["test-flags"]:
            message = "Testcase Skipped: Skipping the testcase since no_brb flag is enabled."
            print message
            tims_dict = update_tims_data(tims_dict, 2, message, [test_id])
            return tims_dict

        # Initialize the Variables
        timeout = 2
        serviceIdlist = []

        # set values based on config
        cmdc_hosts = [cfg['cmdc']['host']]
        pps_hosts = [cfg['pps']['host']]
        upm_hosts = [cfg['upm']['host']]
        upm_port = cfg['upm']['port']
        cmdc_port = cfg['cmdc']['port']
        pps_port = cfg['pps']['port']
        catalogueId = cfg['catalogueId']
        protocol = cfg['protocol']
        region = cfg['region']

        ch1 = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "channels"][0]

        testchannel1 = cfg['test_channels'][ch1]['ServiceId']
        testchannel1_uuid = cfg['test_channels'][ch1]['UUID']

        serviceIdlist.append(unicode(testchannel1))

        prefix = cfg['basic_feature']['household_prefix']
        fetch_bookingcatalog_delay = cfg['pps']['fetch_bookingCatalog_delay']
        recordingstatecheck_timedelay = cfg['pps']['booked_to_recording_delay']
        householdid4 = prefix + '7'
        householdid_list = [householdid4]
        hostlist = list(itertools.product(cmdc_hosts, pps_hosts, upm_hosts))
        recording_delay = 180

        cmdcRegion = cfg['cmdcRegion']
        adZone = cfg['adZone']
        marketingTarget = cfg['marketingTarget']

        invalid_region = "Invalid"
        source_region = cfg["feature"]["brb"]["Recorderegions"]["v2pcVMR"][
            "name"]
        dest_region = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "name"]
        srt_content_reset = [[source_region, "*", source_region, "NoChange"]]
        common_copy = "COMMON"
        unique_copy = "UNIQUE"
        vmr = cfg["vmr"]["instances"]["v2pcVMR"]
        aws_vmr = cfg["vmr"]["instances"]["standaloneVMR"]
        print "VMR : ", vmr
        print "AWS_VMR :", aws_vmr
        region_index = 5

        srt_content = [[invalid_region, '*', dest_region, common_copy]]

        # Do PPS Booking
        pps_headers = {
            'Content-Type': 'application/json',
            'Source-Type': 'WEB',
            'Source-ID': '127.0.0.1',
        }

        # ##########################  USER DEFINED POST TIME IN UTC ############################
        start_delay = 3
        timeslotinminutes = cfg["test_channels"]["longProgramLength"]
        ingestion_time = get_utc_time_after_n_minutes(start_delay, True)
        start_time = datetime.datetime.strptime(ingestion_time,
                                                '%Y-%m-%dT%H:%M:%S')
        post_time = calendar.timegm(start_time.timetuple()) + 0.0001
        #######################################################################################

        print "### STEP1: Ingest an event on channel 1  with 5 minutes duration and 5 minutes " \
              "post time. ###\n"
        ci_host = cfg['ci']['host']
        ci_port = cfg['ci']['port']
        ingest_minimum_delay = cfg['ci']['ingest_minimum_delay']
        ingest_delay_factor_per_minute = cfg['ci'][
            'ingest_delay_factor_per_minute']

        eventtitle1 = "TC10124" + str(random.randint(1, 499))
        channel1 = ChannelLineup(BoundaryInMinutes=0)
        channel1.add_to_lineup(serviceId=testchannel1,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel1.postXmlData(ci_host, ci_port, startTime=post_time)
        channel1.writeXmlFiles(startTime=post_time)

        print "channel1 : ", channel1

        length = channel1.getTotalLength()
        sleep_channel = ingest_minimum_delay + length * ingest_delay_factor_per_minute

        print "Wait time for the catalog ingest to " \
              "get synced with the CI Host in seconds: " + str(sleep_channel)
        time.sleep(sleep_channel)

    except:
        message = "Testcase Failed: Error Occurred in Configuration " + PrintException(
            True)
        print message
        tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
        return tims_dict

    for (cmdc_host, pps_host, upm_host) in hostlist:
        try:
            # Create HH in Invalid recorder region
            print "### STEP2: Ensure an household present in the system pointing to invalid " \
                  "recording region. ###"

            for householdid in householdid_list:
                hh_headers = {
                    'Content-Type': 'application/json',
                    'Source-Type': 'WEB',
                    'Source-ID': '127.0.0.1',
                    'Accept': 'application/json'
                }
                hh_create_payload = """
                                        {
                                          "householdId" : "%s",
                                          "householdStatus" : "ACTIVATED",
                                          "operateStatus": "ACTIVE",
                                          "locale" : {
                                                "region" : "%s",
                                                "cmdcRegion":"%s",
                                                "adZone": "%s",
                                                    "marketingTarget": "%s",
                                                    "recorderRegion": "%s"
                                                     },
                                          "cDvrPvr": true
                                    }
                                    """ % (householdid, region, cmdcRegion,
                                           adZone, marketingTarget,
                                           invalid_region)

                print "Create HouseHold Payload :", hh_create_payload

                create_hh = create_household(protocol, upm_port, householdid,
                                             upm_host, hh_headers,
                                             hh_create_payload)
                assert create_hh, "Testcase Failed: Unable to create household %s " \
                                  "in RR %s" %(householdid, dest_region)

                setoffers = setCdvrSubscriptionOffers(cfg, householdid)
                assert setoffers, "Testcase Failed : Unable to set offers for %s" % householdid

            for household in householdid_list:
                hh_region = get_household_region(cfg, upm_host, household,
                                                 timeout)
                assert hh_region == invalid_region, "Testcase Fail : Household %s not in the " \
                                                   "invalid region %s" % (household, invalid_region)

            print "### STEP3 : Modify the SRT in such a way to record the contents from any " \
                  "channel and an hh pointing to an invalid region with Common copy type in " \
                  "RR2 recording region. ###\n"

            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content)

            # Cleaning up the household
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)

            gridservicelistresponse = fetch_gridRequest(
                catalogueId, protocol, cmdc_host, cmdc_port, [
                    unicode(testchannel1),
                ], region, timeout, printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(
                gridservicelistresponse, eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            content_ev1 = contentId_list[0][0]
            ev1_broadcast_start_time = contentId_list[0][1][0]

            print "### STEP4. Perform booking on the household for the ingested content.###\n"
            payload_ev1 = """{
                                "scheduleInstanceId" : "%s",
                                "checkConflicts" : true,
                                "pvr":"nPVR"
                                }""" % (content_ev1)

            for householdid in householdid_list:
                result = do_PPSbooking(pps_port, protocol, pps_host, householdid, \
                                       pps_headers, payload_ev1, content_ev1, timeout, printflg)
                if result != "PASS":
                    message = "Testcase Failed:Unable to do pps booking of content ID " \
                              + str(content_ev1) + " in household " + str(householdid)
                    print message
                    tims_dict = update_tims_data(tims_dict, 1, message,
                                                 [test_id])

            for householdid in householdid_list:
                catalogresult, catalogresponse = verify_booking(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                print "Booking response of Event 1:", catalogresult
                assert catalogresult == "PASS", "TestCase  Failed : Content ID " + str(content_ev1) \
                                                + " in household " + str(householdid) \
                                                + " is not in the BOOKED state"

            print "## STEP 5 Wait for the program to start its recording on the household. ###"
            broadcasting_starttime = get_timedifference(
                ev1_broadcast_start_time, printflg)
            recordingstatechage = recordingstatecheck_timedelay + broadcasting_starttime
            print "Script will wait for ", recordingstatechage," seconds to check the event " \
                                                               "recording state"
            time.sleep(recordingstatechage)

            for householdid in householdid_list:
                recrding_res1, recrding_resp1 = verify_recording_state(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                if recrding_res1 == "PASS":
                    message = "Testcase Failed: Content ID {0} in household {1} is in the " \
                              "RECORDING state with invalid VMR".format(content_ev1, householdid)
                    assert False, message

            print "### STEP 6. Confirm from VMR API response that recording is not happening. ###\n"
            cfg['vmr']['host'] = aws_vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list,
                                                       timeout)
            print "Playback URI list :", playbackuri_list
            assert not playbackuri_list, "Testcase Failed: Content is in Recording state " \
                                              "which is not as expected"

            cfg['vmr']['host'] = vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list,
                                                       timeout)
            print "Playback URI list :", playbackuri_list
            assert not playbackuri_list, "Testcase Failed: Content is in Recording state " \
                                                 "which is not as expected"

            message = "TestCase Passed : Recording is not happening with the HH created in " \
                      "Invalid Recorder region"
            tims_dict = update_tims_data(tims_dict, 0, message, [test_id])

        except AssertionError as ae:
            message = str(ae)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        except Exception as e:
            message = str(e)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        finally:
            print "### STEP7. Cleanup the households and srt table. ###\n"
            for householdid in householdid_list:
                delete_household(protocol, upm_port, householdid, upm_host)
            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content_reset)
            print message
            return tims_dict
예제 #3
0
def doit_wrapper(cfg, printflg=False):
    message = ""
    status = 3
    test_id = "TC10122"
    tims_dict = {test_id: ["US78110", message, status]}
    print "%s: BRB - Dual VMR - Redirect recording before scheduling from VMR1 to VMR2 based on " \
          "multiple channels and single channel with different copy type" % (test_id)

    try:
        # announce
        # abspath = os.path.abspath(__file__)
        scriptName = os.path.basename(__file__)
        (test, ext) = os.path.splitext(scriptName)
        print "Starting test " + test

        if "no_brb" in cfg["test-flags"]:
            message = "Testcase Skipped: Skipping the testcase since no_brb flag is enabled."
            print message
            tims_dict = update_tims_data(tims_dict, 2, message, [test_id])
            return tims_dict

        # Initialize the Variables
        timeout = 2
        serviceIdlist = []

        # set values based on config
        cmdc_hosts = [cfg['cmdc']['host']]
        pps_hosts = [cfg['pps']['host']]
        upm_hosts = [cfg['upm']['host']]
        upm_port = cfg['upm']['port']
        cmdc_port = cfg['cmdc']['port']
        pps_port = cfg['pps']['port']
        catalogueId = cfg['catalogueId']
        protocol = cfg['protocol']
        region = cfg['region']

        ch1 = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "channels"][0]
        ch2 = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "channels"][1]

        testchannel1 = cfg['test_channels'][ch1]['ServiceId']
        testchannel1_uuid = cfg['test_channels'][ch1]['UUID']
        testchannel2 = cfg['test_channels'][ch2]['ServiceId']

        serviceIdlist.append(unicode(testchannel1))
        serviceIdlist.append(unicode(testchannel2))

        prefix = cfg['basic_feature']['household_prefix']
        fetch_bookingcatalog_delay = cfg['pps']['fetch_bookingCatalog_delay']
        recordingstatecheck_timedelay = cfg['pps']['booked_to_recording_delay']
        householdid1 = prefix + '1'
        householdid2 = prefix + '2'
        householdid3 = prefix + '3'
        householdid4 = prefix + '4'
        householdid_list = [
            householdid1, householdid2, householdid3, householdid4
        ]
        hostlist = list(itertools.product(cmdc_hosts, pps_hosts, upm_hosts))
        recording_delay = 180

        cmdcRegion = cfg['cmdcRegion']
        adZone = cfg['adZone']
        marketingTarget = cfg['marketingTarget']

        source_region = cfg["feature"]["brb"]["Recorderegions"]["v2pcVMR"][
            "name"]
        dest_region = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "name"]
        srt_content_reset = [[source_region, "*", source_region, "NoChange"]]
        common_copy = "COMMON"
        unique_copy = "UNIQUE"
        vmr = cfg["vmr"]["instances"]["v2pcVMR"]
        aws_vmr = cfg["vmr"]["instances"]["standaloneVMR"]
        print "VMR : ", vmr
        print "AWS_VMR :", aws_vmr
        region_index = 5

        srt_content = [[
            source_region,
            str(testchannel1_uuid), dest_region, unique_copy
        ], [source_region, '*', dest_region, common_copy]]

        # Do PPS Booking
        pps_headers = {
            'Content-Type': 'application/json',
            'Source-Type': 'WEB',
            'Source-ID': '127.0.0.1',
        }

        # ##########################  USER DEFINED POST TIME IN UTC ############################
        start_delay = 5
        timeslotinminutes = cfg["test_channels"]["longProgramLength"]
        ingestion_time = get_utc_time_after_n_minutes(start_delay, True)
        start_time = datetime.datetime.strptime(ingestion_time,
                                                '%Y-%m-%dT%H:%M:%S')
        post_time = calendar.timegm(start_time.timetuple()) + 0.0001
        #######################################################################################

        print "### STEP1: Ingest an event on channel 1  with 5 minutes duration and 5 minutes " \
              "post time. ###\n"
        ci_host = cfg['ci']['host']
        ci_port = cfg['ci']['port']
        ingest_minimum_delay = cfg['ci']['ingest_minimum_delay']
        ingest_delay_factor_per_minute = cfg['ci'][
            'ingest_delay_factor_per_minute']

        eventtitle1 = "TC10122" + str(random.randint(1, 499))
        channel1 = ChannelLineup(BoundaryInMinutes=0)
        channel1.add_to_lineup(serviceId=testchannel1,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel1.postXmlData(ci_host, ci_port, startTime=post_time)
        channel1.writeXmlFiles(startTime=post_time)

        print "channel1 : ", channel1

        channel2 = ChannelLineup(BoundaryInMinutes=0)
        channel2.add_to_lineup(serviceId=testchannel2,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel2.postXmlData(ci_host, ci_port, startTime=post_time)
        channel2.writeXmlFiles(startTime=post_time)

        print "channel2 : ", channel2

        length = channel1.getTotalLength() + channel2.getTotalLength()
        sleep_channel = ingest_minimum_delay + length * ingest_delay_factor_per_minute

        print "Wait time for the catalog ingest to " \
              "get synced with the CI Host in seconds: " + str(sleep_channel)
        time.sleep(sleep_channel)

    except:
        message = "Testcase Failed: Error Occurred in Configuration " + PrintException(
            True)
        print message
        tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
        return tims_dict

    for (cmdc_host, pps_host, upm_host) in hostlist:
        try:

            print "### STEP2 : Ensure four household present in the system pointing to" \
                  " RR1 recording region. ###\n"
            for household in householdid_list:
                hh_region = get_household_region(cfg, upm_host, household,
                                                 timeout)
                assert hh_region == source_region, "Testcase Fail : Household %s not in the " \
                                                   "source region %s" % (household, source_region)

            print "### STEP3:  Modify the SRT in such a way, ###\n"
            print "### STEP 3.1. To record the contents of hh 1, hh2(RR1 region) and from " \
                  "channel 1 with Unique copy type in RR2 recording region. ###\n"
            print "### STEP 3.2. To record the contents of hh 3, hh4(RR1 region) and from " \
                  "all channels with common copy type in RR2 recording region.###\n"

            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content)

            # Cleaning up the household
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)

            gridservicelistresponse = fetch_gridRequest(
                catalogueId, protocol, cmdc_host, cmdc_port, [
                    unicode(testchannel1),
                ], region, timeout, printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(
                gridservicelistresponse, eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            content_ev1 = contentId_list[0][0]
            ev1_broadcast_start_time = contentId_list[0][1][0]

            gridservicelistresponse = fetch_gridRequest(
                catalogueId, protocol, cmdc_host, cmdc_port, [
                    unicode(testchannel2),
                ], region, timeout, printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(
                gridservicelistresponse, eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            content_ev2 = contentId_list[0][0]

            print "### STEP4. Perform booking on all four households for the ingested contents###\n"
            print "## STEP 4.1. Perform the booking on channel 1 on hh 1 & hh2.##"
            payload_ev1 = """{
                                "scheduleInstanceId" : "%s",
                                "checkConflicts" : true,
                                "pvr":"nPVR"
                                }""" % (content_ev1)

            for householdid in householdid_list[:2]:
                result = do_PPSbooking(pps_port, protocol, pps_host, householdid, \
                                       pps_headers, payload_ev1, content_ev1, timeout, printflg)
                if result != "PASS":
                    message = "Testcase Failed:Unable to do pps booking of content ID " \
                              + str(content_ev1) + " in household " + str(householdid)
                    print message
                    tims_dict = update_tims_data(tims_dict, 1, message,
                                                 [test_id])

            print "## STEP 4.2. Perform the booking on channel 2 on hh 3 & hh4.##"
            payload_ev2 = """{
                                "scheduleInstanceId" : "%s",
                                "checkConflicts" : true,
                                "pvr":"nPVR"
                                }""" % (content_ev2)

            for householdid in householdid_list[2:4]:
                result = do_PPSbooking(pps_port, protocol, pps_host, householdid, \
                                       pps_headers, payload_ev2, content_ev2, timeout, printflg)
                if result != "PASS":
                    message = "Testcase Failed:Unable to do pps booking of content ID " \
                              + str(content_ev1) + " in household " + str(householdid)
                    print message
                    tims_dict = update_tims_data(tims_dict, 1, message,
                                                 [test_id])

            time.sleep(fetch_bookingcatalog_delay)
            print "About to start the event 1 booking\n"
            # Getting Catalog Response for the Booked Catalog
            for householdid in householdid_list[:2]:
                catalogresult, catalogresponse = verify_booking(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                print "Booking response of Event 1:", catalogresult
                assert catalogresult == "PASS", "TestCase  Failed : Content ID " + str(content_ev1) \
                                                + " in household " + str(householdid) \
                                                + " is not in the BOOKED state"

            for householdid in householdid_list[2:4]:
                catalogresult, catalogresponse = verify_booking(
                    pps_port, protocol, pps_host, householdid, content_ev2,
                    timeout)
                print "Booking response of Event 2 :\n", catalogresult
                assert catalogresult == "PASS", "TestCase  Failed : Content ID " \
                                                + str(content_ev2) + " in household " \
                                                + str(householdid) + " is not in the BOOKED state"

            print "### STEP5.Wait for the program to start its recording on all four " \
                  "households.####\n"

            broadcasting_starttime = get_timedifference(
                ev1_broadcast_start_time, printflg)
            recordingstatechage = recordingstatecheck_timedelay + broadcasting_starttime
            print "Script will wait for ", recordingstatechage," seconds to check the event " \
                                                               "recording state"
            time.sleep(recordingstatechage)
            print "Waiting additional %s seconds to workaround the " \
                  "state change issue." % (recording_delay)
            time.sleep(recording_delay)

            for householdid in householdid_list[:2]:
                recrding_res1, recrding_resp1 = verify_recording_state(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                if recrding_res1 != "PASS":
                    message = "Testcase Failed: Content ID {0} in household {1} is " \
                              "not in the RECORDING state".format(content_ev1, householdid)
                    assert False, message

            for householdid in householdid_list[2:4]:
                recrding_res2, recrding_resp2 = verify_recording_state(
                    pps_port, protocol, pps_host, householdid, content_ev2,
                    timeout)
                if recrding_res2 != "PASS":
                    message = "Testcase Failed: Content ID {0} in household {1} is not in the " \
                              "RECORDING state".format(content_ev2, householdid)
                    assert False, message

            print "### STEP 6. Confirm from VMR API response that recorded contents are as per " \
                  "the rule set in SRT. ###\n"

            cfg['vmr']['host'] = aws_vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list[:2],
                                                       timeout)
            print "Playback URI list :", playbackuri_list
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            print "ContentId list :", contentidlist
            vmr_response_1 = get_vmr_response(cfg, contentidlist[0], timeout)
            vmr_response_2 = get_vmr_response(cfg, contentidlist[1], timeout)
            assert vmr_response_1 and vmr_response_1.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[0]
            assert vmr_response_2 and vmr_response_2.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[1]
            riodev_recording_hh1 = json.loads(vmr_response_1.content)[0]
            riodev_recording_hh2 = json.loads(vmr_response_2.content)[0]
            region_hh1 = riodev_recording_hh1['A8UpdateURL'].split(
                '/')[region_index]
            region_hh2 = riodev_recording_hh2['A8UpdateURL'].split(
                '/')[region_index]
            hh1_copy_type = riodev_recording_hh1["CopyType"]
            hh2_copy_type = riodev_recording_hh2["CopyType"]

            print "riodev_recording_hh1 : ", riodev_recording_hh1
            print "riodev_recording_hh2 : ", riodev_recording_hh2

            print "region_hh1 : ", region_hh1
            print "region_hh2 : ", region_hh2

            assert hh1_copy_type == hh2_copy_type == unique_copy, \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 1 & household 2." % (content_ev1, unique_copy)

            assert region_hh1 == region_hh2 == dest_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 1 & household 2." % (content_ev1, dest_region)

            print "## STEP6.2. Content from channel 2 booked on hh3 & hh4 with common copy " \
                  "type in RR2 recording region. ##"

            cfg['vmr']['host'] = aws_vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev2],
                                                       householdid_list[2:4],
                                                       timeout)
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            vmr_response_3 = get_vmr_response(cfg, contentidlist[0], timeout)
            vmr_response_4 = get_vmr_response(cfg, contentidlist[1], timeout)
            assert vmr_response_3 and vmr_response_3.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[0]
            assert vmr_response_4 and vmr_response_4.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[1]
            riodev_recording_hh3 = json.loads(vmr_response_3.content)[0]
            riodev_recording_hh4 = json.loads(vmr_response_4.content)[0]
            region_hh3 = riodev_recording_hh3['A8UpdateURL'].split(
                '/')[region_index]
            region_hh4 = riodev_recording_hh4['A8UpdateURL'].split(
                '/')[region_index]
            hh3_copy_type = riodev_recording_hh3["CopyType"]
            hh4_copy_type = riodev_recording_hh4["CopyType"]

            print "riodev_recording_hh3 : ", riodev_recording_hh3
            print "riodev_recording_hh4 : ", riodev_recording_hh4

            print "region_hh3 : ", region_hh3
            print "region_hh4 : ", region_hh4

            assert hh3_copy_type == hh4_copy_type == common_copy, \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 3." % (content_ev1, common_copy)

            assert region_hh3 == dest_region and region_hh4 == dest_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 3." % (content_ev1, dest_region)

            message = "TestCase Passed : SRT is working as expected."
            tims_dict = update_tims_data(tims_dict, 0, message, [test_id])

        except AssertionError as ae:
            message = str(ae)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        except Exception as e:
            message = str(e)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        finally:
            print "### STEP7. Cleanup the households and srt table. ###\n"
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)
            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content_reset)
            print message
            return tims_dict
예제 #4
0
def doit_wrapper(cfg, printflg=False):
    message = ""
    status = 3
    test_id = "TC10141"
    tims_dict = {test_id: ["US78110", message, status]}
    print "%s: BRB - Dual VMR - Redirect recording before scheduling from a VMR to another VMR " \
          "for a single channel in Common copy mode and playback the recording once done" % (test_id)

    try:
        # announce
        abspath = os.path.abspath(__file__)
        scriptName = os.path.basename(__file__)
        (test, ext) = os.path.splitext(scriptName)
        print "Starting test " + test

        if "no_brb" in cfg["test-flags"]:
            message = "Testcase Skipped: Skipping the testcases since no_brb flag is enabled."
            print message
            tims_dict = update_tims_data(tims_dict, 2, message, [test_id])
            return tims_dict

        # Initialize the Variables
        timeout = 2
        serviceIdlist = []

        # set values based on config
        cmdc_hosts = [cfg['cmdc']['host']]
        pps_hosts = [cfg['pps']['host']]
        upm_hosts = [cfg['upm']['host']]
        cmdc_port = cfg['cmdc']['port']
        pps_port = cfg['pps']['port']
        catalogueId = cfg['catalogueId']
        protocol = cfg['protocol']
        region = cfg['region']

        # Playback config
        prmsupportedflag = cfg['prm_supported']
        proxyhostcheckflag = cfg['proxyHostNeeded']
        proxy_host = cfg['proxyhost']['host']
        proxy_port = cfg['proxyhost']['port']
        contentplayback_host = cfg['contentplayback']['host']
        contentplayback_host_aws = "cdvrDash.mpe-58a1293c2e83f6b7.elb.us-east-1.amazonaws.com"
        contentplayback_port = cfg['contentplayback']['port']
        contentplayback_url = cfg['contentplayback']['url']
        contentplayback_url_aws = "/cdvrDash-cisc/"
        rm_host = cfg['rm']['host']

        # Handle if the there are less channels than the threshold.
        threshold_channels = 17
        channelfilter1 = []
        for channels in cfg['test_channels'].keys():
            if channels.startswith("GenericCh"):
                channelfilter1.append(channels)
        if len(channelfilter1) < threshold_channels:
            message = "Skipping this TC since number of channels are less than 17."
            print message
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
            return tims_dict

        ch1 = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "channels"][0]
        ch2 = cfg["feature"]["brb"]["Recorderegions"]["v2pcVMR"]["channels"][0]

        testchannel1 = cfg['test_channels'][ch1]['ServiceId']
        testchannel1_uuid = cfg['test_channels'][ch1]['UUID']
        testchannel2 = cfg['test_channels'][ch2]['ServiceId']

        serviceIdlist.append(unicode(testchannel1))
        serviceIdlist.append(unicode(testchannel2))

        prefix = cfg['basic_feature']['household_prefix']
        fetch_booking_delay = cfg['pps']['fetch_bookingCatalog_delay']
        recording_state_delay = cfg['pps']['booked_to_recording_delay']
        recording_to_recorded_delay = cfg['pps']['recording_to_recorded_delay']
        householdid1 = prefix + '1'
        householdid2 = prefix + '2'
        householdid3 = prefix + '3'
        householdid4 = prefix + '4'
        householdid_list = [
            householdid1, householdid2, householdid3, householdid4
        ]
        hostlist = list(itertools.product(cmdc_hosts, pps_hosts, upm_hosts))
        recording_delay = 60

        source_region = cfg["feature"]["brb"]["Recorderegions"]["v2pcVMR"][
            "name"]
        dest_region = cfg["feature"]["brb"]["Recorderegions"]["standaloneVMR"][
            "name"]
        srt_content_reset = [[source_region, "*", source_region, "NoChange"]]
        common_copy = "COMMON"
        unique_copy = "UNIQUE"
        vmr = cfg["vmr"]["instances"]["v2pcVMR"]
        aws_vmr = cfg["vmr"]["instances"]["standaloneVMR"]
        print "VMR : ", vmr
        print "AWS_VMR :", aws_vmr
        region_index = 5

        srt_content = [[
            source_region,
            str(testchannel1_uuid), dest_region, common_copy
        ]]

        # Do PPS Booking
        pps_headers = {
            'Content-Type': 'application/json',
            'Source-Type': 'WEB',
            'Source-ID': '127.0.0.1',
        }

        # ##########################  USER DEFINED POST TIME IN UTC ###########################
        start_delay = 5
        timeslotinminutes = cfg["test_channels"]["longProgramLength"]
        ingestion_time = get_utc_time_after_n_minutes(start_delay, True)
        start_time = datetime.datetime.strptime(ingestion_time,
                                                '%Y-%m-%dT%H:%M:%S')
        post_time = calendar.timegm(start_time.timetuple()) + 0.0001
        #######################################################################################

        print "### STEP1: Ingest an event on channel 1 & channel 2 with 5 minutes duration and " \
              "5 minues post time. ##### \n \n"
        ci_host = cfg['ci']['host']
        ci_port = cfg['ci']['port']
        ingest_minimum_delay = cfg['ci']['ingest_minimum_delay']
        ingest_delay_factor_per_minute = cfg['ci'][
            'ingest_delay_factor_per_minute']

        eventtitle1 = "TC10141" + str(random.randint(1, 499))

        channel1 = ChannelLineup(BoundaryInMinutes=0)
        channel1.add_to_lineup(serviceId=testchannel1,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel1.postXmlData(ci_host, ci_port, startTime=post_time)
        channel1.writeXmlFiles(startTime=post_time)

        print "channel1 : ", channel1

        channel2 = ChannelLineup(BoundaryInMinutes=0)
        channel2.add_to_lineup(serviceId=testchannel2,
                               timeSlotLengthMinutes=timeslotinminutes,
                               timeSlotCount=1,
                               programIDPrefix=eventtitle1)
        channel2.postXmlData(ci_host, ci_port, startTime=post_time)
        channel2.writeXmlFiles(startTime=post_time)

        print "channel2 : ", channel2

        length = channel1.getTotalLength() + channel2.getTotalLength()
        sleep_channel = ingest_minimum_delay + length * ingest_delay_factor_per_minute

        print "Wait time for the catalog ingest to " \
              "get synced with the CI Host in seconds: " + str(sleep_channel)
        time.sleep(sleep_channel)

    except:
        message = "Testcase Failed: Error Occurred in Configuration " + PrintException(
            True)
        print message
        tims_dict = update_tims_data(tims_dict, 1, message, [test_id])
        return tims_dict

    for (cmdc_host, pps_host, upm_host) in hostlist:
        try:
            print "### STEP2 :  Ensure four household present in the system pointing to RR1 " \
                  "recording region. ###\n"
            for household in householdid_list:
                hh_region = get_household_region(cfg, upm_host, household,
                                                 timeout)
                assert hh_region == source_region, "Testcase Fail : Household %s not in the " \
                                                   "source region %s" % (household, source_region)

            print "### STEP3: Modify the SRT in such a way to record the contents from channel 1 " \
                  "with common copy type in RR2 recording region. ###\n"
            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content)

            # Cleaning up the household
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host,
                                  householdid, pps_headers, timeout)

            gridservicelistresponse = fetch_gridRequest(
                catalogueId, protocol, cmdc_host, cmdc_port, [
                    unicode(testchannel1),
                ], region, timeout, printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(
                gridservicelistresponse, eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            content_ev1 = contentId_list[0][0]
            broadcast_starttime = contentId_list[0][1][0]
            broadcast_endtime = contentId_list[0][1][1]

            gridservicelistresponse = fetch_gridRequest(
                catalogueId, protocol, cmdc_host, cmdc_port, [
                    unicode(testchannel2),
                ], region, timeout, printflg)
            assert gridservicelistresponse, "Testcase Failed: Unable to Fetch Grid Response"

            contentId_dict_all = get_contentIddict_bytitle(
                gridservicelistresponse, eventtitle1, ['title'])
            print "ContentID dictionary from the Grid Response\n" + str(
                contentId_dict_all)
            assert contentId_dict_all, "Testcase Failed: Unable " \
                                       "to Form ContentId dictionary from the Grid Response"

            contentId_list = sorted(contentId_dict_all.items(),
                                    key=lambda x: x[1])
            print "ContentId list after Sorting\n" + str(contentId_list)
            assert (len(contentId_list) > 0), "Testcase Failed: Unable " \
                                              "to form ContentId list from ContentId dictionary"
            print "len(contentId_list) : ", len(contentId_list)

            content_ev2 = contentId_list[0][0]

            print "###STEP4: Perform booking on all four households for the ingested contents.###\n"
            print "## STEP 4.1. Perform the booking on channel 1 on hh 1 & hh2. ##"
            payload_ev1 = """{
                            "scheduleInstanceId" : "%s",
                            "checkConflicts" : true,
                            "pvr":"nPVR"
                            }""" % (content_ev1)

            for householdid in householdid_list[:2]:
                result = do_PPSbooking(pps_port, protocol, pps_host, householdid, \
                                       pps_headers, payload_ev1, content_ev1, timeout, printflg)
                if result != "PASS":
                    message = "Testcase Failed:Unable to do pps booking of content ID " \
                              + str(content_ev1) + " in household " + str(householdid)
                    print message
                    tims_dict = update_tims_data(tims_dict, 1, message,
                                                 [test_id])

            print "## STEP 4.2. Perform the booking on channel 2 on hh 3 & hh4. ##"
            payload_ev2 = """{
                            "scheduleInstanceId" : "%s",
                            "checkConflicts" : true,
                            "pvr":"nPVR"
                            }""" % (content_ev2)

            for householdid in householdid_list[2:4]:
                result = do_PPSbooking(pps_port, protocol, pps_host, householdid, \
                                       pps_headers, payload_ev2, content_ev2, timeout, printflg)
                if result != "PASS":
                    message = "Testcase Failed:Unable to do pps booking of content ID " \
                              + str(content_ev2) + " in household " + str(householdid)
                    print message
                    tims_dict = update_tims_data(tims_dict, 1, message,
                                                 [test_id])

            time.sleep(fetch_booking_delay)
            print "About to start the event 1 booking\n"
            # Getting Catalog Response for the Booked Catalog
            for householdid in householdid_list[:2]:
                catalogresult, catalogresponse = verify_booking(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                print "Booking response of Event 1:", catalogresult
                assert catalogresult == "PASS", "TestCase  Failed : Content ID " + str(content_ev1) \
                                                + " in household " + str(householdid) + \
                                                " is not in the BOOKED state"

            for householdid in householdid_list[2:4]:
                catalogresult, catalogresponse = verify_booking(
                    pps_port, protocol, pps_host, householdid, content_ev2,
                    timeout)
                print "Booking response of Event 2 :\n", catalogresult
                assert catalogresult == "PASS", "TestCase  Failed : Content ID " \
                                                + str(content_ev2) + " in household " + \
                                                str(householdid) + " is not in the BOOKED state"

            print "### STEP5. Wait for the program to start its recording on all four " \
                  "households.####\n"
            broadcast_starttime = get_timedifference(broadcast_starttime,
                                                     printflg)
            recordingstatechage = recording_state_delay + broadcast_starttime
            print "Script will wait for " + str(recordingstatechage / 60) \
                  + " minutes to check the event recording state"
            time.sleep(recordingstatechage)
            print "Waiting additional %s seconds to workaround the " \
                  "state change issue." % (recording_delay)
            time.sleep(recording_delay)

            for householdid in householdid_list[:2]:
                recrding_res1, recrding_resp1 = verify_recording_state(
                    pps_port, protocol, pps_host, householdid, content_ev1,
                    timeout)
                if recrding_res1 != "PASS":
                    message = "Testcase Failed: Content ID {0} in household {1} is " \
                              "not in the RECORDING state".format(content_ev1, householdid)
                    assert False, message

            for householdid in householdid_list[2:4]:
                recrding_res2, recrding_resp2 = verify_recording_state(
                    pps_port, protocol, pps_host, householdid, content_ev2,
                    timeout)
                if recrding_res2 != "PASS":
                    message = "Testcase Failed: Content ID {0} in household {1} is not in the " \
                              "RECORDING state".format(content_ev2, householdid)
                    assert False, message

            print "### STEP6. Confirm from VMR API response that recorded contents. ###\n"

            print "## STEP6.1. Content from channel 1 recorded on hh1 & hh2 with common copy " \
                  "type in RR2 recording region. ##"
            cfg['vmr']['host'] = aws_vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev1],
                                                       householdid_list[:2],
                                                       timeout)
            print "Playback URI list :", playbackuri_list
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            print "ContentId list :", contentidlist
            vmr_response_1 = get_vmr_response(cfg, contentidlist[0], timeout)
            vmr_response_2 = get_vmr_response(cfg, contentidlist[1], timeout)
            assert vmr_response_1 and vmr_response_1.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[0]
            assert vmr_response_2 and vmr_response_2.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[1]
            riodev_recording_hh1 = json.loads(vmr_response_1.content)[0]
            riodev_recording_hh2 = json.loads(vmr_response_2.content)[0]
            region_hh1 = riodev_recording_hh1['A8UpdateURL'].split(
                '/')[region_index]
            region_hh2 = riodev_recording_hh2['A8UpdateURL'].split(
                '/')[region_index]
            copy_type_hh1 = riodev_recording_hh1["CopyType"]
            copy_type_hh2 = riodev_recording_hh2["CopyType"]

            print "riodev_recording_hh1 : ", riodev_recording_hh1
            print "riodev_recording_hh2 : ", riodev_recording_hh2

            print "region_hh1 : ", region_hh1
            print "region_hh2 : ", region_hh2
            assert copy_type_hh1 == copy_type_hh2 == common_copy , \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 1 and 2." % (content_ev1, common_copy)

            assert region_hh1 == region_hh2 == dest_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 1 & household 2." % (content_ev1, dest_region)

            print "## STEP6.2. Content from channel 2 recorded on hh3 & hh4 with default " \
                  "copy type in RR1 recording region.##"

            cfg['vmr']['host'] = vmr
            playbackuri_list = get_content_playbackURI(pps_host, pps_port,
                                                       protocol, [content_ev2],
                                                       householdid_list[2:4],
                                                       timeout)
            contentidlist = get_contentid_from_recid(cfg, playbackuri_list,
                                                     timeout)
            vmr_response_1 = get_vmr_response(cfg, contentidlist[0], timeout)
            vmr_response_2 = get_vmr_response(cfg, contentidlist[1], timeout)
            assert vmr_response_1 and vmr_response_1.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[0]
            assert vmr_response_2 and vmr_response_2.content != 'null', \
                "Testcase Failed : Unable to get the VMR response for contentId " \
                "%s" % contentidlist[1]
            riodev_recording_hh3 = json.loads(vmr_response_1.content)[0]
            riodev_recording_hh4 = json.loads(vmr_response_2.content)[0]
            region_hh3 = riodev_recording_hh3['A8UpdateURL'].split(
                '/')[region_index]
            region_hh4 = riodev_recording_hh4['A8UpdateURL'].split(
                '/')[region_index]
            copy_type_hh3 = riodev_recording_hh3["CopyType"]
            copy_type_hh4 = riodev_recording_hh4["CopyType"]

            print "riodev_recording_hh3 : ", riodev_recording_hh3
            print "riodev_recording_hh4 : ", riodev_recording_hh4

            print "region_hh3 : ", region_hh3
            print "region_hh4 : ", region_hh4

            assert copy_type_hh3 == copy_type_hh4 == unique_copy, \
                "Testcase Failed: Content %s are not in expected copy " \
                "type %s in household 3 and 4." % (content_ev2, unique_copy)

            assert region_hh3 == region_hh4 == source_region, \
                "Testcase Failed: Content %s are not in expected region " \
                " %s in household 3 and 4." % (content_ev2, source_region)

            print "### STEP7: Wait for the content to move to recorded state and confirm " \
                  "playback happening on all households. ###\n"

            broadcast_endtime = get_timedifference(broadcast_endtime, printflg)
            recordedstatechage = recording_to_recorded_delay + broadcast_endtime
            print "Script will wait for " + str(recordedstatechage / 60) \
                  + " minutes to check the event recorded state"
            time.sleep(recordedstatechage)

            playback_event1_dict = {}
            # Verify Recorded State
            for household in householdid_list[:2]:
                recorded_res, recorded_response = verify_recorded_state(
                    pps_port, protocol, pps_host, household, [content_ev1],
                    timeout)
                assert recorded_res == "PASS", "Testcase Failed: " + recorded_response
                print "Event 1 Recorded in HH :", household
                recordedcatalogcontent = json.loads(recorded_response.content)
                for items in recordedcatalogcontent:
                    if items['scheduleInstance'] == content_ev1:
                        if items['state'] == "RECORDED":
                            contentplayuri = items['contentPlayUri']
                            recordedtitle = items['title']
                            playback_event1_dict[household] = [
                                contentplayuri, recordedtitle
                            ]
            print "Playback Content Details of Event 1:", playback_event1_dict

            playback_event2_dict = {}
            for household in householdid_list[2:4]:
                recorded_res, recorded_response = verify_recorded_state(
                    pps_port, protocol, pps_host, household, [content_ev2],
                    timeout)
                assert recorded_res == "PASS", "Testcase Failed: " + recorded_response
                print "Event 2 Recorded in HH :", household
                recordedcatalogcontent = json.loads(recorded_response.content)
                for items in recordedcatalogcontent:
                    if items['scheduleInstance'] == content_ev2:
                        if items['state'] == "RECORDED":
                            contentplayuri = items['contentPlayUri']
                            recordedtitle = items['title']
                            playback_event2_dict[household] = [
                                contentplayuri, recordedtitle
                            ]

            print "Playback Content Details of Event 2:", playback_event2_dict
            print "All the programs are in RECORDED state"
            print "\nStart Playback verification from AWS recorder region:\n"
            for hhid, val in playback_event1_dict.items():
                print "Playback for HH : %s" % hhid
                playback_rslt, playback_msg = playback_recordedevent(
                    cfg,
                    abspath,
                    test,
                    pps_headers,
                    pps_port,
                    pps_host,
                    prmsupportedflag,
                    proxyhostcheckflag,
                    protocol,
                    rm_host,
                    contentplayback_host_aws,
                    contentplayback_port,
                    proxy_host,
                    proxy_port,
                    contentplayback_url_aws,
                    val[0],
                    val[1],
                    hhid,
                    timeout,
                    printflg,
                    cleanuphousehold=False)
                assert playback_rslt == "PASS", "Testcase Failed" + playback_msg
                # print playback_msg

            print "\nStart Playback verification from OnPrem recorder region:\n"
            for hhid, val in playback_event2_dict.items():
                print "Playback for HH : %s" % hhid
                playback_rslt, playback_msg = playback_recordedevent(
                    cfg,
                    abspath,
                    test,
                    pps_headers,
                    pps_port,
                    pps_host,
                    prmsupportedflag,
                    proxyhostcheckflag,
                    protocol,
                    rm_host,
                    contentplayback_host,
                    contentplayback_port,
                    proxy_host,
                    proxy_port,
                    contentplayback_url,
                    val[0],
                    val[1],
                    hhid,
                    timeout,
                    printflg,
                    cleanuphousehold=False)
                assert playback_rslt == "PASS", "Testcase Failed" + playback_msg
                # print playback_msg

            message = "TestCase Passed : Program recorded in VMR 2 and played back successfully"
            tims_dict = update_tims_data(tims_dict, 0, message, [test_id])

        except AssertionError as ae:
            message = str(ae)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        except Exception as e:
            message = str(e)
            tims_dict = update_tims_data(tims_dict, 1, message, [test_id])

        finally:
            print "### STEP8. Cleanup the households and srt table. ###\n"
            for householdid in householdid_list:
                cleanup_household(cfg, pps_port, protocol, pps_host, \
                                  householdid, pps_headers, timeout)
            configureSRT_instance = ConfigureSRT()
            configureSRT_instance.modify_srt(cfg, srt_content_reset)
            print message
            return tims_dict