示例#1
0
 def check_from_s3(key):
     video = get_from_s3(key)
     if video:
         logger.info("Video is in s3.")
         return "Video is in s3"
     else:
         logger.info("Video is not in s3.")
         return "Video is not in s3"
示例#2
0
 def check_from_s3(key):
     video = get_from_s3(key)
     if video:
         logger.info("Video is in s3.")
         return 'Video is in s3'
     else:
         logger.info("Video is not in s3.")
         return 'Video is not in s3'
示例#3
0
            total_mins = total_seconds / 60.0
            logger.info("Total minutes: %s" % total_mins)
        else:
            raise AssertionError("File did not download properly")
        self.assertTrue(Decimal(str(total_mins)) >= Decimal(str(LONG_VIDEO_LENGTH)))
        logger.info("Long video duration check passed.")

        """
        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(Decimal(str(video_status.encode_duration)) - Decimal(str(LONG_VIDEO_ENCODING)))
        percent_error = (duration_difference / LONG_VIDEO_ENCODING) * 100
        self.assertTrue(percent_error < 30.0)
        logger.info("Long video encoding time check passed.")
        """

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - LONG_VIDEO_SIZE)
        percent_error = (size_difference / LONG_VIDEO_SIZE) * 100
        logger.info("Percent error: %s" % percent_error)
        self.assertTrue(percent_error <= 10.0)
        logger.info("Long video encoded size check passed.")

        # Get video
        slug = "SHORTENCODE"
        title = "Encode Test B"
        description = "2-minute video with no audio"
        video = Video(title=title, slug=slug, uploader=uploader, description=description)
        video.save()
        logger.info("Video slug: %s" % slug)
        slug_tmp = slug + "_tmp"
def check_from_s3(key):
    video = get_from_s3(key)
    if video:
        print("Video is in s3.")
    else:
        print("Video is not in s3.")
示例#5
0
    def handle_noargs(self, **options):
        short_video_size_passed = False
        short_video_duration_passed = False
        short_video_encode_time_passed = False

        long_video_size_passed = False
        long_video_duration_passed = False
        long_video_encode_time_passed = False

        #check if rabbitmq is working
        try:
            connection = pika.BlockingConnection(
                pika.ConnectionParameters(settings.RABBITMQ_SERVER))
        except:
            logger.critical(
                "We are experiencing a connection problem and cannot perform uploads for now. Please try again later."
            )

        # Get uploader
        uploader, created = User.objects.get_or_create(username='******')

        # Get video
        slug = reserve_slug(SLUG_LENGTH)
        title = "Encode Test A"
        description = "5-minute video with audio"
        video = Video(title=title,
                      slug=slug,
                      uploader=uploader,
                      description=description)
        video.save()
        print("Video slug: %s" % slug)
        slug_tmp = slug + '_tmp'

        print("Uploading file to s3...")
        upload_to_s3(slug_tmp, LONG_VIDEO)
        print("Upload process successful.")

        print("Enqueuing slug to rabbitmq...")
        enqueue(slug_tmp)
        print("Enqueue process successful.")

        # Mark reserved slug as used
        try:
            reserved_slug = ReservedSlug.objects.get(slug=slug)
        except:
            pass
        else:
            reserved_slug.used = True
            reserved_slug.save()

        while not is_encoded(slug):
            time.sleep(3)

        print("Encoded!")

        # Checks
        video = Video.objects.get(slug=slug)
        video_duration = video.video_duration
        if Decimal(str(video_duration)) != Decimal(str(LONG_VIDEO_LENGTH)):
            print("Long video duration check failed.")
            print("%s vs %s" % (video_duration, LONG_VIDEO_LENGTH))
        else:
            print("Long video duration check passed.")
            long_video_duration_passed = True

        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(
            Decimal(str(video_status.encode_duration)) -
            Decimal(str(LONG_VIDEO_ENCODING)))
        percent_error = (duration_difference / LONG_VIDEO_ENCODING) * 100
        if percent_error > 30.0:
            print("Long video encoding time check failed.")
        else:
            print("Long video encoding time check passed.")
            long_video_encode_time_passed = True
        print("Percent error: %s" % percent_error)

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - LONG_VIDEO_SIZE)
        percent_error = (size_difference / LONG_VIDEO_SIZE) * 100
        if percent_error > 5.0:
            print("Long video encoded size check failed.")
        else:
            print("Long video encoded size check passed.")
            long_video_size_passed = True
        print("Percent error: %s" % percent_error)

        # Get video
        slug = reserve_slug(SLUG_LENGTH)
        title = "Encode Test B"
        description = "2-minute video with no audio"
        video = Video(title=title,
                      slug=slug,
                      uploader=uploader,
                      description=description)
        video.save()
        print("Video slug: %s" % slug)
        slug_tmp = slug + '_tmp'

        print("Uploading file to s3...")
        upload_to_s3(slug_tmp, SHORT_VIDEO)
        print("Upload process successful.")

        print("Enqueuing slug to rabbitmq...")
        enqueue(slug_tmp)
        print("Enqueue process successful.")

        # Mark reserved slug as used
        try:
            reserved_slug = ReservedSlug.objects.get(slug=slug)
        except:
            pass
        else:
            reserved_slug.used = True
            reserved_slug.save()

        while not is_encoded(slug):
            time.sleep(3)

        print("Encoded!")

        # Checks
        video = Video.objects.get(slug=slug)
        video_duration = video.video_duration
        if Decimal(str(video_duration)) != Decimal(str(SHORT_VIDEO_LENGTH)):
            print("Short video duration check failed.")
            print("%s vs %s" % (video_duration, SHORT_VIDEO_LENGTH))
        else:
            print("Short video duration check passed.")
            short_video_duration_passed = True

        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(
            Decimal(str(video_status.encode_duration)) -
            Decimal(str(SHORT_VIDEO_ENCODING)))
        percent_error = (duration_difference / SHORT_VIDEO_ENCODING) * 100
        if percent_error > 30.0:
            print("Short video encoding time check failed.")
        else:
            print("Short video encoding time check passed.")
            short_video_encode_time_passed = True
        print("Percent error: %s" % percent_error)

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - SHORT_VIDEO_SIZE)
        percent_error = (size_difference / SHORT_VIDEO_SIZE) * 100
        if percent_error > 5.0:
            print("Short video encoded size check failed.")
        else:
            print("Short video encoded size check passed.")
            short_video_size_passed = True
        print("Percent error: %s" % percent_error)

        if not ((long_video_duration_passed and long_video_encode_time_passed
                 and long_video_size_passed) and
                (short_video_duration_passed and short_video_encode_time_passed
                 and short_video_size_passed)):
            print("Encoding tests failed!")
            message = \
