autotest: deploy_server_local should log out the hostname of updated server
BUG=chromium:841949
TEST=unittest
Change-Id: I6227c4ce79060cf76f8b5c8b64bda8a569d556eb
Reviewed-on: https://chromium-review.googlesource.com/1054627
Commit-Ready: Shuqian Zhao <shuqianz@chromium.org>
Tested-by: Shuqian Zhao <shuqianz@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/site_utils/deploy_server_local.py b/site_utils/deploy_server_local.py
index bd4650b..728efda 100755
--- a/site_utils/deploy_server_local.py
+++ b/site_utils/deploy_server_local.py
@@ -17,6 +17,7 @@
import os
import re
import subprocess
+import socket
import sys
import time
@@ -43,6 +44,7 @@
AFE = frontend_wrappers.RetryingAFE(
server=server_utils.get_global_afe_hostname(), timeout_min=5,
delay_sec=10)
+HOSTNAME = socket.gethostname()
class DirtyTreeException(Exception):
"""Raised when the tree has been modified in an unexpected way."""
@@ -97,7 +99,7 @@
out = strip_terminal_codes(out).strip()
if not 'working directory clean' in out and not 'working tree clean' in out:
- raise DirtyTreeException(out)
+ raise DirtyTreeException('%s repo not clean: %s' % (HOSTNAME, out))
def _clean_externals():
@@ -250,7 +252,7 @@
cwd=common.autotest_dir,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- print('FAILED:')
+ print('FAILED %s :' % HOSTNAME)
print(e.output)
raise
@@ -331,7 +333,8 @@
# Report any services having issues.
if unstable_services:
- raise UnstableServices(unstable_services)
+ raise UnstableServices('%s service restart failed: %s' %
+ (HOSTNAME, unstable_services))
def run_deploy_actions(cmds_skip=set(), dryrun=False,
@@ -501,7 +504,7 @@
global_config.global_config.parse_config_file()
behaviors = parse_arguments(args)
-
+ print('Updating server: %s' % HOSTNAME)
if behaviors.verify:
print('Checking tree status:')
verify_repo_clean()
diff --git a/site_utils/deploy_server_local_unittest.py b/site_utils/deploy_server_local_unittest.py
index 592da40..0e2bf94 100755
--- a/site_utils/deploy_server_local_unittest.py
+++ b/site_utils/deploy_server_local_unittest.py
@@ -222,6 +222,7 @@
def test_restart_services(self):
"""Test deploy_server_local.restart_services."""
+ dsl.HOSTNAME = 'test_server'
single_stable = {'foo': ['status_ok', 'status_ok']}
double_stable = {'foo': ['status_a', 'status_a'],
'bar': ['status_b', 'status_b']}
@@ -238,11 +239,13 @@
# Verify we can handle unstable services and report the right failures.
with self.assertRaises(dsl.UnstableServices) as unstable:
self._test_restart_services(single_unstable)
- self.assertEqual(unstable.exception.args[0], ['foo'])
+ self.assertEqual(unstable.exception.args[0],
+ "test_server service restart failed: ['foo']")
with self.assertRaises(dsl.UnstableServices) as unstable:
self._test_restart_services(triple_unstable)
- self.assertEqual(unstable.exception.args[0], ['bar', 'joe'])
+ self.assertEqual(unstable.exception.args[0],
+ "test_server service restart failed: ['bar', 'joe']")
@mock.patch('subprocess.check_output', autospec=True)
def test_report_changes_no_update(self, run_cmd):