Merge "probe-tests: Avoid a DuplicateSectionError on py3"

This commit is contained in:
Zuul 2020-10-07 00:11:43 +00:00 committed by Gerrit Code Review
commit 73c0c72735

View File

@ -327,11 +327,19 @@ class TestProxyServerReloadBase(TestWSGIServerProcessHandling):
self.new_swift_conf_path = self.swift_conf_path + '.new' self.new_swift_conf_path = self.swift_conf_path + '.new'
self.saved_swift_conf_path = self.swift_conf_path + '.orig' self.saved_swift_conf_path = self.swift_conf_path + '.orig'
shutil.copy(self.swift_conf_path, self.saved_swift_conf_path) shutil.copy(self.swift_conf_path, self.saved_swift_conf_path)
shutil.copy(self.swift_conf_path, self.new_swift_conf_path) with open(self.swift_conf_path, 'r') as rfh:
with open(self.new_swift_conf_path, 'a+') as fh: config = rfh.read()
fh.seek(0, os.SEEK_END) section_header = '\n[swift-constraints]\n'
fh.write('\n[swift-constraints]\nmax_header_size = 8191\n') if section_header in config:
fh.flush() config = config.replace(
section_header,
section_header + 'max_header_size = 8191\n',
1)
else:
config += section_header + 'max_header_size = 8191\n'
with open(self.new_swift_conf_path, 'w') as wfh:
wfh.write(config)
wfh.flush()
def tearDown(self): def tearDown(self):
shutil.move(self.saved_swift_conf_path, self.swift_conf_path) shutil.move(self.saved_swift_conf_path, self.swift_conf_path)