Fix Helm repositories and pod logs integration tests (#2015)

* Fix Helm repository and pod logs integration tests

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>

* Return parsed object

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala authored and GitHub committed 2021-01-26 13:26:45 +02:00
1 parent 09dc2790db
commit 5f19606129
2 files changed
+55 -10

No files matched your search

+23
View File
@@ -1,4 +1,6 @@
import { Application } from "spectron";
import * as util from "util";
import { exec } from "child_process";
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
"win32": "./dist/win-unpacked/Lens.exe",
@@ -26,7 +28,12 @@ export function setup(): Application {
});
}
type HelmRepository = {
name: string;
url: string;
};
type AsyncPidGetter = () => Promise<number>;
export const promiseExec = util.promisify(exec);
export async function tearDown(app: Application) {
const pid = await (app.mainProcess.pid as any as AsyncPidGetter)();
@@ -39,3 +46,19 @@ export async function tearDown(app: Application) {
console.error(e);
}
}
export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]>{
if (retries < 5) {
try {
const { stdout: reposJson } = await promiseExec("helm repo list -o json");
return JSON.parse(reposJson);
} catch {
await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository
return await listHelmRepositories((retries + 1));
}
}
return [];
}