From 600e9c86722301cbe881f8a7e8a9706bb41ffacc Mon Sep 17 00:00:00 2001 From: Ksenia Demina Date: Fri, 19 Jul 2013 14:32:55 +0400 Subject: [PATCH] Add delay in swift-bench With enable write affinity, it's necessary to wait until replication has moved things to their proper homes before running delete request. With write affinity turned on, only nodes in local region will get the object right after PUT request. Fix bug #1198926 Change-Id: I3aa8933d45c47a010ae05561e12176479e7c9bcc --- bin/swift-bench | 3 +++ swift/common/bench.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/bin/swift-bench b/bin/swift-bench index b24345c873..04a0428eef 100755 --- a/bin/swift-bench +++ b/bin/swift-bench @@ -50,6 +50,7 @@ CONF_DEFAULTS = { 'devices': 'sdb1', # space-sep list 'log_level': 'INFO', 'timeout': '10', + 'delay': '0', 'bench_clients': [], } @@ -117,6 +118,8 @@ if __name__ == '__main__': help='If set, will not delete the objects created') parser.add_option('-V', '--auth_version', dest='auth_version', help='Authentication version') + parser.add_option('-d', '--delay', dest='delay', + help='Delay before delete requests in seconds') if len(sys.argv) == 1: parser.print_help() diff --git a/swift/common/bench.py b/swift/common/bench.py index bc45d809c8..0a46be2d76 100644 --- a/swift/common/bench.py +++ b/swift/common/bench.py @@ -352,6 +352,7 @@ class BenchController(object): self.delete = config_true_value(conf.delete) self.gets = int(conf.num_gets) self.aborted = False + self.delay = int(self.conf.delay) def sigint1(self, signum, frame): if self.delete: @@ -378,6 +379,11 @@ class BenchController(object): self.running = gets gets.run() if self.delete: + if self.delay != 0: + self.logger.info('Delay before ' + 'DELETE request %s sec' + % self.delay) + time.sleep(self.delay) dels = BenchDELETE(self.logger, self.conf, self.names) self.running = dels dels.run()