Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43b812da7b |
@@ -154,24 +154,18 @@ describe('IntelGpuDataProvider', () => {
|
|||||||
|
|
||||||
it('treats a hanging CRD request as unavailable after 2s timeout', async () => {
|
it('treats a hanging CRD request as unavailable after 2s timeout', async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
const nodeWrapper = { jsonData: {} };
|
vi.mocked(K8s.ResourceClasses.Node.useList).mockReturnValue([[], null] as any);
|
||||||
vi.mocked(K8s.ResourceClasses.Node.useList).mockReturnValue([[nodeWrapper], null] as any);
|
vi.mocked(K8s.ResourceClasses.Pod.useList).mockReturnValue([[], null] as any);
|
||||||
vi.mocked(K8s.ResourceClasses.Pod.useList).mockReturnValue([[nodeWrapper], null] as any);
|
vi.mocked(ApiProxy.request).mockReturnValue(new Promise(() => {}));
|
||||||
vi.mocked(ApiProxy.request)
|
|
||||||
.mockReturnValueOnce(new Promise(() => {}))
|
|
||||||
.mockResolvedValueOnce({ items: [] })
|
|
||||||
.mockResolvedValueOnce({ items: [] })
|
|
||||||
.mockResolvedValueOnce({ items: [] });
|
|
||||||
|
|
||||||
const { result } = renderHook(() => useIntelGpuContext(), { wrapper: Wrapper });
|
const { result } = renderHook(() => useIntelGpuContext(), { wrapper: Wrapper });
|
||||||
|
|
||||||
expect(result.current.loading).toBe(true);
|
await act(async () => {
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
});
|
||||||
|
|
||||||
vi.advanceTimersByTime(2000);
|
|
||||||
await act(async () => {});
|
|
||||||
expect(result.current.crdAvailable).toBe(false);
|
|
||||||
expect(result.current.loading).toBe(false);
|
expect(result.current.loading).toBe(false);
|
||||||
|
expect(result.current.crdAvailable).toBe(false);
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -154,7 +154,10 @@ export function IntelGpuDataProvider({ children }: { children: React.ReactNode }
|
|||||||
|
|
||||||
for (const url of pluginPodSelectors) {
|
for (const url of pluginPodSelectors) {
|
||||||
try {
|
try {
|
||||||
const list = await withTimeout(ApiProxy.request(url), DEFAULT_REQUEST_TIMEOUT_MS);
|
const list = await withTimeout(
|
||||||
|
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