"""
5-minute video with audio
    Video time check passed: %s
    Video encoding time check passed: %s
    Video size check passed: %s

2-minute video with audio
    Video time check passed: %s
    Video encoding time check passed: %s
    Video size check passed: %s
""" % (long_video_duration_passed, long_video_encode_time_passed, long_video_size_passed, short_video_duration_passed, short_video_encode_time_passed, short_video_size_passed)

            email = EmailMessage(
                subject="Encoding tests failed",
                body=message,
                from_email="*****@*****.**",
                # to = ["*****@*****.**" % settings.ASSEMBLA_SPACE,],
                to=[
                    "*****@*****.**",
                ])
        else:
            print("Encoding tests passed!")
示例#6
0
            total_mins = total_seconds / 60.0
            logger.info("Total minutes: %s" % total_mins)
        else:
            raise AssertionError("File did not download properly")
        self.assertTrue(
            Decimal(str(total_mins)) >= Decimal(str(LONG_VIDEO_LENGTH)))
        logger.info("Long video duration check passed.")
        """
        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(Decimal(str(video_status.encode_duration)) - Decimal(str(LONG_VIDEO_ENCODING)))
        percent_error = (duration_difference / LONG_VIDEO_ENCODING) * 100
        self.assertTrue(percent_error < 30.0)
        logger.info("Long video encoding time check passed.")
        """

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - LONG_VIDEO_SIZE)
        percent_error = (size_difference / LONG_VIDEO_SIZE) * 100
        logger.info("Percent error: %s" % percent_error)
        self.assertTrue(percent_error <= 10.0)
        logger.info("Long video encoded size check passed.")

        # Get video
        slug = 'SHORTENCODE'
        title = "Encode Test B"
        description = "2-minute video with no audio"
        video = Video(title=title,
                      slug=slug,
                      uploader=uploader,
                      description=description)
        video.save()
