Fix zuul client and remote tests
The client test framework needs to be updated to handle !unsafe tags. The remote tests need the following fixes: * Remove the hostvars test since it was added to test that setting ansible_python_interpreter as a job hostvar works, and we no longer permit that. * The variable freezing process causes gather_facts to run during the freeze playbook, so these tasks no longer appear in the job results. Change-Id: I5d5277b3f4cc3536f3ab18fb4775551281ee99f9
This commit is contained in:
parent
449e45a9da
commit
6a5df37586
|
@ -1,80 +0,0 @@
|
|||
# Copyright 2019 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
import yaml
|
||||
|
||||
from tests.base import AnsibleZuulTestCase
|
||||
|
||||
|
||||
class TestZuulHostVars(AnsibleZuulTestCase):
|
||||
tenant_config_file = 'config/remote-zuul-json/main.yaml'
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.fake_nodepool.remote_ansible = True
|
||||
|
||||
ansible_remote = os.environ.get('ZUUL_REMOTE_IPV4')
|
||||
self.assertIsNotNone(ansible_remote)
|
||||
|
||||
def _run_job(self, job_name):
|
||||
# Keep the jobdir around so we can inspect contents if an
|
||||
# assert fails. It will be cleaned up anyway as it is contained
|
||||
# in a tmp dir which gets cleaned up after the test.
|
||||
self.executor_server.keep_jobdir = True
|
||||
|
||||
# Output extra ansible info so we might see errors.
|
||||
self.executor_server.verbose = True
|
||||
conf = textwrap.dedent(
|
||||
"""
|
||||
- job:
|
||||
name: {job_name}
|
||||
run: playbooks/{job_name}.yaml
|
||||
roles:
|
||||
- zuul: org/common-config
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: controller
|
||||
label: whatever
|
||||
host-vars:
|
||||
controller:
|
||||
ansible_python_interpreter: python2
|
||||
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- {job_name}
|
||||
""".format(job_name=job_name))
|
||||
|
||||
file_dict = {'zuul.yaml': conf}
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
|
||||
files=file_dict)
|
||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
job = self.getJobFromHistory(job_name)
|
||||
return job
|
||||
|
||||
def test_hostvars(self):
|
||||
job = self._run_job('no-log')
|
||||
with self.jobLog(job):
|
||||
build = self.history[-1]
|
||||
inventory = yaml.safe_load(open(os.path.join(
|
||||
self.jobdir_root, build.uuid, 'ansible', 'inventory.yaml')))
|
||||
self.assertEqual(
|
||||
"python2",
|
||||
inventory["all"]["hosts"]["controller"][
|
||||
"ansible_python_interpreter"])
|
|
@ -91,10 +91,8 @@ class FunctionalZuulJSONMixIn:
|
|||
text = self._get_json_as_text(build)
|
||||
json_result = json.loads(text)
|
||||
tasks = json_result[0]['plays'][0]['tasks']
|
||||
# NOTE(pabelanger): In 2.8 gather_facts are now logged as an
|
||||
# expected action.
|
||||
expected_actions = [
|
||||
'gather_facts', 'debug', 'debug', 'debug', 'copy', 'find',
|
||||
'debug', 'debug', 'debug', 'copy', 'find',
|
||||
'stat', 'debug'
|
||||
]
|
||||
for i, expected in enumerate(expected_actions):
|
||||
|
@ -111,12 +109,10 @@ class FunctionalZuulJSONMixIn:
|
|||
self.assertIn('json-role', text)
|
||||
|
||||
json_result = json.loads(text)
|
||||
# NOTE(pabelanger): In 2.8 gather_facts are now logged as the
|
||||
# first task.
|
||||
role_name = json_result[0]['plays'][0]['tasks'][1]['role']['name']
|
||||
role_name = json_result[0]['plays'][0]['tasks'][0]['role']['name']
|
||||
self.assertEqual('json-role', role_name)
|
||||
|
||||
role_path = json_result[0]['plays'][0]['tasks'][1]['role']['path']
|
||||
role_path = json_result[0]['plays'][0]['tasks'][0]['role']['path']
|
||||
self.assertEqual('json-role', os.path.basename(role_path))
|
||||
|
||||
def test_json_time_log(self):
|
||||
|
|
|
@ -21,7 +21,7 @@ import textwrap
|
|||
|
||||
import zuul.web
|
||||
import zuul.rpcclient
|
||||
from zuul.lib.yamlutil import yaml
|
||||
from zuul.lib import yamlutil
|
||||
|
||||
from tests.base import iterate_timeout
|
||||
from tests.base import ZuulDBTestCase, AnsibleZuulTestCase
|
||||
|
@ -53,7 +53,8 @@ class TestZuulClientEncrypt(BaseTestWeb):
|
|||
build = self.getJobFromHistory(job)
|
||||
for pb in getattr(build.jobdir, pbtype):
|
||||
if pb.secrets_content:
|
||||
secrets.append(yaml.safe_load(pb.secrets_content))
|
||||
secrets.append(
|
||||
yamlutil.ansible_unsafe_load(pb.secrets_content))
|
||||
else:
|
||||
secrets.append({})
|
||||
return secrets
|
||||
|
|
Loading…
Reference in New Issue