-
Notifications
You must be signed in to change notification settings - Fork 16
DEVPROD-1435: Use renderingType GQL field to determine Row rendering format #486
Conversation
1 failed test on run #5222 ↗︎
Details:
Review all test suite changes for PR #486 ↗︎ |
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.
I think this can be done in a way that is a little more flexible for expanding to different rendering types. Right now the assumption is that there are only 2 types of logs and doesn't leave room for future log types like how the previous implementation did.
If we are going to be using renderingType
to determine log render behavior we should try to be consistent across the app about how it is used instead of having it only apply to a very specific subset of test logs.
// At this point, logMetadata.renderingType is guaranteed to be defined from LogView/LoadingPage.tsx. | ||
// logType can be removed from this calculation when the Parsley resmoke route is fully deprecated. | ||
const Row = | ||
logMetadata?.renderingType === "resmoke" || |
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.
Can we use enums instead of strings like "resmoke" or "default"
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.
I also don't quite understand this bit of logic. Is there a way we can preserve rowRenderMap it seems far more flexible and would allow the expansion of future row types in the future.
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.
I think this logic doesn't make sense because it doesn't do a good job at holistically bringing in renderingType
to Parsley. The logic that you reviewed utilizes parsley route (logType) and renderingType when available. I just pushed some code to decouple the route from renderingType, utilizes testlog renderingType from the GQL endpoint but also extrapolates rendering type per logType.
@@ -9,18 +9,19 @@ interface SearchState { | |||
} | |||
|
|||
interface LogMetadata { |
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.
Thanks for sorting!
src/pages/LogDrop/FileDropper.tsx
Outdated
isUploadedLog: true, | ||
logType, | ||
renderingType: | ||
logType === LogTypes.RESMOKE_LOGS ? "resmoke" : "default", |
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.
Same comment about using an enum value.
type SelectState = | ||
| LogTypes.RESMOKE_LOGS | ||
| LogTypes.EVERGREEN_TASK_LOGS | ||
| undefined; | ||
|
||
const ParseLogSelect: React.FC<ParseLogSelectProps> = ({ | ||
fileName, | ||
onCancel, | ||
onParse, | ||
}) => { | ||
const [logType, setLogType] = useState<LogTypes | undefined>( | ||
(Cookie.get(LAST_SELECTED_LOG_TYPE) as LogTypes) ?? undefined, | ||
const [logType, setLogType] = useState<SelectState>( | ||
(Cookie.get(LAST_SELECTED_LOG_TYPE) as SelectState) ?? undefined, |
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.
Why did you make this change it seems to do the same thing but is arguably slightly less readable.
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.
LogTypes
includes values that are unrelated to the Select component state which makes it harder to infer usage. We should be more strict with our typings and exclude unused values when representing state.
|
||
// renderingType is only propagated for evergreen test logs as of DEVPROD-1435. | ||
const renderingType = | ||
(testData?.task?.tests.testResults[0]?.logs |
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.
renderingType
will default to default
for resmoke logs which is confusing. I think we should try to be consistent about how this value is treated and used.
@@ -108,6 +111,7 @@ export const useResolveLogURL = ({ | |||
let htmlLogURL = ""; | |||
let jobLogsURL = ""; | |||
let legacyJobLogsURL = ""; | |||
let renderingType = ""; |
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.
let renderingType = ""; | |
let renderingType: SupportedLogRenderingTypes = LogRenderingTypes.Default; |
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.
This is still necessary. Otherwise the type alias on line 206 has no effect.
reportError(new Error("Encountered unsupported renderType"), { | ||
rawLogURL: logMetadata?.rawLogURL, | ||
renderingType: logMetadata?.renderingType, | ||
}).warning(); |
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.
We wouldn't want to report an error here. This will result in us logging an error for every single row.
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.
I agree it's better to report the error closer to ingestion. Technically this wouldn't run into an error on every line because this code is in the generator body and not the return value.
@@ -38,6 +40,24 @@ const ParsleyRow: RowRendererFunction = ({ logType, processedLogLines }) => { | |||
? new RegExp(`${highlights.map((h) => `(${h})`).join("|")}`, "gi") | |||
: undefined; | |||
|
|||
let Row: React.FC<ResmokeRowProps> | React.FC<AnsiRowProps>; | |||
// At this point, logMetadata is defined from <LoadingPage /> |
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.
I think we can remove this comment since its implied.
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.
I will find this comment helpful in the future. If I were looking at this code after time away, this is something I would want to verify because logMetadata
and renderingType
are both marked as optional in their type structures.
src/constants/enums.ts
Outdated
@@ -5,6 +5,11 @@ enum LogTypes { | |||
RESMOKE_LOGS = "RESMOKE_LOGS", | |||
} | |||
|
|||
enum SupportedLogRenderingTypes { |
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.
Can we remove the word Supported since it being here implies that it is supported?
enum SupportedLogRenderingTypes { | |
enum LogRenderingTypes { |
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.
Originally, I wanted to make a distinction between unsupported and supported rendering types because unsupported types may be cached in the Apollo request layer and the code may encounter unsupported types. Either way works and I updated the code to your suggestion.
reportError(new Error("Encountered unsupported renderingType"), { | ||
rawLogURL: logMetadata?.rawLogURL, | ||
renderingType: logMetadata?.renderingType, | ||
}).warning(); |
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.
We shouldn't log this here since it would log for every single log row we try to render.
@@ -189,17 +200,21 @@ export const useResolveLogURL = ({ | |||
text: false, | |||
}); | |||
downloadURL = rawLogURL; | |||
renderingType = | |||
renderingTypeFromQuery || SupportedLogRenderingTypes.Default; | |||
break; | |||
} | |||
default: |
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.
This is probably a good place to error. We should set also probably set a default rendering type so the page can still work.
type SelectState = | ||
| LogTypes.RESMOKE_LOGS | ||
| LogTypes.EVERGREEN_TASK_LOGS | ||
| undefined; |
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.
I think maybe the select states should correspond to rendering types instead of LogTypes since with this refactor the LogTypes
only really reflect the origin of the log.
src/pages/LogDrop/FileDropper.tsx
Outdated
renderingType: | ||
logType === LogTypes.RESMOKE_LOGS | ||
? SupportedLogRenderingTypes.Resmoke | ||
: SupportedLogRenderingTypes.Default, |
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.
Doing the above we can also avoid this.
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.
If I change the function parameter from LogTypes
to LogRenderingType
, then I will have to cast the function parameter to LogType
for the logType value on line 47 which is fine for now. These tickets will look more into logType usage.
https://jira.mongodb.org/browse/DEVPROD-5130
https://jira.mongodb.org/browse/DEVPROD-5163
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.
hmm i think this may be ok, Since this could be used to distinguish between log types for log sectioning project? I do think it would be important to iron that out in your project or at some point before it.
@@ -38,6 +40,24 @@ const ParsleyRow: RowRendererFunction = ({ logType, processedLogLines }) => { | |||
? new RegExp(`${highlights.map((h) => `(${h})`).join("|")}`, "gi") | |||
: undefined; | |||
|
|||
let Row: React.FC<ResmokeRowProps> | React.FC<AnsiRowProps>; |
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.
This is more flexible and avoids exporting the the Row props.
let Row: React.FC<ResmokeRowProps> | React.FC<AnsiRowProps>; | |
let Row: typeof ResmokeRow | typeof AnsiRow; |
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.
nit. Can you capitalize DEVPROD in the pr title
Great job just a few more comments and follow up from my last review.
const { | ||
renderingType: renderingTypeFromQuery, | ||
url, | ||
urlRaw, | ||
} = testData?.task?.tests.testResults[0]?.logs || {}; |
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.
Can we leave a comment here.
Something simple such as if we fetched test results use that URL otherwise fallback to hardcoded routes?
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.
I left a comment a comment for the query at the top of the file that describes how LogRenderingType is reasoned. I'm not actually sure what to comment here that would be useful for me. Please suggest a comment and I will commit it.
@@ -108,6 +111,7 @@ export const useResolveLogURL = ({ | |||
let htmlLogURL = ""; | |||
let jobLogsURL = ""; | |||
let legacyJobLogsURL = ""; | |||
let renderingType = ""; |
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.
This is still necessary. Otherwise the type alias on line 206 has no effect.
} else if (!renderingTypeFromQuery) { | ||
renderingType = LogRenderingTypes.Default; | ||
} else { | ||
renderingType = LogRenderingTypes.Default; |
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.
I think this can be refactored out. The first if statement handles the case where renderingTypeFromQuery is undefined. renderingTypeFromQuery
can't be in LogRenderingTypes
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.
If we assign a default value for renderingType
like my suggestion on on L115 this assignment in the else statement becomes unnecessary as well
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.
the value from the query will overwrite renderingType
so I still need the condition on line 206
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.
I may be missing what you mean but Afaict renderingType
doesn't get overridden anywhere else so I still think it's not necessary. Can you point me to where it does?
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.
Ah, you're right. I jumbled the variable assignment on line 187 when I made that comment.
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.
Ah, so renderingTypeFromQuery
may actually be an empty string. In that case, I would want to cast it to the default rendering type and not submit an error -- that's when the condition on 206 comes into play.
rawLogURL, | ||
unsupportedRenderingType: renderingTypeFromQuery, | ||
}, | ||
}).warning(); |
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.
This should probably be logged at .severe()
since this indicates we encountered some sort of unsupported rendering type.
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.
Great job on this! 🚀 mod my comment
} else if (!renderingTypeFromQuery) { | ||
renderingType = LogRenderingTypes.Default; | ||
} else { | ||
renderingType = LogRenderingTypes.Default; |
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.
I may be missing what you mean but Afaict renderingType
doesn't get overridden anywhere else so I still think it's not necessary. Can you point me to where it does?
DevProd-1435
Description
The resmoke route is not fully deprecated yet so we must support it until Julian lets us know.
renderingType
is only applicable to test logs at the moment.