-
Notifications
You must be signed in to change notification settings - Fork 360
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
WX-1110[risk=low] Added endpoint to fetch failed tasks by workflow id #7165
Changes from 15 commits
b0efcf5
978304d
bec897b
c3b5f0e
53bd3f8
e6ba45e
3f648a3
ff6b590
5e71659
55559ef
4b62b90
f8fa61e
f5bcb3e
6f4137b
27d9461
c6105cc
4235421
ccc601b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -510,6 +510,26 @@ paths: | |
$ref: '#/responses/NotFound' | ||
'500': | ||
$ref: '#/responses/ServerError' | ||
'/api/workflows/{version}/{id}/metadata/failed-jobs': | ||
get: | ||
operationId: failed-jobs | ||
summary: Get call-level metadata of failed tasks for a specified workflow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work for subworkflows as well? If not this should probably say "root workflow." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point (only works for root workflows). I'll update the description |
||
parameters: | ||
- $ref: '#/parameters/versionParam' | ||
- $ref: '#/parameters/singleId' | ||
tags: | ||
- Workflows | ||
responses: | ||
'200': | ||
description: Successful request | ||
schema: | ||
$ref: '#/definitions/WorkflowMetadataResponse' | ||
'400': | ||
$ref: '#/responses/BadRequest' | ||
'404': | ||
$ref: '#/responses/NotFound' | ||
'500': | ||
$ref: '#/responses/ServerError' | ||
'/api/workflows/{version}/{id}/metadata': | ||
get: | ||
operationId: metadata | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
events: Seq[MetadataEvent], | ||
expectedRes: String, | ||
metadataBuilderActorName: String, | ||
failedTasks: Boolean = false | ||
): Future[Assertion] = { | ||
val mockReadMetadataWorkerActor = TestProbe("mockReadMetadataWorkerActor") | ||
def readMetadataWorkerMaker = () => mockReadMetadataWorkerActor.props | ||
|
@@ -45,13 +46,17 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
props = MetadataBuilderActor.props(readMetadataWorkerMaker, 1000000), | ||
name = metadataBuilderActorName, | ||
) | ||
|
||
val response = mba.ask(action).mapTo[MetadataJsonResponse] | ||
mockReadMetadataWorkerActor.expectMsg(defaultTimeout, action) | ||
mockReadMetadataWorkerActor.reply(MetadataLookupResponse(queryReply, events)) | ||
mockReadMetadataWorkerActor.reply( | ||
if(failedTasks) FetchFailedJobsMetadataLookupResponse(events) else MetadataLookupResponse(queryReply, events) | ||
) | ||
response map { r => r shouldBe a [SuccessfulMetadataJsonResponse] } | ||
response.mapTo[SuccessfulMetadataJsonResponse] map { b => b.responseJson shouldBe expectedRes.parseJson} | ||
} | ||
|
||
|
||
def assertMetadataFailureResponse(action: MetadataServiceAction, | ||
metadataServiceResponse: MetadataServiceResponse, | ||
expectedException: Exception, | ||
|
@@ -95,6 +100,7 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
// We'll use a Query instead of a SingleWorkflowMetadataGet, so we expect the WorkflowID this time: | ||
val expectedRes = | ||
s"""{ | ||
|"${workflowA}": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this change represent a real change in behavior, or just a change in the structure of the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this comment. TLDR: I updated the wrong test. |
||
| "calls": { | ||
| "callB": [{ | ||
| "attempt": 1, | ||
|
@@ -123,8 +129,8 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
| "shardIndex": -1 | ||
| }] | ||
| }, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "id": "$workflowA" | ||
| "NOT_CHECKED": "NOT_CHECKED" | ||
| } | ||
|}""".stripMargin | ||
|
||
val mdQuery = MetadataQuery(workflowA, None, None, None, None, expandSubWorkflows = false) | ||
|
@@ -134,7 +140,8 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
queryReply = mdQuery, | ||
events = workflowAEvents, | ||
expectedRes = expectedRes, | ||
metadataBuilderActorName = "mba-scope-tree", | ||
metadataBuilderActorName = "mba-failed-tasks-tree", | ||
true | ||
) | ||
} | ||
|
||
|
@@ -162,6 +169,7 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
eventMaker: WorkflowId => (String, MetadataValue, OffsetDateTime) => MetadataEvent = | ||
makeEvent, | ||
metadataBuilderActorName: String, | ||
isFailedTaskFetch: Boolean = false | ||
): Future[Assertion] = { | ||
|
||
val events = eventList map { e => (e._1, MetadataValue(e._2), e._3) } map Function.tupled(eventMaker(workflow)) | ||
|
@@ -172,6 +180,72 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with | |
assertMetadataResponse(queryAction, mdQuery, events, expectedRes, metadataBuilderActorName) | ||
} | ||
|
||
it should "build the call list for failed tasks when prompted" in { | ||
|
||
def makeEvent(workflow: WorkflowId, key: Option[MetadataJobKey]) = { | ||
MetadataEvent(MetadataKey(workflow, key, "NOT_CHECKED"), MetadataValue("NOT_CHECKED")) | ||
} | ||
|
||
val workflowA = WorkflowId.randomId() | ||
|
||
val workflowACalls = List( | ||
Option(MetadataJobKey("callB", Option(1), 3)), | ||
Option(MetadataJobKey("callB", None, 1)), | ||
Option(MetadataJobKey("callB", Option(1), 2)), | ||
Option(MetadataJobKey("callA", None, 1)), | ||
Option(MetadataJobKey("callB", Option(1), 1)), | ||
Option(MetadataJobKey("callB", Option(0), 1)), | ||
None | ||
) | ||
val workflowAEvents = workflowACalls map { | ||
makeEvent(workflowA, _) | ||
} | ||
|
||
val expectedRes = | ||
s"""{ | ||
| "calls": { | ||
| "callB": [{ | ||
| "attempt": 1, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": -1 | ||
| }, { | ||
| "attempt": 1, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": 0 | ||
| }, { | ||
| "attempt": 1, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": 1 | ||
| }, { | ||
| "attempt": 2, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": 1 | ||
| }, { | ||
| "attempt": 3, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": 1 | ||
| }], | ||
| "callA": [{ | ||
| "attempt": 1, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "shardIndex": -1 | ||
| }] | ||
| }, | ||
| "NOT_CHECKED": "NOT_CHECKED", | ||
| "id": "$workflowA" | ||
|}""".stripMargin | ||
|
||
val mdQuery = MetadataQuery(workflowA, None, None, None, None, expandSubWorkflows = false) | ||
val queryAction = GetMetadataAction(mdQuery) | ||
assertMetadataResponse( | ||
action = queryAction, | ||
queryReply = mdQuery, | ||
events = workflowAEvents, | ||
expectedRes = expectedRes, | ||
metadataBuilderActorName = "mba-failed-tasks", | ||
JVThomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
|
||
it should "assume the event list is ordered and keep last event if 2 events have same key" in { | ||
val eventBuilderList = List( | ||
("a", "aLater", OffsetDateTime.parse("2000-01-02T12:00:00Z")), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with these hash signs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Slick's way of handling string interpolation. You would think "Why not use
${}
? It's because Slick is using that notation specifically to bind values in a query.So something like
tableName.colName = ${val}
would work, but `SELECT ${tableName}.${colName} would throw an error since you're declaring an identifier rather than providing a value.This also caught me off guard and is only briefly covered in the Slick docs.