Fix repeated unnecessarily 'os.makedirs()' in test_recon_cron.py
Return value instead of sys.exit() if an exception occurs RelatedChange: I4ca91e3b519a99f3096b95b286779a183e936eb7 Change-Id: I9ebbf5b9f4216c3eab5ab42a0014a750ca28980b
This commit is contained in:
@@ -50,7 +50,7 @@ def main():
|
|||||||
except Exception:
|
except Exception:
|
||||||
print("Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1])
|
print("Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1])
|
||||||
print("ex: swift-recon-cron /etc/swift/object-server.conf")
|
print("ex: swift-recon-cron /etc/swift/object-server.conf")
|
||||||
sys.exit(1)
|
return 1
|
||||||
conf = readconf(conf_path, 'filter:recon')
|
conf = readconf(conf_path, 'filter:recon')
|
||||||
device_dir = conf.get('devices', '/srv/node')
|
device_dir = conf.get('devices', '/srv/node')
|
||||||
recon_cache_path = conf.get('recon_cache_path', DEFAULT_RECON_CACHE_PATH)
|
recon_cache_path = conf.get('recon_cache_path', DEFAULT_RECON_CACHE_PATH)
|
||||||
@@ -70,4 +70,4 @@ def main():
|
|||||||
msg = 'Exception during recon-cron while accessing devices'
|
msg = 'Exception during recon-cron while accessing devices'
|
||||||
logger.exception(msg)
|
logger.exception(msg)
|
||||||
print('%s: %s' % (msg, err))
|
print('%s: %s' % (msg, err))
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
@@ -32,11 +32,8 @@ class TestReconCron(TestCase):
|
|||||||
|
|
||||||
def test_get_async_count(self):
|
def test_get_async_count(self):
|
||||||
device_dir = os.path.join(self.temp_dir, 'device')
|
device_dir = os.path.join(self.temp_dir, 'device')
|
||||||
os.makedirs(device_dir)
|
|
||||||
device_index = os.path.join(device_dir, '1')
|
device_index = os.path.join(device_dir, '1')
|
||||||
os.makedirs(device_index)
|
|
||||||
async_dir = os.path.join(device_index, ASYNCDIR_BASE)
|
async_dir = os.path.join(device_index, ASYNCDIR_BASE)
|
||||||
os.makedirs(async_dir)
|
|
||||||
entry1 = os.path.join(async_dir, 'entry1')
|
entry1 = os.path.join(async_dir, 'entry1')
|
||||||
entry2 = os.path.join(async_dir, 'entry2')
|
entry2 = os.path.join(async_dir, 'entry2')
|
||||||
os.makedirs(entry1)
|
os.makedirs(entry1)
|
||||||
|
Reference in New Issue
Block a user