Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the "vscode-debug-adapter-apache-camel" extension will be
## 1.10.0

- Use Node 22 instead of Node 20, minimal version of VS Code is now 1.101
- Update default Camel version used for Camel JBang from 4.13.0 to 4.14.0

## 1.9.0

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"camel.debugAdapter.JBangVersion": {
"type": "string",
"markdownDescription": "Apache Camel JBang CLI version used for internal VS Code JBang commands execution. Camel JBang CLI requirements can differ between versions, it is recommended to use `default` version to ensure all extension features work properly.\n\n**Note**: This change will affect only commands provided by Debug Adapter for Apache Camel extension.",
"default": "4.13.0"
"default": "4.14.0"
},
"camel.debugAdapter.CamelVersion": {
"type": "string",
Expand Down
2 changes: 2 additions & 0 deletions src/ui-test/tests/context.menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
selectContextMenuItem,
waitUntilTerminalHasText
} from '../utils';
import { waitForPortToBeFreed } from './helper/PortHelper';

(process.platform === 'darwin' ? describe.skip : describe)('Camel file context menu test', function () {
this.timeout(240000);
Expand Down Expand Up @@ -96,5 +97,6 @@ import {
await (await new ActivityBar().getViewControl('Run and Debug'))?.closeView();
await disconnectDebugger(driver);
await killTerminal();
await waitForPortToBeFreed(1099);
});
});
2 changes: 2 additions & 0 deletions src/ui-test/tests/editor.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from '../utils';
import { CAMEL_RUN_DEBUG_FOLDER_ACTION_LABEL, CAMEL_RUN_DEBUG_WORKSPACE_ACTION_LABEL, CAMEL_RUN_FOLDER_ACTION_LABEL, CAMEL_RUN_WORKSPACE_ACTION_LABEL, TOP_ROUTE_1 } from '../variables';
import { openDropDownMenuEditorAction, selectDropDownMenuEditorAction } from './helper/Awaiters';
import { waitForPortToBeFreed } from './helper/PortHelper';

describe('Camel file editor test', function () {

Expand All @@ -56,6 +57,7 @@ describe('Camel file editor test', function () {
await driver.wait(async function () {
return (await editorView.getOpenEditorTitles()).find(title => title === TOP_ROUTE_1);
}, 5000);
await waitForPortToBeFreed(1099);
});

afterEach(async function () {
Expand Down
47 changes: 47 additions & 0 deletions src/ui-test/tests/helper/PortHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import net from 'net';

/**
* Checks if a port is available.
* @param port - The port number to check.
* @returns A promise that resolves when the port is free.
*/
export async function waitForPortToBeFreed(port: number): Promise<void> {
while (true) {
const isFree = await isPortFree(port);
if (isFree) {
return;
}
await delay(1000); // Wait for 1 second before checking again
}
}

/**
* Checks if a port is free.
* @param port - The port number to check.
* @returns A promise that resolves to true if the port is free, otherwise false.
*/
function isPortFree(port: number): Promise<boolean> {
return new Promise((resolve) => {
const server = net.createServer();

server.once('error', () => {
resolve(false); // Port is in use
});

server.once('listening', () => {
server.close();
resolve(true); // Port is free
});

server.listen(port);
});
}

/**
* Delays execution for a given number of milliseconds.
* @param ms - The number of milliseconds to delay.
* @returns A promise that resolves after the delay.
*/
function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
Loading