Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for job to be ready before cancelling #1126

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/integration/test_launchers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from time import sleep
import time

from feast.pyspark.abc import RetrievalJobParameters, SparkJobStatus
from feast.pyspark.abc import RetrievalJobParameters, SparkJobStatus, SparkJob
from feast.pyspark.launchers.gcloud import DataprocClusterLauncher

from .fixtures.job_parameters import customer_entity # noqa: F401
Expand All @@ -9,6 +9,13 @@
from .fixtures.launchers import dataproc_launcher # noqa: F401


def wait_for_job_status(job: SparkJob, expected_status: SparkJobStatus, max_retry: int = 4, retry_interval: int = 5):
for i in range(max_retry):
if job.get_status() == expected_status:
return
time.sleep(retry_interval)
raise ValueError(f"Timeout waiting for job status to become {expected_status.name}")

def test_dataproc_job_api(
dataproc_launcher: DataprocClusterLauncher, # noqa: F811
dataproc_retrieval_job_params: RetrievalJobParameters, # noqa: F811
Expand All @@ -27,5 +34,6 @@ def test_dataproc_job_api(
job.get_id() for job in dataproc_launcher.list_jobs(include_terminated=False)
]
assert job_id in active_job_ids
wait_for_job_status(retrieved_job, SparkJobStatus.IN_PROGRESS)
retrieved_job.cancel()
assert retrieved_job.get_status() == SparkJobStatus.FAILED