| Index: scripts/slave/unittests/run_slavelastic_test.py
|
| diff --git a/scripts/slave/unittests/run_slavelastic_test.py b/scripts/slave/unittests/run_slavelastic_test.py
|
| index cb93d68a42d40904bf87381734821e3ab24c6d9a..538a5b8a8412f09987e0ce5d5c810a4c5d448c87 100755
|
| --- a/scripts/slave/unittests/run_slavelastic_test.py
|
| +++ b/scripts/slave/unittests/run_slavelastic_test.py
|
| @@ -4,11 +4,9 @@
|
| # found in the LICENSE file.
|
|
|
| import json
|
| -import os
|
| -import socket
|
| import sys
|
| import unittest
|
| -import urllib
|
| +import urlparse
|
|
|
| import test_env # pylint: disable=W0403,W0611
|
|
|
| @@ -21,87 +19,84 @@ ENV_VARS = {'GTEST_TOTAL_SHARDS': '%(num_instances)s',
|
| 'GTEST_SHARD_INDEX': '%(instance_index)s'}
|
|
|
|
|
| -class Switches(object):
|
| +class Options(object):
|
| def __init__(self, working_dir="swarm_tests", min_shards=1, num_shards=1,
|
| - os_image='win32', url='http://localhost:8080'):
|
| + os_image='win32', url='http://localhost:8080',
|
| + data_url='http://www.google.com', data_dest_dir='temp_data'):
|
| self.working_dir = working_dir
|
| self.min_shards = min_shards
|
| self.num_shards = num_shards
|
| self.os_image = os_image
|
| self.url = url
|
| -
|
| -
|
| -class ManifestTest(unittest.TestCase):
|
| - def setUp(self):
|
| - self.hostname = socket.gethostbyname(socket.gethostname()) + ':8080'
|
| - self.filename_url = urllib.pathname2url(
|
| - os.path.relpath(TEST_NAME + '.zip', '../..'))
|
| - self.correct_data = ['http://%s/%s' % (self.hostname, self.filename_url)]
|
| -
|
| -
|
| - def GenerateExpectedJSON(self, switches):
|
| - platform_mapping = {
|
| - 'win32': 'Windows',
|
| - 'cygwin': 'Windows',
|
| - 'linux2': 'Linux',
|
| - 'darwin': 'Mac'
|
| + self.data_url = data_url
|
| + self.data_dest_dir = data_dest_dir
|
| +
|
| +
|
| +def GenerateExpectedJSON(options):
|
| + platform_mapping = {
|
| + 'cygwin': 'Windows',
|
| + 'darwin': 'Mac',
|
| + 'linux2': 'Linux',
|
| + 'win32': 'Windows'
|
| + }
|
| +
|
| + expected = {
|
| + 'test_case_name': TEST_NAME,
|
| + 'data': [urlparse.urljoin(options.data_url, TEST_NAME + '.zip')],
|
| + 'tests' : [
|
| + {
|
| + 'action': [
|
| + 'python', 'src/tools/isolate/run_test_from_archive.py',
|
| + '-m', FILE_NAME,
|
| + '-r', urlparse.urljoin(options.data_url, 'hashtable')
|
| + ],
|
| + 'test_name': 'Run Test'
|
| }
|
| -
|
| - expected = {
|
| - 'test_case_name': TEST_NAME,
|
| - 'data': self.correct_data,
|
| - 'tests' : [
|
| - {
|
| - 'action': [
|
| - 'python', 'src/tools/isolate/run_test_from_archive.py',
|
| - '-m', FILE_NAME,
|
| - '-r', 'http://' + self.hostname + '/hashtable/'
|
| - ],
|
| - 'test_name': 'Run Test'
|
| - }
|
| - ],
|
| - 'env_vars': ENV_VARS,
|
| - 'configurations': [
|
| - {
|
| - 'min_instances': 1,
|
| - 'max_instances': 1,
|
| - 'config_name': platform_mapping[switches.os_image],
|
| - 'dimensions': {
|
| - 'os': platform_mapping[switches.os_image],
|
| - },
|
| + ],
|
| + 'env_vars': ENV_VARS,
|
| + 'configurations': [
|
| + {
|
| + 'min_instances': 1,
|
| + 'max_instances': 1,
|
| + 'config_name': platform_mapping[options.os_image],
|
| + 'dimensions': {
|
| + 'os': platform_mapping[options.os_image],
|
| },
|
| - ],
|
| - 'working_dir': switches.working_dir,
|
| - 'cleanup': 'data'
|
| - }
|
| -
|
| - if switches.os_image == 'win32':
|
| - expected['tests'].append(
|
| - {'action': ['del', 'unit_tests.zip'], 'test_name': 'Clean Up'})
|
| - else:
|
| - expected['tests'].append(
|
| - {'action': ['rm', '-rf', 'unit_tests.zip'], 'test_name': 'Clean Up'})
|
| -
|
| - if switches.os_image == 'win32':
|
| - expected['tests'].append(
|
| - {
|
| - 'action': [
|
| - sys.executable,
|
| - '..\\b\\build\\scripts\\slave\\kill_processes.py'
|
| - ],
|
| - 'test_name': 'Kill Processes'
|
| - }
|
| - )
|
| -
|
| - return expected
|
| + },
|
| + ],
|
| + 'working_dir': options.working_dir,
|
| + 'cleanup': 'data'
|
| + }
|
| +
|
| + if options.os_image == 'win32':
|
| + expected['tests'].append(
|
| + {'action': ['del', 'unit_tests.zip'], 'test_name': 'Clean Up'})
|
| + else:
|
| + expected['tests'].append(
|
| + {'action': ['rm', '-rf', 'unit_tests.zip'], 'test_name': 'Clean Up'})
|
| +
|
| + if options.os_image == 'win32':
|
| + expected['tests'].append(
|
| + {
|
| + 'action': [
|
| + sys.executable,
|
| + '..\\b\\build\\scripts\\slave\\kill_processes.py'
|
| + ],
|
| + 'test_name': 'Kill Processes'
|
| + }
|
| + )
|
| +
|
| + return expected
|
|
|
| +
|
| +class ManifestTest(unittest.TestCase):
|
| def test_basic_manifest(self):
|
| - switches = Switches()
|
| - manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, switches)
|
| + options = Options()
|
| + manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, options)
|
|
|
| manifest_json = json.loads(manifest.to_json())
|
|
|
| - expected = self.GenerateExpectedJSON(switches)
|
| + expected = GenerateExpectedJSON(options)
|
| self.assertEqual(expected, manifest_json)
|
|
|
| def test_basic_linux(self):
|
| @@ -109,12 +104,12 @@ class ManifestTest(unittest.TestCase):
|
| aren't used.
|
| """
|
|
|
| - switches = Switches(os_image='linux2')
|
| - manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, switches)
|
| + options = Options(os_image='linux2')
|
| + manifest = run_slavelastic.Manifest(FILE_NAME, TEST_NAME, options)
|
|
|
| manifest_json = json.loads(manifest.to_json())
|
|
|
| - expected = self.GenerateExpectedJSON(switches)
|
| + expected = GenerateExpectedJSON(options)
|
| self.assertEqual(expected, manifest_json)
|
|
|
|
|
|
|