Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17a9aa165a | |||
| 3e306b70f8 | |||
| 3aa9c15e80 | |||
| 957cf144a7 | |||
| 52b1429ba0 | |||
| 66575982af | |||
| 66932958b1 | |||
| 0d5f65176b |
@@ -151,4 +151,27 @@ describe('IntelGpuDataProvider', () => {
|
|||||||
expect(callCountAfter).toBeGreaterThan(callCountBefore);
|
expect(callCountAfter).toBeGreaterThan(callCountBefore);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('treats a hanging CRD request as unavailable after 2s timeout', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
const nodeWrapper = { jsonData: {} };
|
||||||
|
vi.mocked(K8s.ResourceClasses.Node.useList).mockReturnValue([[nodeWrapper], null] as any);
|
||||||
|
vi.mocked(K8s.ResourceClasses.Pod.useList).mockReturnValue([[nodeWrapper], null] as any);
|
||||||
|
vi.mocked(ApiProxy.request)
|
||||||
|
.mockReturnValueOnce(new Promise(() => {}))
|
||||||
|
.mockResolvedValueOnce({ items: [] })
|
||||||
|
.mockResolvedValueOnce({ items: [] })
|
||||||
|
.mockResolvedValueOnce({ items: [] });
|
||||||
|
|
||||||
|
const { result } = renderHook(() => useIntelGpuContext(), { wrapper: Wrapper });
|
||||||
|
|
||||||
|
expect(result.current.loading).toBe(true);
|
||||||
|
|
||||||
|
vi.advanceTimersByTime(2000);
|
||||||
|
await act(async () => {});
|
||||||
|
expect(result.current.crdAvailable).toBe(false);
|
||||||
|
expect(result.current.loading).toBe(false);
|
||||||
|
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -154,10 +154,7 @@ export function IntelGpuDataProvider({ children }: { children: React.ReactNode }
|
|||||||
|
|
||||||
for (const url of pluginPodSelectors) {
|
for (const url of pluginPodSelectors) {
|
||||||
try {
|
try {
|
||||||
const list = await withTimeout(
|
const list = await withTimeout(ApiProxy.request(url), DEFAULT_REQUEST_TIMEOUT_MS);
|
||||||
ApiProxy.request(url),
|
|
||||||
DEFAULT_REQUEST_TIMEOUT_MS
|
|
||||||
);
|
|
||||||
if (!cancelled && isKubeList(list)) {
|
if (!cancelled && isKubeList(list)) {
|
||||||
const gpuPluginPods = filterIntelGpuPluginPods(list.items);
|
const gpuPluginPods = filterIntelGpuPluginPods(list.items);
|
||||||
foundPluginPods.push(...gpuPluginPods);
|
foundPluginPods.push(...gpuPluginPods);
|
||||||
|
|||||||
Reference in New Issue
Block a user