Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: scripts/slave/unittests/run_slavelastic_test.py

Issue 10386096: Get Swarm Bots to Use Network Storage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/slave/run_slavelastic.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import json 6 import json
7 import os
8 import socket
9 import sys 7 import sys
10 import unittest 8 import unittest
11 import urllib 9 import urlparse
12 10
13 import test_env # pylint: disable=W0403,W0611 11 import test_env # pylint: disable=W0403,W0611
14 12
15 import slave.run_slavelastic as run_slavelastic 13 import slave.run_slavelastic as run_slavelastic
16 14
17 FILE_NAME = "test.results" 15 FILE_NAME = "test.results"
18 TEST_NAME = "unit_tests" 16 TEST_NAME = "unit_tests"
19 17
20 ENV_VARS = {'GTEST_TOTAL_SHARDS': '%(num_instances)s', 18 ENV_VARS = {'GTEST_TOTAL_SHARDS': '%(num_instances)s',
21 'GTEST_SHARD_INDEX': '%(instance_index)s'} 19 'GTEST_SHARD_INDEX': '%(instance_index)s'}
22 20
23 21
24 class Switches(object): 22 class Options(object):
25 def __init__(self, working_dir="swarm_tests", min_shards=1, num_shards=1, 23 def __init__(self, working_dir="swarm_tests", min_shards=1, num_shards=1,
26 os_image='win32', url='http://localhost:8080'): 24 os_image='win32', url='http://localhost:8080',
25 data_url='http://www.google.com', data_dest_dir='temp_data'):
27 self.working_dir = working_dir 26 self.working_dir = working_dir
28 self.min_shards = min_shards 27 self.min_shards = min_shards
29 self.num_shards = num_shards 28 self.num_shards = num_shards
30 self.os_image = os_image 29 self.os_image = os_image
31 self.url = url 30 self.url = url
31 self.data_url = data_url
32 self.data_dest_dir = data_dest_dir
33
34
35 def GenerateExpectedJSON(options):
36 platform_mapping = {
37 'cygwin': 'Windows',
38 'darwin': 'Mac',
39 'linux2': 'Linux',
40 'win32': 'Windows'
41 }
42
43 expected = {
44 'test_case_name': TEST_NAME,
45 'data': [urlparse.urljoin(options.data_url, TEST_NAME + '.zip')],
46 'tests' : [
47 {
48 'action': [
49 'python', 'src/tools/isolate/run_test_from_archive.py',
50 '-m', FILE_NAME,
51 '-r', urlparse.urljoin(options.data_url, 'hashtable')
52 ],
53 'test_name': 'Run Test'
54 }
55 ],
56 'env_vars': ENV_VARS,
57 'configurations': [
58 {
59 'min_instances': 1,
60 'max_instances': 1,
61 'config_name': platform_mapping[options.os_image],
62 'dimensions': {
63 'os': platform_mapping[options.os_image],
64 },
65 },
66 ],
67 'working_dir': options.working_dir,
68 'cleanup': 'data'
69 }
70
71 if options.os_image == 'win32':
72 expected['tests'].append(
73 {'action': ['del', 'unit_tests.zip'], 'test_name': 'Clean Up'})
74 else:
75 expected['tests'].append(
76 {'action': ['rm', '-rf', 'unit_tests.zip'], 'test_name': 'Clean Up'})
77
78 if options.os_image == 'win32':
79 expected['tests'].append(
80 {
81 'action': [
82 sys.executable,
83 '..\\b\\build\\scripts\\slave\\kill_processes.py'
84 ],
85 'test_name': 'Kill Processes'
86 }
87 )
88
89 return expected
32 90
33 91
34 class ManifestTest(unittest.TestCase): 92 class ManifestTest(unittest.TestCase):
35 def setUp(self):
36 self.hostname = socket.gethostbyname(socket.gethostname()) + ':8080'
37 self.filename_url = urllib.pathname2url(
38 os.path.relpath(TEST_NAME + '.zip', '../..'))
39 self.correct_data = ['http://%s/%s' % (self.hostname, self.filename_url)]
40
41
42 def GenerateExpectedJSON(self, switches):
43 platform_mapping = {
44 'win32': 'Windows',
45 'cygwin': 'Windows',
46 'linux2': 'Linux',
47 'darwin': 'Mac'
48 }
49
50 expected = {
51 'test_case_name': TEST_NAME,
52 'data': self.correct_data,
53 'tests' : [
54 {
55 'action': [
56 'python', 'src/tools/isolate/run_test_from_archive.py',
57 '-m', FILE_NAME,
58 '-r', 'http://' + self.hostname + '/hashtable/'
59 ],
60 'test_name': 'Run Test'
61 }
62 ],
63 'env_vars': ENV_VARS,
64 'configurations': [
65 {
66 'min_instances': 1,
67 'max_instances': 1,
68 'config_name': platform_mapping[switches.os_image],
69 'dimensions': {
70 'os': platform_mapping[switches.os_image],
71 },
72 },
73 ],
74 'working_dir': switches.working_dir,
75 'cleanup': 'data'
76 }
77
78 if switches.os_image == 'win32':
79 expected['tests'].append(
80 {'action': ['del', 'unit_tests.zip'], 'test_name': 'Clean Up'})
81 else:
82 expected['tests'].append(
83 {'action': ['rm', '-rf', 'unit_tests.zip'], 'test_name': 'Clean Up'})
84
85 if switches.os_image == 'win32':
86 expected['tests'].append(
87 {
88 'action': [
89 sys.executable,
90 '..\\b\\build\\scripts\\slave\\kill_processes.py'
91 ],
92 'test_name': 'Kill Processes'
93 }
94 )
95
96 return expected
97
98 def test_basic_manifest(self): 93 def test_basic_manifest(self):
99 switches = Switches() 94 options = Options()
100 manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, switches) 95 manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, options)
101 96
102 manifest_json = json.loads(manifest.to_json()) 97 manifest_json = json.loads(manifest.to_json())
103 98
104 expected = self.GenerateExpectedJSON(switches) 99 expected = GenerateExpectedJSON(options)
105 self.assertEqual(expected, manifest_json) 100 self.assertEqual(expected, manifest_json)
106 101
107 def test_basic_linux(self): 102 def test_basic_linux(self):
108 """A basic linux manifest test to ensure that windows specific values 103 """A basic linux manifest test to ensure that windows specific values
109 aren't used. 104 aren't used.
110 """ 105 """
111 106
112 switches = Switches(os_image='linux2') 107 options = Options(os_image='linux2')
113 manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, switches) 108 manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, options)
114 109
115 manifest_json = json.loads(manifest.to_json()) 110 manifest_json = json.loads(manifest.to_json())
116 111
117 expected = self.GenerateExpectedJSON(switches) 112 expected = GenerateExpectedJSON(options)
118 self.assertEqual(expected, manifest_json) 113 self.assertEqual(expected, manifest_json)
119 114
120 115
121 if __name__ == '__main__': 116 if __name__ == '__main__':
122 unittest.main() 117 unittest.main()
OLDNEW
« no previous file with comments | « scripts/slave/run_slavelastic.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698