forked from TrueCloudLab/s3-tests
Rework nuke_buckets
Nuke all buckets on the master, sync, and then nuke any remaining buckets on non-master regions. Signed-off-by: Joe Buck <jbbuck@gmail.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
parent
e54c700bbd
commit
d0ad2aad20
1 changed files with 43 additions and 23 deletions
|
@ -7,6 +7,8 @@ import os
|
|||
import random
|
||||
import string
|
||||
|
||||
from .utils import region_sync_meta
|
||||
|
||||
s3 = bunch.Bunch()
|
||||
config = bunch.Bunch()
|
||||
targets = bunch.Bunch()
|
||||
|
@ -49,8 +51,7 @@ def choose_bucket_prefix(template, max_len=30):
|
|||
)
|
||||
|
||||
|
||||
def nuke_prefixed_buckets(prefix):
|
||||
for name, conn in s3.items():
|
||||
def nuke_prefixed_buckets_on_conn(prefix, name, conn):
|
||||
print 'Cleaning buckets from connection {name} prefix {prefix!r}.'.format(
|
||||
name=name,
|
||||
prefix=prefix,
|
||||
|
@ -75,6 +76,25 @@ def nuke_prefixed_buckets(prefix):
|
|||
# seems like we're not the owner of the bucket; ignore
|
||||
pass
|
||||
|
||||
def nuke_prefixed_buckets(prefix):
|
||||
# First, delete all buckets on the master connection
|
||||
for name, conn in s3.items():
|
||||
#if conn == s3[targets.main.master]:
|
||||
if conn == targets.main.master.connection:
|
||||
print 'Deleting buckets on {name} (master)'.format(name=name)
|
||||
nuke_prefixed_buckets_on_conn(prefix, name, conn)
|
||||
|
||||
# Then sync to propagate deletes to secondaries
|
||||
region_sync_meta(targets.main, targets.main.master.connection)
|
||||
print 'region-sync in nuke_prefixed_buckets'
|
||||
|
||||
# Now delete remaining buckets on any other connection
|
||||
for name, conn in s3.items():
|
||||
#if conn != s3[targets.main.master]:
|
||||
if conn != targets.main.master.connection:
|
||||
print 'Deleting buckets on {name} (non-master)'.format(name=name)
|
||||
nuke_prefixed_buckets_on_conn(prefix, name, conn)
|
||||
|
||||
print 'Done with cleanup of test buckets.'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue