s3 integration tests (#28396)
* Replace pause in integration tests with until. Use resource prefix instead of generating a random number Only try to delete keys if they exist * Add alias to tests
This commit is contained in:
parent
e0a5b7d7ea
commit
bdbe5337c6
4 changed files with 21 additions and 26 deletions
|
@ -353,7 +353,8 @@ def delete_bucket(module, s3, bucket):
|
||||||
# if there are contents then we need to delete them before we can delete the bucket
|
# if there are contents then we need to delete them before we can delete the bucket
|
||||||
for keys in paginated_list(s3, Bucket=bucket):
|
for keys in paginated_list(s3, Bucket=bucket):
|
||||||
formatted_keys = [{'Key': key} for key in keys]
|
formatted_keys = [{'Key': key} for key in keys]
|
||||||
s3.delete_objects(Bucket=bucket, Delete={'Objects': formatted_keys})
|
if formatted_keys:
|
||||||
|
s3.delete_objects(Bucket=bucket, Delete={'Objects': formatted_keys})
|
||||||
s3.delete_bucket(Bucket=bucket)
|
s3.delete_bucket(Bucket=bucket)
|
||||||
return True
|
return True
|
||||||
except botocore.exceptions.ClientError as e:
|
except botocore.exceptions.ClientError as e:
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
cloud/aws
|
cloud/aws
|
||||||
|
posix/ci/cloud/aws
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
---
|
---
|
||||||
# defaults file for s3
|
# defaults file for s3
|
||||||
|
bucket_name: '{{resource_prefix}}'
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
---
|
---
|
||||||
# tasks file for test_s3
|
# tasks file for test_s3
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: generate random name for the bucket name
|
|
||||||
command: bash -c 'echo ansible_test_$RANDOM'
|
|
||||||
register: bucket
|
|
||||||
# ============================================================
|
|
||||||
# ============================================================
|
|
||||||
- name: test create bucket
|
- name: test create bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: create
|
mode: create
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
aws_secret_key: "{{ ec2_secret_key }}"
|
aws_secret_key: "{{ ec2_secret_key }}"
|
||||||
|
@ -21,7 +16,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: trying to create a bucket name that already exists
|
- name: trying to create a bucket name that already exists
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: create
|
mode: create
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
aws_secret_key: "{{ ec2_secret_key }}"
|
aws_secret_key: "{{ ec2_secret_key }}"
|
||||||
|
@ -51,7 +46,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test putting an object in the bucket
|
- name: test putting an object in the bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: put
|
mode: put
|
||||||
src: "{{ tmp1.path }}"
|
src: "{{ tmp1.path }}"
|
||||||
object: delete.txt
|
object: delete.txt
|
||||||
|
@ -67,16 +62,12 @@
|
||||||
- result.changed == True
|
- result.changed == True
|
||||||
- result.msg == "PUT operation complete"
|
- result.msg == "PUT operation complete"
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: wait a few seconds before continuing
|
|
||||||
pause:
|
|
||||||
seconds: 3
|
|
||||||
# ============================================================
|
|
||||||
- name: create a second temp file to download the object from the bucket
|
- name: create a second temp file to download the object from the bucket
|
||||||
tempfile:
|
tempfile:
|
||||||
register: tmp2
|
register: tmp2
|
||||||
- name: test get object
|
- name: test get object
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: get
|
mode: get
|
||||||
dest: "{{ tmp2.path }}"
|
dest: "{{ tmp2.path }}"
|
||||||
object: delete.txt
|
object: delete.txt
|
||||||
|
@ -86,6 +77,7 @@
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: 3
|
delay: 3
|
||||||
register: result
|
register: result
|
||||||
|
until: "result.msg == 'GET operation complete'"
|
||||||
- name: get the stat of the file so we can compare the checksums
|
- name: get the stat of the file so we can compare the checksums
|
||||||
stat:
|
stat:
|
||||||
path: "{{ tmp2.path }}"
|
path: "{{ tmp2.path }}"
|
||||||
|
@ -96,13 +88,9 @@
|
||||||
that:
|
that:
|
||||||
- file1stat.stat.checksum == file2stat.stat.checksum
|
- file1stat.stat.checksum == file2stat.stat.checksum
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: wait a few seconds before continuing
|
|
||||||
pause:
|
|
||||||
seconds: 3
|
|
||||||
# ============================================================
|
|
||||||
- name: test geturl of the object
|
- name: test geturl of the object
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: geturl
|
mode: geturl
|
||||||
object: delete.txt
|
object: delete.txt
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
|
@ -111,6 +99,7 @@
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: 3
|
delay: 3
|
||||||
register: result
|
register: result
|
||||||
|
until: result.changed
|
||||||
- name: assert we have the object's url
|
- name: assert we have the object's url
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -119,7 +108,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test getstr of the object
|
- name: test getstr of the object
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: getstr
|
mode: getstr
|
||||||
object: delete.txt
|
object: delete.txt
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
|
@ -136,7 +125,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test list to get all objects in the bucket
|
- name: test list to get all objects in the bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: list
|
mode: list
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
|
@ -152,7 +141,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test delobj to just delete an object in the bucket
|
- name: test delobj to just delete an object in the bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: delobj
|
mode: delobj
|
||||||
object: delete.txt
|
object: delete.txt
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
|
@ -169,12 +158,15 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test delete bucket
|
- name: test delete bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout }}"
|
bucket: "{{ bucket_name }}"
|
||||||
mode: delete
|
mode: delete
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
aws_secret_key: "{{ ec2_secret_key }}"
|
aws_secret_key: "{{ ec2_secret_key }}"
|
||||||
register: result
|
register: result
|
||||||
|
retries: 3
|
||||||
|
delay: 3
|
||||||
|
until: result.changed
|
||||||
- name: assert that changed is True
|
- name: assert that changed is True
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -191,7 +183,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test create a bucket with a dot in the name
|
- name: test create a bucket with a dot in the name
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout + '.bucket' }}"
|
bucket: "{{ bucket_name + '.bucket' }}"
|
||||||
mode: create
|
mode: create
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
|
@ -204,7 +196,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test delete a bucket with a dot in the name
|
- name: test delete a bucket with a dot in the name
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout + '.bucket' }}"
|
bucket: "{{ bucket_name + '.bucket' }}"
|
||||||
mode: delete
|
mode: delete
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
|
@ -217,7 +209,7 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: test delete a nonexistent bucket
|
- name: test delete a nonexistent bucket
|
||||||
s3:
|
s3:
|
||||||
bucket: "{{ bucket.stdout + '.bucket' }}"
|
bucket: "{{ bucket_name + '.bucket' }}"
|
||||||
mode: delete
|
mode: delete
|
||||||
security_token: "{{security_token}}"
|
security_token: "{{security_token}}"
|
||||||
aws_access_key: "{{ ec2_access_key }}"
|
aws_access_key: "{{ ec2_access_key }}"
|
||||||
|
|
Loading…
Reference in a new issue