Skip to content

Commit

Permalink
DEVPROD-5949: Render Resmoke 'All' Logs when given taskID, execution …
Browse files Browse the repository at this point in the history
…and groupID (#40)
  • Loading branch information
SupaJoon authored Apr 11, 2024
1 parent 5331fe3 commit 80b1169
Show file tree
Hide file tree
Showing 22 changed files with 316 additions and 177 deletions.
1 change: 1 addition & 0 deletions apps/parsley/config/jest/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "@testing-library/jest-dom/extend-expect";
// The following two variables are dummy values used in auth.test.tsx.
process.env.REACT_APP_EVERGREEN_URL = "test-evergreen.com";
process.env.REACT_APP_GRAPHQL_URL = "test-graphql.com";
process.env.REACT_APP_SPRUCE_URL = "test-spruce.com";

if (process.env.CI) {
// Avoid printing debug statements when running tests.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
describe("Basic resmoke log view", () => {
const logLink =
"/resmoke/mongodb_mongo_master_enterprise_amazon_linux2_arm64_all_feature_flags_jsCore_patch_9801cf147ed208ce4c0ff8dff4a97cdb216f4c22_65f06bd09ccd4eaaccca1391_24_03_12_14_51_29/0/job0/all";
beforeEach(() => {
cy.visit(logLink);
});

it("should render resmoke lines", () => {
cy.dataCy("resmoke-row").should("be.visible");
cy.dataCy("ansii-row").should("not.exist");
});

it("the HTML log button is disabled", () => {
cy.toggleDetailsPanel(true);
cy.dataCy("html-log-button").should("have.attr", "aria-disabled", "true");
});

it("the job logs button has a link to the job logs page", () => {
cy.toggleDetailsPanel(true);
cy.dataCy("job-logs-button").should(
"have.attr",
"href",
"http://localhost:3000/job-logs/mongodb_mongo_master_enterprise_amazon_linux2_arm64_all_feature_flags_jsCore_patch_9801cf147ed208ce4c0ff8dff4a97cdb216f4c22_65f06bd09ccd4eaaccca1391_24_03_12_14_51_29/0/job0",
);
});

it("should show the project, patch, task, and group the breadcrumb", () => {
cy.dataCy("project-breadcrumb")
.contains("mongodb-mongo-master")
.should("be.visible");
cy.dataCy("version-breadcrumb").contains("Patch 1994").should("be.visible");
cy.dataCy("task-breadcrumb").contains("jsCore").should("be.visible");
cy.dataCy("group-breadcrumb").contains("job0").should("be.visible");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("cliInstructions", () => {
hook.current.setLogMetadata({
buildID: "buildId",
execution: "0",
logType: LogTypes.RESMOKE_LOGS,
logType: LogTypes.LOGKEEPER_LOGS,
taskID: "taskId",
testID: "testId",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getCLICommand = (logMetadata: LogMetadata) => {
return "";
}
return `evergreen buildlogger fetch --task_id ${taskID} --execution ${execution} --test_name ${testID}`;
case LogTypes.RESMOKE_LOGS:
case LogTypes.LOGKEEPER_LOGS:
if (!buildID) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("jump to failing line toggle", () => {
);
render(<Component />, { wrapper });
act(() => {
hook.current.setLogMetadata({ logType: LogTypes.RESMOKE_LOGS });
hook.current.setLogMetadata({ logType: LogTypes.LOGKEEPER_LOGS });
});
const jumpToFailingLineToggle = screen.getByDataCy(
"jump-to-failing-line-toggle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const CollapsedResmokeRowStory = (
const { setWrap } = preferences;

useEffect(() => {
setLogMetadata({ logType: LogTypes.RESMOKE_LOGS });
setLogMetadata({ logType: LogTypes.LOGKEEPER_LOGS });
ingestLines(resmokeLogLines, LogRenderingTypes.Resmoke);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("evergreen task subheader", () => {
<EvergreenTaskSubHeader
buildID="7e208050e166b1a9025c817b67eee48d"
execution={0}
logType={LogTypes.RESMOKE_LOGS}
logType={LogTypes.LOGKEEPER_LOGS}
taskID="mongodb_mongo_master_rhel80_debug_v4ubsan_all_feature_flags_experimental_concurrency_sharded_with_stepdowns_and_balancer_4_linux_enterprise_361789ed8a613a2dc0335a821ead0ab6205fbdaa_22_09_21_02_53_24"
testID="1716e11b4f8a4541c5e2faf70affbfab"
/>
Expand Down
14 changes: 12 additions & 2 deletions apps/parsley/src/components/SubHeader/EvergreenTaskSubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ import { shortenGithash, trimStringFromMiddle } from "utils/string";
interface Props {
buildID: string;
execution: number;
fileName?: string;
groupID?: string;
logType?: LogTypes;
taskID: string;
testID?: string;
fileName?: string;
}

export const EvergreenTaskSubHeader: React.FC<Props> = ({
buildID,
execution,
fileName,
groupID,
logType,
taskID,
testID,
Expand Down Expand Up @@ -76,7 +78,7 @@ export const EvergreenTaskSubHeader: React.FC<Props> = ({

let currentTest: { testFile: string; status: string } | null = null;
switch (logType) {
case LogTypes.RESMOKE_LOGS:
case LogTypes.LOGKEEPER_LOGS:
currentTest =
taskData?.tests?.testResults?.find((test) =>
test?.logs?.urlRaw?.match(new RegExp(`${testID}`)),
Expand Down Expand Up @@ -142,6 +144,14 @@ export const EvergreenTaskSubHeader: React.FC<Props> = ({
},
]
: []),
...(groupID
? [
{
"data-cy": "group-breadcrumb",
text: groupID,
},
]
: []),
];

return (
Expand Down
3 changes: 2 additions & 1 deletion apps/parsley/src/components/SubHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { gray } = palette;
interface SubHeaderProps {}
const SubHeader: React.FC<SubHeaderProps> = () => {
const { isUploadedLog, logMetadata } = useLogContext();
const { buildID, execution, fileName, logType, taskID, testID } =
const { buildID, execution, fileName, groupID, logType, taskID, testID } =
logMetadata || {};

return (
Expand Down Expand Up @@ -39,6 +39,7 @@ const SubHeader: React.FC<SubHeaderProps> = () => {
buildID={buildID as string}
execution={Number(execution)}
fileName={fileName}
groupID={groupID}
logType={logType}
taskID={taskID}
testID={testID as string}
Expand Down
3 changes: 2 additions & 1 deletion apps/parsley/src/constants/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ enum LogTypes {
EVERGREEN_TASK_FILE = "EVERGREEN_TASK_FILE",
EVERGREEN_TASK_LOGS = "EVERGREEN_TASK_LOGS",
EVERGREEN_TEST_LOGS = "EVERGREEN_TEST_LOGS",
RESMOKE_LOGS = "RESMOKE_LOGS",
EVERGREEN_COMPLETE_LOGS = "EVERGREEN_COMPLETE_LOGS",
LOGKEEPER_LOGS = "LOGKEEPER_LOGS",
LOCAL_UPLOAD = "LOCAL_UPLOAD",
}

Expand Down
16 changes: 14 additions & 2 deletions apps/parsley/src/constants/externalURLTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ const getEvergreenTaskURL = (taskID: string, execution: string | number) => {
)}`;
};

const getJobLogsURL = (buildID: string) => `${spruceURL}/job-logs/${buildID}`;
const getLogkeeperJobLogsURL = (buildID: string) =>
`${spruceURL}/job-logs/${buildID}`;

const getEvergreenJobLogsURL = (
taskID: string,
execution: string | number,
groupID: string,
) => `${spruceURL}/job-logs/${taskID}/${execution}/${groupID}`;

const getLegacyJobLogsURL = (buildID: string) =>
`${logkeeperURL}/build/${buildID}`;

export { getEvergreenTaskURL, getJobLogsURL, getLegacyJobLogsURL };
export {
getEvergreenTaskURL,
getLogkeeperJobLogsURL,
getLegacyJobLogsURL,
getEvergreenJobLogsURL,
};
15 changes: 15 additions & 0 deletions apps/parsley/src/constants/logURLTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,23 @@ const getEvergreenTaskFileURL = (
fileName: string,
) => `${evergreenURL}/task_file_raw/${taskID}/${execution}/${fileName}`;

/**
* getEvergreenCompleteLogsURL constructs an Evergreen URL to download complete logs for a task.
* @param taskID - the task ID
* @param execution - the execution number of the task
* @param groupID - the group ID of the task
* @returns an Evergreen URL of the format /rest/v2/tasks/${taskID}/build/TestLogs/${groupID}?execution=${execution}
*/
const getEvergreenCompleteLogsURL = (
taskID: string,
execution: string | number,
groupID: string,
) =>
`${evergreenURL}/rest/v2/tasks/${taskID}/build/TestLogs/${groupID}?execution=${execution}`;

export {
constructEvergreenTaskLogURL,
getEvergreenCompleteLogsURL,
getEvergreenTaskFileURL,
getEvergreenTaskLogURL,
getEvergreenTestLogURL,
Expand Down
5 changes: 3 additions & 2 deletions apps/parsley/src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ enum slugs {
}

const routes = {
completeLogs: `${paths.resmokeLogs}/:${slugs.taskID}/:${slugs.execution}/:${slugs.groupID}/all`,
evergreenLogs: `${paths.evergreenLogs}/:${slugs.taskID}/:${slugs.execution}/:${slugs.origin}`,
login: paths.login,
resmokeLogs: `${paths.resmokeLogs}/:${slugs.buildID}/test/:${slugs.testID}`,
resmokeLogsAll: `${paths.resmokeLogs}/:${slugs.buildID}/all`,
logkeeperLogs: `${paths.resmokeLogs}/:${slugs.buildID}/test/:${slugs.testID}`,
logkeeperLogsAll: `${paths.resmokeLogs}/:${slugs.buildID}/all`,
root: paths.home,
taskFiles: `${paths.taskFile}/:${slugs.taskID}/:${slugs.execution}/:${slugs.fileName}`,
testLogs: `${paths.testLogs}/:${slugs.taskID}/:${slugs.execution}/:${slugs.testID}`,
Expand Down
1 change: 1 addition & 0 deletions apps/parsley/src/context/LogContext/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface LogMetadata {
buildID?: string;
execution?: string;
fileName?: string;
groupID?: string;
htmlLogURL?: string;
jobLogsURL?: string;
legacyJobLogsURL?: string;
Expand Down
10 changes: 5 additions & 5 deletions apps/parsley/src/hooks/useLogDownloader/useLogDownloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("useLogDownloader", () => {
// RenderFakeToastContext is a mock of the ToastContext
RenderFakeToastContext();
const { result } = renderHook(() =>
useLogDownloader({ logType: LogTypes.RESMOKE_LOGS, url: API_URL }),
useLogDownloader({ logType: LogTypes.LOGKEEPER_LOGS, url: API_URL }),
);
expect(result.current.isLoading).toBe(true);
await waitFor(() => {
Expand Down Expand Up @@ -77,7 +77,7 @@ describe("useLogDownloader", () => {
// RenderFakeToastContext is a mock of the ToastContext
RenderFakeToastContext();
const { result } = renderHook(() =>
useLogDownloader({ logType: LogTypes.RESMOKE_LOGS, url: API_URL }),
useLogDownloader({ logType: LogTypes.LOGKEEPER_LOGS, url: API_URL }),
);
expect(result.current.isLoading).toBe(true);
expect(result.current.fileSize).toBe(0);
Expand All @@ -98,7 +98,7 @@ describe("useLogDownloader", () => {
// RenderFakeToastContext is a mock of the ToastContext
RenderFakeToastContext();
const { result } = renderHook(() =>
useLogDownloader({ logType: LogTypes.RESMOKE_LOGS, url: API_URL }),
useLogDownloader({ logType: LogTypes.LOGKEEPER_LOGS, url: API_URL }),
);
expect(result.current.isLoading).toBe(true);
await waitFor(() => {
Expand All @@ -121,7 +121,7 @@ describe("useLogDownloader", () => {
const { result } = renderHook(() =>
useLogDownloader({
downloadSizeLimit: 5,
logType: LogTypes.RESMOKE_LOGS,
logType: LogTypes.LOGKEEPER_LOGS,
url: API_URL,
}),
);
Expand Down Expand Up @@ -150,7 +150,7 @@ describe("useLogDownloader", () => {
// RenderFakeToastContext is a mock of the ToastContext
const { dispatchToast } = RenderFakeToastContext();
const { result } = renderHook(() =>
useLogDownloader({ logType: LogTypes.RESMOKE_LOGS, url: API_URL }),
useLogDownloader({ logType: LogTypes.LOGKEEPER_LOGS, url: API_URL }),
);
expect(result.current.isLoading).toBe(true);
await waitFor(() => {
Expand Down
6 changes: 3 additions & 3 deletions apps/parsley/src/hooks/useTaskQuery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ export const useTaskQuery = ({
logType,
taskID,
}: UseTaskQueryProps): UseTaskQueryReturnType => {
const isResmoke = logType === LogTypes.RESMOKE_LOGS;
const isLogkeeper = logType === LogTypes.LOGKEEPER_LOGS;
const { data: taskData, loading: taskLoading } = useQuery<
TaskQuery,
TaskQueryVariables
>(GET_TASK, {
skip: isResmoke || !taskID,
skip: isLogkeeper || !taskID,
variables: { execution: Number(execution), taskId: String(taskID) },
});

const { data: logkeeperData, loading: logkeeperLoading } = useQuery<
LogkeeperTaskQuery,
LogkeeperTaskQueryVariables
>(GET_LOGKEEPER_TASK, {
skip: logType !== LogTypes.RESMOKE_LOGS || !buildID,
skip: !isLogkeeper || !buildID,
variables: { buildId: String(buildID) },
});

Expand Down
2 changes: 1 addition & 1 deletion apps/parsley/src/hooks/useTaskQuery/useTaskQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("useTaskQuery", () => {
() =>
useTaskQuery({
buildID: "7e208050e166b1a9025c817b67eee48d",
logType: LogTypes.RESMOKE_LOGS,
logType: LogTypes.LOGKEEPER_LOGS,
}),
{
wrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("parse log select", () => {

it("clicking the 'Process Log' button calls the onParse function", async () => {
const user = userEvent.setup();
mockedGet.mockImplementation(() => LogTypes.RESMOKE_LOGS);
mockedGet.mockImplementation(() => LogTypes.LOGKEEPER_LOGS);
const onParse = jest.fn();
render(
<ParseLogSelect
Expand Down
4 changes: 3 additions & 1 deletion apps/parsley/src/pages/LogView/LoadingPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const LoadingPage: React.FC<LoadingPageProps> = ({ logType }) => {
useFetch<LogkeeperMetadata>(
getResmokeLogURL(buildID || "", { metadata: true, testID }),
{
skip: buildID === undefined,
skip: logType !== LogTypes.LOGKEEPER_LOGS || buildID === undefined,
},
);

Expand All @@ -77,6 +77,7 @@ const LoadingPage: React.FC<LoadingPageProps> = ({ logType }) => {
buildID,
execution: execution || String(logkeeperMetadata?.execution || 0),
fileName,
groupID,
htmlLogURL,
jobLogsURL,
legacyJobLogsURL,
Expand All @@ -99,6 +100,7 @@ const LoadingPage: React.FC<LoadingPageProps> = ({ logType }) => {
error,
execution,
fileName,
groupID,
htmlLogURL,
ingestLines,
isLoadingLogkeeperMetadata,
Expand Down
Loading

0 comments on commit 80b1169

Please sign in to comment.