Skip to content

Commit 0826e0f

Browse files
authored
ci: add test_compat_client_standalone (#18631)
* nox * update * update * java * testng * arm * jdbc test * fix
1 parent a3bce5a commit 0826e0f

File tree

17 files changed

+397
-0
lines changed

17 files changed

+397
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Test compat client"
2+
description: "Running client compat tests in standalone mode"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- uses: ./.github/actions/setup_test
8+
with:
9+
artifacts: meta,query
10+
11+
- uses: wntrblm/[email protected]
12+
13+
- name: Run databend with Standalone mode
14+
shell: bash
15+
env:
16+
STORAGE_ALLOW_INSECURE: true
17+
run: bash ./scripts/ci/deploy/databend-query-standalone.sh
18+
19+
- name: Run test
20+
shell: bash
21+
run: nox -f tests/nox/noxfile.py

.github/workflows/reuse.linux.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ jobs:
166166
- uses: ./.github/actions/test_compat_meta_meta
167167
timeout-minutes: 20
168168

169+
test_compat_client_standalone:
170+
needs: [ build, check ]
171+
runs-on:
172+
- self-hosted
173+
- "${{ inputs.runner_arch }}"
174+
- Linux
175+
- 2c8g
176+
- "${{ inputs.runner_provider }}"
177+
steps:
178+
- uses: actions/checkout@v4
179+
- uses: ./.github/actions/test_compat_client_standalone
180+
timeout-minutes: 20
181+
169182
test_logs:
170183
needs: [ build, check ]
171184
runs-on:

tests/nox/cache/jdbc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.jar

tests/nox/cache/lib/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.jar

tests/nox/java_client/perpare.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import argparse
2+
from pathlib import Path
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
6+
7+
def main():
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument("version")
10+
args = parser.parse_args()
11+
12+
download_jdbc(args.version)
13+
download_testng()
14+
create_user()
15+
16+
17+
def download_jdbc(version):
18+
19+
files = [f"databend-jdbc-{version}.jar", f"databend-jdbc-{version}-tests.jar"]
20+
21+
for filename in files:
22+
target = Path(f"cache/jdbc/{filename}")
23+
if target.exists():
24+
print(f"{filename} exists")
25+
continue
26+
target.parent.mkdir(parents=True, exist_ok=True)
27+
28+
print(f"start download {filename}")
29+
resp = requests.get(
30+
f"https://github.com/databendlabs/databend-jdbc/releases/download/v{version}/{filename}"
31+
)
32+
resp.raise_for_status()
33+
target.write_bytes(resp.content)
34+
35+
36+
def create_user():
37+
requests.post(
38+
"http://localhost:8000/v1/query/",
39+
auth=HTTPBasicAuth("root", ""),
40+
headers={"Content-Type": "application/json"},
41+
json={"sql": "CREATE USER IF NOT EXISTS databend IDENTIFIED BY 'databend'"},
42+
).raise_for_status()
43+
requests.post(
44+
"http://localhost:8000/v1/query/",
45+
auth=HTTPBasicAuth("root", ""),
46+
headers={"Content-Type": "application/json"},
47+
json={"sql": "GRANT ALL ON *.* TO databend"},
48+
).raise_for_status()
49+
50+
51+
def download_testng():
52+
urls = [
53+
"https://repo.maven.apache.org/maven2/org/testng/testng/7.11.0/testng-7.11.0.jar",
54+
"https://repo1.maven.org/maven2/com/vdurmont/semver4j/3.1.0/semver4j-3.1.0.jar",
55+
"https://repo1.maven.org/maven2/org/jcommander/jcommander/1.83/jcommander-1.83.jar",
56+
"https://repo1.maven.org/maven2/org/locationtech/jts/jts-core/1.19.0/jts-core-1.19.0.jar",
57+
"https://repo1.maven.org/maven2/org/slf4j/slf4j-api/2.0.16/slf4j-api-2.0.16.jar",
58+
"https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/2.0.13/slf4j-simple-2.0.13.jar",
59+
"https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.11.3/junit-platform-console-standalone-1.11.3.jar",
60+
]
61+
62+
for url in urls:
63+
splited = url.rsplit("/", 1)
64+
filename = splited[1]
65+
target = Path(f"cache/lib/{filename}")
66+
if target.exists():
67+
print(f"{filename} exists")
68+
continue
69+
target.parent.mkdir(parents=True, exist_ok=True)
70+
71+
print(f"start download {filename}")
72+
resp = requests.get(url)
73+
resp.raise_for_status()
74+
target.write_bytes(resp.content)
75+
76+
77+
if __name__ == "__main__":
78+
main()

tests/nox/java_client/testng.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.1.dtd" >
2+
<suite name="DatabendJdbcTests" verbose="10">
3+
<test name="AllTests">
4+
<groups>
5+
<run>
6+
<exclude name="FLAKY"/>
7+
</run>
8+
</groups>
9+
<classes>
10+
<class name="com.databend.jdbc.TestBasicDriver"/>
11+
<class name="com.databend.jdbc.TestDatabendDatabaseMetaData"/>
12+
<class name="com.databend.jdbc.TestDatabendParameterMetaData"/>
13+
<class name="com.databend.jdbc.TestHeartbeat"/>
14+
<class name="com.databend.jdbc.TestTransaction"/>
15+
<class name="com.databend.jdbc.TestTempTable"/>
16+
17+
<!-- <class name="com.databend.jdbc.TestPresignContext"/> -->
18+
<!-- <class name="com.databend.jdbc.TestDatabendDriverUri"/> -->
19+
<!-- <class name="com.databend.jdbc.TestFileTransfer"/> -->
20+
<!-- <class name="com.databend.jdbc.TestMultiHost"/> -->
21+
<!-- <class name="com.databend.jdbc.TestPrepareStatement"/> -->
22+
</classes>
23+
</test>
24+
</suite>

tests/nox/noxfile.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import nox
2+
3+
4+
PYTHON_DRIVER = ["0.28.1", "0.28.2"]
5+
6+
7+
@nox.session
8+
@nox.parametrize("driver_version", PYTHON_DRIVER)
9+
def python_client(session, driver_version):
10+
11+
session.install("pytest")
12+
session.install(f"databend-driver=={driver_version}")
13+
session.run("pytest", "python_client")
14+
15+
16+
JDBC_DRIVER = ["0.4.0"]
17+
18+
19+
@nox.session
20+
@nox.parametrize("driver_version", JDBC_DRIVER)
21+
def java_client(session, driver_version):
22+
23+
session.install("requests")
24+
session.run("python", "java_client/perpare.py", driver_version)
25+
run_jdbc_test(session, driver_version)
26+
27+
28+
def run_jdbc_test(session, driver_version):
29+
session.run(
30+
"java",
31+
"-cp",
32+
":".join(
33+
[
34+
"cache/lib/*",
35+
f"cache/jdbc/databend-jdbc-{driver_version}.jar",
36+
f"cache/jdbc/databend-jdbc-{driver_version}-tests.jar",
37+
]
38+
),
39+
"org.testng.TestNG",
40+
"java_client/testng.xml",
41+
external=True,
42+
)

tests/nox/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.pytest.ini_options]
2+
addopts = "-s -vv"

tests/nox/python_client/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from databend_driver import BlockingDatabendClient
2+
import importlib
3+
4+
from .utils import DATABEND_DSL
5+
6+
7+
def test_version():
8+
# client = BlockingDatabendClient(DATABEND_DSL)
9+
# print(client.get_conn().version()) server version
10+
print(importlib.metadata.version("databend_driver"))
11+
12+
13+
def test_basic_select():
14+
15+
client = BlockingDatabendClient(DATABEND_DSL)
16+
17+
cursor = client.cursor()
18+
cursor.execute("SELECT * FROM numbers(10)")
19+
rows = cursor.fetchall()
20+
assert [row.values()[0] for row in rows] == [x for x in range(10)]
21+
cursor.close()

0 commit comments

Comments
 (0)