Skip to content

Commit

Permalink
feat(machines): Add kernel crash dump checkbox to deploy form MAASENG…
Browse files Browse the repository at this point in the history
…-3759 (#5539)

Resolves [MAASENG-3759](https://warthogs.atlassian.net/browse/MAASENG-3759)
  • Loading branch information
ndv99 authored Oct 9, 2024
1 parent 4a29667 commit 5f0f63e
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import configureStore from "redux-mock-store";
import { test } from "vitest";

import DeployForm from "../DeployForm";

Expand All @@ -15,6 +16,8 @@ import {
renderWithBrowserRouter,
} from "@/testing/utils";

const kernelCrashDumpEnabled =
process.env.VITE_APP_KERNEL_CRASH_DUMP_ENABLED === "true";
const mockStore = configureStore();

describe("DeployFormFields", () => {
Expand Down Expand Up @@ -708,4 +711,54 @@ describe("DeployFormFields", () => {
screen.queryByRole("checkbox", { name: "Register as MAAS KVM host" })
).not.toBeInTheDocument();
});

test.runIf(kernelCrashDumpEnabled)(
"shows a tooltip for minimum OS requirements",
async () => {
renderWithBrowserRouter(
<DeployForm
clearSidePanelContent={vi.fn()}
machines={[]}
processingCount={0}
viewingDetails={false}
/>,
{ route: "/machines/add", state }
);

await userEvent.hover(
screen.getAllByRole("button", { name: "help-mid-dark" })[1]
);

await waitFor(() => {
expect(screen.getByRole("tooltip")).toHaveTextContent(
"Ubuntu 24.04 LTS or higher."
);
});
}
);

test.runIf(kernelCrashDumpEnabled)(
"shows a tooltip for minimum hardware requirements",
async () => {
renderWithBrowserRouter(
<DeployForm
clearSidePanelContent={vi.fn()}
machines={[]}
processingCount={0}
viewingDetails={false}
/>,
{ route: "/machines/add", state }
);

await userEvent.hover(
screen.getAllByRole("button", { name: "help-mid-dark" })[0]
);

await waitFor(() => {
expect(screen.getByRole("tooltip")).toHaveTextContent(
">= 4 CPU threads, >= 6GB RAM, Reserve >5x RAM size as free disk space in /var."
);
});
}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,43 @@ export const DeployFormFields = (): JSX.Element => {
name="enableHwSync"
type="checkbox"
/>

{import.meta.env.VITE_APP_KERNEL_CRASH_DUMP_ENABLED === "true" && (
<FormikField
help={
<>
To enable kernel crash dump, the hardware{" "}
<TooltipButton
iconName="help-mid-dark"
message={
<span className="u-align-text--center u-flex--center">
{" "}
&gt;= 4 CPU threads, <br /> &gt;= 6GB RAM, <br />
Reserve &gt;5x RAM size as free disk space in /var.
</span>
}
/>{" "}
and OS{" "}
<TooltipButton
iconName="help-mid-dark"
message="Ubuntu 24.04 LTS or higher."
/>{" "}
must meet the minimum requirements and secure boot must be
disabled. Check crash dump status in machine details.
</>
}
label={
<>
Try to enable kernel crash dump{" "}
<ExternalLink to="https://ubuntu.com/server/docs/kernel-crash-dump">
Kernel crash dump docs
</ExternalLink>
</>
}
name="kernel_crash_dump"
type="checkbox"
/>
)}
</Col>
</Row>
{user && user.sshkeys_count === 0 && (
Expand Down

0 comments on commit 5f0f63e

Please sign in to comment.