forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#2756] Integration test with Gravitino Python client
- Loading branch information
Showing
8 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" | ||
import os | ||
import unittest | ||
import subprocess | ||
import time | ||
|
||
from gravitino import GravitinoClient | ||
from gravitino.constants import TIMEOUT | ||
|
||
# Provide real test environment for the Gravitino Server | ||
class IntegrationTestEnv(unittest.TestCase): | ||
GravitinoHome = None | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
print("Starting integration test environment...") | ||
cls.GravitinoHome = os.environ.get('GRAVITINO_HOME') | ||
if cls.GravitinoHome is None: | ||
print('WARN: Currently, Python Client integration test only runs in the Gradle build environment, ' | ||
'Please execute `./gradlew :clients:client-python:test` in the gravitino project root directory.') | ||
quit(0) | ||
|
||
# Start Gravitino Server | ||
result = subprocess.run([cls.GravitinoHome + '/bin/gravitino.sh', 'start'], capture_output=True, text=True) | ||
print('stdout:', result.stdout) | ||
print('stderr:', result.stderr) | ||
time.sleep(3) | ||
cls.client = GravitinoClient("http://localhost:8090", timeout=TIMEOUT) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
print("Stop integration test environment...") | ||
result = subprocess.run([cls.GravitinoHome + '/bin/gravitino.sh', 'stop'], capture_output=True, text=True) | ||
print('stdout:', result.stdout) | ||
print('stderr:', result.stderr) | ||
time.sleep(3) | ||
|
||
# Determine whether to run from Gradle base on environment variables | ||
# integrated test environment (ITE) | ||
@staticmethod | ||
def notInITE(): | ||
return os.environ.get('GRAVITINO_HOME') is None and os.environ.get('PROJECT_VERSION') is None | ||
|
25 changes: 25 additions & 0 deletions
25
clients/client-python/tests/test_integration_gravitino_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" | ||
|
||
import os | ||
import unittest | ||
from tests.integration_test_env import IntegrationTestEnv | ||
|
||
|
||
@unittest.skipIf(IntegrationTestEnv.notInITE(), | ||
"Currently, Python Client integration test only runs in the Gradle build environment") | ||
class IntegrationTestGravitinoClient(IntegrationTestEnv): | ||
def test_version(self): | ||
versionDTO = self.client.version | ||
assert versionDTO['version'] is not None | ||
|
||
# Get project version from environment (Setting by Gradle build script `build.gradle.kts`), | ||
# But if you directly execute this test in IDEA, maybe can not get it. | ||
projectVersion = os.environ.get('PROJECT_VERSION', '') | ||
|
||
if projectVersion != '': | ||
print(versionDTO['version']) | ||
print(projectVersion) | ||
assert versionDTO['version'] == projectVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters