mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Support caching for ec2 inventory sync to avoid unit test failures.
This commit is contained in:
@@ -807,8 +807,8 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
ec2_opts.setdefault('vpc_destination_variable', 'ip_address')
|
ec2_opts.setdefault('vpc_destination_variable', 'ip_address')
|
||||||
ec2_opts.setdefault('route53', 'False')
|
ec2_opts.setdefault('route53', 'False')
|
||||||
ec2_opts.setdefault('nested_groups', 'True')
|
ec2_opts.setdefault('nested_groups', 'True')
|
||||||
ec2_opts['cache_path'] = tempfile.mkdtemp(prefix='awx_ec2_')
|
ec2_opts.setdefault('cache_path', tempfile.mkdtemp(prefix='awx_ec2_'))
|
||||||
ec2_opts['cache_max_age'] = '300'
|
ec2_opts.setdefault('cache_max_age', '300')
|
||||||
for k,v in ec2_opts.items():
|
for k,v in ec2_opts.items():
|
||||||
cp.set(section, k, str(v))
|
cp.set(section, k, str(v))
|
||||||
# Build pyrax creds INI for rax inventory script.
|
# Build pyrax creds INI for rax inventory script.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -1396,9 +1397,11 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
|||||||
group.name = 'ec2'
|
group.name = 'ec2'
|
||||||
group.save()
|
group.save()
|
||||||
self.group = group
|
self.group = group
|
||||||
|
cache_path = tempfile.mkdtemp(prefix='awx_ec2_')
|
||||||
|
self._temp_paths.append(cache_path)
|
||||||
inventory_source = self.update_inventory_source(self.group,
|
inventory_source = self.update_inventory_source(self.group,
|
||||||
source='ec2', credential=credential, source_regions=source_regions,
|
source='ec2', credential=credential, source_regions=source_regions,
|
||||||
source_vars='---\n\nnested_groups: false\n')
|
source_vars='---\n\nnested_groups: false\ncache_path: %s\n' % cache_path)
|
||||||
# Check first without instance_id set (to import by name only).
|
# Check first without instance_id set (to import by name only).
|
||||||
with self.settings(EC2_INSTANCE_ID_VAR=''):
|
with self.settings(EC2_INSTANCE_ID_VAR=''):
|
||||||
self.check_inventory_source(inventory_source)
|
self.check_inventory_source(inventory_source)
|
||||||
@@ -1447,11 +1450,6 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
|||||||
source='ec2', credential=credential, source_regions=source_regions,
|
source='ec2', credential=credential, source_regions=source_regions,
|
||||||
source_vars='---') # nested_groups is true by default.
|
source_vars='---') # nested_groups is true by default.
|
||||||
self.check_inventory_source(inventory_source)
|
self.check_inventory_source(inventory_source)
|
||||||
# Manually disable all hosts, verify a new update re-enables them.
|
|
||||||
for host in self.inventory.hosts.all():
|
|
||||||
host.enabled = False
|
|
||||||
host.save()
|
|
||||||
self.check_inventory_source(inventory_source, initial=False)
|
|
||||||
# Verify that main group is in top level groups (hasn't been added as
|
# Verify that main group is in top level groups (hasn't been added as
|
||||||
# its own child).
|
# its own child).
|
||||||
self.assertTrue(self.group in self.inventory.root_groups)
|
self.assertTrue(self.group in self.inventory.root_groups)
|
||||||
|
|||||||
Reference in New Issue
Block a user