summaryrefslogtreecommitdiff
path: root/tests/unit/test_content_cache.py
diff options
context:
space:
mode:
authorHaw Loeung <[email protected]>2023-04-06 03:52:59 +0000
committerCanonical IS Mergebot <[email protected]>2023-04-06 03:52:59 +0000
commitafd864ff3ac8956ba535f932663a0a34394a28dd (patch)
tree7c0005b3250f21392eac34f78f5ed6022508e32f /tests/unit/test_content_cache.py
parent3de032c4dd6771519affd5e46f83ec3636914d46 (diff)
parente2fdc72b287caee5a773d750c6622d2fe57f2582 (diff)
Add support for overriding backend site name
Reviewed-on: https://code.launchpad.net/~hloeung/content-cache-charm/+git/content-cache-charm/+merge/440446 Reviewed-by: Paul Collins <[email protected]>
Diffstat (limited to 'tests/unit/test_content_cache.py')
-rw-r--r--tests/unit/test_content_cache.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
index 8d392b3..9dd21b7 100644
--- a/tests/unit/test_content_cache.py
+++ b/tests/unit/test_content_cache.py
@@ -481,6 +481,33 @@ site1.local:
got = f.read()
self.assertEqual(got, want)
+ # Overriding backend-site-name
+ config = '''
+site1.local:
+ locations:
+ /:
+ backend-check-path: '/swift/v1/AUTH_aabbccdd001122/mybucket/index.html'
+ backend-site-name: 'objectstorage.ps5.internal'
+ backend-tls: true
+ backends: ['10.0.1.10:443']
+ tls-cert-bundle-path: /var/lib/haproxy/certs
+'''
+ self.mock_config.return_value = {'haproxy_hard_stop_after': '15m', 'max_connections': 8192, 'sites': config}
+ with mock.patch('lib.haproxy.HAProxyConf.conf_file', new_callable=mock.PropertyMock) as mock_conf_file:
+ mock_conf_file.return_value = os.path.join(self.tmpdir, 'haproxy.cfg')
+ opened_ports.return_value = ['443/tcp']
+ content_cache.configure_haproxy()
+
+ with open(
+ 'tests/unit/files/content_cache_rendered_haproxy_test_output_override_backend_site.txt',
+ 'r',
+ encoding='utf-8',
+ ) as f:
+ want = f.read()
+ with open(os.path.join(self.tmpdir, 'haproxy.cfg'), 'r', encoding='utf-8') as f:
+ got = f.read()
+ self.assertEqual(got, want)
+
@freezegun.freeze_time("2019-03-22", tz_offset=0)
@mock.patch('charmhelpers.core.hookenv.opened_ports')
@mock.patch('charms.reactive.set_flag')