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

test: add downstream UI test for deployment into OpenShift cluster #809

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: UI Tests
run: |
eval $(minikube -p minikube docker-env)
xvfb-run --auto-servernum npm run ui-test:deploy
xvfb-run --auto-servernum npm run ui-test:deploy:minikube

- name: Upload Coverage Results
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the "vscode-debug-adapter-apache-camel" extension will be

## 1.6.0

- Update default Camel version used for Camel JBang from 4.8.1 to 4.8.2

## 1.5.0

- Use containing folder by default with commands and quick editor action when launching a specific Camel Route. It allows to have other relative parameters still working when it is inside a subfolder.
Expand Down
4 changes: 2 additions & 2 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ When testing new version of the Camel Debug Adapter Server, just replace the jar
* Create the Pull Request
* Wait for Pull Request to be merged
* Check that someone listed as _submitter_ in the [Jenkinsfile](Jenkinsfile) is available
* Check build is working fine on [GitHub Actions](https://github.com/camel-tooling/camel-dap-client-vscode/actions) and [Jenkins CI](https://master-jenkins-csb-fusetools-qe.apps.ocp-c1.prod.psi.redhat.com/view/VS%20Code%20-%20release/job/vscode/job/eng/job/vscode-camel-dap-release/)
* Start build on [Jenkins CI](https://master-jenkins-csb-fusetools-qe.apps.ocp-c1.prod.psi.redhat.com/view/VS%20Code%20-%20release/job/vscode/job/eng/job/vscode-camel-dap-release/) with _publishToMarketPlace_ and _publishToOVSX_ parameters checked
* Check build is working fine on [GitHub Actions](https://github.com/camel-tooling/camel-dap-client-vscode/actions) and [Jenkins CI](https://jenkins-csb-fusetools-qe-master.dno.corp.redhat.com/view/VS%20Code%20-%20release/job/vscode/job/eng/job/vscode-camel-dap-release/)
* Start build on [Jenkins CI](https://jenkins-csb-fusetools-qe-master.dno.corp.redhat.com/view/VS%20Code%20-%20release/job/vscode/job/eng/job/vscode-camel-dap-release/) with _publishToMarketPlace_ and _publishToOVSX_ parameters checked
* Wait the build is waiting on step _Publish to Marketplace_
* Check manually the `vsix` file pushed on [snapshots area](https://download.jboss.org/jbosstools/vscode/snapshots/vscode-debug-adapter-apache-camel/)
* For someone from _submitter_ list:
Expand Down
30 changes: 21 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
node('rhel9'){
stage('Checkout repo') {
deleteDir()
git url: 'https://github.com/camel-tooling/camel-dap-client-vscode.git',
branch: 'main'
git url: "https://github.com/${FORK}/camel-dap-client-vscode.git",
branch: "${BRANCH}"
}

stage('Install requirements') {
Expand All @@ -17,7 +17,7 @@ node('rhel9'){
}

stage('Build') {
env.JAVA_HOME="${tool 'openjdk-11'}"
env.JAVA_HOME="${tool 'openjdk-17'}"
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
sh "java -version"

Expand All @@ -27,13 +27,25 @@ node('rhel9'){

withEnv(['JUNIT_REPORT_PATH=report.xml']) {
stage('Test') {
wrap([$class: 'Xvnc']) {
sh "npm test --silent"
junit 'report.xml'
}
wrap([$class: 'Xvnc']) {
sh "npm test --silent"
junit 'report.xml'
}
}
}

withEnv(['TEST_RESOURCES=test-resources','CODE_VERSION=max']) {
stage('UI Test: OpenShift deployment') {
wrap([$class: 'Xvnc']) {
withCredentials([[$class: 'StringBinding', credentialsId: 'oc_developer_token', variable: 'TOKEN']]) {
sh 'oc login --token=${TOKEN} --server=https://api.ft-417-a.fuse.integration-qe.com:6443 --insecure-skip-tls-verify=true'
sh 'oc project camel-dap-uitest'
}
sh 'npm run ui-test:deploy:openshift'
}
}
}

stage('Package') {
def packageJson = readJSON file: 'package.json'
sh "vsce package -o vscode-debug-adapter-apache-camel-${packageJson.version}-${env.BUILD_NUMBER}.vsix --no-yarn"
Expand Down Expand Up @@ -92,8 +104,8 @@ node('rhel9'){
sh "sftp -C ${UPLOAD_LOCATION}/stable/vscode-debug-adapter-apache-camel/ <<< \$'put -p -r ${tgz[0].path}'"

sh "npm install -g ovsx"
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions 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.8.1"
"default": "4.8.2"
},
"camel.debugAdapter.CamelVersion": {
"type": "string",
Expand Down Expand Up @@ -331,7 +331,8 @@
"lint": "eslint src",
"test": "node ./out/test/runTest.js",
"ui-test": "node ./out/ui-test/uitest_runner.js",
"ui-test:deploy": "npm run ui-test -- deploy",
"ui-test:deploy:minikube": "npm run ui-test -- minikube",
"ui-test:deploy:openshift": "npm run ui-test -- openshift",
"ui-test:coverage": "npm run ui-test -- coverage"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions src/ui-test/resources/vscode-settings-minikube.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"camel.debugAdapter.KubernetesRunParameters": [
"--cluster-type=minikube",
"--build-property=quarkus.kubernetes.image-pull-policy=Never"
]
}
6 changes: 6 additions & 0 deletions src/ui-test/resources/vscode-settings-openshift.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"camel.debugAdapter.KubernetesRunParameters": [
"--cluster-type=openshift",
"--dev"
]
}
6 changes: 1 addition & 5 deletions src/ui-test/resources/vscode-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
"window.title": "${dirty}${activeEditorLong}${separator}${rootPath}${separator}${appName}",
"redhat.telemetry.enabled": false,
"terminal.integrated.sendKeybindingsToShell": true,
"git.autoRepositoryDetection": false,
"camel.debugAdapter.KubernetesRunParameters": [
"--cluster-type=minikube",
"--build-property=quarkus.kubernetes.image-pull-policy=Never"
]
"git.autoRepositoryDetection": false
}
64 changes: 64 additions & 0 deletions src/ui-test/tests/deploy.openshift.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License", destination); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { resolve } from 'node:path';
import { CAMEL_ROUTE_YAML_WITH_SPACE } from '../variables';
import {
ActivityBar,
after,
before,
EditorAction,
EditorView,
SideBarView,
VSBrowser,
} from 'vscode-extension-tester';
import { killTerminal, waitUntilTerminalHasText } from '../utils';

/**
* Note: OC login needs to be done before executing this test
*/
describe('Camel standalone file deployment using Camel JBang Kubernetes Run', function () {
this.timeout(600_000); // 10 minutes

let editorView: EditorView;
const RESOURCES_PATH: string = resolve('src', 'ui-test', 'resources');

before(async function () {
await VSBrowser.instance.openResources(RESOURCES_PATH);
await (await new ActivityBar().getViewControl('Explorer'))?.openView();
const section = await new SideBarView().getContent().getSection('resources');
await section.openItem(CAMEL_ROUTE_YAML_WITH_SPACE);

editorView = new EditorView();
await editorView.getDriver().wait(async function () {
return (await editorView.getOpenEditorTitles()).find(title => title === CAMEL_ROUTE_YAML_WITH_SPACE);
}, 10_000, `The test file ${CAMEL_ROUTE_YAML_WITH_SPACE} was not opened`);
});

after(async function () {
await killTerminal();
await editorView.closeAllEditors();
});

it('Deploy integration to OpenShift cluster', async function () {
const action = (await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run')) as EditorAction;
await action.click();

await waitUntilTerminalHasText(action.getDriver(), ['BUILD SUCCESS'], 5_000, 600_000);
await waitUntilTerminalHasText(action.getDriver(), ['Hello Camel from'], 3_000, 30_000);
});

});
31 changes: 24 additions & 7 deletions src/ui-test/uitest_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,32 @@ const releaseType: ReleaseQuality = process.env.CODE_TYPE === 'insider' ? Releas
export const projectPath = path.resolve(__dirname, '..', '..');
const extensionFolder = variables.EXTENSION_DIR;
const coverage = process.argv[2] === 'coverage';
const deploy = process.argv[2] === 'deploy';
const deploy = process.argv[2] === 'minikube' ? 'minikube' : process.argv[2] === 'openshift' ? 'openshift' : undefined;

async function main(): Promise<void> {
const tester = new ExTester(storageFolder, releaseType, extensionFolder, coverage);
const tests = deploy ? 'out/ui-test/tests/deploy*.test.js' : [
'out/ui-test/env/set.camel.version.js',
'out/ui-test/tests/!(deploy)*.test.js', // run everything, except deployment tests
'out/ui-test/env/check.camel.version.js'
];

let tests: string | string[] = '';
let settings: string = './src/ui-test/resources/';

switch (deploy) {
case 'minikube':
tests = 'out/ui-test/tests/deploy.kubernetes*.test.js';
settings += 'vscode-settings-minikube.json';
break;
case 'openshift':
tests = 'out/ui-test/tests/deploy.openshift*.test.js';
settings += 'vscode-settings-openshift.json';
break;
default:
tests = [
'out/ui-test/env/set.camel.version.js',
'out/ui-test/tests/!(deploy)*.test.js', // run everything, except deployment tests
'out/ui-test/env/check.camel.version.js'
];
settings += 'vscode-settings.json';
break;
}

await tester.setupAndRunTests(
tests,
Expand All @@ -44,7 +61,7 @@ async function main(): Promise<void> {
},
{
'cleanup': true,
'settings': './src/ui-test/resources/vscode-settings.json',
'settings': settings,
resources: []
}
);
Expand Down
Loading