Skip to content

Commit d7ac83e

Browse files
authored
Introduce sub-tabs with full Grafana dashboard embeds on Metrics tab (#57561)
1 parent 023e470 commit d7ac83e

File tree

2 files changed

+129
-578
lines changed

2 files changed

+129
-578
lines changed

python/ray/dashboard/client/src/pages/metrics/Metrics.component.test.tsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ const MetricsDisabledWrapper = ({ children }: PropsWithChildren<{}>) => {
6464

6565
describe("Metrics", () => {
6666
it("renders", async () => {
67-
expect.assertions(5);
67+
expect.assertions(4);
6868

6969
render(<Metrics />, { wrapper: Wrapper });
70-
await screen.findByText(/View in Grafana/);
71-
expect(screen.getByText(/5 minutes/)).toBeVisible();
72-
expect(screen.getByText(/Tasks and Actors/)).toBeVisible();
73-
expect(screen.getByText(/Ray Resource Usage/)).toBeVisible();
74-
expect(screen.getByText(/Hardware Utilization/)).toBeVisible();
70+
await screen.findByText(/View tab in Grafana/);
71+
expect(screen.getByText(/Core/)).toBeVisible();
72+
expect(screen.getByText(/Ray Data/)).toBeVisible();
73+
expect(document.querySelector("iframe")).toBeTruthy();
7574
expect(
7675
screen.queryByText(
7776
/Set up Prometheus and Grafana for better Ray Dashboard experience/,
@@ -80,47 +79,45 @@ describe("Metrics", () => {
8079
});
8180

8281
it("renders warning when grafana is not available", async () => {
83-
expect.assertions(5);
82+
expect.assertions(3);
8483

8584
render(<Metrics />, { wrapper: MetricsDisabledWrapper });
8685
await screen.findByText(
8786
/Set up Prometheus and Grafana for better Ray Dashboard experience/,
8887
);
89-
expect(screen.queryByText(/View in Grafana/)).toBeNull();
90-
expect(screen.queryByText(/5 minutes/)).toBeNull();
91-
expect(screen.queryByText(/Tasks and Actors/)).toBeNull();
92-
expect(screen.queryByText(/Ray Resource Usage/)).toBeNull();
93-
expect(screen.queryByText(/Hardware Utilization/)).toBeNull();
88+
expect(screen.queryByText(/View tab in Grafana/)).toBeNull();
89+
expect(screen.queryByText(/Core/)).toBeNull();
90+
expect(document.querySelector("iframe")).toBeNull();
9491
});
9592

9693
it("validates iframe query parameters are correctly constructed", async () => {
9794
expect.assertions(11);
9895

9996
render(<Metrics />, { wrapper: Wrapper });
100-
await screen.findByText(/View in Grafana/);
97+
await screen.findByText(/View tab in Grafana/);
10198

102-
// Get all iframe elements
99+
// Get iframe element (should be only one)
103100
const iframes = document.querySelectorAll("iframe");
104-
expect(iframes.length).toBeGreaterThan(0);
101+
expect(iframes.length).toBe(1);
105102

106-
// Test the first iframe to validate query parameters
107-
const firstIframe = iframes[0] as HTMLIFrameElement;
108-
const iframeSrc = firstIframe.src;
103+
// Test the iframe to validate query parameters
104+
const iframe = iframes[0] as HTMLIFrameElement;
105+
const iframeSrc = iframe.src;
109106
const url = new URL(iframeSrc);
110107

111108
// Validate required iframe query parameters
112109
expect(url.searchParams.get("orgId")).toBe("1");
113110
expect(url.searchParams.get("theme")).toBe("light");
114-
expect(url.searchParams.get("panelId")).toBeTruthy();
111+
expect(url.searchParams.get("kiosk")).toBe("1");
115112
expect(url.searchParams.get("var-SessionName")).toBe("session-name");
116113
expect(url.searchParams.get("var-datasource")).toBe("Prometheus");
117114
expect(url.searchParams.get("refresh")).toBe("5s");
118115
expect(url.searchParams.get("from")).toBe("now-5m");
119116
expect(url.searchParams.get("to")).toBe("now");
120117

121-
// Validate URL structure
122-
expect(iframeSrc).toMatch(/localhost:3000\/d-solo\/rayDefaultDashboard\?/);
123-
expect(iframeSrc).toContain("/d-solo/rayDefaultDashboard");
118+
// Validate URL structure (full dashboard, not panel-only)
119+
expect(iframeSrc).toMatch(/localhost:3000\/d\/rayDefaultDashboard\/\?/);
120+
expect(iframeSrc).toContain("/d/rayDefaultDashboard");
124121
});
125122

126123
it("validates iframe query parameters with cluster filter", async () => {
@@ -156,12 +153,12 @@ describe("Metrics", () => {
156153
expect.assertions(2);
157154

158155
render(<Metrics />, { wrapper: WrapperWithClusterFilter });
159-
await screen.findByText(/View in Grafana/);
156+
await screen.findByText(/View tab in Grafana/);
160157

161-
// Get the first iframe and validate cluster filter parameter
158+
// Get the iframe and validate cluster filter parameter
162159
const iframes = document.querySelectorAll("iframe");
163-
const firstIframe = iframes[0] as HTMLIFrameElement;
164-
const iframeSrc = firstIframe.src;
160+
const iframe = iframes[0] as HTMLIFrameElement;
161+
const iframeSrc = iframe.src;
165162
const url = new URL(iframeSrc);
166163

167164
expect(url.searchParams.get("var-Cluster")).toBe("test-cluster");

0 commit comments

Comments
 (0)