Fix ansible-test inventory and vars path handling. (#55186)

* Fix ansible-test inventory and vars path handling.
* Improve explanation for missing commit.
This commit is contained in:
Matt Clay 2019-04-12 11:52:44 -07:00 committed by GitHub
parent 39445786ff
commit a4d0c24bbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View file

@ -321,7 +321,8 @@ def get_merged_commit(args, commit):
# This should only fail for pull requests where the commit does not exist. # This should only fail for pull requests where the commit does not exist.
# Merge runs would fail much earlier when attempting to checkout the commit. # Merge runs would fail much earlier when attempting to checkout the commit.
raise ApplicationError('Commit %s was not found:\n\n%s\n\n' raise ApplicationError('Commit %s was not found:\n\n%s\n\n'
'The commit was likely removed by a force push between job creation and execution.\n' 'GitHub may not have fully replicated the commit across their infrastructure.\n'
'It is also possible the commit was removed by a force push between job creation and execution.\n'
'Find the latest run for the pull request and restart failed jobs as needed.' 'Find the latest run for the pull request and restart failed jobs as needed.'
% (commit, ex.stderr.strip())) % (commit, ex.stderr.strip()))

View file

@ -1241,7 +1241,7 @@ def command_integration_role(args, target, start_at_task, test_dir, inventory_pa
hosts=hosts, hosts=hosts,
gather_facts=gather_facts, gather_facts=gather_facts,
vars_files=[ vars_files=[
test_env.vars_file, os.path.relpath(test_env.vars_file, test_env.integration_dir),
], ],
roles=[ roles=[
target.name, target.name,
@ -1262,7 +1262,7 @@ def command_integration_role(args, target, start_at_task, test_dir, inventory_pa
display.info('>>> Playbook: %s\n%s' % (filename, playbook.strip()), verbosity=3) display.info('>>> Playbook: %s\n%s' % (filename, playbook.strip()), verbosity=3)
cmd = ['ansible-playbook', filename, '-i', test_env.inventory_path] cmd = ['ansible-playbook', filename, '-i', os.path.relpath(test_env.inventory_path, test_env.integration_dir)]
if start_at_task: if start_at_task:
cmd += ['--start-at-task', start_at_task] cmd += ['--start-at-task', start_at_task]

View file

@ -125,15 +125,12 @@ def integration_test_environment(args, target, inventory_path):
if args.no_temp_workdir or 'no/temp_workdir/' in target.aliases: if args.no_temp_workdir or 'no/temp_workdir/' in target.aliases:
display.warning('Disabling the temp work dir is a temporary debugging feature that may be removed in the future without notice.') display.warning('Disabling the temp work dir is a temporary debugging feature that may be removed in the future without notice.')
integration_dir = 'test/integration' integration_dir = os.path.abspath('test/integration')
inventory_path = os.path.abspath(inventory_path)
ansible_config = os.path.join(integration_dir, '%s.cfg' % args.command) ansible_config = os.path.join(integration_dir, '%s.cfg' % args.command)
vars_file = os.path.join(integration_dir, vars_file)
inventory_name = os.path.relpath(inventory_path, integration_dir) yield IntegrationEnvironment(integration_dir, inventory_path, ansible_config, vars_file)
if '/' in inventory_name:
inventory_name = inventory_path
yield IntegrationEnvironment(integration_dir, inventory_name, ansible_config, vars_file)
return return
root_temp_dir = os.path.expanduser('~/.ansible/test/tmp') root_temp_dir = os.path.expanduser('~/.ansible/test/tmp')
@ -216,7 +213,10 @@ def integration_test_environment(args, target, inventory_path):
make_dirs(os.path.dirname(file_dst)) make_dirs(os.path.dirname(file_dst))
shutil.copy2(file_src, file_dst) shutil.copy2(file_src, file_dst)
yield IntegrationEnvironment(integration_dir, inventory_name, ansible_config, vars_file) inventory_path = os.path.join(integration_dir, inventory_name)
vars_file = os.path.join(integration_dir, vars_file)
yield IntegrationEnvironment(integration_dir, inventory_path, ansible_config, vars_file)
finally: finally:
if not args.explain: if not args.explain:
shutil.rmtree(temp_dir) shutil.rmtree(temp_dir)