-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Create POC of Fix dev spaces devfile api tests to avoid using an absolute devfile registry for PHP stack #23200
Changes from 5 commits
9c3a928
c0c507d
7ecb355
ba6352d
4410b82
75c9f63
162f462
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** ******************************************************************* | ||
* copyright (c) 2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; | ||
import { e2eContainer } from '../../configs/inversify.config'; | ||
import { CLASSES } from '../../configs/inversify.types'; | ||
import {Logger} from "../../utils/Logger"; | ||
import {DevfilesRegistryHelper} from "../../utils/DevfilesRegistryHelper"; | ||
import {ContainerTerminal, KubernetesCommandLineToolsExecutor} from "../../utils/KubernetesCommandLineToolsExecutor"; | ||
import {ShellExecutor} from "../../utils/ShellExecutor"; | ||
import {DevWorkspaceConfigurationHelper} from "../../utils/DevWorkspaceConfigurationHelper"; | ||
import {DevfileContext} from "@eclipse-che/che-devworkspace-generator/lib/api/devfile-context"; | ||
import {ShellString} from "shelljs"; | ||
import {expect} from "chai"; | ||
import {API_TEST_CONSTANTS} from "../../constants/API_TEST_CONSTANTS"; | ||
import YAML from "yaml"; | ||
import {StringUtil} from "../../utils/StringUtil"; | ||
import {string} from "yaml/dist/schema/common/string"; | ||
|
||
|
||
suite('PHP devfile API test', function (): void { | ||
const devfilesRegistryHelper: DevfilesRegistryHelper = e2eContainer.get(CLASSES.DevfilesRegistryHelper); | ||
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor); | ||
let containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal); | ||
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper; | ||
let devfileContext: DevfileContext; | ||
let devfileContent: string =''; | ||
|
||
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, async function (): Promise<void> { | ||
kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
}); | ||
|
||
test('Create PHP DevSpace', async function (): Promise<void> { | ||
kubernetesCommandLineToolsExecutor.namespace = 'admin-devspaces'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test will be supporting both Eclipse Che and Dev Spaces if use
|
||
devfileContent = devfilesRegistryHelper.getDevfileContent('php'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'php' would better to extract as a DEVFILE_ID constant to make localizing the sample name simpler when investigate the test failure.
|
||
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions'); | ||
kubernetesCommandLineToolsExecutor.workspaceName = YAML.parse(devfileContent).metadata.name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add a random string to the end of workspace name to avoid conflict with existed workspaces having the same name. |
||
|
||
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({ | ||
editorContent: editorDevfileContent, devfileContent: devfileContent | ||
}); | ||
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext(); | ||
|
||
const devWorkspaceConfigurationYamlString: string = | ||
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext); | ||
const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString); | ||
expect(output.stdout).contains('condition met'); | ||
}); | ||
|
||
test('Check running application', async function (): Promise<void> { | ||
const workdir:string = YAML.parse(devfileContent).commands[0].exec.workingDir; | ||
const commandLine:string = YAML.parse(devfileContent).commands[0].exec.commandLine; | ||
const containerName:string = YAML.parse(devfileContent).commands[0].exec.component; | ||
const runCommandInBash:string = `cd ${workdir} && ${commandLine}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would also be useful to see the actual values of |
||
const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName); | ||
expect(output.code).eqls(0); | ||
expect(output.stdout.trim()).contains('Hello, world!'); | ||
|
||
}); | ||
|
||
suiteTeardown('Delete workspace', function (): void { | ||
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean
PHP workspace
?