mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
parent
09dc2790db
commit
5f19606129
@ -6,10 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
import * as utils from "../helpers/utils";
|
import * as utils from "../helpers/utils";
|
||||||
import { spawnSync, exec } from "child_process";
|
import { spawnSync } from "child_process";
|
||||||
import * as util from "util";
|
import { listHelmRepositories } from "../helpers/utils";
|
||||||
|
import { fail } from "assert";
|
||||||
|
|
||||||
export const promiseExec = util.promisify(exec);
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
@ -96,8 +96,11 @@ describe("Lens integration tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ensures helm repos", async () => {
|
it("ensures helm repos", async () => {
|
||||||
const { stdout: reposJson } = await promiseExec("helm repo list -o json");
|
const repos = await listHelmRepositories();
|
||||||
const repos = JSON.parse(reposJson);
|
|
||||||
|
if (!repos[0]) {
|
||||||
|
fail("Lens failed to add Bitnami repository");
|
||||||
|
}
|
||||||
|
|
||||||
await app.client.waitUntilTextExists("div.repos #message-bitnami", repos[0].name); // wait for the helm-cli to fetch the repo(s)
|
await app.client.waitUntilTextExists("div.repos #message-bitnami", repos[0].name); // wait for the helm-cli to fetch the repo(s)
|
||||||
await app.client.click("#HelmRepoSelect"); // click the repo select to activate the drop-down
|
await app.client.click("#HelmRepoSelect"); // click the repo select to activate the drop-down
|
||||||
@ -505,19 +508,35 @@ describe("Lens integration tests", () => {
|
|||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
await app.client.click('a[href^="/pods"]');
|
await app.client.click('a[href^="/pods"]');
|
||||||
|
await app.client.click(".NamespaceSelect");
|
||||||
|
await app.client.keys("kube-system");
|
||||||
|
await app.client.keys("Enter");// "\uE007"
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
||||||
|
let podMenuItemEnabled = false;
|
||||||
|
|
||||||
|
// Wait until extensions are enabled on renderer
|
||||||
|
while (!podMenuItemEnabled) {
|
||||||
|
const logs = await app.client.getRenderProcessLogs();
|
||||||
|
|
||||||
|
podMenuItemEnabled = !!logs.find(entry => entry.message.includes("[EXTENSION]: enabled lens-pod-menu@"));
|
||||||
|
|
||||||
|
if (!podMenuItemEnabled) {
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await new Promise(r => setTimeout(r, 500)); // Give some extra time to prepare extensions
|
||||||
// Open logs tab in dock
|
// Open logs tab in dock
|
||||||
await app.client.click(".list .TableRow:first-child");
|
await app.client.click(".list .TableRow:first-child");
|
||||||
await app.client.waitForVisible(".Drawer");
|
await app.client.waitForVisible(".Drawer");
|
||||||
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
||||||
// Check if controls are available
|
// Check if controls are available
|
||||||
await app.client.waitForVisible(".Logs .VirtualList");
|
await app.client.waitForVisible(".LogList .VirtualList");
|
||||||
await app.client.waitForVisible(".LogResourceSelector");
|
await app.client.waitForVisible(".LogResourceSelector");
|
||||||
await app.client.waitForVisible(".LogResourceSelector .SearchInput");
|
//await app.client.waitForVisible(".LogSearch .SearchInput");
|
||||||
await app.client.waitForVisible(".LogResourceSelector .SearchInput input");
|
await app.client.waitForVisible(".LogSearch .SearchInput input");
|
||||||
// Search for semicolon
|
// Search for semicolon
|
||||||
await app.client.keys(":");
|
await app.client.keys(":");
|
||||||
await app.client.waitForVisible(".Logs .list span.active");
|
await app.client.waitForVisible(".LogList .list span.active");
|
||||||
// Click through controls
|
// Click through controls
|
||||||
await app.client.click(".LogControls .show-timestamps");
|
await app.client.click(".LogControls .show-timestamps");
|
||||||
await app.client.click(".LogControls .show-previous");
|
await app.client.click(".LogControls .show-previous");
|
||||||
@ -556,7 +575,10 @@ describe("Lens integration tests", () => {
|
|||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
await app.client.click('a[href^="/pods"]');
|
await app.client.click('a[href^="/pods"]');
|
||||||
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
|
||||||
|
await app.client.click(".NamespaceSelect");
|
||||||
|
await app.client.keys(TEST_NAMESPACE);
|
||||||
|
await app.client.keys("Enter");// "\uE007"
|
||||||
await app.client.click(".Icon.new-dock-tab");
|
await app.client.click(".Icon.new-dock-tab");
|
||||||
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
|
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
|
||||||
await app.client.click("li.MenuItem.create-resource-tab");
|
await app.client.click("li.MenuItem.create-resource-tab");
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
|
import * as util from "util";
|
||||||
|
import { exec } from "child_process";
|
||||||
|
|
||||||
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
||||||
"win32": "./dist/win-unpacked/Lens.exe",
|
"win32": "./dist/win-unpacked/Lens.exe",
|
||||||
@ -26,7 +28,12 @@ export function setup(): Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HelmRepository = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
type AsyncPidGetter = () => Promise<number>;
|
type AsyncPidGetter = () => Promise<number>;
|
||||||
|
export const promiseExec = util.promisify(exec);
|
||||||
|
|
||||||
export async function tearDown(app: Application) {
|
export async function tearDown(app: Application) {
|
||||||
const pid = await (app.mainProcess.pid as any as AsyncPidGetter)();
|
const pid = await (app.mainProcess.pid as any as AsyncPidGetter)();
|
||||||
@ -39,3 +46,19 @@ export async function tearDown(app: Application) {
|
|||||||
console.error(e);
|
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 [];
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user