Skip to content

Commit 4b44f3a

Browse files
author
Guilherme Saraiva
committed
Export the FE logs
- This patch prepares the FE logs to be exported on jenkins for the Extension tests - When the extension is not loaded, instead of using the UI to open the OUTPUT tab and select the extension channel, we read and export directly the FE log file, which is a less costly operation Change-Id: I26501a4b3e09fdb2972d51aa97cedbe0c8096536
1 parent d32f5b1 commit 4b44f3a

File tree

10 files changed

+90
-10
lines changed

10 files changed

+90
-10
lines changed

gui/extension/tests/e2e/lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { join } from "path";
2525

2626
// EXTENSION NAME
2727
export const extensionName = "MySQL Shell for VS Code";
28+
export const feLogFile = "1-MySQL Shell for VS Code.log";
2829

2930
// BASE PATH
3031
export const basePath = process.env.USERPROFILE ?? process.env.HOME;

gui/extension/tests/e2e/lib/misc.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,66 @@ export class Misc {
385385
spawnSync(mysqlsh, params);
386386
};
387387

388+
public static getExtentionOutputLogsFolder = async (): Promise<string> => {
389+
let testResources: string;
390+
if (Misc.isMacOs()) {
391+
testResources = "test-resources";
392+
} else {
393+
testResources = `test-resources-${process.env.TEST_SUITE}`;
394+
}
395+
const today = new Date();
396+
const month = (`0${(today.getMonth() + 1)}`).slice(-2);
397+
const day = (`0${today.getDate()}`).slice(-2);
398+
const todaysDate = `${today.getFullYear()}${month}${day}`;
399+
400+
let pathToLog = join(
401+
constants.basePath,
402+
testResources,
403+
"settings",
404+
"logs",
405+
);
406+
const variableFolder = await fs.readdir(pathToLog);
407+
pathToLog = join(
408+
constants.basePath,
409+
testResources,
410+
"settings",
411+
"logs",
412+
variableFolder[0],
413+
"window1",
414+
"exthost",
415+
);
416+
const folders = await fs.readdir(pathToLog);
417+
let outputLogging: string;
418+
for (const folder of folders) {
419+
if (folder.startsWith(`output_logging_${todaysDate}`)) {
420+
outputLogging = folder;
421+
break;
422+
}
423+
}
424+
pathToLog = join(
425+
constants.basePath,
426+
testResources,
427+
"settings",
428+
"logs",
429+
variableFolder[0],
430+
"window1",
431+
"exthost",
432+
outputLogging,
433+
);
434+
435+
return pathToLog;
436+
};
437+
438+
public static prepareExtensionLogsForExport = async (testSuite: string): Promise<void> => {
439+
const logPathFolder = await Misc.getExtentionOutputLogsFolder();
440+
// rename the file
441+
await fs.rename(join(logPathFolder, constants.feLogFile),
442+
join(logPathFolder, `${testSuite}_output_tab.log`));
443+
// copy to workspace
444+
await fs.copyFile(join(logPathFolder, `${testSuite}_output_tab.log`),
445+
join(constants.workspace, `${testSuite}_output_tab.log`));
446+
};
447+
388448
public static killRouterFromTerminal = (): void => {
389449
if (Misc.isWindows()) {
390450
try {
@@ -430,7 +490,6 @@ export class Misc {
430490
await fs.writeFile(imgPath, img, "base64");
431491

432492
addContext(testContext, { title: "Failure", value: `../screenshots/${String(testName)}_screenshot.png` });
433-
434493
};
435494

436495
public static expandDBConnectionTree = async (conn: TreeItem, password: string): Promise<void> => {

gui/extension/tests/e2e/lib/until.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import {
2424
Condition,
2525
ActivityBar,
2626
EditorView,
27-
BottomBarPanel,
2827
logging,
2928
WebElement,
3029
Locator,
3130
} from "vscode-extension-tester";
3231
import { execSync } from "child_process";
32+
import { join } from "path";
3333
import fs from "fs/promises";
3434
import * as constants from "./constants";
3535
import { Misc, driver } from "./misc";
@@ -266,18 +266,15 @@ export const extensionIsReady = (): Condition<boolean> => {
266266
if (feWasLoaded === false) {
267267
console.log("<<<<MYSQLSH Logs>>>>");
268268
await Misc.writeMySQLshLogs();
269-
const bottomBar = new BottomBarPanel();
270-
await bottomBar.maximize();
271-
await (await bottomBar.openOutputView()).selectChannel(constants.extensionName);
272-
const output = await (await bottomBar.openOutputView()).getText();
273-
console.log("<<<<OUTPUT Tab Logs>>>>");
274-
console.log(output);
275269
const logs = driver.manage().logs();
276270
console.log("<<<<<DEV TOOLS Console log>>>>");
277271
console.log(await logs.get(logging.Type.BROWSER));
278272

279273
let text = `Extension was not loaded successfully after ${feLoadTries} tries. Check the logs. `;
280274
// one last try to recover
275+
const path = join(await Misc.getExtentionOutputLogsFolder(), constants.feLogFile);
276+
const output = (await fs.readFile(path)).toString();
277+
281278
if (output.match(/(ERROR|error)/) !== null) {
282279
console.log("An error was found on the OUTPUT tab, removing Internal DB");
283280
await Misc.removeInternalDB();

gui/extension/tests/e2e/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"terminal.integrated.copyOnSelection": true,
33
"terminal.integrated.sendKeybindingsToShell": true,
44
"window.dialogStyle": "custom",
5-
"msg.debugLog.level": "DEBUG3",
5+
"msg.debugLog.level": "DEBUG2",
66
"terminal.integrated.gpuAcceleration": "off"
77
}

gui/extension/tests/e2e/tests/ui-db.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ describe("DATABASE CONNECTIONS", () => {
9595
}
9696
} catch (e) {
9797
await Misc.processFailure(this);
98+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
9899
throw e;
99100
}
100101
});
101102

102103
after(async function () {
103104
try {
105+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
104106
const dbConnections = await Misc.getDBConnections();
105107
for (const dbConnection of dbConnections) {
106108
await Misc.deleteConnection(dbConnection.name, dbConnection.isMySQL, false);

gui/extension/tests/e2e/tests/ui-notebook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ describe("NOTEBOOKS", () => {
9898

9999
after(async function () {
100100
try {
101+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
101102
const dbConnections = await Misc.getDBConnections();
102103
for (const dbConnection of dbConnections) {
103104
await Misc.deleteConnection(dbConnection.name, dbConnection.isMySQL, false);

gui/extension/tests/e2e/tests/ui-oci.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ describe("ORACLE CLOUD INFRASTRUCTURE", () => {
9898

9999
});
100100

101+
after(async function () {
102+
try {
103+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
104+
} catch (e) {
105+
await Misc.processFailure(this);
106+
throw e;
107+
}
108+
});
109+
101110
describe("Profile", () => {
102111

103112
beforeEach(async function () {

gui/extension/tests/e2e/tests/ui-open-editors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ describe("OPEN EDITORS", () => {
9595

9696
after(async function () {
9797
try {
98+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
9899
const dbConnections = await Misc.getDBConnections();
99100
for (const dbConnection of dbConnections) {
100101
await Misc.deleteConnection(dbConnection.name, dbConnection.isMySQL, false);

gui/extension/tests/e2e/tests/ui-rest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe("MySQL REST Service", () => {
123123

124124
after(async function () {
125125
try {
126+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
126127
const dbConnections = await Misc.getDBConnections();
127128
for (const dbConnection of dbConnections) {
128129
await Misc.deleteConnection(dbConnection.name, dbConnection.isMySQL, false);

gui/extension/tests/e2e/tests/ui-shell.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@ describe("MYSQL SHELL CONSOLES", () => {
9191

9292
});
9393

94-
describe("Shell generic operations", () => {
94+
after(async function () {
95+
try {
96+
await Misc.prepareExtensionLogsForExport(process.env.TEST_SUITE);
97+
} catch (e) {
98+
await Misc.processFailure(this);
99+
throw e;
100+
}
101+
});
102+
103+
describe.only("Shell generic operations", () => {
95104

96105
beforeEach(async function () {
97106
try {

0 commit comments

Comments
 (0)