Skip to content

Commit d0d0a72

Browse files
committed
fix pyspark tests
1 parent 76e405b commit d0d0a72

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/test/python/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ weaviate-client==3.26.7
55
pandas
66
testcontainers
77
kafka-python
8+
requests

src/test/python/test_spark.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ def get_connector_version():
3131
return re.search(r"version :=\ \"(.*)\"", version_str).group(1)
3232

3333

34+
def wait_until_ready(max_attempts: int = 10) -> bool:
35+
import requests, time
36+
for i in range(max_attempts):
37+
try:
38+
if requests.get("http://localhost:8080/v1/.well-known/ready", timeout=5).status_code == 200:
39+
return True
40+
except requests.RequestException:
41+
pass
42+
if i < max_attempts - 1:
43+
time.sleep(1)
44+
return False
45+
46+
3447
connector_version = os.environ.get("CONNECTOR_VERSION", get_connector_version())
3548
scala_version = os.environ.get("SCALA_VERSION", "2.13")
3649
weaviate_version = os.environ.get("WEAVIATE_VERSION", "1.32.17")
@@ -69,7 +82,9 @@ def weaviate_client():
6982
"CLUSTER_HOSTNAME": "node1",
7083
"PERSISTENCE_DATA_PATH": "./data"},
7184
)
72-
time.sleep(2)
85+
time.sleep(3)
86+
if not wait_until_ready():
87+
raise RuntimeError("Weaviate is not ready, stopping tests")
7388
wclient = weaviate.Client('http://localhost:8080')
7489
test_class_name = "TestWillBeRemoved"
7590
retries = 3
@@ -83,6 +98,7 @@ def weaviate_client():
8398
time.sleep(1)
8499
yield wclient
85100
client.containers.get(container_name).remove(force=True)
101+
time.sleep(2)
86102

87103

88104
def test_string_arrays(spark: SparkSession, weaviate_client: weaviate.Client):
@@ -446,7 +462,6 @@ def test_kafka_person_data(spark: SparkSession, weaviate_client: weaviate.Client
446462
person_uuids = set([e["id_column"] for e in people])
447463
assert result["data"]["Aggregate"]["Person"][0]["meta"]["count"] == len(person_uuids)
448464

449-
@pytest.mark.skip(reason="Uncomment after migration to python v4")
450465
def test_kafka_streaming_byov_data(spark: SparkSession, weaviate_client: weaviate.Client, tmp_path, kafka_host):
451466
weaviate_client.schema.create_class(byov_schema)
452467
producer = KafkaProducer(bootstrap_servers=[kafka_host],

0 commit comments

Comments
 (0)