|
| 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 | +}); |
0 commit comments