Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query editor smoke test race condition #6213

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/smoke/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ after(async function () {
await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c()));
});

export const allExtensionsLoadedText = 'All Extensions Loaded';

describe('Running Code', () => {
before(async function () {
const app = new Application(this.defaultOptions);
await app!.start();
//{{SQL CARBON EDIT}}
const testExtLoadedText = 'Test Extension Loaded';
const testSetupCompletedText = 'Test Setup Completed';
const allExtensionsLoadedText = 'All Extensions Loaded';
const setupTestCommand = 'Test: Setup Integration Test';
const waitForExtensionsCommand = 'Test: Wait For Extensions To Load';
await app.workbench.statusbar.waitForStatusbarText(testExtLoadedText, testExtLoadedText);
Expand Down
10 changes: 10 additions & 0 deletions test/smoke/src/sql/queryEditor/queryEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
*--------------------------------------------------------------------------------------------*/

import { Application } from '../../application';
import { allExtensionsLoadedText } from '../../main';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

export function setup() {
describe('Query Editor Test Suite', () => {
before(async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this would change anything. This is already done here

await app.workbench.quickopen.runCommand(waitForExtensionsCommand);
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well shoot, yeah I saw that but for some reason thought we were doing a reload of the app after waiting. The issue is definitely because focus is being taken from the query window though - although why that's happening after the service should be done downloading I'm not sure...it doesn't repro consistently enough to really help here.

I'll try changing it to just specifically focus the query pane before typing the text - that should also solve the problem unless the focus stealing is happening even after the download is finished.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it this is being caused because of the service downloading, you could change the output channel logic in the extensions to not continuously open the output log. https://github.com/microsoft/azuredatastudio/blob/master/extensions/mssql/src/main.ts#L365 I have been thinking about doing this, but its been low pri since it has no user impact on our releases since we never download new service binaries for releases.

// Wait for all extensions to load. This is to prevent a race condition where some extensions
// were downloading additional resources and sending messages for that to the output window,
// which was grabbing focus from the text area. If this happened while the text in the tests
// was being typed then it would not be able to finish typing the text and thus the test would
// fail.
const app = this.app as Application;
await app.workbench.statusbar.waitForStatusbarText(allExtensionsLoadedText, allExtensionsLoadedText);
});

it('Can open and edit existing file', async function () {
const testFilePath = path.join(os.tmpdir(), 'QueryEditorSmokeTest.sql');
Expand Down