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

Proxy fix #461

Merged
merged 5 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 39 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"runtimeExecutable": "${execPath}",
"env": {
"FIXTURE_NAME": "gradle-groovy-default-build-file",
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests with Gradle"
},
"args": [
"--disable-extensions",
Expand All @@ -72,7 +73,8 @@
"runtimeExecutable": "${execPath}",
"env": {
"FIXTURE_NAME": "gradle-kotlin-default-build-file",
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests with Gradle"
},
"args": [
"--disable-extensions",
Expand All @@ -96,7 +98,8 @@
"runtimeExecutable": "${execPath}",
"env": {
"FIXTURE_NAME": "gradle-groovy-custom-build-file",
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests with Gradle"
},
"args": [
"--disable-extensions",
Expand All @@ -119,7 +122,8 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"env": {
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests without Gradle"
},
"args": [
"--disable-extensions",
Expand All @@ -143,7 +147,8 @@
"runtimeExecutable": "${execPath}",
"env": {
"FIXTURE_NAME": "multi-root-workspace",
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests with multi-root vscode project"
},
"args": [
"--disable-extensions",
Expand All @@ -166,7 +171,8 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"env": {
"VSCODE_TEST": "true"
"VSCODE_TEST": "true",
"SUITE_NAME": "Run tests with Gradle multi-project"
},
"args": [
"--disable-extensions",
Expand All @@ -182,7 +188,33 @@
"presentation": {
"group": "test"
}
}
},
{
"name": "Test: Network",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"env": {
"FIXTURE_NAME": "gradle-groovy-default-build-file",
"VSCODE_TEST": "true",
"http_proxy": "http://0.0.0.0",
"SUITE_NAME": "Run network tests with Gradle"
},
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}/extension",
"--extensionTestsPath=${workspaceFolder}/extension/out/test/gradle",
"${workspaceFolder}/extension/test-fixtures/gradle-groovy-default-build-file"
],
"outFiles": [
"${workspaceFolder}/extension/dist/**/*.js",
"${workspaceFolder}/extension/out/test/**/*.js"
],
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
},
],
"compounds": [
{
Expand Down
21 changes: 10 additions & 11 deletions extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
},
"dependencies": {},
"devDependencies": {
"@grpc/grpc-js": "^1.0.4",
"@grpc/grpc-js": "^1.0.5",
"@types/fs-extra": "^9.0.0",
"@types/glob": "^7.1.1",
"@types/google-protobuf": "^3.7.2",
Expand All @@ -492,6 +492,7 @@
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"get-port": "^5.1.1",
"google-auth-library": "^6.0.1",
"google-protobuf": "^3.11.4",
"grpc-tools": "^1.9.0",
"mocha": "^7.1.2",
Expand Down
3 changes: 2 additions & 1 deletion extension/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export class GradleTasksClient implements vscode.Disposable {
try {
this.grpcClient = new GrpcClient(
`localhost:${this.server.getPort()}`,
grpc.credentials.createInsecure()
grpc.credentials.createInsecure(),
{ 'grpc.enable_http_proxy': 0 }
);
const deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + this.connectDeadline);
Expand Down
25 changes: 2 additions & 23 deletions extension/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@ import * as getPort from 'get-port';

import { logger } from './logger';
import { buildGradleServerTask } from './tasks';
import { isDebuggingServer, waitOnTcp } from './util';
import { isDebuggingServer } from './util';

export const SERVER_TASK_NAME = 'Gradle Tasks Server';

function isProcessRunning(pid: number): boolean {
try {
process.kill(pid, 0);
return true;
} catch (error) {
return error.code === 'EPERM';
}
}

export interface ServerOptions {
host: string;
}
Expand All @@ -38,19 +29,7 @@ export class GradleTasksServer implements vscode.Disposable {
context.subscriptions.push(
vscode.tasks.onDidStartTaskProcess(async (event) => {
if (event.execution.task.name === SERVER_TASK_NAME) {
if (isProcessRunning(event.processId)) {
logger.debug(
'Gradle server process started, waiting for server to start'
);
try {
await waitOnTcp('localhost', this.port!);
this.fireOnReady();
} catch (e) {
logger.error('Gradle server not started:', e.message);
}
} else {
logger.error('Gradle server processes not started');
}
this.fireOnReady();
}
}),
vscode.tasks.onDidEndTaskProcess((event) => {
Expand Down
3 changes: 2 additions & 1 deletion extension/src/test/gradle/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import { Output } from '../../proto/gradle_tasks_pb';
const extensionName = 'richardwillis.vscode-gradle';
const refreshCommand = 'gradle.refresh';
const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)';
const suiteName = process.env.SUITE_NAME || '(unknown suite)';
const fixturePath = vscode.Uri.file(
path.resolve(__dirname, '..', '..', '..', 'test-fixtures', fixtureName)
);

describe(fixtureName, () => {
describe(`${suiteName} - ${fixtureName}`, () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let extension: vscode.Extension<any> | undefined;

Expand Down
3 changes: 2 additions & 1 deletion extension/src/test/multi-project/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { waitForTasksToLoad } from '../testUtil';

const extensionName = 'richardwillis.vscode-gradle';
const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)';
const suiteName = process.env.SUITE_NAME || '(unknown suite)';

describe(fixtureName, () => {
describe(`${suiteName} - ${fixtureName}`, () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let extension: vscode.Extension<any> | undefined;

Expand Down
3 changes: 2 additions & 1 deletion extension/src/test/multi-root/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { waitForTasksToLoad } from '../testUtil';

const extensionName = 'richardwillis.vscode-gradle';
const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)';
const suiteName = process.env.SUITE_NAME || '(unknown suite)';

describe(fixtureName, () => {
describe(`${suiteName} - ${fixtureName}`, () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let extension: vscode.Extension<any> | undefined;

Expand Down
31 changes: 31 additions & 0 deletions extension/src/test/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,39 @@ async function runTestsWithGradle(
],
extensionTestsEnv: {
FIXTURE_NAME: fixture,
SUITE_NAME: 'Run tests with Gradle',
VSCODE_TEST: 'true',
},
});
}
}

async function runNetworkTestsWithGradle(
vscodeExecutablePath: string,
userDir: string
): Promise<void> {
const fixtures = ['gradle-groovy-custom-build-file'];
for (const fixture of fixtures) {
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath: path.resolve(__dirname, 'gradle'),
launchArgs: [
path.resolve(__dirname, `../../test-fixtures/${fixture}`),
'--disable-extensions',
`--user-data-dir=${userDir}`,
],
extensionTestsEnv: {
FIXTURE_NAME: fixture,
VSCODE_TEST: 'true',
SUITE_NAME: 'Run network tests with Gradle',
// eslint-disable-next-line @typescript-eslint/camelcase
http_proxy: 'http://0.0.0.0',
},
});
}
}

function runTestsWithoutGradle(
vscodeExecutablePath: string,
userDir: string
Expand All @@ -50,6 +77,7 @@ function runTestsWithoutGradle(
],
extensionTestsEnv: {
VSCODE_TEST: 'true',
SUITE_NAME: 'Run tests without Gradle',
},
});
}
Expand All @@ -73,6 +101,7 @@ function runTestsWithMultiRoot(
extensionTestsEnv: {
FIXTURE_NAME: 'multi-root',
VSCODE_TEST: 'true',
SUITE_NAME: 'Run tests with multi-root vscode project',
},
});
}
Expand All @@ -93,6 +122,7 @@ function runTestsWithMultiProject(
extensionTestsEnv: {
FIXTURE_NAME: 'multi-project',
VSCODE_TEST: 'true',
SUITE_NAME: 'Run tests with Gradle multi-project',
},
});
}
Expand All @@ -109,6 +139,7 @@ async function main(): Promise<void> {

try {
await runTestsWithGradle(vscodeExecutablePath, tmpDir);
await runNetworkTestsWithGradle(vscodeExecutablePath, tmpDir);
await runTestsWithMultiRoot(vscodeExecutablePath, tmpDir);
await runTestsWithMultiProject(vscodeExecutablePath, tmpDir);
await runTestsWithoutGradle(vscodeExecutablePath, tmpDir);
Expand Down
6 changes: 3 additions & 3 deletions npm-package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"compile": "tsc -p ./"
},
"dependencies": {
"@grpc/grpc-js": "^1.0.3",
"@grpc/grpc-js": "^1.0.5",
"@types/google-protobuf": "^3.7.2",
"@types/vscode": "^1.45.0",
"google-protobuf": "^3.12.0-rc.1"
Expand Down