Skip to content

Commit b3c08aa

Browse files
committed
adding ui tests
add UI tests deploy workflow tmp - terminal logs switch to minikube workaround deploy to kubernetes for Camel 4.8.1/4.9
1 parent f6b7272 commit b3c08aa

File tree

8 files changed

+179
-11
lines changed

8 files changed

+179
-11
lines changed

.github/workflows/coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ jobs:
5454
- name: Coverage
5555
run: |
5656
set +e
57-
xvfb-run --auto-servernum npm run ui-coverage
57+
xvfb-run --auto-servernum npm run ui-test:coverage
5858
exit 0
5959
- name: Upload Coverage Results
6060
uses: actions/upload-artifact@v4
6161
if: always()
6262
with:
63-
name: ui-coverage
63+
name: ui-test-coverage
6464
path: ${{ github.workspace }}/coverage

.github/workflows/deploy.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy to Kubernetes CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy:
16+
env:
17+
CODE_VERSION: max
18+
TEST_RESOURCES: test-resources
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: 17
32+
distribution: "temurin"
33+
34+
- name: Install JBang
35+
run: |
36+
curl -Ls https://sh.jbang.dev | bash -s - app setup
37+
echo "$HOME/.jbang/bin" >> $GITHUB_PATH
38+
- name: Setup JBang (trusted sources)
39+
run: jbang trust add https://github.com/apache/
40+
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: npm
46+
47+
- name: Start Minikube
48+
uses: medyagh/setup-minikube@latest
49+
with:
50+
driver: docker
51+
addons: registry
52+
53+
- name: Cluster info
54+
run: |
55+
kubectl cluster-info
56+
kubectl get pods -n kube-system
57+
echo "current-context:" $(kubectl config current-context)
58+
echo "environment-kubeconfig:" ${KUBECONFIG}
59+
60+
- name: Install
61+
run: npm ci
62+
63+
- name: Compile
64+
run: npm run compile
65+
66+
- name: UI Tests
67+
run: |
68+
eval $(minikube -p minikube docker-env)
69+
xvfb-run --auto-servernum npm run ui-test:deploy
70+
71+
- name: Upload Coverage Results
72+
uses: actions/upload-artifact@v4
73+
if: always()
74+
with:
75+
name: ui-test-screenshots
76+
path: test-resources/screenshots/*.png

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_modules
55
*.vsix
66
jars/camel-dap-server.jar
77
test-resources
8-
.camel-jbang
8+
.camel-jbang*
99
.test-extensions
1010
*sbom.json
1111
coverage

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@
331331
"lint": "eslint src --ext ts",
332332
"test": "node ./out/test/runTest.js",
333333
"ui-test": "node ./out/ui-test/uitest_runner.js",
334-
"ui-coverage": "npm run ui-test -- coverage"
334+
"ui-test:deploy": "npm run ui-test -- deploy",
335+
"ui-test:coverage": "npm run ui-test -- coverage"
335336
},
336337
"devDependencies": {
337338
"@stylistic/eslint-plugin": "^2.9.0",

src/task/CamelJBangTaskProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ export class CamelJBangTaskProvider implements TaskProvider {
8181
'jbang',
8282
[
8383
{
84-
"value": `-Dcamel.jbang.version=${this.getCamelJBangCLIVersion()}`,
84+
// "value": `-Dcamel.jbang.version=${this.getCamelJBangCLIVersion()}`,
85+
// it can be switched back after bump to default version Camel JBang 4.8.1
86+
// the 4.9.0-SNAPSHOT version will be used only for deploy feature
87+
"value": `-Dcamel.jbang.version=4.9.0-SNAPSHOT`,
8588
"quoting": ShellQuoting.Strong
8689
},
8790
'camel@apache/camel',

src/ui-test/resources/vscode-settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
"window.title": "${dirty}${activeEditorLong}${separator}${rootPath}${separator}${appName}",
1515
"redhat.telemetry.enabled": false,
1616
"terminal.integrated.sendKeybindingsToShell": true,
17-
"git.autoRepositoryDetection": false
17+
"git.autoRepositoryDetection": false,
18+
"camel.debugAdapter.KubernetesRunParameters": [
19+
"--cluster-type=minikube",
20+
"--build-property=quarkus.kubernetes.image-pull-policy=Never"
21+
]
1822
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License", destination); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import { resolve } from 'node:path';
18+
import { CAMEL_ROUTE_YAML_WITH_SPACE } from '../variables';
19+
import {
20+
ActivityBar,
21+
after,
22+
before,
23+
BottomBarPanel,
24+
EditorAction,
25+
EditorView,
26+
repeat,
27+
SideBarView,
28+
VSBrowser,
29+
} from 'vscode-uitests-tooling';
30+
import { killTerminal, waitUntilTerminalHasText } from '../utils';
31+
import { execSync } from 'child_process';
32+
33+
describe('Camel standalone file deployment using Camel JBang Kubernetes Run', function () {
34+
this.timeout(800_000);
35+
36+
let editorView: EditorView;
37+
const RESOURCES_PATH: string = resolve('src', 'ui-test', 'resources');
38+
39+
before(async function () {
40+
await VSBrowser.instance.openResources(RESOURCES_PATH);
41+
await (await new ActivityBar().getViewControl('Explorer')).openView();
42+
const section = await new SideBarView().getContent().getSection('resources');
43+
await section.openItem(CAMEL_ROUTE_YAML_WITH_SPACE);
44+
45+
editorView = new EditorView();
46+
await repeat(async function () {
47+
return (await editorView.getOpenEditorTitles()).find(title => title === CAMEL_ROUTE_YAML_WITH_SPACE);
48+
}, {
49+
timeout: 10_000,
50+
message: `The test file ${CAMEL_ROUTE_YAML_WITH_SPACE} was not opened`
51+
});
52+
});
53+
54+
after(async function () {
55+
await killTerminal();
56+
await editorView.closeAllEditors();
57+
// remove deployed integration from a local cluster
58+
execSync('jbang camel@apache/camel kubernetes delete --name=demoroute', { stdio: 'inherit', cwd: RESOURCES_PATH });
59+
});
60+
61+
it('Deploy integration to Kubernetes (Minikube)', async function () {
62+
const action = (await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run')) as EditorAction;
63+
await action.click();
64+
65+
// using some additional steps for CAMEL 4.9.0-SNAPSHOT / 4.8.1 version
66+
// because the '--dev' parameter is not working for a deployment to Kubernetes
67+
await waitUntilTerminalHasText(action.getDriver(), ['BUILD SUCCESS'], 3_000, 240_000);
68+
await killTerminal();
69+
70+
const terminalView = await new BottomBarPanel().openTerminalView();
71+
await terminalView.getDriver().wait(async () => {
72+
const found = (await terminalView.getText()).match(/[A-Za-z]/g);
73+
return found;
74+
}, 10_000, 'New terminal shell was not opened properly.', 2_000);
75+
// skip 'await' for async function to allow continue test after terminal command execution which would be blocking thread for infinity
76+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
77+
terminalView.executeCommand('jbang camel@apache/camel kubernetes logs --name=demoroute');
78+
await waitUntilTerminalHasText(action.getDriver(), ['Hello Camel from'], 3_000, 120_000);
79+
});
80+
81+
});

src/ui-test/uitest_runner.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ const releaseType: ReleaseQuality = process.env.CODE_TYPE === 'insider' ? Releas
2626
export const projectPath = path.resolve(__dirname, '..', '..');
2727
const extensionFolder = variables.EXTENSION_DIR;
2828
const coverage = process.argv[2] === 'coverage';
29+
const deploy = process.argv[2] === 'deploy';
2930

3031
async function main(): Promise<void> {
3132
const tester = new ExTester(storageFolder, releaseType, extensionFolder, coverage);
33+
const tests = deploy ? 'out/ui-test/tests/deploy*.test.js' : [
34+
'out/ui-test/env/set.camel.version.js',
35+
'out/ui-test/tests/*.test.js',
36+
'out/ui-test/env/check.camel.version.js'
37+
];
38+
3239
await tester.setupAndRunTests(
33-
[
34-
'out/ui-test/env/set.camel.version.js',
35-
'out/ui-test/tests/*.test.js',
36-
'out/ui-test/env/check.camel.version.js'
37-
],
40+
tests,
3841
process.env.CODE_VERSION,
3942
{
4043
'installDependencies': true

0 commit comments

Comments
 (0)