Merge pull request #4971 from erjohnso/devel
fixes #4954 plus updates for gcutil/v1beta16 tests
This commit is contained in:
commit
82a9387532
3 changed files with 26 additions and 26 deletions
|
@ -121,13 +121,13 @@ EXAMPLES = '''
|
|||
zone: us-central1-a
|
||||
tasks:
|
||||
- name: Launch instances
|
||||
local_action: gce instance_names=${names} machine_type=${machine_type}
|
||||
image=${image} zone=${zone}
|
||||
local_action: gce instance_names={{names}} machine_type={{machine_type}}
|
||||
image={{image}} zone={{zone}}
|
||||
register: gce
|
||||
- name: Wait for SSH to come up
|
||||
local_action: wait_for host=${item.public_ip} port=22 delay=10
|
||||
local_action: wait_for host={{item.public_ip}} port=22 delay=10
|
||||
timeout=60 state=started
|
||||
with_items: ${gce.instance_data}
|
||||
with_items: {{gce.instance_data}}
|
||||
|
||||
- name: Configure instance(s)
|
||||
hosts: launched
|
||||
|
@ -144,7 +144,7 @@ EXAMPLES = '''
|
|||
local_action:
|
||||
module: gce
|
||||
state: 'absent'
|
||||
instance_names: ${gce.instance_names}
|
||||
instance_names: {{gce.instance_names}}
|
||||
|
||||
'''
|
||||
|
||||
|
@ -211,8 +211,8 @@ def get_instance_info(inst):
|
|||
'metadata': metadata,
|
||||
'name': inst.name,
|
||||
'network': netname,
|
||||
'private_ip': inst.private_ip[0],
|
||||
'public_ip': inst.public_ip[0],
|
||||
'private_ip': inst.private_ips[0],
|
||||
'public_ip': inst.public_ips[0],
|
||||
'status': ('status' in inst.extra) and inst.extra['status'] or None,
|
||||
'tags': ('tags' in inst.extra) and inst.extra['tags'] or [],
|
||||
'zone': ('zone' in inst.extra) and inst.extra['zone'].name or None,
|
||||
|
@ -344,7 +344,7 @@ def main():
|
|||
instance_names = dict(),
|
||||
machine_type = dict(default='n1-standard-1'),
|
||||
metadata = dict(),
|
||||
name = dict(default='gce'),
|
||||
name = dict(),
|
||||
network = dict(default='default'),
|
||||
persistent_boot_disk = dict(type='bool', choices=BOOLEANS, default=False),
|
||||
state = dict(choices=['active', 'present', 'absent', 'deleted'],
|
||||
|
|
|
@ -114,8 +114,12 @@ class GceInventory(object):
|
|||
def get_gce_driver(self):
|
||||
'''Determine GCE authorization settings and return libcloud driver.'''
|
||||
|
||||
gce_ini_default_path = os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)), "gce.ini")
|
||||
gce_ini_path = os.environ.get('GCE_INI_PATH', gce_ini_default_path)
|
||||
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
config.read(os.path.dirname(os.path.realpath(__file__)) + '/gce.ini')
|
||||
config.read(gce_ini_path)
|
||||
|
||||
# the GCE params in 'secrets.py' will override these
|
||||
secrets_path = config.get('gce', 'libcloud_secrets')
|
||||
|
@ -180,8 +184,8 @@ class GceInventory(object):
|
|||
'gce_id': inst.id,
|
||||
'gce_image': inst.image,
|
||||
'gce_machine_type': inst.size,
|
||||
'gce_private_ip': inst.private_ip[0],
|
||||
'gce_public_ip': inst.public_ip[0],
|
||||
'gce_private_ip': inst.private_ips[0],
|
||||
'gce_public_ip': inst.public_ips[0],
|
||||
'gce_name': inst.name,
|
||||
'gce_description': inst.extra['description'],
|
||||
'gce_status': inst.extra['status'],
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
# 9) Set your PROJECT variable below
|
||||
# 10) Run and time the tests and log output, take ~30 minutes to run
|
||||
# $ time stdbuf -oL python test/gce_tests.py 2>&1 | tee log
|
||||
#
|
||||
# Last update: gcutil-1.11.0 and v1beta16
|
||||
|
||||
# Set this to your test Project ID
|
||||
PROJECT="google.com:erjohnso"
|
||||
|
@ -66,7 +68,7 @@ DNAME2="aaaaa-ansible-disk2"
|
|||
DNAME6="aaaaa-ansible-inst6"
|
||||
DNAME7="aaaaa-ansible-inst7"
|
||||
USE_PD="true"
|
||||
KERNEL="https://www.googleapis.com/compute/v1beta15/projects/google/global/kernels/gce-v20130813"
|
||||
KERNEL="https://www.googleapis.com/compute/v1beta16/projects/google/global/kernels/gce-no-conn-track-v20130813"
|
||||
|
||||
# instances
|
||||
INAME="aaaaa-ansible-inst"
|
||||
|
@ -77,7 +79,7 @@ INAME5="aaaaa-ansible-inst5"
|
|||
INAME6="aaaaa-ansible-inst6"
|
||||
INAME7="aaaaa-ansible-inst7"
|
||||
TYPE="n1-standard-1"
|
||||
IMAGE="https://www.googleapis.com/compute/v1beta15/projects/debian-cloud/global/images/debian-7-wheezy-v20130816"
|
||||
IMAGE="https://www.googleapis.com/compute/v1beta16/projects/debian-cloud/global/images/debian-7-wheezy-v20131014"
|
||||
NETWORK="default"
|
||||
SCOPES="https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/devstorage.full_control"
|
||||
|
||||
|
@ -108,7 +110,7 @@ import sys
|
|||
test_cases = [
|
||||
{'id': '01', 'desc': 'Detach / Delete disk tests',
|
||||
'setup': ['gcutil addinstance "%s" --wait_until_running --zone=%s --machine_type=%s --network=%s --service_account_scopes="%s" --image="%s" --persistent_boot_disk=%s' % (INAME, ZONE, TYPE, NETWORK, SCOPES, IMAGE, USE_PD),
|
||||
'gcutil adddisk "%s" --size_gb=2 --zone=%s' % (DNAME, ZONE)],
|
||||
'gcutil adddisk "%s" --size_gb=2 --zone=%s --wait_until_complete' % (DNAME, ZONE)],
|
||||
|
||||
'tests': [
|
||||
{'desc': 'DETACH_ONLY but disk not found [success]',
|
||||
|
@ -206,8 +208,7 @@ test_cases = [
|
|||
'setup': ['gcutil addinstance "%s" --zone=%s --machine_type=%s --network=%s --service_account_scopes="%s" --image="%s" --persistent_boot_disk=%s' % (INAME2, ZONE, TYPE, NETWORK, SCOPES, IMAGE, USE_PD),
|
||||
'gcutil addinstance "%s" --zone=%s --machine_type=%s --network=%s --service_account_scopes="%s" --image="%s" --persistent_boot_disk=%s' % (INAME, ZONE, "g1-small", NETWORK, SCOPES, IMAGE, USE_PD),
|
||||
'gcutil adddisk "%s" --size_gb=2 --zone=%s' % (DNAME, ZONE),
|
||||
'gcutil adddisk "%s" --size_gb=2 --zone=%s' % (DNAME2, ZONE),
|
||||
'sleep 10'],
|
||||
'gcutil adddisk "%s" --size_gb=2 --zone=%s --wait_until_complete' % (DNAME2, ZONE),],
|
||||
'tests': [
|
||||
{'desc': 'CREATE_AND_ATTACH "string" for size_gb [FAIL]',
|
||||
'm': 'gce_pd',
|
||||
|
@ -264,9 +265,7 @@ test_cases = [
|
|||
},
|
||||
{'desc': 'CREATE_AND_ATTACH attach too many disks to inst [FAIL]',
|
||||
'setup': ['gcutil adddisk aa-disk-dummy --size_gb=2 --zone=%s' % (ZONE),
|
||||
'sleep 10',
|
||||
'gcutil adddisk aa-disk-dummy2 --size_gb=2 --zone=%s' % (ZONE),
|
||||
'sleep 10',
|
||||
'gcutil adddisk aa-disk-dummy2 --size_gb=2 --zone=%s --wait_until_complete' % (ZONE),
|
||||
'gcutil attachdisk --disk=aa-disk-dummy --zone=%s %s' % (ZONE, INAME),
|
||||
'sleep 5'],
|
||||
'peek_before': ["gcutil --format=csv listinstances --zone=%s --filter=\"name eq 'aaaa.*'\"" % (ZONE)],
|
||||
|
@ -337,7 +336,9 @@ test_cases = [
|
|||
},
|
||||
|
||||
{'id': '05', 'desc': 'Create instances',
|
||||
'setup': [],
|
||||
'setup': ['gcutil adddisk --source_image=%s --zone=%s %s --wait_until_complete' % (IMAGE, ZONE, DNAME7),
|
||||
'gcutil addinstance boo --wait_until_running --zone=%s --machine_type=%s --network=%s --disk=%s,mode=READ_WRITE,boot --kernel=%s' % (ZONE,TYPE,NETWORK,DNAME7,KERNEL),
|
||||
],
|
||||
'tests': [
|
||||
{'desc': 'CREATE_INSTANCE invalid image arg [FAIL]',
|
||||
'm': 'gce',
|
||||
|
@ -410,18 +411,13 @@ test_cases = [
|
|||
'r': '127.0.0.1 | success >> {"changed": true, "instance_data": [{"image": null, "machine_type": "n1-standard-1", "metadata": {}, "name": "%s", "network": "default", "private_ip": "10.240.178.140", "public_ip": "173.255.121.176", "status": "RUNNING", "tags": [], "zone": "%s"}], "name": "%s", "state": "present", "zone": "%s"}' % (INAME3, ZONE, INAME3, ZONE),
|
||||
},
|
||||
{'desc': 'CREATE_INSTANCE instance with root pd, that already exists [success]',
|
||||
'setup': ['gcutil adddisk --source_image=%s --zone=%s %s' % (IMAGE, ZONE, DNAME6),
|
||||
'sleep 10'],
|
||||
'setup': ['gcutil adddisk --source_image=%s --zone=%s %s --wait_until_complete' % (IMAGE, ZONE, DNAME6),],
|
||||
'strip_numbers': True,
|
||||
'm': 'gce',
|
||||
'a': 'name=%s zone=%s persistent_boot_disk=yes' % (INAME6, ZONE),
|
||||
'r': '127.0.0.1 | success >> {"changed": true, "instance_data": [{"image": null, "machine_type": "n1-standard-1", "metadata": {}, "name": "%s", "network": "default", "private_ip": "10.240.178.140", "public_ip": "173.255.121.176", "status": "RUNNING", "tags": [], "zone": "%s"}], "name": "%s", "state": "present", "zone": "%s"}' % (INAME6, ZONE, INAME6, ZONE),
|
||||
},
|
||||
{'desc': 'CREATE_INSTANCE instance with root pd attached to other inst [FAIL]',
|
||||
'setup': ['gcutil adddisk --source_image=%s --zone=%s %s' % (IMAGE, ZONE, DNAME7),
|
||||
'sleep 10',
|
||||
'gcutil addinstance boo --wait_until_running --zone=%s --machine_type=%s --network=%s --disk=%s,mode=READ_WRITE,boot --kernel=%s' % (ZONE,TYPE,NETWORK,DNAME7,KERNEL),
|
||||
],
|
||||
'm': 'gce',
|
||||
'a': 'name=%s zone=%s persistent_boot_disk=yes' % (INAME7, ZONE),
|
||||
'r': '127.0.0.1 | FAILED >> {"failed": true, "msg": "Unexpected error attempting to create instance %s, error: The disk resource \'projects/%s/zones/%s/disks/%s\' is already being used in read-write mode"}' % (INAME7,PROJECT,ZONE,DNAME7),
|
||||
|
|
Loading…
Reference in a new issue