This is an automated email from the ASF dual-hosted git repository.
diqiu50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 155ad3d857 [#9760] feat(client): disable version check by enviroment
varibles (#9763)
155ad3d857 is described below
commit 155ad3d857cc823274a5fabbb650950ee123c468
Author: FANNG <[email protected]>
AuthorDate: Mon Jan 26 15:39:32 2026 +0900
[#9760] feat(client): disable version check by enviroment varibles (#9763)
### What changes were proposed in this pull request?
disable version check by enviroment varibles
### Why are the changes needed?
Fix: #9760
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
existsing tests
---
.../gravitino/client/GravitinoAdminClient.java | 3 +-
.../apache/gravitino/client/GravitinoClient.java | 2 +-
.../gravitino/client/GravitinoClientBase.java | 32 +++
.../gravitino/client/TestGravitinoAdminClient.java | 87 -------
.../apache/gravitino/client/TestVersionCheck.java | 269 +++++++++++++++++++++
.../gravitino/client/gravitino_client_base.py | 8 +-
.../unittests/test_version_check_disabled_env.py | 70 ++++++
7 files changed, 381 insertions(+), 90 deletions(-)
diff --git
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoAdminClient.java
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoAdminClient.java
index ae89408d27..9272e19c86 100644
---
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoAdminClient.java
+++
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoAdminClient.java
@@ -258,7 +258,8 @@ public class GravitinoAdminClient extends
GravitinoClientBase implements Support
public GravitinoAdminClient build() {
Preconditions.checkArgument(
uri != null && !uri.isEmpty(), "The argument 'uri' must be a valid
URI");
- return new GravitinoAdminClient(uri, authDataProvider, checkVersion,
headers, properties);
+ return new GravitinoAdminClient(
+ uri, authDataProvider, isVersionCheckEnabled(), headers, properties);
}
}
}
diff --git
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
index 4083f2e5ff..d47c88882a 100644
---
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
+++
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
@@ -712,7 +712,7 @@ public class GravitinoClient extends GravitinoClientBase
"The argument 'metalakeName' must be a valid name");
return new GravitinoClient(
- uri, metalakeName, authDataProvider, checkVersion, headers,
properties);
+ uri, metalakeName, authDataProvider, isVersionCheckEnabled(),
headers, properties);
}
}
}
diff --git
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClientBase.java
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClientBase.java
index 7c53dbc1e1..60e6902091 100644
---
a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClientBase.java
+++
b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClientBase.java
@@ -49,6 +49,8 @@ public abstract class GravitinoClientBase implements
Closeable {
/** The REST client to communicate with the REST server */
protected final RESTClient restClient;
+ /** Environment variable to disable version checks. */
+ private static final String VERSION_CHECK_DISABLED_ENV =
"GRAVITINO_VERSION_CHECK_DISABLED";
/** The REST API path for listing metalakes */
protected static final String API_METALAKES_LIST_PATH = "api/metalakes";
/** The REST API path prefix for load a specific metalake */
@@ -222,6 +224,36 @@ public abstract class GravitinoClientBase implements
Closeable {
this.uri = uri;
}
+ /**
+ * Returns whether the client version check is enabled.
+ *
+ * @return {@code true} if version check is enabled, otherwise {@code
false}.
+ */
+ protected boolean isVersionCheckEnabled() {
+ return checkVersion && !isVersionCheckDisabledByEnv();
+ }
+
+ /**
+ * Returns whether the version check is disabled by the environment
variable.
+ *
+ * @return {@code true} if version check is disabled by env, otherwise
{@code false}.
+ */
+ @VisibleForTesting
+ protected boolean isVersionCheckDisabledByEnv() {
+ String envValue = versionCheckDisabledEnvValue();
+ return envValue != null && "true".equalsIgnoreCase(envValue.trim());
+ }
+
+ /**
+ * Returns the raw value of the version check disabling environment
variable.
+ *
+ * @return The environment variable value, or {@code null} if unset.
+ */
+ @VisibleForTesting
+ protected String versionCheckDisabledEnvValue() {
+ return System.getenv(VERSION_CHECK_DISABLED_ENV);
+ }
+
/**
* Sets the simple mode authentication for Gravitino
*
diff --git
a/clients/client-java/src/test/java/org/apache/gravitino/client/TestGravitinoAdminClient.java
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestGravitinoAdminClient.java
index 66960791ec..a7b8984386 100644
---
a/clients/client-java/src/test/java/org/apache/gravitino/client/TestGravitinoAdminClient.java
+++
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestGravitinoAdminClient.java
@@ -27,10 +27,8 @@ import java.util.stream.Collectors;
import org.apache.gravitino.Catalog;
import org.apache.gravitino.MetalakeChange;
import org.apache.gravitino.NameIdentifier;
-import org.apache.gravitino.Version;
import org.apache.gravitino.dto.AuditDTO;
import org.apache.gravitino.dto.MetalakeDTO;
-import org.apache.gravitino.dto.VersionDTO;
import org.apache.gravitino.dto.requests.CatalogCreateRequest;
import org.apache.gravitino.dto.requests.MetalakeCreateRequest;
import org.apache.gravitino.dto.requests.MetalakeUpdatesRequest;
@@ -39,9 +37,7 @@ import org.apache.gravitino.dto.responses.DropResponse;
import org.apache.gravitino.dto.responses.ErrorResponse;
import org.apache.gravitino.dto.responses.MetalakeListResponse;
import org.apache.gravitino.dto.responses.MetalakeResponse;
-import org.apache.gravitino.dto.responses.VersionResponse;
import org.apache.gravitino.exceptions.ConnectionFailedException;
-import org.apache.gravitino.exceptions.GravitinoRuntimeException;
import org.apache.gravitino.exceptions.IllegalNamespaceException;
import org.apache.gravitino.exceptions.MetalakeAlreadyExistsException;
import org.apache.gravitino.exceptions.NoSuchMetalakeException;
@@ -50,9 +46,6 @@ import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.Method;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.mockserver.matchers.Times;
-import org.mockserver.model.HttpRequest;
-import org.mockserver.model.HttpResponse;
public class TestGravitinoAdminClient extends TestBase {
@@ -263,86 +256,6 @@ public class TestGravitinoAdminClient extends TestBase {
excep1.getMessage().contains("Metalake namespace must be non-null and
empty"));
}
- @Test
- public void testGetServerVersion() throws JsonProcessingException {
- String version = "0.1.3";
- String date = "2024-01-03 12:28:33";
- String commitId = "6ef1f9d";
-
- VersionResponse resp = new VersionResponse(new VersionDTO(version, date,
commitId));
- buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
- GravitinoVersion gravitinoVersion = client.serverVersion();
-
- Assertions.assertEquals(version, gravitinoVersion.version());
- Assertions.assertEquals(date, gravitinoVersion.compileDate());
- Assertions.assertEquals(commitId, gravitinoVersion.gitCommit());
- }
-
- @Test
- public void testGetClientVersion() {
- GravitinoVersion version = client.clientVersion();
- Version.VersionInfo currentVersion = Version.getCurrentVersion();
-
- Assertions.assertEquals(currentVersion.version, version.version());
- Assertions.assertEquals(currentVersion.compileDate, version.compileDate());
- Assertions.assertEquals(currentVersion.gitCommit, version.gitCommit());
- }
-
- @Test
- public void testCheckVersionFailed() throws JsonProcessingException {
- String version = "0.1.1";
- String date = "2024-01-03 12:28:33";
- String commitId = "6ef1f9d";
-
- VersionResponse resp = new VersionResponse(new VersionDTO(version, date,
commitId));
- buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
-
- // check the client version is greater than server version
- Assertions.assertThrows(GravitinoRuntimeException.class, () ->
client.checkVersion());
- }
-
- @Test
- public void testCheckVersionSuccess() throws JsonProcessingException {
- VersionResponse resp = new VersionResponse(Version.getCurrentVersionDTO());
- buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
-
- // check the client version is equal to server version
- Assertions.assertDoesNotThrow(() -> client.checkVersion());
-
- String version = "100.1.1-SNAPSHOT";
- String date = "2024-01-03 12:28:33";
- String commitId = "6ef1f9d";
-
- resp = new VersionResponse(new VersionDTO(version, date, commitId));
- buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
-
- // check the client version is less than server version
- Assertions.assertDoesNotThrow(() -> client.checkVersion());
- }
-
- @Test
- public void testUnusedDTOAttribute() throws JsonProcessingException {
- VersionResponse resp = new VersionResponse(Version.getCurrentVersionDTO());
-
- HttpRequest mockRequest =
HttpRequest.request("/api/version").withMethod(Method.GET.name());
- HttpResponse mockResponse =
HttpResponse.response().withStatusCode(HttpStatus.SC_OK);
- String respJson = MAPPER.writeValueAsString(resp);
-
- // add unused attribute for version DTO
- respJson = respJson.replace("\"gitCommit\"",
"\"unused_key\":\"unused_value\", \"gitCommit\"");
- mockResponse = mockResponse.withBody(respJson);
- mockServer.when(mockRequest, Times.exactly(1)).respond(mockResponse);
-
- Assertions.assertDoesNotThrow(
- () -> {
- GravitinoVersion version = client.serverVersion();
- Version.VersionInfo currentVersion = Version.getCurrentVersion();
- Assertions.assertEquals(currentVersion.version, version.version());
- Assertions.assertEquals(currentVersion.compileDate,
version.compileDate());
- Assertions.assertEquals(currentVersion.gitCommit,
version.gitCommit());
- });
- }
-
@Test
public void testTestConnection() throws Exception {
MetalakeDTO mockMetalake =
diff --git
a/clients/client-java/src/test/java/org/apache/gravitino/client/TestVersionCheck.java
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestVersionCheck.java
new file mode 100644
index 0000000000..46e7d485f4
--- /dev/null
+++
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestVersionCheck.java
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.client;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.Collections;
+import org.apache.gravitino.Version;
+import org.apache.gravitino.dto.MetalakeDTO;
+import org.apache.gravitino.dto.VersionDTO;
+import org.apache.gravitino.dto.responses.MetalakeListResponse;
+import org.apache.gravitino.dto.responses.VersionResponse;
+import org.apache.gravitino.exceptions.GravitinoRuntimeException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.Method;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockserver.matchers.Times;
+import org.mockserver.model.HttpRequest;
+import org.mockserver.model.HttpResponse;
+import org.mockserver.verify.VerificationTimes;
+
+public class TestVersionCheck extends TestBase {
+
+ private static String envValue;
+
+ private static class TestClient extends GravitinoClientBase {
+ protected TestClient(String uri, AuthDataProvider authDataProvider,
boolean checkVersion) {
+ super(uri, authDataProvider, checkVersion, Collections.emptyMap(),
Collections.emptyMap());
+ }
+ }
+
+ private static class TestAdminClient extends GravitinoClientBase {
+ protected TestAdminClient(String uri, AuthDataProvider authDataProvider,
boolean checkVersion) {
+ super(uri, authDataProvider, checkVersion, Collections.emptyMap(),
Collections.emptyMap());
+ }
+
+ private int listMetalakesCount() {
+ MetalakeListResponse resp =
+ restClient.get(
+ "api/metalakes",
+ MetalakeListResponse.class,
+ Collections.emptyMap(),
+ ErrorHandlers.metalakeErrorHandler());
+ resp.validate();
+ return resp.getMetalakes().length;
+ }
+ }
+
+ private static class TestBuilder extends
GravitinoClientBase.Builder<TestClient> {
+ protected TestBuilder() {
+ super("http://localhost:12345");
+ }
+
+ protected TestBuilder(String uri) {
+ super(uri);
+ }
+
+ @Override
+ protected String versionCheckDisabledEnvValue() {
+ return TestVersionCheck.envValue;
+ }
+
+ @Override
+ public TestClient build() {
+ return new TestClient(uri, authDataProvider, isVersionCheckEnabled());
+ }
+
+ private boolean isEnabled() {
+ return isVersionCheckEnabled();
+ }
+ }
+
+ private static class TestAdminBuilder extends
GravitinoClientBase.Builder<TestAdminClient> {
+ protected TestAdminBuilder(String uri) {
+ super(uri);
+ }
+
+ @Override
+ protected String versionCheckDisabledEnvValue() {
+ return TestVersionCheck.envValue;
+ }
+
+ @Override
+ public TestAdminClient build() {
+ return new TestAdminClient(uri, authDataProvider,
isVersionCheckEnabled());
+ }
+ }
+
+ @AfterEach
+ public void resetEnvValue() {
+ envValue = null;
+ }
+
+ @Test
+ public void testEnvDisablesVersionCheck() {
+ envValue = "true";
+ TestBuilder builder = new TestBuilder();
+
+ Assertions.assertFalse(builder.isEnabled());
+ }
+
+ @Test
+ public void testEnvIsCaseInsensitive() {
+ envValue = "TrUe";
+ TestBuilder builder = new TestBuilder();
+
+ Assertions.assertFalse(builder.isEnabled());
+ }
+
+ @Test
+ public void testEnvFalseKeepsVersionCheckEnabled() {
+ envValue = "false";
+ TestBuilder builder = new TestBuilder();
+
+ Assertions.assertTrue(builder.isEnabled());
+ }
+
+ @Test
+ public void testExplicitDisableOverridesEnvFalse() {
+ envValue = "false";
+ TestBuilder builder = new TestBuilder();
+ builder.withVersionCheckDisabled();
+
+ Assertions.assertFalse(builder.isEnabled());
+ }
+
+ @Test
+ public void testGetServerVersion() throws JsonProcessingException {
+ String version = "0.1.3";
+ String date = "2024-01-03 12:28:33";
+ String commitId = "6ef1f9d";
+
+ VersionResponse resp = new VersionResponse(new VersionDTO(version, date,
commitId));
+ buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
+ GravitinoVersion gravitinoVersion = client.serverVersion();
+
+ Assertions.assertEquals(version, gravitinoVersion.version());
+ Assertions.assertEquals(date, gravitinoVersion.compileDate());
+ Assertions.assertEquals(commitId, gravitinoVersion.gitCommit());
+ }
+
+ @Test
+ public void testGetClientVersion() {
+ GravitinoVersion version = client.clientVersion();
+ Version.VersionInfo currentVersion = Version.getCurrentVersion();
+
+ Assertions.assertEquals(currentVersion.version, version.version());
+ Assertions.assertEquals(currentVersion.compileDate, version.compileDate());
+ Assertions.assertEquals(currentVersion.gitCommit, version.gitCommit());
+ }
+
+ @Test
+ public void testCheckVersionFailed() throws JsonProcessingException {
+ String version = "0.1.1";
+ String date = "2024-01-03 12:28:33";
+ String commitId = "6ef1f9d";
+
+ VersionResponse resp = new VersionResponse(new VersionDTO(version, date,
commitId));
+ buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
+
+ // check the client version is greater than server version
+ Assertions.assertThrows(GravitinoRuntimeException.class, () ->
client.checkVersion());
+ }
+
+ @Test
+ public void testVersionCheckSkippedByEnv() throws JsonProcessingException {
+ String version = "0.1.1";
+ String date = "2024-01-03 12:28:33";
+ String commitId = "6ef1f9d";
+
+ mockServer.clear(HttpRequest.request("/api/version"));
+ mockServer.clear(HttpRequest.request("/api/metalakes"));
+
+ envValue = "false";
+ TestAdminBuilder builder =
+ new TestAdminBuilder("http://127.0.0.1:" + mockServer.getLocalPort());
+
+ VersionResponse resp = new VersionResponse(new VersionDTO(version, date,
commitId));
+ buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
+
+ try (TestAdminClient testClient = builder.build()) {
+ Assertions.assertThrows(GravitinoRuntimeException.class,
testClient::listMetalakesCount);
+ }
+
+ mockServer.verify(
+ HttpRequest.request("/api/version").withMethod(Method.GET.name()),
+ VerificationTimes.once());
+ mockServer.verify(
+ HttpRequest.request("/api/metalakes").withMethod(Method.GET.name()),
+ VerificationTimes.exactly(0));
+
+ mockServer.clear(HttpRequest.request("/api/version"));
+ mockServer.clear(HttpRequest.request("/api/metalakes"));
+
+ envValue = "true";
+ TestAdminBuilder skipBuilder =
+ new TestAdminBuilder("http://127.0.0.1:" + mockServer.getLocalPort());
+ MetalakeListResponse listResponse = new MetalakeListResponse(new
MetalakeDTO[] {});
+ buildMockResource(Method.GET, "/api/metalakes", null, listResponse,
HttpStatus.SC_OK);
+
+ try (TestAdminClient testClient = skipBuilder.build()) {
+ Assertions.assertEquals(0, testClient.listMetalakesCount());
+ }
+
+ mockServer.verify(
+ HttpRequest.request("/api/version").withMethod(Method.GET.name()),
+ VerificationTimes.exactly(0));
+ }
+
+ @Test
+ public void testCheckVersionSuccess() throws JsonProcessingException {
+ VersionResponse resp = new VersionResponse(Version.getCurrentVersionDTO());
+ buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
+
+ // check the client version is equal to server version
+ Assertions.assertDoesNotThrow(() -> client.checkVersion());
+
+ String version = "100.1.1-SNAPSHOT";
+ String date = "2024-01-03 12:28:33";
+ String commitId = "6ef1f9d";
+
+ resp = new VersionResponse(new VersionDTO(version, date, commitId));
+ buildMockResource(Method.GET, "/api/version", null, resp,
HttpStatus.SC_OK);
+
+ // check the client version is less than server version
+ Assertions.assertDoesNotThrow(() -> client.checkVersion());
+ }
+
+ @Test
+ public void testUnusedDTOAttribute() throws JsonProcessingException {
+ VersionResponse resp = new VersionResponse(Version.getCurrentVersionDTO());
+
+ HttpRequest mockRequest =
HttpRequest.request("/api/version").withMethod(Method.GET.name());
+ HttpResponse mockResponse =
HttpResponse.response().withStatusCode(HttpStatus.SC_OK);
+ String respJson = MAPPER.writeValueAsString(resp);
+
+ // add unused attribute for version DTO
+ respJson = respJson.replace("\"gitCommit\"",
"\"unused_key\":\"unused_value\", \"gitCommit\"");
+ mockResponse = mockResponse.withBody(respJson);
+ mockServer.when(mockRequest, Times.exactly(1)).respond(mockResponse);
+
+ Assertions.assertDoesNotThrow(
+ () -> {
+ GravitinoVersion version = client.serverVersion();
+ Version.VersionInfo currentVersion = Version.getCurrentVersion();
+ Assertions.assertEquals(currentVersion.version, version.version());
+ Assertions.assertEquals(currentVersion.compileDate,
version.compileDate());
+ Assertions.assertEquals(currentVersion.gitCommit,
version.gitCommit());
+ });
+ }
+}
diff --git a/clients/client-python/gravitino/client/gravitino_client_base.py
b/clients/client-python/gravitino/client/gravitino_client_base.py
index cc4078aab8..ebf14cad82 100644
--- a/clients/client-python/gravitino/client/gravitino_client_base.py
+++ b/clients/client-python/gravitino/client/gravitino_client_base.py
@@ -17,6 +17,7 @@
import logging
import configparser
+import os
import os.path
from gravitino.auth.auth_data_provider import AuthDataProvider
@@ -52,6 +53,7 @@ class GravitinoClientBase:
"""The REST API path prefix for load a specific metalake"""
CLIENT_VERSION_HEADER = "X-Client-Version"
+ VERSION_CHECK_DISABLED_ENV = "GRAVITINO_VERSION_CHECK_DISABLED"
def __init__(
self,
@@ -71,9 +73,13 @@ class GravitinoClientBase:
request_headers=new_headers,
client_config=client_config,
)
- if check_version:
+ if check_version and not self._is_version_check_disabled_by_env():
self.check_version()
+ def _is_version_check_disabled_by_env(self) -> bool:
+ env_value = os.getenv(self.VERSION_CHECK_DISABLED_ENV)
+ return env_value is not None and env_value.strip().lower() == "true"
+
def load_metalake(self, name: str) -> GravitinoMetalake:
"""Loads a specific Metalake from the Gravitino API.
diff --git
a/clients/client-python/tests/unittests/test_version_check_disabled_env.py
b/clients/client-python/tests/unittests/test_version_check_disabled_env.py
new file mode 100644
index 0000000000..4bc5e0ee79
--- /dev/null
+++ b/clients/client-python/tests/unittests/test_version_check_disabled_env.py
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# pylint: disable=wrong-import-position
+
+import os
+import unittest
+from unittest.mock import Mock, patch
+
+from gravitino.client.gravitino_admin_client import GravitinoAdminClient
+from gravitino.client.gravitino_client_base import GravitinoClientBase
+
+
+class TestVersionCheckDisabledEnv(unittest.TestCase):
+ def test_env_true_disables_version_check(self):
+ with patch.dict(os.environ, {"GRAVITINO_VERSION_CHECK_DISABLED":
"true"}):
+ with patch.object(
+ GravitinoClientBase,
+ "get_client_version",
+ autospec=True,
+ return_value=Mock(version=lambda: None),
+ ):
+ with patch.object(
+ GravitinoClientBase, "check_version", autospec=True
+ ) as check_version:
+ GravitinoAdminClient(uri="http://localhost:8090")
+ check_version.assert_not_called()
+
+ def test_env_false_keeps_version_check(self):
+ with patch.dict(os.environ, {"GRAVITINO_VERSION_CHECK_DISABLED":
"false"}):
+ with patch.object(
+ GravitinoClientBase,
+ "get_client_version",
+ autospec=True,
+ return_value=Mock(version=lambda: None),
+ ):
+ with patch.object(
+ GravitinoClientBase, "check_version", autospec=True
+ ) as check_version:
+ GravitinoAdminClient(uri="http://localhost:8090")
+ check_version.assert_called_once()
+
+ def test_env_unset_keeps_version_check(self):
+ with patch.dict(os.environ, {}, clear=False):
+ os.environ.pop("GRAVITINO_VERSION_CHECK_DISABLED", None)
+ with patch.object(
+ GravitinoClientBase,
+ "get_client_version",
+ autospec=True,
+ return_value=Mock(version=lambda: None),
+ ):
+ with patch.object(
+ GravitinoClientBase, "check_version", autospec=True
+ ) as check_version:
+ GravitinoAdminClient(uri="http://localhost:8090")
+ check_version.assert_called_once()