mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update support for Tower testing.
This is required for compatibility with the latest version of ansible-core-ci, which now handles more of the Tower instance setup.
This commit is contained in:
parent
1ceaf84108
commit
5688d2243c
1 changed files with 15 additions and 75 deletions
|
@ -121,10 +121,6 @@ class TowerCloudProvider(CloudProvider):
|
||||||
|
|
||||||
connection = aci.get()
|
connection = aci.get()
|
||||||
|
|
||||||
self._set_cloud_config('ssh_hostname', connection.hostname)
|
|
||||||
self._set_cloud_config('ssh_username', connection.username)
|
|
||||||
self._set_cloud_config('ssh_port', connection.port)
|
|
||||||
|
|
||||||
config = self._read_config_template()
|
config = self._read_config_template()
|
||||||
|
|
||||||
if not self.args.explain:
|
if not self.args.explain:
|
||||||
|
@ -133,8 +129,8 @@ class TowerCloudProvider(CloudProvider):
|
||||||
values = dict(
|
values = dict(
|
||||||
VERSION=self.version,
|
VERSION=self.version,
|
||||||
HOST=connection.hostname,
|
HOST=connection.hostname,
|
||||||
USERNAME='admin',
|
USERNAME=connection.username,
|
||||||
PASSWORD=generate_password(),
|
PASSWORD=connection.password,
|
||||||
)
|
)
|
||||||
|
|
||||||
config = self._populate_config_template(config, values)
|
config = self._populate_config_template(config, values)
|
||||||
|
@ -147,51 +143,8 @@ class TowerCloudEnvironment(CloudEnvironment):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Setup which should be done once per environment instead of once per test target."""
|
"""Setup which should be done once per environment instead of once per test target."""
|
||||||
self.setup_cli()
|
self.setup_cli()
|
||||||
|
|
||||||
if self.managed:
|
|
||||||
self.setup_dynamic()
|
|
||||||
|
|
||||||
self.ping_tower_api()
|
|
||||||
self.disable_pendo()
|
self.disable_pendo()
|
||||||
|
|
||||||
def setup_dynamic(self):
|
|
||||||
"""Dynamic setup which should be done once per environment instead of once per test target."""
|
|
||||||
display.info('Waiting for Tower instance to become reachable over SSH')
|
|
||||||
|
|
||||||
ssh_hostname = self._get_cloud_config('ssh_hostname')
|
|
||||||
ssh_username = self._get_cloud_config('ssh_username')
|
|
||||||
ssh_port = self._get_cloud_config('ssh_port')
|
|
||||||
|
|
||||||
config = TowerConfig.parse(self.config_path)
|
|
||||||
|
|
||||||
aci = get_tower_aci(self.args)
|
|
||||||
aci.connection = InstanceConnection(True, ssh_hostname, ssh_port, ssh_username, None)
|
|
||||||
|
|
||||||
mci = ManagePosixCI(aci)
|
|
||||||
mci.wait()
|
|
||||||
|
|
||||||
display.info('Waiting for Tower to be reconfigured')
|
|
||||||
|
|
||||||
attempts = 60
|
|
||||||
|
|
||||||
while attempts:
|
|
||||||
attempts -= 1
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Tower is supposed to drop a /etc/tower/reset/.reconfigured file when it is reconfigured.
|
|
||||||
# However, the playbook sometimes fails, so we'll look for the completion of the playbook in the log instead.
|
|
||||||
mci.ssh(['grep', '--quiet', '--no-messages', 'PLAY RECAP', '/etc/tower/reset/reset.log'])
|
|
||||||
break
|
|
||||||
except SubprocessError:
|
|
||||||
time.sleep(5)
|
|
||||||
else:
|
|
||||||
raise ApplicationError('Timed out waiting for Tower to be reconfigured.')
|
|
||||||
|
|
||||||
display.info('Updating the Tower %s password' % config.username)
|
|
||||||
|
|
||||||
cmd = ['awx-manage', 'update_password', '--username', config.username, '--password', config.password]
|
|
||||||
mci.ssh(cmd)
|
|
||||||
|
|
||||||
def setup_cli(self):
|
def setup_cli(self):
|
||||||
"""Install the correct Tower CLI for the version of Tower being tested."""
|
"""Install the correct Tower CLI for the version of Tower being tested."""
|
||||||
tower_cli_version = self._get_cloud_config('tower_cli_version')
|
tower_cli_version = self._get_cloud_config('tower_cli_version')
|
||||||
|
@ -203,31 +156,6 @@ class TowerCloudEnvironment(CloudEnvironment):
|
||||||
|
|
||||||
run_command(self.args, cmd)
|
run_command(self.args, cmd)
|
||||||
|
|
||||||
def ping_tower_api(self):
|
|
||||||
"""Wait for Tower API to become available."""
|
|
||||||
display.info('Waiting for the Tower API to become reachable')
|
|
||||||
|
|
||||||
config = TowerConfig.parse(self.config_path)
|
|
||||||
|
|
||||||
http = HttpClient(self.args, insecure=True)
|
|
||||||
http.username = config.username
|
|
||||||
http.password = config.password
|
|
||||||
|
|
||||||
uri = 'https://%s/api/v1/ping/' % config.host
|
|
||||||
|
|
||||||
attempts = 60
|
|
||||||
|
|
||||||
while attempts:
|
|
||||||
attempts -= 1
|
|
||||||
response = http.get(uri)
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
return
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
raise ApplicationError('Timed out waiting for Tower API to become reachable.')
|
|
||||||
|
|
||||||
def disable_pendo(self):
|
def disable_pendo(self):
|
||||||
"""Disable Pendo tracking."""
|
"""Disable Pendo tracking."""
|
||||||
display.info('Disable Pendo tracking')
|
display.info('Disable Pendo tracking')
|
||||||
|
@ -238,7 +166,19 @@ class TowerCloudEnvironment(CloudEnvironment):
|
||||||
cmd = ['tower-cli', 'setting', 'modify', 'PENDO_TRACKING_STATE', 'off',
|
cmd = ['tower-cli', 'setting', 'modify', 'PENDO_TRACKING_STATE', 'off',
|
||||||
'-h', config.host, '-u', config.username, '-p', config.password]
|
'-h', config.host, '-u', config.username, '-p', config.password]
|
||||||
|
|
||||||
run_command(self.args, cmd)
|
attempts = 60
|
||||||
|
|
||||||
|
while True:
|
||||||
|
attempts -= 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
run_command(self.args, cmd, capture=True)
|
||||||
|
return
|
||||||
|
except SubprocessError as ex:
|
||||||
|
if not attempts:
|
||||||
|
raise ApplicationError('Timed out trying to disable Pendo tracking:\n%s' % ex)
|
||||||
|
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
def configure_environment(self, env, cmd):
|
def configure_environment(self, env, cmd):
|
||||||
"""Configuration which should be done once for each test target.
|
"""Configuration which should be done once for each test target.
|
||||||
|
|
Loading…
Reference in a new issue