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

Dependencies weren't fulfilled fix #5731

Merged
merged 3 commits into from
Jul 17, 2023
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
86 changes: 42 additions & 44 deletions avocado/core/task/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from avocado.core.exceptions import JobFailFast
from avocado.core.task.runtime import RuntimeTaskStatus
from avocado.core.teststatus import STATUSES_NOT_OK
from avocado.core.utils import messages

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -192,25 +193,14 @@ async def _send_finished_tasks_message(self, terminate_tasks, reason):
for terminated_task in terminate_tasks:
task_id = str(terminated_task.task.identifier)
job_id = terminated_task.task.job_id
encoding = "utf-8"
log_message = {
"status": "running",
"type": "log",
"log": f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} | "
f"Runner error occurred: {reason}".encode(encoding),
"encoding": encoding,
"time": time.monotonic(),
"id": task_id,
"job_id": job_id,
}
finish_message = {
"status": "finished",
"result": "interrupted",
"fail_reason": f"Test interrupted: {reason}",
"time": time.monotonic(),
"id": task_id,
"job_id": job_id,
}
log_message = messages.LogMessage.get(
f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} | Runner error occurred: {reason}",
id=task_id,
job_id=job_id,
)
finish_message = messages.FinishedMessage.get(
"interrupted", f"Test interrupted: {reason}", id=task_id, job_id=job_id
)
try:
current_status, _ = self._state_machine._status_repo._status[task_id]
except KeyError:
Expand Down Expand Up @@ -276,6 +266,25 @@ async def triage(self):
LOG.debug(
'Task "%s" has failed dependencies', runtime_task.task.identifier
)
task_id = str(runtime_task.task.identifier)
job_id = runtime_task.task.job_id
reason = "Dependency was not fulfilled."
start_message = messages.StartedMessage.get(
output_dir=runtime_task.task.runnable.output_dir,
id=task_id,
job_id=job_id,
)
log_message = messages.LogMessage.get(
f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} | {reason}",
id=task_id,
job_id=job_id,
)
finish_message = messages.FinishedMessage.get(
"skip", reason, id=task_id, job_id=job_id
)
self._state_machine._status_repo.process_message(start_message)
self._state_machine._status_repo.process_message(log_message)
self._state_machine._status_repo.process_message(finish_message)
runtime_task.result = "fail"
await self._state_machine.finish_task(
runtime_task, RuntimeTaskStatus.FAIL_TRIAGE
Expand All @@ -298,31 +307,20 @@ async def triage(self):
if is_task_in_cache:
task_id = str(runtime_task.task.identifier)
job_id = runtime_task.task.job_id
encoding = "utf-8"
start_message = {
"status": "started",
"time": time.monotonic(),
"output_dir": runtime_task.task.runnable.output_dir,
"id": task_id,
"job_id": job_id,
}
log_message = {
"status": "running",
"type": "log",
"log": f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} | "
f"Dependency fulfilled from cache.".encode(encoding),
"encoding": encoding,
"time": time.monotonic(),
"id": task_id,
"job_id": job_id,
}
finish_message = {
"status": "finished",
"result": "pass",
"time": time.monotonic(),
"id": task_id,
"job_id": job_id,
}
start_message = messages.StartedMessage.get(
output_dir=runtime_task.task.runnable.output_dir,
id=task_id,
job_id=job_id,
)
log_message = messages.LogMessage.get(
f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} | "
f"Dependency fulfilled from cache.",
id=task_id,
job_id=job_id,
)
finish_message = messages.FinishedMessage.get(
"pass", id=task_id, job_id=job_id
)
self._state_machine._status_repo.process_message(start_message)
self._state_machine._status_repo.process_message(log_message)
self._state_machine._status_repo.process_message(finish_message)
Expand Down
16 changes: 8 additions & 8 deletions avocado/core/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get(
class_name=None,
fail_class=None,
traceback=None,
**kwargs,
): # pylint: disable=W0221
"""Creates finished message with all necessary information.

Expand All @@ -79,14 +80,13 @@ def get(
:return: finished message
:rtype: dict
"""
return super().get(
result=result,
fail_reason=fail_reason,
returncode=returncode,
class_name=class_name,
fail_class=fail_class,
traceback=traceback,
)
kwargs["result"] = result
kwargs["fail_reason"] = fail_reason
kwargs["returncode"] = returncode
kwargs["class_name"] = class_name
kwargs["fail_class"] = fail_class
kwargs["traceback"] = traceback
return super().get(**kwargs)


class GenericRunningMessage(GenericMessage):
Expand Down
4 changes: 4 additions & 0 deletions selftests/functional/serial/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def test_single_fail(self):
"SKIP 1",
result.stdout_text,
)
self.assertIn(
"SKIP: Dependency was not fulfilled.",
result.stdout_text,
)
self.assertNotIn(
"-foo-bar-",
result.stdout_text,
Expand Down