mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-20 05:23:44 +00:00
Add job stopped task info (#648)
This commit is contained in:
@ -3,55 +3,57 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
from uuid import UUID
|
||||
from onefuzztypes.primitives import Region, Container
|
||||
|
||||
from onefuzztypes.enums import (
|
||||
TaskType,
|
||||
ContainerType,
|
||||
ErrorCode,
|
||||
OS,
|
||||
Architecture,
|
||||
ContainerType,
|
||||
ErrorCode,
|
||||
NodeState,
|
||||
)
|
||||
from onefuzztypes.models import (
|
||||
TaskConfig,
|
||||
TaskDetails,
|
||||
TaskContainers,
|
||||
TaskState,
|
||||
Error,
|
||||
UserInfo,
|
||||
JobConfig,
|
||||
Report,
|
||||
BlobRef,
|
||||
TaskType,
|
||||
)
|
||||
from onefuzztypes.events import (
|
||||
Event,
|
||||
EventPing,
|
||||
EventCrashReported,
|
||||
EventFileAdded,
|
||||
EventTaskCreated,
|
||||
EventTaskStopped,
|
||||
EventTaskFailed,
|
||||
EventProxyCreated,
|
||||
EventProxyDeleted,
|
||||
EventProxyFailed,
|
||||
EventPoolCreated,
|
||||
EventPoolDeleted,
|
||||
EventScalesetCreated,
|
||||
EventScalesetFailed,
|
||||
EventScalesetDeleted,
|
||||
EventJobCreated,
|
||||
EventJobStopped,
|
||||
EventTaskStateUpdated,
|
||||
EventNodeStateUpdated,
|
||||
EventNodeCreated,
|
||||
EventNodeDeleted,
|
||||
EventNodeHeartbeat,
|
||||
EventNodeStateUpdated,
|
||||
EventPing,
|
||||
EventPoolCreated,
|
||||
EventPoolDeleted,
|
||||
EventProxyCreated,
|
||||
EventProxyDeleted,
|
||||
EventProxyFailed,
|
||||
EventScalesetCreated,
|
||||
EventScalesetDeleted,
|
||||
EventScalesetFailed,
|
||||
EventTaskCreated,
|
||||
EventTaskFailed,
|
||||
EventTaskHeartbeat,
|
||||
get_event_type,
|
||||
EventTaskStateUpdated,
|
||||
EventTaskStopped,
|
||||
EventType,
|
||||
JobTaskStopped,
|
||||
get_event_type,
|
||||
)
|
||||
from onefuzztypes.models import (
|
||||
BlobRef,
|
||||
Error,
|
||||
JobConfig,
|
||||
Report,
|
||||
TaskConfig,
|
||||
TaskContainers,
|
||||
TaskDetails,
|
||||
UserInfo,
|
||||
)
|
||||
from onefuzztypes.primitives import Container, PoolName, Region
|
||||
from onefuzztypes.webhooks import WebhookMessage
|
||||
|
||||
EMPTY_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
@ -68,7 +70,7 @@ def typed(depth: int, title: str, content: str, data_type: str) -> None:
|
||||
print(f"{'#' * depth} {title}\n\n```{data_type}\n{content}\n```\n")
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
task_config = TaskConfig(
|
||||
job_id=UUID(int=0),
|
||||
task=TaskDetails(
|
||||
@ -79,13 +81,13 @@ def main():
|
||||
target_options=[],
|
||||
),
|
||||
containers=[
|
||||
TaskContainers(name="my-setup", type=ContainerType.setup),
|
||||
TaskContainers(name="my-inputs", type=ContainerType.inputs),
|
||||
TaskContainers(name="my-crashes", type=ContainerType.crashes),
|
||||
TaskContainers(name=Container("my-setup"), type=ContainerType.setup),
|
||||
TaskContainers(name=Container("my-inputs"), type=ContainerType.inputs),
|
||||
TaskContainers(name=Container("my-crashes"), type=ContainerType.crashes),
|
||||
],
|
||||
tags={},
|
||||
)
|
||||
examples = [
|
||||
examples: List[Event] = [
|
||||
EventPing(ping_id=UUID(int=0)),
|
||||
EventTaskCreated(
|
||||
job_id=UUID(int=0),
|
||||
@ -131,12 +133,15 @@ def main():
|
||||
error=Error(code=ErrorCode.PROXY_FAILED, errors=["example error message"]),
|
||||
),
|
||||
EventPoolCreated(
|
||||
pool_name="example", os=OS.linux, arch=Architecture.x86_64, managed=True
|
||||
pool_name=PoolName("example"),
|
||||
os=OS.linux,
|
||||
arch=Architecture.x86_64,
|
||||
managed=True,
|
||||
),
|
||||
EventPoolDeleted(pool_name="example"),
|
||||
EventPoolDeleted(pool_name=PoolName("example")),
|
||||
EventScalesetCreated(
|
||||
scaleset_id=UUID(int=0),
|
||||
pool_name="example",
|
||||
pool_name=PoolName("example"),
|
||||
vm_sku="Standard_D2s_v3",
|
||||
image="Canonical:UbuntuServer:18.04-LTS:latest",
|
||||
region=Region("eastus"),
|
||||
@ -144,12 +149,12 @@ def main():
|
||||
),
|
||||
EventScalesetFailed(
|
||||
scaleset_id=UUID(int=0),
|
||||
pool_name="example",
|
||||
pool_name=PoolName("example"),
|
||||
error=Error(
|
||||
code=ErrorCode.UNABLE_TO_RESIZE, errors=["example error message"]
|
||||
),
|
||||
),
|
||||
EventScalesetDeleted(scaleset_id=UUID(int=0), pool_name="example"),
|
||||
EventScalesetDeleted(scaleset_id=UUID(int=0), pool_name=PoolName("example")),
|
||||
EventJobCreated(
|
||||
job_id=UUID(int=0),
|
||||
config=JobConfig(
|
||||
@ -167,11 +172,26 @@ def main():
|
||||
build="build 1",
|
||||
duration=24,
|
||||
),
|
||||
task_info=[
|
||||
JobTaskStopped(
|
||||
task_id=UUID(int=0),
|
||||
task_type=TaskType.libfuzzer_fuzz,
|
||||
error=Error(
|
||||
code=ErrorCode.TASK_FAILED, errors=["example error message"]
|
||||
),
|
||||
),
|
||||
JobTaskStopped(
|
||||
task_id=UUID(int=1),
|
||||
task_type=TaskType.libfuzzer_coverage,
|
||||
),
|
||||
],
|
||||
),
|
||||
EventNodeCreated(machine_id=UUID(int=0), pool_name="example"),
|
||||
EventNodeDeleted(machine_id=UUID(int=0), pool_name="example"),
|
||||
EventNodeCreated(machine_id=UUID(int=0), pool_name=PoolName("example")),
|
||||
EventNodeDeleted(machine_id=UUID(int=0), pool_name=PoolName("example")),
|
||||
EventNodeStateUpdated(
|
||||
machine_id=UUID(int=0), pool_name="example", state=NodeState.setting_up
|
||||
machine_id=UUID(int=0),
|
||||
pool_name=PoolName("example"),
|
||||
state=NodeState.setting_up,
|
||||
),
|
||||
EventCrashReported(
|
||||
container=Container("container-name"),
|
||||
@ -196,11 +216,12 @@ def main():
|
||||
),
|
||||
),
|
||||
EventFileAdded(container=Container("container-name"), filename="example.txt"),
|
||||
EventNodeHeartbeat(machine_id=UUID(int=0), pool_name="example"),
|
||||
EventNodeHeartbeat(machine_id=UUID(int=0), pool_name=PoolName("example")),
|
||||
EventTaskHeartbeat(task_id=UUID(int=0), job_id=UUID(int=0), config=task_config),
|
||||
]
|
||||
|
||||
for event in Event.__args__:
|
||||
# works around `mypy` not handling that Union has `__args__`
|
||||
for event in getattr(Event, "__args__", []):
|
||||
seen = False
|
||||
for value in examples:
|
||||
if isinstance(value, event):
|
||||
@ -227,7 +248,8 @@ def main():
|
||||
layer(
|
||||
1,
|
||||
"Webhook Events",
|
||||
"This document describes the basic webhook event subscriptions available in OneFuzz",
|
||||
"This document describes the basic webhook event subscriptions "
|
||||
"available in OneFuzz",
|
||||
)
|
||||
layer(
|
||||
2,
|
||||
|
@ -5,12 +5,12 @@
|
||||
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional, Union
|
||||
from typing import List, Optional, Union
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from pydantic import BaseModel, Extra, Field
|
||||
|
||||
from .enums import OS, Architecture, NodeState, TaskState
|
||||
from .enums import OS, Architecture, NodeState, TaskState, TaskType
|
||||
from .models import AutoScaleConfig, Error, JobConfig, Report, TaskConfig, UserInfo
|
||||
from .primitives import Container, PoolName, Region
|
||||
from .responses import BaseResponse
|
||||
@ -42,10 +42,17 @@ class EventJobCreated(BaseEvent):
|
||||
user_info: Optional[UserInfo]
|
||||
|
||||
|
||||
class JobTaskStopped(BaseModel):
|
||||
task_id: UUID
|
||||
task_type: TaskType
|
||||
error: Optional[Error]
|
||||
|
||||
|
||||
class EventJobStopped(BaseEvent):
|
||||
job_id: UUID
|
||||
config: JobConfig
|
||||
user_info: Optional[UserInfo]
|
||||
task_info: Optional[List[JobTaskStopped]]
|
||||
|
||||
|
||||
class EventTaskCreated(BaseEvent):
|
||||
|
Reference in New Issue
Block a user