OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Records metrics on playing media under constrained network conditions. | 6 """Records metrics on playing media under constrained network conditions. |
7 | 7 |
8 Spins up a Constrained Network Server (CNS) and runs through a test matrix of | 8 Spins up a Constrained Network Server (CNS) and runs through a test matrix of |
9 bandwidth, latency, and packet loss settings. Tests running media files defined | 9 bandwidth, latency, and packet loss settings. Tests running media files defined |
10 in _TEST_MEDIA_EPP record the extra-play-percentage (EPP) metric and the | 10 in _TEST_MEDIA_EPP record the extra-play-percentage (EPP) metric and the |
11 time-to-playback (TTP) metric in a format consumable by the Chromium perf bots. | 11 time-to-playback (TTP) metric in a format consumable by the Chromium perf bots. |
12 Other tests running media files defined in _TEST_MEDIA_NO_EPP record only the | 12 Other tests running media files defined in _TEST_MEDIA_NO_EPP record only the |
13 TTP metric. | 13 TTP metric. |
14 | 14 |
15 Since even a small number of different settings yields a large test matrix, the | 15 Since even a small number of different settings yields a large test matrix, the |
16 design is threaded... however PyAuto is not, so a global lock is used when calls | 16 design is threaded... however PyAuto is not, so a global lock is used when calls |
17 into PyAuto are necessary. The number of threads can be set by _TEST_THREADS. | 17 into PyAuto are necessary. The number of threads can be set by _TEST_THREADS. |
18 | 18 |
19 The CNS code is located under: <root>/src/media/tools/constrained_network_server | 19 The CNS code is located under: <root>/src/media/tools/constrained_network_server |
20 """ | 20 """ |
21 | 21 |
22 import logging | 22 import logging |
23 import os | 23 import os |
| 24 import posixpath |
24 import Queue | 25 import Queue |
25 | 26 |
26 import pyauto_media | 27 import pyauto_media |
27 import pyauto_utils | 28 import pyauto_utils |
28 | 29 |
29 import cns_test_base | 30 import cns_test_base |
30 import worker_thread | 31 import worker_thread |
31 | 32 |
32 # The network constraints used for measuring ttp and epp. | 33 # The network constraints used for measuring ttp and epp. |
33 # Previous tests with 2% and 5% packet loss resulted in inconsistent data. Thus | 34 # Previous tests with 2% and 5% packet loss resulted in inconsistent data. Thus |
(...skipping 13 matching lines...) Expand all Loading... |
47 'media', 'html', 'media_constrained_network.html') | 48 'media', 'html', 'media_constrained_network.html') |
48 | 49 |
49 # Number of threads to use during testing. | 50 # Number of threads to use during testing. |
50 _TEST_THREADS = 3 | 51 _TEST_THREADS = 3 |
51 | 52 |
52 # Number of times we run the same test to eliminate outliers. | 53 # Number of times we run the same test to eliminate outliers. |
53 _TEST_ITERATIONS = 3 | 54 _TEST_ITERATIONS = 3 |
54 | 55 |
55 # Media file names used for measuring epp and tpp. | 56 # Media file names used for measuring epp and tpp. |
56 _TEST_MEDIA_EPP = ['roller.webm'] | 57 _TEST_MEDIA_EPP = ['roller.webm'] |
57 _TEST_MEDIA_EPP.extend(os.path.join('crowd', name) for name in | 58 _TEST_MEDIA_EPP.extend(posixpath.join('crowd', name) for name in |
58 ['crowd360.ogv', 'crowd.wav', 'crowd.ogg']) | 59 ['crowd360.ogv', 'crowd.wav', 'crowd.ogg']) |
59 | 60 |
60 # Media file names used for measuring tpp without epp. | 61 # Media file names used for measuring tpp without epp. |
61 _TEST_MEDIA_NO_EPP = [os.path.join('dartmoor', name) for name in | 62 _TEST_MEDIA_NO_EPP = [posixpath.join('dartmoor', name) for name in |
62 ['dartmoor2.ogg', 'dartmoor2.m4a', 'dartmoor2.mp3', | 63 ['dartmoor2.ogg', 'dartmoor2.m4a', 'dartmoor2.mp3', |
63 'dartmoor2.wav']] | 64 'dartmoor2.wav']] |
64 _TEST_MEDIA_NO_EPP.extend(os.path.join('crowd', name) for name in | 65 _TEST_MEDIA_NO_EPP.extend(posixpath.join('crowd', name) for name in |
65 ['crowd1080.webm', 'crowd1080.ogv', 'crowd1080.mp4', | 66 ['crowd1080.webm', 'crowd1080.ogv', 'crowd1080.mp4', |
66 'crowd360.webm', 'crowd360.mp4']) | 67 'crowd360.webm', 'crowd360.mp4']) |
67 | 68 |
68 # Timeout values for epp and ttp tests in seconds. | 69 # Timeout values for epp and ttp tests in seconds. |
69 _TEST_EPP_TIMEOUT = 180 | 70 _TEST_EPP_TIMEOUT = 180 |
70 _TEST_TTP_TIMEOUT = 20 | 71 _TEST_TTP_TIMEOUT = 20 |
71 | 72 |
72 | 73 |
73 class CNSWorkerThread(worker_thread.WorkerThread): | 74 class CNSWorkerThread(worker_thread.WorkerThread): |
74 """Worker thread. Runs a test for each task in the queue.""" | 75 """Worker thread. Runs a test for each task in the queue.""" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 media_files = [(name, True) for name in _TEST_MEDIA_EPP] | 201 media_files = [(name, True) for name in _TEST_MEDIA_EPP] |
201 media_files.extend((name, False) for name in _TEST_MEDIA_NO_EPP) | 202 media_files.extend((name, False) for name in _TEST_MEDIA_NO_EPP) |
202 tasks = cns_test_base.CreateCNSPerfTasks(_TESTS_TO_RUN, media_files) | 203 tasks = cns_test_base.CreateCNSPerfTasks(_TESTS_TO_RUN, media_files) |
203 if worker_thread.RunWorkerThreads(self, CNSWorkerThread, tasks, | 204 if worker_thread.RunWorkerThreads(self, CNSWorkerThread, tasks, |
204 _TEST_THREADS, _TEST_HTML_PATH): | 205 _TEST_THREADS, _TEST_HTML_PATH): |
205 self.fail('Some tests failed to run as expected.') | 206 self.fail('Some tests failed to run as expected.') |
206 | 207 |
207 | 208 |
208 if __name__ == '__main__': | 209 if __name__ == '__main__': |
209 pyauto_media.Main() | 210 pyauto_media.Main() |
OLD | NEW |