1#!/usr/bin/env python 2 3""" 4This file generates all video_VDAStress control files from a master list. 5""" 6 7import collections 8 9Testdata = collections.namedtuple('Testdata', 'gs, decoder, access') 10 11TESTS = [ 12 Testdata('gs://chromeos-test-assets-private/VDA/', 'h264', 'private'), 13 Testdata('gs://chromeos-test-assets-private/VDA/', 'vp8', 'private'), 14 # TODO(ihf): Populate public bucket with test videos. 15 #Testdata('gs://chromiumos-test-assets-public/VDA/', 'h264', 'public'), 16 #Testdata('gs://chromiumos-test-assets-public/VDA/', 'vp8', 'public'), 17 #Testdata('gs://chromiumos-test-assets-public/VDA/', 'vp9', 'public'), 18] 19 20CONTROLFILE_TEMPLATE = ( 21"""# Copyright 2013 The Chromium OS Authors. All rights reserved. 22# Use of this source code is governed by a BSD-style license that can be 23# found in the LICENSE file. 24 25AUTHOR = 'Chrome OS Team, chromeos-video@google.com' 26NAME = 'video_VDAStress.{1}.{2}.{3}' 27ATTRIBUTES = 'suite:video' 28TIME = 'LENGTHY' 29TEST_CATEGORY = 'Stress' 30TEST_CLASS = 'video' 31TEST_TYPE = 'server' 32DEPENDENCIES = 'hw_video_acc_{1}' 33 34DOC = \"\"\" 35VDA stress test to download and run with {1} test videos from cloud storage. 36\"\"\" 37 38import shutil 39import tempfile 40 41# Download the test videos from the gs bucket to the server. 42server_videos_dir = tempfile.mkdtemp(dir=job.tmpdir) 43videos = [] 44job.run_test( 45 'video_VDAStressSetup', 46 gs_bucket='{0}{1}/', 47 server_videos_dir=server_videos_dir, 48 videos=videos, 49 shard_number={3}, 50 shard_count={4}) 51 52 53def run(machine): 54 job.run_test('video_VDAStress', 55 machine=machine, 56 server_videos_dir=server_videos_dir, 57 videos=videos) 58 59 60job.parallel_on_machines(run, machines) 61shutil.rmtree(server_videos_dir)""") 62 63 64shard_count = 10 65for test in TESTS: 66 for shard_number in xrange(0, shard_count): 67 filename = 'control.%s.%s.%d' % (test.decoder, test.access, shard_number) 68 with open(filename, 'w+') as f: 69 content = ( 70 CONTROLFILE_TEMPLATE.format( 71 test.gs, test.decoder, test.access, 72 shard_number, shard_count)) 73 f.write(content) 74