summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-09-05 16:37:55 +0000
committerGerrit Code Review <review@openstack.org>2022-09-05 16:37:55 +0000
commitcb0392ca6b91999c093f458da01c17bd4e4820f8 (patch)
treece24f18b76f4188a064fee9a464581fbd9594818
parent00972f3b09f57d1c715facacf3dd945c0608ebac (diff)
parentb64623daeb9e0f94fd5322a1c7e47403f187e7ed (diff)
downloadtooz-cb0392ca6b91999c093f458da01c17bd4e4820f8.tar.gz
Merge "Support etcd3gw api version"3.1.0
-rw-r--r--tooz/drivers/etcd3gw.py6
-rw-r--r--tooz/tests/drivers/test_etcd3gw.py7
2 files changed, 12 insertions, 1 deletions
diff --git a/tooz/drivers/etcd3gw.py b/tooz/drivers/etcd3gw.py
index d426b74..b1ad633 100644
--- a/tooz/drivers/etcd3gw.py
+++ b/tooz/drivers/etcd3gw.py
@@ -180,6 +180,7 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor):
================== =======
Name Default
================== =======
+ api_version v3alpha
ca_cert None
cert_key None
cert_cert None
@@ -198,6 +199,9 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor):
#: Default port used if none provided (4001 or 2379 are the common ones).
DEFAULT_PORT = 2379
+ #: Default api version if none provided
+ DEFAULT_API_VERSION = "v3alpha"
+
GROUP_PREFIX = b"tooz/groups/"
def __init__(self, member_id, parsed_url, options):
@@ -210,12 +214,14 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor):
cert_key = options.get('cert_key')
cert_cert = options.get('cert_cert')
timeout = int(options.get('timeout', self.DEFAULT_TIMEOUT))
+ api_version = options.get("api_version", self.DEFAULT_API_VERSION)
self.client = etcd3gw.client(host=host,
port=port,
protocol=protocol,
ca_cert=ca_cert,
cert_key=cert_key,
cert_cert=cert_cert,
+ api_path="/" + api_version + "/",
timeout=timeout)
self.lock_timeout = int(options.get('lock_timeout', timeout))
self.membership_timeout = int(options.get(
diff --git a/tooz/tests/drivers/test_etcd3gw.py b/tooz/tests/drivers/test_etcd3gw.py
index a182b77..3b8a09c 100644
--- a/tooz/tests/drivers/test_etcd3gw.py
+++ b/tooz/tests/drivers/test_etcd3gw.py
@@ -34,16 +34,19 @@ class TestEtcd3Gw(testcase.TestCase):
'ca_cert': None,
'cert_key': None,
'cert_cert': None,
+ 'api_path': (
+ "/" + etcd3gw_driver.Etcd3Driver.DEFAULT_API_VERSION + "/"),
'timeout': etcd3gw_driver.Etcd3Driver.DEFAULT_TIMEOUT},
{'coord_url': ('etcd3+https://my_host:666?ca_cert=/my/ca_cert&'
'cert_key=/my/cert_key&cert_cert=/my/cert_cert&'
- 'timeout=42'),
+ 'timeout=42&api_version=v3'),
'protocol': 'https',
'host': 'my_host',
'port': 666,
'ca_cert': '/my/ca_cert',
'cert_key': '/my/cert_key',
'cert_cert': '/my/cert_cert',
+ 'api_path': '/v3/',
'timeout': 42})
@ddt.unpack
@mock.patch('etcd3gw.client')
@@ -56,6 +59,7 @@ class TestEtcd3Gw(testcase.TestCase):
ca_cert,
cert_key,
cert_cert,
+ api_path,
timeout):
tooz.coordination.get_coordinator(coord_url, self.FAKE_MEMBER_ID)
mock_etcd3gw_client.assert_called_with(host=host,
@@ -64,4 +68,5 @@ class TestEtcd3Gw(testcase.TestCase):
ca_cert=ca_cert,
cert_key=cert_key,
cert_cert=cert_cert,
+ api_path=api_path,
timeout=timeout)