mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
[test_ec2*] cloud integration test updates
To support parallel cloud test execution, create and provide a random string to
cloud integration tests. The variable 'resource_prefix' can be used in cloud
roles and during resource cleanup to safely create/destroy cloud-based
resources.
Additional changes include:
* The roles test_ec2_key and test_ec2_group were updated to use to
{{resource_prefix}}.
* Additionally, the Makefile was updated to set resource_prefix to a random
string. The Makefile will also use 'resource_prefix' during cloud_cleanup.
* All test_ec2* roles were updated to add 'setup_ec2' as a role dependency.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
INVENTORY ?= inventory
|
||||
VARS_FILE ?= integration_config.yml
|
||||
|
||||
# Create a semi-random string for use when testing cloud-based resources
|
||||
ifndef CLOUD_RESOURCE_PREFIX
|
||||
CLOUD_RESOURCE_PREFIX := $(shell python -c "import string,random; print 'ansible-testing-' + ''.join(random.choice(string.ascii_letters + string.digits) for _ in xrange(8));")
|
||||
endif
|
||||
|
||||
all: non_destructive destructive check_mode test_hash
|
||||
|
||||
non_destructive:
|
||||
@@ -21,24 +26,24 @@ cloud: amazon rackspace
|
||||
cloud_cleanup: amazon_cleanup rackspace_cleanup
|
||||
|
||||
amazon_cleanup:
|
||||
python cleanup_ec2.py -y
|
||||
python cleanup_ec2.py -y --match="^$(CLOUD_RESOURCE_PREFIX)"
|
||||
|
||||
rackspace_cleanup:
|
||||
@echo "FIXME - cleanup_rax.py not yet implemented"
|
||||
@#python cleanup_rax.py -y
|
||||
@# python cleanup_rax.py -y --match="^$(CLOUD_RESOURCE_PREFIX)"
|
||||
|
||||
credentials.yml:
|
||||
@echo "No credentials.yml file found. A file named 'credentials.yml' is needed to provide credentials needed to run cloud tests. See sample 'credentials.template' file."
|
||||
@exit 1
|
||||
|
||||
amazon: credentials.yml
|
||||
ansible-playbook amazon.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @credentials.yml -v $(TEST_FLAGS) ; \
|
||||
ansible-playbook amazon.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @credentials.yml -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
|
||||
RC=$$? ; \
|
||||
make amazon_cleanup ; \
|
||||
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make amazon_cleanup ; \
|
||||
exit $$RC;
|
||||
|
||||
rackspace: credentials.yml
|
||||
ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @credentials.yml -v $(TEST_FLAGS) ; \
|
||||
ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @credentials.yml -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
|
||||
RC=$$? ; \
|
||||
make rackspace_cleanup ; \
|
||||
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make rackspace_cleanup ; \
|
||||
exit $$RC;
|
||||
|
||||
Reference in New Issue
Block a user