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

[draft]vkd-heartbeat: Add execution API to vdk heartbeat #116

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions projects/vdk-heartbeat/src/taurus/vdk/heartbeat/hearbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def run(self):

run_test.execute_test()

job_controller.disable_deployment()

job_controller.check_job_execution_finished()
job_controller.start_job_execution()
job_controller.check_job_execution_finished()

self.clean(run_test, job_controller)
log.info("Heartbeat has finished successfully.")
except:
Expand Down
50 changes: 50 additions & 0 deletions projects/vdk-heartbeat/src/taurus/vdk/heartbeat/job_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,56 @@ def deploy_job(self):
"-t", self.config.job_team,
"-p", heartbeat_job_dir,
"-r", "Updating heartbeat data job"])

@LogDecorator(log)
def start_job_execution(self):
log.info("Starting data job execution through API.")
job_execution = self._execute(["execute",
"--start",
"-t", self.config.job_team,
"-n", self.config.job_name,
"-o", "json",
"-u", self.config.control_api_url])

job_execution_id = json.loads(job_execution)["execution_id"]

response = self._execute(["execute",
"--show",
"-t", self.config.job_team,
"-n", self.config.job_name,
"-o", "json",
"-u", self.config.control_api_url,
"--execution-id", str(job_execution_id)])
execution_response = json.loads(response)

assert str(job_execution_id) in str(execution_response), "Failed to start data job execution."
log.info("Execution started successfully.")

@LogDecorator(log)
def check_job_execution_finished(self):
log.info("Checking if data job execution is still running.")
job_execution_running = True
start = time.time()

while job_execution_running and time.time() - start < self.config.RUN_TEST_TIMEOUT_SECONDS:
response = self._execute(["execute",
"--list",
"-t", self.config.job_team,
"-n", self.config.job_name,
"-o" "json",
"-u", self.config.control_api_url])
execution_list = json.loads(response)

job_execution_running = False
for execution in execution_list:
if str(execution["status"]) == "running":
job_execution_running = True
log.info(f"Data job execution is in state {execution['status']}. Will wait 10 seconds and check again.")
break
time.sleep(10)
log.info(f"Data job is running : {job_execution_running}")
assert not job_execution_running, (f"VDK-heartbeat timed out. Job execution {self.config.job_name} " +
f"did not finish in {self.config.RUN_TEST_TIMEOUT_SECONDS}.")

def _update_config_ini(self, heartbeat_job_dir):
config_ini = configparser.ConfigParser()
Expand Down