示例#7
0
    def handle_noargs(self, **options):
        short_video_size_passed = False
        short_video_duration_passed = False
        short_video_encode_time_passed = False

        long_video_size_passed = False
        long_video_duration_passed = False
        long_video_encode_time_passed = False

        #check if rabbitmq is working
        try:
            connection = pika.BlockingConnection(pika.ConnectionParameters(settings.RABBITMQ_SERVER))
        except:
            logger.critical("We are experiencing a connection problem and cannot perform uploads for now. Please try again later.")

        # Get uploader
        uploader, created = User.objects.get_or_create(username='******')

        # Get video
        slug = reserve_slug(SLUG_LENGTH)
        title = "Encode Test A"
        description = "5-minute video with audio"
        video = Video(title=title, slug=slug, uploader=uploader, description=description)
        video.save()
        print ("Video slug: %s" % slug)
        slug_tmp = slug + '_tmp'

        print ("Uploading file to s3...")
        upload_to_s3(slug_tmp, LONG_VIDEO)
        print ("Upload process successful.")
        
        print ("Enqueuing slug to rabbitmq...")
        enqueue(slug_tmp)
        print ("Enqueue process successful.")

        # Mark reserved slug as used
        try:
            reserved_slug = ReservedSlug.objects.get(slug=slug)
        except:
            pass
        else:
            reserved_slug.used = True
            reserved_slug.save()

        while not is_encoded(slug):
            time.sleep(3)

        print ("Encoded!")

        # Checks
        video = Video.objects.get(slug=slug)
        video_duration = video.video_duration
        if Decimal(str(video_duration)) != Decimal(str(LONG_VIDEO_LENGTH)):
            print ("Long video duration check failed.")
            print ("%s vs %s" % (video_duration, LONG_VIDEO_LENGTH))
        else:
            print ("Long video duration check passed.")
            long_video_duration_passed = True

        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(Decimal(str(video_status.encode_duration)) - Decimal(str(LONG_VIDEO_ENCODING)))
        percent_error = (duration_difference / LONG_VIDEO_ENCODING) * 100
        if percent_error > 30.0:
            print ("Long video encoding time check failed.")
        else:
            print ("Long video encoding time check passed.")
            long_video_encode_time_passed = True
        print ("Percent error: %s" % percent_error)

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - LONG_VIDEO_SIZE)
        percent_error = (size_difference / LONG_VIDEO_SIZE) * 100
        if percent_error > 5.0:
            print ("Long video encoded size check failed.")
        else:
            print ("Long video encoded size check passed.")
            long_video_size_passed = True
        print ("Percent error: %s" % percent_error)

        # Get video
        slug = reserve_slug(SLUG_LENGTH)
        title = "Encode Test B"
        description = "2-minute video with no audio"
        video = Video(title=title, slug=slug, uploader=uploader, description=description)
        video.save()
        print ("Video slug: %s" % slug)
        slug_tmp = slug + '_tmp'

        print ("Uploading file to s3...")
        upload_to_s3(slug_tmp, SHORT_VIDEO)
        print ("Upload process successful.")
        
        print ("Enqueuing slug to rabbitmq...")
        enqueue(slug_tmp)
        print ("Enqueue process successful.")

        # Mark reserved slug as used
        try:
            reserved_slug = ReservedSlug.objects.get(slug=slug)
        except:
            pass
        else:
            reserved_slug.used = True
            reserved_slug.save()

        while not is_encoded(slug):
            time.sleep(3)

        print ("Encoded!")

        # Checks
        video = Video.objects.get(slug=slug)
        video_duration = video.video_duration
        if Decimal(str(video_duration)) != Decimal(str(SHORT_VIDEO_LENGTH)):
            print ("Short video duration check failed.")
            print ("%s vs %s" % (video_duration, SHORT_VIDEO_LENGTH))
        else:
            print ("Short video duration check passed.")
            short_video_duration_passed = True

        video_status = VideoStatus.objects.get(video_slug=slug)
        duration_difference = math.fabs(Decimal(str(video_status.encode_duration)) - Decimal(str(SHORT_VIDEO_ENCODING)))
        percent_error = (duration_difference / SHORT_VIDEO_ENCODING) * 100
        if percent_error > 30.0:
            print ("Short video encoding time check failed.")
        else:
            print ("Short video encoding time check passed.")
            short_video_encode_time_passed = True
        print ("Percent error: %s" % percent_error)

        video_file_len = len(get_from_s3(slug))
        size_difference = math.fabs(video_file_len - SHORT_VIDEO_SIZE)
        percent_error = (size_difference / SHORT_VIDEO_SIZE) * 100
        if percent_error > 5.0:
            print ("Short video encoded size check failed.")
        else:
            print ("Short video encoded size check passed.")
            short_video_size_passed = True
        print ("Percent error: %s" % percent_error)

        if not ((long_video_duration_passed and long_video_encode_time_passed and long_video_size_passed) and (short_video_duration_passed and short_video_encode_time_passed and short_video_size_passed)):
            print ("Encoding tests failed!")
            message = \
"""
5-minute video with audio
    Video time check passed: %s
    Video encoding time check passed: %s
    Video size check passed: %s

2-minute video with audio
    Video time check passed: %s
    Video encoding time check passed: %s
    Video size check passed: %s
""" % (long_video_duration_passed, long_video_encode_time_passed, long_video_size_passed, short_video_duration_passed, short_video_encode_time_passed, short_video_size_passed)

            email = EmailMessage(
                subject = "Encoding tests failed",
                body = message,
                from_email = "*****@*****.**",
                # to = ["*****@*****.**" % settings.ASSEMBLA_SPACE,],
                to = ["*****@*****.**",]
            )
        else:
            print ("Encoding tests passed!")
示例#8
0
def check_from_s3(key):
    video = get_from_s3(key)
    if video:
        print ("Video is in s3.")
    else:
        print ("Video is not in s3.")