Merge "zuul-tox-remote: use unique zuul_console service"

This commit is contained in:
Zuul 2019-05-17 21:08:23 +00:00 committed by Gerrit Code Review
commit 17e15f1bbe
6 changed files with 23 additions and 5 deletions

View File

@ -2425,6 +2425,8 @@ class ZuulTestCase(BaseTestCase):
infrastructure should insert dummy keys to save time during infrastructure should insert dummy keys to save time during
startup. Defaults to False. startup. Defaults to False.
:cvar int log_console_port: The zuul_stream/zuul_console port.
The following are instance variables that are useful within test The following are instance variables that are useful within test
methods: methods:
@ -2459,6 +2461,7 @@ class ZuulTestCase(BaseTestCase):
create_project_keys = False create_project_keys = False
use_ssl = False use_ssl = False
git_url_with_auth = False git_url_with_auth = False
log_console_port = 19885
def _startMerger(self): def _startMerger(self):
self.merge_server = zuul.merger.server.MergeServer(self.config, self.merge_server = zuul.merger.server.MergeServer(self.config,
@ -2577,7 +2580,8 @@ class ZuulTestCase(BaseTestCase):
jobdir_root=self.test_root, jobdir_root=self.test_root,
_run_ansible=self.run_ansible, _run_ansible=self.run_ansible,
_test_root=self.test_root, _test_root=self.test_root,
keep_jobdir=KEEP_TEMPDIRS) keep_jobdir=KEEP_TEMPDIRS,
log_console_port=self.log_console_port)
self.executor_server.start() self.executor_server.start()
self.history = self.executor_server.build_history self.history = self.executor_server.build_history
self.builds = self.executor_server.running_builds self.builds = self.executor_server.running_builds

View File

@ -18,6 +18,8 @@
- name: Start zuul_console daemon - name: Start zuul_console daemon
zuul_console: zuul_console:
port: "{{ test_console_port }}"
- name: Create first file - name: Create first file
copy: copy:
content: "command test one\n" content: "command test one\n"

View File

@ -24,6 +24,7 @@ class TestZuulStream25(AnsibleZuulTestCase):
ansible_version = '2.5' ansible_version = '2.5'
def setUp(self): def setUp(self):
self.log_console_port = 19000 + int(self.ansible_version.split('.')[1])
super().setUp() super().setUp()
self.fake_nodepool.remote_ansible = True self.fake_nodepool.remote_ansible = True
@ -44,6 +45,8 @@ class TestZuulStream25(AnsibleZuulTestCase):
name: {job_name} name: {job_name}
run: playbooks/{job_name}.yaml run: playbooks/{job_name}.yaml
ansible-version: {version} ansible-version: {version}
vars:
test_console_port: {console_port}
roles: roles:
- zuul: org/common-config - zuul: org/common-config
nodeset: nodeset:
@ -57,7 +60,10 @@ class TestZuulStream25(AnsibleZuulTestCase):
check: check:
jobs: jobs:
- {job_name} - {job_name}
""".format(job_name=job_name, version=self.ansible_version)) """.format(
job_name=job_name,
version=self.ansible_version,
console_port=self.log_console_port))
file_dict = {'zuul.yaml': conf} file_dict = {'zuul.yaml': conf}
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A', A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',

View File

@ -33,7 +33,7 @@ from zuul.ansible import paths
from zuul.ansible import logconfig from zuul.ansible import logconfig
LOG_STREAM_PORT = 19885 LOG_STREAM_PORT = int(os.environ.get("ZUUL_CONSOLE_PORT", 19885))
def zuul_filter_result(result): def zuul_filter_result(result):

2
zuul/ansible/base/library/zuul_console.py Normal file → Executable file
View File

@ -274,7 +274,7 @@ def main():
else: else:
pid = None pid = None
exceptions = [] exceptions = []
inode = get_inode() inode = get_inode(port)
if not inode: if not inode:
module.fail_json( module.fail_json(
msg="Could not find inode for port", msg="Could not find inode for port",

View File

@ -53,6 +53,7 @@ BUFFER_LINES_FOR_SYNTAX = 200
COMMANDS = ['stop', 'pause', 'unpause', 'graceful', 'verbose', COMMANDS = ['stop', 'pause', 'unpause', 'graceful', 'verbose',
'unverbose', 'keep', 'nokeep'] 'unverbose', 'keep', 'nokeep']
DEFAULT_FINGER_PORT = 7900 DEFAULT_FINGER_PORT = 7900
DEFAULT_STREAM_PORT = 19885
BLACKLISTED_ANSIBLE_CONNECTION_TYPES = [ BLACKLISTED_ANSIBLE_CONNECTION_TYPES = [
'network_cli', 'kubectl', 'project', 'namespace'] 'network_cli', 'kubectl', 'project', 'namespace']
@ -1841,6 +1842,9 @@ class AnsibleJob(object):
env_copy['ARA_LOG_CONFIG'] = self.jobdir.logging_json env_copy['ARA_LOG_CONFIG'] = self.jobdir.logging_json
env_copy['ZUUL_JOB_LOG_CONFIG'] = self.jobdir.logging_json env_copy['ZUUL_JOB_LOG_CONFIG'] = self.jobdir.logging_json
env_copy['ZUUL_JOBDIR'] = self.jobdir.root env_copy['ZUUL_JOBDIR'] = self.jobdir.root
if self.executor_server.log_console_port != DEFAULT_STREAM_PORT:
env_copy['ZUUL_CONSOLE_PORT'] = str(
self.executor_server.log_console_port)
env_copy['TMP'] = self.jobdir.local_tmp env_copy['TMP'] = self.jobdir.local_tmp
pythonpath = env_copy.get('PYTHONPATH') pythonpath = env_copy.get('PYTHONPATH')
if pythonpath: if pythonpath:
@ -2207,7 +2211,8 @@ class ExecutorServer(object):
_job_class = AnsibleJob _job_class = AnsibleJob
def __init__(self, config, connections={}, jobdir_root=None, def __init__(self, config, connections={}, jobdir_root=None,
keep_jobdir=False, log_streaming_port=DEFAULT_FINGER_PORT): keep_jobdir=False, log_streaming_port=DEFAULT_FINGER_PORT,
log_console_port=DEFAULT_STREAM_PORT):
self.config = config self.config = config
self.keep_jobdir = keep_jobdir self.keep_jobdir = keep_jobdir
self.jobdir_root = jobdir_root self.jobdir_root = jobdir_root
@ -2230,6 +2235,7 @@ class ExecutorServer(object):
keep=self.keep, keep=self.keep,
nokeep=self.nokeep, nokeep=self.nokeep,
) )
self.log_console_port = log_console_port
statsd_extra_keys = {'hostname': self.hostname} statsd_extra_keys = {'hostname': self.hostname}
self.statsd = get_statsd(config, statsd_extra_keys) self.statsd = get_statsd(config, statsd_extra_keys)