Skip to content

Commit

Permalink
Fixed Java and standard tests (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben authored Jun 7, 2024
1 parent bcbb1c2 commit 223040a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
10 changes: 9 additions & 1 deletion test_container/tests/test/java/java_modules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import os
import json
from pathlib import Path
import shutil
import subprocess
Expand All @@ -14,6 +15,11 @@
from exasol_python_test_framework.udf import useData, expectedFailure
from exasol_python_test_framework.udf.udf_debug import UdfDebugger

def bucket_fs_port_from_environment_info_file():
with open("/environment_info.json", "r") as f:
env_info_dict = json.load(f)
return env_info_dict["database_info"]["ports"]["bucketfs"]

script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
java_udf_dir = script_dir / "resources/java_udf"

Expand Down Expand Up @@ -50,10 +56,12 @@ def test_udf_jar_is_module_java17(self):
with zipfile.ZipFile(self.java_udf_jar_java17, 'r') as zip:
assert "module-info.class" in zip.namelist()


def upload_to_bucketfs(self, path: Path) -> str:
docker_db_container = self.env.get_docker_db_container()
docker_db_ip = self.env.get_ip_address_of_container(docker_db_container)
upload_url = f"http://{docker_db_ip}:2580/myudfs/{path.name}"
bucketfs_port = bucket_fs_port_from_environment_info_file()
upload_url = f"http://{docker_db_ip}:{bucketfs_port}/myudfs/{path.name}"
username = "w"
password = "write"
print(f"Trying to upload to {upload_url}")
Expand Down
11 changes: 10 additions & 1 deletion test_container/tests/test/java/test_hadoop_etl_udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
from io import BytesIO
import tarfile
import unittest
import json

from exasol_python_test_framework import udf
from exasol_python_test_framework import docker_db_environment
from exasol_python_test_framework.udf.udf_debug import UdfDebugger


def bucket_fs_port_from_environment_info_file():
with open("/environment_info.json", "r") as f:
env_info_dict = json.load(f)
return env_info_dict["database_info"]["ports"]["bucketfs"]


@unittest.skip("""ClassLoader.class.getDeclaredField("usr_paths") in addDirToJavaLibraryPath doesn't work in Java 17""")
class JavaHive(udf.TestCase):

Expand Down Expand Up @@ -115,7 +123,8 @@ def add_containers_to_hosts_file_in_docker_db(self, env):
def upload_hadoop_etl_udf_jar_to_bucket_fs(self, env):
docker_db_container = env.get_docker_db_container()
docker_db_ip = env.get_ip_address_of_container(docker_db_container)
upload_url = "http://{docker_db_ip}:6583/myudfs/hadoop-etl-udfs-v0.0.1-apache-2.8.5-3.0.0.jar".format(
bucketfs_port = bucket_fs_port_from_environment_info_file()
upload_url = f"http://{docker_db_ip}:{bucketfs_port}/myudfs/hadoop-etl-udfs-v0.0.1-apache-2.8.5-3.0.0.jar".format(
docker_db_ip=docker_db_ip)
username = "w"
password = "write" # TOOD hardcoded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env python3

import json

from exasol_python_test_framework import udf


def db_port_from_environment_info_file():
with open("/environment_info.json", "r") as f:
env_info_dict = json.load(f)
return env_info_dict["database_info"]["ports"]["database"]


class WebsocketAPIConnectionTest(udf.TestCase):
# TODO use dsn and credentials injected into the testcase
connection = "localhost:8888"
db_port = db_port_from_environment_info_file()
connection = f"localhost:{db_port}"
user = "sys"
pwd = "exasol"

Expand Down
10 changes: 9 additions & 1 deletion test_container/tests/test/standard-flavor/all/pyexasol.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/usr/bin/env python3

import json

from exasol_python_test_framework import udf


def db_port_from_environment_info_file():
with open("/environment_info.json", "r") as f:
env_info_dict = json.load(f)
return env_info_dict["database_info"]["ports"]["database"]


class PyexsolConnectionTest(udf.TestCase):
# TODO use dsn and credentials injected into the testcase
db_port = db_port_from_environment_info_file()
host = "localhost"
port = "8888"
port = str(db_port)
user = "sys"
pwd = "exasol"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env python3

from exasol_python_test_framework import udf
import json
import os


def db_port_from_environment_info_file():
with open("/environment_info.json", "r") as f:
env_info_dict = json.load(f)
return env_info_dict["database_info"]["ports"]["database"]


class WebsocketAPIConnectionTest(udf.TestCase):
connection = "localhost:8888"
db_port = db_port_from_environment_info_file()
connection = f"localhost:{db_port}"
user = "sys"
pwd = "exasol"

Expand Down

0 comments on commit 223040a

Please sign in to comment.