| Index: appengine/swarming/local_smoke_test.py
|
| diff --git a/appengine/swarming/local_smoke_test.py b/appengine/swarming/local_smoke_test.py
|
| index 9d61a16dfa32faaaa2ff99a5ae57243fc2c31904..76942d9f44ae79f58284d3e3f0453e863cda420a 100755
|
| --- a/appengine/swarming/local_smoke_test.py
|
| +++ b/appengine/swarming/local_smoke_test.py
|
| @@ -19,6 +19,7 @@ import socket
|
| import sys
|
| import tempfile
|
| import textwrap
|
| +import time
|
| import unittest
|
| import urllib
|
|
|
| @@ -208,6 +209,14 @@ class SwarmingClient(object):
|
| file_path.rmtree(self._tmpdir)
|
| self._tmpdir = None
|
|
|
| + def query_bot(self):
|
| + """Returns the bot's properties."""
|
| + data = json.loads(self._capture('query', ['bots/list', '--limit', '10']))
|
| + if not data.get('items'):
|
| + return None
|
| + assert len(data['items']) == 1
|
| + return data['items'][0]
|
| +
|
| def dump_log(self):
|
| print >> sys.stderr, '-' * 60
|
| print >> sys.stderr, 'Client calls'
|
| @@ -241,6 +250,13 @@ class SwarmingClient(object):
|
| p.communicate()
|
| return p.returncode
|
|
|
| + def _capture(self, command, args):
|
| + cmd = [
|
| + sys.executable, 'swarming.py', command, '-S', self._swarming_server,
|
| + ] + args
|
| + p = subprocess42.Popen(cmd, stdout=subprocess42.PIPE, cwd=CLIENT_DIR)
|
| + return p.communicate()[0]
|
| +
|
|
|
| def gen_expected(**kwargs):
|
| expected = {
|
| @@ -636,6 +652,10 @@ class Test(unittest.TestCase):
|
| def test_local_cache(self):
|
| # First task creates the cache, second copy the content to the output
|
| # directory. Each time it's the exact same script.
|
| + dimensions = {
|
| + i['key']: i['value'] for i in self.client.query_bot()['dimensions']}
|
| + self.assertEqual(set(self.dimensions), set(dimensions))
|
| + self.assertNotIn(u'cache', set(dimensions))
|
| script = '\n'.join((
|
| 'import os, shutil, sys',
|
| 'p = "p/b/a.txt"',
|
| @@ -692,12 +712,21 @@ class Test(unittest.TestCase):
|
| },
|
| },
|
| )
|
| + # The previous task caused the bot to have a named cache.
|
| + expected_summary['bot_dimensions'][u'caches'] = [u'fuu']
|
| self._run_isolated(
|
| script, 'cache_second',
|
| ['--named-cache', 'fuu', 'p/b', '--', '${ISOLATED_OUTDIR}/yo'],
|
| expected_summary,
|
| {'0/yo': 'Yo!'})
|
|
|
| + # Check that the bot now has a cache dimension by independently querying.
|
| + expected = set(self.dimensions)
|
| + expected.add(u'caches')
|
| + dimensions = {
|
| + i['key']: i['value'] for i in self.client.query_bot()['dimensions']}
|
| + self.assertEqual(expected, set(dimensions))
|
| +
|
| def _run_isolated(self, hello_world, name, args, expected_summary,
|
| expected_files, deduped=False, isolated_content=None):
|
| """Runs hello_world.py as an isolated file."""
|
| @@ -850,6 +879,10 @@ def main():
|
| # which mutates the bot.
|
| Test.client = client
|
| Test.servers = servers
|
| + while not client.query_bot():
|
| + # Wait for the bot to come online helps when the unit test cases query the
|
| + # bot. It may takes a few loop.
|
| + time.sleep(0.1)
|
| failed = not unittest.main(exit=False).result.wasSuccessful()
|
|
|
| # Then try to terminate the bot sanely. After the terminate request
|
|
|