@eclipse-che/che-e2e 7.68.0-dev-280c8c9 → 7.68.0-dev-e7cb474

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/configs/inversify.config.ts +2 -2
  2. package/configs/inversify.types.ts +1 -2
  3. package/configs/mocharc.ts +2 -2
  4. package/constants/TestConstants.ts +10 -13
  5. package/dist/configs/inversify.config.js +2 -2
  6. package/dist/configs/inversify.config.js.map +1 -1
  7. package/dist/configs/inversify.types.js +1 -1
  8. package/dist/configs/inversify.types.js.map +1 -1
  9. package/dist/configs/mocharc.js +2 -2
  10. package/dist/configs/mocharc.js.map +1 -1
  11. package/dist/constants/TestConstants.js +11 -12
  12. package/dist/constants/TestConstants.js.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +86 -33
  16. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  17. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +3 -3
  18. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  19. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +2 -2
  20. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  21. package/dist/specs/factory/Factory.spec.js +2 -2
  22. package/dist/specs/factory/Factory.spec.js.map +1 -1
  23. package/dist/specs/factory/NoSetupRepoFactory.spec.js +2 -2
  24. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  25. package/dist/specs/factory/RefusedOAuthFactory.spec.js +2 -2
  26. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  27. package/dist/utils/CheReporter.js +3 -3
  28. package/dist/utils/CheReporter.js.map +1 -1
  29. package/dist/utils/DevfilesRegistryHelper.js +82 -0
  30. package/dist/utils/DevfilesRegistryHelper.js.map +1 -0
  31. package/dist/utils/KubernetesCommandLineToolsExecutor.js +18 -7
  32. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  33. package/dist/utils/ScreenCatcher.js +4 -7
  34. package/dist/utils/ScreenCatcher.js.map +1 -1
  35. package/dist/utils/{vsc/GitUtil.js → StringUtil.js} +20 -23
  36. package/dist/utils/StringUtil.js.map +1 -0
  37. package/index.ts +2 -2
  38. package/package.json +4 -3
  39. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +90 -33
  40. package/specs/api/EmptyWorkspaceAPI.spec.ts +3 -3
  41. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +2 -2
  42. package/specs/factory/Factory.spec.ts +2 -2
  43. package/specs/factory/NoSetupRepoFactory.spec.ts +2 -2
  44. package/specs/factory/RefusedOAuthFactory.spec.ts +2 -2
  45. package/utils/CheReporter.ts +3 -4
  46. package/utils/DevfilesRegistryHelper.ts +77 -0
  47. package/utils/KubernetesCommandLineToolsExecutor.ts +20 -7
  48. package/utils/ScreenCatcher.ts +3 -4
  49. package/utils/{vsc/GitUtil.ts → StringUtil.ts} +19 -15
  50. package/constants/DevfilesRegistryConstants.ts +0 -26
  51. package/dist/constants/DevfilesRegistryConstants.js +0 -32
  52. package/dist/constants/DevfilesRegistryConstants.js.map +0 -1
  53. package/dist/utils/Sanitizer.js +0 -29
  54. package/dist/utils/Sanitizer.js.map +0 -1
  55. package/dist/utils/vsc/GitUtil.js.map +0 -1
  56. package/utils/Sanitizer.ts +0 -19
@@ -3,47 +3,104 @@ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigu
3
3
  import { ShellString } from 'shelljs';
4
4
  import { expect } from 'chai';
5
5
  import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
6
- import { TestConstants } from '../../constants/TestConstants';
7
- import { GitUtil } from '../../utils/vsc/GitUtil';
6
+ import { StringUtil } from '../../utils/StringUtil';
7
+ import { DevfilesRegistryHelper } from '../../utils/DevfilesRegistryHelper';
8
+ import { Logger } from '../../utils/Logger';
8
9
 
9
- suite(`Devfile acceptance test`, async function (): Promise<void> {
10
- let devfileUrl: string;
11
- let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
12
- let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
13
- let devfileContext: DevfileContext;
14
- let devWorkspaceName: string | undefined;
10
+ /**
11
+ * Dynamically generating tests
12
+ * info: https://mochajs.org/#delayed-root-suite
13
+ */
15
14
 
16
- suiteSetup('Get DevWorkspace configuration from meta.yaml', async function (): Promise<void> {
17
- devfileUrl = await GitUtil.getProjectGitLinkFromLinkToMetaYaml(TestConstants.TS_API_TEST_LINK_TO_META_YAML);
15
+ (async function (): Promise<void> {
18
16
 
19
- devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
20
- devfileUrl,
21
- });
22
- devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
23
- devWorkspaceName = devfileContext?.devWorkspace?.metadata?.name;
17
+ const devfilesRegistryHelper: DevfilesRegistryHelper = new DevfilesRegistryHelper();
18
+ const devfileSamples: any = await devfilesRegistryHelper.collectPathsToDevfilesFromRegistry();
19
+
20
+ for (const devfileSample of devfileSamples) {
21
+ suite(`Devfile acceptance test suite for ${devfileSample.name}`, async function (): Promise<void> {
22
+ this.bail(false);
23
+ this.timeout(1500000); // 25 minutes because build of Quarkus sample takes 20+ minutes
24
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
25
+ let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
26
+ let containerTerminal: KubernetesCommandLineToolsExecutor.ContainerTerminal;
27
+ let devfileContext: DevfileContext;
28
+ let devWorkspaceName: string | undefined;
29
+ let clonedProjectName: string;
30
+ let containerWorkDir: string;
31
+ let devfilesBuildCommands: any[] = [];
32
+
33
+ test('Get DevWorkspace configuration', async function (): Promise<void> {
34
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
35
+ devfileUrl: devfileSample.link,
36
+ });
37
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
38
+ devWorkspaceName = devfileContext?.devWorkspace?.metadata?.name;
39
+
40
+ kubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(devWorkspaceName);
41
+ containerTerminal = new KubernetesCommandLineToolsExecutor.ContainerTerminal(kubernetesCommandLineToolsExecutor);
42
+ kubernetesCommandLineToolsExecutor.loginToOcp();
43
+ });
44
+
45
+ test('Collect build commands from the devfile', async function (): Promise<void> {
46
+ if (devfileContext.devfile.commands === undefined) {
47
+ Logger.info(`Devfile does not contains any commands.`);
48
+ } else {
49
+ devfileContext.devfile.commands.forEach((command: any) => {
50
+ if (command.exec?.group?.kind === 'build') {
51
+ Logger.debug(`Build command found: ${command.exec.commandLine}`);
52
+ devfilesBuildCommands.push(command);
53
+ }
54
+ });
55
+ }
56
+ });
24
57
 
25
- kubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(devWorkspaceName);
26
- kubernetesCommandLineToolsExecutor.loginToOcp();
27
- });
58
+ test('Create DevWorkspace', async function (): Promise<void> {
59
+ const devWorkspaceConfigurationYamlString: string = await devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
60
+ const applyOutput: ShellString = kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput(devWorkspaceConfigurationYamlString);
28
61
 
29
- test('Create DevWorkspace', async function (): Promise<void> {
30
- const devWorkspaceConfigurationYamlString: string = await devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
31
- const applyOutput: ShellString = kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput(devWorkspaceConfigurationYamlString);
62
+ expect(applyOutput.stdout)
63
+ .contains('devworkspacetemplate')
64
+ .and.contains('devworkspace')
65
+ .and.contains.oneOf(['created', 'configured']);
32
66
 
33
- expect(applyOutput.stdout)
34
- .contains('devworkspacetemplate')
35
- .and.contains('devworkspace')
36
- .and.contains.oneOf(['created', 'configured']);
67
+ });
37
68
 
38
- });
69
+ test('Wait until DevWorkspace has status "ready"', async function (): Promise<void> {
70
+ expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
71
+ });
39
72
 
40
- test('Wait until DevWorkspace has status "ready"', async function (): Promise<void> {
41
- expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
42
- });
73
+ test('Check if project was created', function (): void {
74
+ clonedProjectName = StringUtil.getProjectNameFromGitUrl(devfileSample.link);
75
+ expect(containerTerminal.ls().stdout).includes(clonedProjectName);
76
+ });
43
77
 
44
- suiteTeardown('Delete DevWorkspace', async function (): Promise<void> {
45
- kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
46
- });
47
- });
78
+ test('Check if project files are imported', function (): void {
79
+ containerWorkDir = containerTerminal.pwd().stdout.replace('\n', '');
80
+ expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout).includes(`devfile.yaml`);
81
+ });
48
82
 
83
+ test(`Check if build commands returns success`, function (): void {
84
+ if (devfilesBuildCommands.length === 0) {
85
+ Logger.info(`Devfile does not contains build commands.`);
86
+ } else {
87
+ devfilesBuildCommands.forEach((command) => {
88
+ Logger.info(`command.exec: ${JSON.stringify(command.exec)}`);
89
+
90
+ const commandString: string = StringUtil.updateCommandEnvsToShStyle(`cd ${command.exec.workingDir} && ${command.exec.commandLine}`);
91
+ Logger.info(`Full build command to be executed: ${commandString}`);
92
+
93
+ const output: ShellString = containerTerminal.executeCommand(commandString, command.exec.component);
94
+ expect(output.code).eqls(0);
95
+ });
96
+ }
97
+ });
98
+
99
+ test('Delete DevWorkspace', async function (): Promise<void> {
100
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
101
+ });
102
+ });
103
+ }
49
104
 
105
+ run();
106
+ })();
@@ -1,7 +1,7 @@
1
1
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
2
2
  import { expect } from 'chai';
3
3
  import { ShellString } from 'shelljs';
4
- import { GitUtil } from '../../utils/vsc/GitUtil';
4
+ import { StringUtil } from '../../utils/StringUtil';
5
5
  import { TestConstants } from '../../constants/TestConstants';
6
6
  import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
7
7
  import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
@@ -51,11 +51,11 @@ suite(`Empty workspace API test`, async function (): Promise<void> {
51
51
  });
52
52
 
53
53
  test('Check if project was created', function (): void {
54
- clonedProjectName = GitUtil.getProjectNameFromGitUrl(gitRepository);
54
+ clonedProjectName = StringUtil.getProjectNameFromGitUrl(gitRepository);
55
55
  expect(containerTerminal.ls().stdout).includes(clonedProjectName);
56
56
  });
57
57
 
58
- test('Check if files were imported ', function (): void {
58
+ test('Check if project files are imported', function (): void {
59
59
  expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout)
60
60
  .includes(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
61
61
  });
@@ -24,7 +24,7 @@ import { TestConstants } from '../../constants/TestConstants';
24
24
  import { OcpMainPage } from '../../pageobjects/openshift/OcpMainPage';
25
25
  import { OcpImportFromGitPage } from '../../pageobjects/openshift/OcpImportFromGitPage';
26
26
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
27
- import { GitUtil } from '../../utils/vsc/GitUtil';
27
+ import { StringUtil } from '../../utils/StringUtil';
28
28
  import { OcpApplicationPage } from '../../pageobjects/openshift/OcpApplicationPage';
29
29
 
30
30
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
@@ -84,7 +84,7 @@ suite(`DevConsole Integration`, async function (): Promise<void> {
84
84
  });
85
85
 
86
86
  test('Check if project and files imported', async function (): Promise<void> {
87
- const applicationSourceProjectName: string = GitUtil.getProjectNameFromGitUrl(gitImportRepo);
87
+ const applicationSourceProjectName: string = StringUtil.getProjectNameFromGitUrl(gitImportRepo);
88
88
  const projectSection: ViewSection = await new SideBarView().getContent().getSection(applicationSourceProjectName);
89
89
  const isFileImported: ViewItem | undefined = await projectSection.findItem(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
90
90
  expect(isFileImported).not.eqls(undefined);
@@ -28,7 +28,7 @@ import {
28
28
  import { TestConstants } from '../../constants/TestConstants';
29
29
  import { expect } from 'chai';
30
30
  import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
31
- import { GitUtil } from '../../utils/vsc/GitUtil';
31
+ import { StringUtil } from '../../utils/StringUtil';
32
32
  import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
33
33
  import { registerRunningWorkspace } from '../MochaHooks';
34
34
  import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
@@ -88,7 +88,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
88
88
  });
89
89
 
90
90
  test('Check if a project folder has been created', async function (): Promise<void> {
91
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
91
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
92
92
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
93
93
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
94
94
  });
@@ -27,7 +27,7 @@ import {
27
27
  ViewSection
28
28
  } from 'monaco-page-objects';
29
29
  import { expect } from 'chai';
30
- import { GitUtil } from '../../utils/vsc/GitUtil';
30
+ import { StringUtil } from '../../utils/StringUtil';
31
31
  import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
32
32
  import WebDriverError = error.WebDriverError;
33
33
  import { registerRunningWorkspace } from '../MochaHooks';
@@ -114,7 +114,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
114
114
  });
115
115
 
116
116
  test('Check if a project folder has been created', async function (): Promise<void> {
117
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
117
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
118
118
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
119
119
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
120
120
  });
@@ -37,7 +37,7 @@ import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
37
37
  import { DriverHelper } from '../../utils/DriverHelper';
38
38
  import { TestConstants } from '../../constants/TestConstants';
39
39
  import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
40
- import { GitUtil } from '../../utils/vsc/GitUtil';
40
+ import { StringUtil } from '../../utils/StringUtil';
41
41
  import { Logger } from '../../utils/Logger';
42
42
  import { TimeoutConstants } from '../../constants/TimeoutConstants';
43
43
  import { LoginTests } from '../../tests-library/LoginTests';
@@ -97,7 +97,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
97
97
  });
98
98
 
99
99
  test('Check if a project folder has been created', async function (): Promise<void> {
100
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
100
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
101
101
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
102
102
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
103
103
  });
@@ -18,13 +18,12 @@ import { ScreenCatcher } from './ScreenCatcher';
18
18
  import { ITestWorkspaceUtil } from './workspace/ITestWorkspaceUtil';
19
19
  import { TimeoutConstants } from '../constants/TimeoutConstants';
20
20
  import { Logger } from './Logger';
21
- import { Sanitizer } from './Sanitizer';
22
21
  import { e2eContainer } from '../configs/inversify.config';
23
22
  import { WriteStream } from 'fs';
23
+ import { StringUtil } from './StringUtil';
24
24
 
25
25
  const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
26
26
  const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher);
27
- const sanitizer: Sanitizer = e2eContainer.get(CLASSES.Sanitizer);
28
27
  let methodIndex: number = 0;
29
28
  let deleteScreencast: boolean = true;
30
29
  let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
@@ -129,10 +128,10 @@ class CheReporter extends mocha.reporters.Spec {
129
128
  deleteScreencast = false;
130
129
 
131
130
  Logger.trace(`FullTitle:${test.fullTitle()}`);
132
- const testFullTitle: string = sanitizer.sanitize(test.fullTitle());
131
+ const testFullTitle: string = StringUtil.sanitizeTitle(test.fullTitle());
133
132
  Logger.trace(`FullTitleSanitized:${testFullTitle}`);
134
133
  Logger.trace(`TestTitle:${test.title}`);
135
- const testTitle: string = sanitizer.sanitize(test.title);
134
+ const testTitle: string = StringUtil.sanitizeTitle(test.title);
136
135
  Logger.trace(`TestTitleSanitized:${testTitle}`);
137
136
 
138
137
  const testReportDirPath: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/${testFullTitle}`;
@@ -0,0 +1,77 @@
1
+ /*********************************************************************
2
+ * Copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import { SupportedDevfilesRegistries, TestConstants } from '../constants/TestConstants';
11
+ import axios, { AxiosResponse } from 'axios';
12
+ import { Logger } from './Logger';
13
+ import YAML from 'yaml';
14
+
15
+ export class DevfilesRegistryHelper {
16
+
17
+ async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
18
+ Logger.debug(`${this.constructor.name}.${this.getInbuiltDevfilesRegistryContent.name}`);
19
+ return await this.getContent(SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
20
+ }
21
+
22
+ async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
23
+ Logger.debug(`${this.constructor.name}.${this.getGitHubCheDevfileRegistryContent.name}`);
24
+ return await this.getContent(SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
25
+ }
26
+
27
+ async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
28
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}`);
29
+ const devfileSamples: object[] = [];
30
+ const sampleNames: string[] = [];
31
+ switch (TestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()) {
32
+ case (SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL): {
33
+ const content: any[any] = await this.getGitHubCheDevfileRegistryContent();
34
+ content.forEach((e: any) => {
35
+ if (e.name[0] !== '.') { sampleNames.push(e.name); }
36
+ });
37
+
38
+ for (const sample of sampleNames) {
39
+ const sampleEndpoint: string = `${SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL}${sample}/meta.yaml`;
40
+ const sampleEndpointContent: AxiosResponse = await this.getContent(sampleEndpoint);
41
+ const decodedFileContent: string = Buffer.from((sampleEndpointContent as any).content, 'base64').toString();
42
+ const metaYamlContent: any = YAML.parse(decodedFileContent);
43
+ devfileSamples.push({name: sample, link: metaYamlContent.links.v2});
44
+ }
45
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
46
+ }
47
+ break;
48
+ case (SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL()): {
49
+ const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
50
+
51
+ for (const sample of content) {
52
+ devfileSamples.push({name: sample.displayName, link: sample.links.v2});
53
+ }
54
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
55
+ }
56
+ break;
57
+ default: {
58
+ Logger.error(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: unsupported registry url - ${TestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
59
+ supported registries: ${JSON.stringify(SupportedDevfilesRegistries)}`);
60
+ }
61
+ }
62
+ return devfileSamples;
63
+ }
64
+
65
+ private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
66
+ Logger.debug(`${this.constructor.name}.${this.getContent.name}: ${url}`);
67
+
68
+ let response: AxiosResponse | undefined;
69
+ try {
70
+ response = await axios.get(url, headers);
71
+ } catch (error) {
72
+ Logger.error(`${error} + ${url}`);
73
+ throw error;
74
+ }
75
+ return response?.data;
76
+ }
77
+ }
@@ -66,15 +66,12 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
66
66
  this.createNamespace();
67
67
  }
68
68
  this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
69
- const output: ShellString = this.waitDevWorkspace();
70
- KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
71
- KubernetesCommandLineToolsExecutor.container = this.getContainerName();
72
- return output;
69
+ return this.waitDevWorkspace();
73
70
  }
74
71
 
75
- executeCommand(commandToExecute: string): ShellString {
72
+ executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
76
73
  Logger.debug(`${this.getLoggingName(this.executeCommand.name)}:`);
77
- return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${KubernetesCommandLineToolsExecutor.container} -- sh -c "${commandToExecute}"`);
74
+ return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
78
75
  }
79
76
 
80
77
  applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
@@ -96,7 +93,9 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
96
93
 
97
94
  waitDevWorkspace(timeout: number = 360): ShellString {
98
95
  Logger.debug(`${this.getLoggingName(this.waitDevWorkspace.name)}: Wait till workspace ready.`);
99
- return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
96
+ const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
97
+ this.getPodAndContainerNames();
98
+ return output;
100
99
  }
101
100
 
102
101
  createNamespace(): void {
@@ -114,6 +113,11 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
114
113
  ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
115
114
  }
116
115
 
116
+ private getPodAndContainerNames(): void {
117
+ KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
118
+ KubernetesCommandLineToolsExecutor.container = this.getContainerName();
119
+ }
120
+
117
121
  private isUserLoggedIn(): boolean {
118
122
  const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
119
123
 
@@ -163,5 +167,14 @@ export namespace KubernetesCommandLineToolsExecutor {
163
167
  removeFolder(path: string): ShellString {
164
168
  return this.executeCommand('rm -rf ' + path);
165
169
  }
170
+
171
+ getEnvValue(envName: string): string {
172
+ envName = envName.replace(/[${}]/g, '');
173
+ const output: ShellString = this.executeCommand(`env | grep ${envName}`);
174
+ return output.stderr ? output.stderr :
175
+ output.stdout
176
+ .substring(output.stdout.lastIndexOf('=') + 1)
177
+ .replace('\n', '');
178
+ }
166
179
  }
167
180
  }
@@ -11,15 +11,14 @@ import * as fs from 'fs';
11
11
  import { injectable, inject } from 'inversify';
12
12
  import { CLASSES } from '../configs/inversify.types';
13
13
  import { DriverHelper } from './DriverHelper';
14
- import { Sanitizer } from './Sanitizer';
15
14
  import { error } from 'selenium-webdriver';
16
15
  import { TestConstants } from '../constants/TestConstants';
17
16
  import { WriteStream } from 'fs';
17
+ import { StringUtil } from './StringUtil';
18
18
 
19
19
  @injectable()
20
20
  export class ScreenCatcher {
21
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
22
- @inject(CLASSES.Sanitizer) private readonly sanitizer: Sanitizer) { }
21
+ constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
23
22
 
24
23
  async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
25
24
  const executionScreenCastDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
@@ -38,7 +37,7 @@ export class ScreenCatcher {
38
37
  const date: Date = new Date();
39
38
  const timeStr: string = date.toLocaleTimeString('en-us', { hour12: false }) + '.' + new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(date.getMilliseconds());
40
39
 
41
- const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${this.sanitizer.sanitize(timeStr)})_${this.sanitizer.sanitize(methodName)}.png`;
40
+ const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${StringUtil.sanitizeTitle(timeStr)})_${StringUtil.sanitizeTitle(methodName)}.png`;
42
41
 
43
42
  try {
44
43
  await this.catchScreen(screenshotPath);
@@ -9,35 +9,39 @@
9
9
  **********************************************************************/
10
10
 
11
11
  import { injectable } from 'inversify';
12
- import YAML from 'yaml';
13
- import { Logger } from '../Logger';
14
- import axios, { AxiosResponse } from 'axios';
12
+ import { Logger } from './Logger';
13
+ import { KubernetesCommandLineToolsExecutor } from './KubernetesCommandLineToolsExecutor';
15
14
 
16
15
  @injectable()
17
- export class GitUtil {
16
+ export class StringUtil {
18
17
  /**
19
18
  * Method extracts a test repo name from git clone https url;
20
- * it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git" word, than returns the last one;
19
+ * it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git", "main" or "tree" word, than returns the last one;
21
20
  * please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
22
21
  * @param url git https url (which using for "git clone")
23
22
  * @return project name
24
23
  */
25
24
  static getProjectNameFromGitUrl(url: string): string {
26
25
  Logger.debug(`${this.constructor.name}.${this.getProjectNameFromGitUrl.name} - ${url}`);
27
- const projectName: string = url.split(/[\/.]/).filter((e: string) => e !== '' && e !== 'git').reverse()[0];
26
+ if (url.includes('/tree/')) {
27
+ url = url.split('/').slice(0, -2).join('/');
28
+ }
29
+ const projectName: string = url.split(/[\/.]/).filter((e: string) => !['git', ''].includes(e)).reverse()[0];
28
30
  Logger.debug(`${this.constructor.name}.${this.getProjectNameFromGitUrl.name} - ${projectName}`);
29
31
  return projectName;
30
32
  }
33
+
34
+ static sanitizeTitle(arg: string): string {
35
+ return arg.replace(/\//g, '+').replace(/,/g, '.').replace(/:/g, '-').replace(/['"]/g, '').replace(/[^a-z0-9+\-.()\[\]_]/gi, '_');
36
+ }
37
+
31
38
  /**
32
- * Method extracts a git url for DevWorkspace configuration from meta.yaml file;
33
- * @param linkToMetaYaml raw url to git repository where meta.yaml is;
34
- * @return git link which uses in DevWorkspaceConfigurationHelper as DevfileUrl parameter
39
+ * Replaces ${ENV}, $ENV to "$ENV"
40
+ * @param command string command with environmental variables in unsupported format
41
+ * @return updated command with environmental variables in supported format
35
42
  */
36
- static async getProjectGitLinkFromLinkToMetaYaml(linkToMetaYaml: string): Promise<string> {
37
- Logger.debug(`${this.constructor.name}.${this.getProjectGitLinkFromLinkToMetaYaml.name} - ${linkToMetaYaml}`);
38
- const response: AxiosResponse = await axios.get(linkToMetaYaml);
39
- const metaYamlContent: any = YAML.parse(response.data);
40
- Logger.debug(`${this.constructor.name}.${this.getProjectGitLinkFromLinkToMetaYaml.name} - ${metaYamlContent.links.v2}`);
41
- return metaYamlContent.links.v2;
43
+
44
+ static updateCommandEnvsToShStyle(command: string): string {
45
+ return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, `"\$&"`);
42
46
  }
43
47
  }
@@ -1,26 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
- import { TestConstants } from './TestConstants';
11
- import axios, { AxiosResponse } from 'axios';
12
- import { Logger } from '../utils/Logger';
13
-
14
- function getDevfileRegistryUrl(): string {
15
- return `${TestConstants.TS_SELENIUM_BASE_URL}/devfile-registry/devfiles/`;
16
- }
17
-
18
- export const DevfilesRegistryConstants: Promise<object> = (async () => {
19
- let response: AxiosResponse | undefined;
20
- try {
21
- response = await axios.get(getDevfileRegistryUrl());
22
- } catch (error) {
23
- Logger.error(error);
24
- }
25
- return response?.data;
26
- })();
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DevfilesRegistryConstants = void 0;
7
- /*********************************************************************
8
- * Copyright (c) 2023 Red Hat, Inc.
9
- *
10
- * This program and the accompanying materials are made
11
- * available under the terms of the Eclipse Public License 2.0
12
- * which is available at https://www.eclipse.org/legal/epl-2.0/
13
- *
14
- * SPDX-License-Identifier: EPL-2.0
15
- **********************************************************************/
16
- const TestConstants_1 = require("./TestConstants");
17
- const axios_1 = __importDefault(require("axios"));
18
- const Logger_1 = require("../utils/Logger");
19
- function getDevfileRegistryUrl() {
20
- return `${TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL}/devfile-registry/devfiles/`;
21
- }
22
- exports.DevfilesRegistryConstants = (async () => {
23
- let response;
24
- try {
25
- response = await axios_1.default.get(getDevfileRegistryUrl());
26
- }
27
- catch (error) {
28
- Logger_1.Logger.error(error);
29
- }
30
- return response === null || response === void 0 ? void 0 : response.data;
31
- })();
32
- //# sourceMappingURL=DevfilesRegistryConstants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DevfilesRegistryConstants.js","sourceRoot":"","sources":["../../constants/DevfilesRegistryConstants.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;wEAQwE;AACxE,mDAAgD;AAChD,kDAA6C;AAC7C,4CAAyC;AAEzC,SAAS,qBAAqB;IAC1B,OAAO,GAAG,6BAAa,CAAC,oBAAoB,6BAA6B,CAAC;AAC9E,CAAC;AAEY,QAAA,yBAAyB,GAAoB,CAAC,KAAK,IAAI,EAAE;IAClE,IAAI,QAAmC,CAAC;IAC5C,IAAI;QACA,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACZ,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;IACD,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;AACtB,CAAC,CAAC,EAAE,CAAC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- /*********************************************************************
3
- * Copyright (c) 2021-2023 Red Hat, Inc.
4
- *
5
- * This program and the accompanying materials are made
6
- * available under the terms of the Eclipse Public License 2.0
7
- * which is available at https://www.eclipse.org/legal/epl-2.0/
8
- *
9
- * SPDX-License-Identifier: EPL-2.0
10
- **********************************************************************/
11
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
12
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
14
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
15
- return c > 3 && r && Object.defineProperty(target, key, r), r;
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Sanitizer = void 0;
19
- const inversify_1 = require("inversify");
20
- let Sanitizer = class Sanitizer {
21
- sanitize(arg) {
22
- return arg.replace(/[\/]/g, '+').replace(/[\,]/g, '.').replace(/[\:]/g, '-').replace(/[\'\"]/g, '').replace(/[^a-z0-9\+\-\.\(\)\[\]\_]/gi, '_');
23
- }
24
- };
25
- Sanitizer = __decorate([
26
- inversify_1.injectable()
27
- ], Sanitizer);
28
- exports.Sanitizer = Sanitizer;
29
- //# sourceMappingURL=Sanitizer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Sanitizer.js","sourceRoot":"","sources":["../../utils/Sanitizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE;;;;;;;;;AAExE,yCAAuC;AAGvC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAElB,QAAQ,CAAC,GAAW;QAChB,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IACpJ,CAAC;CACJ,CAAA;AALY,SAAS;IADrB,sBAAU,EAAE;GACA,SAAS,CAKrB;AALY,8BAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitUtil.js","sourceRoot":"","sources":["../../../utils/vsc/GitUtil.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE;;;;;;;;;;;;AAExE,yCAAuC;AACvC,gDAAwB;AACxB,sCAAmC;AACnC,kDAA6C;AAG7C,IAAa,OAAO,GAApB,MAAa,OAAO;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,wBAAwB,CAAC,GAAW;QACvC,eAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC;QACxF,MAAM,WAAW,GAAW,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3G,eAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,MAAM,WAAW,EAAE,CAAC,CAAC;QAChG,OAAO,WAAW,CAAC;IACvB,CAAC;IACD;;;;OAIG;IACF,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,cAAsB;QACpE,eAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,mCAAmC,CAAC,IAAI,MAAM,cAAc,EAAE,CAAC,CAAC;QAC9G,MAAM,QAAQ,GAAkB,MAAM,eAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAChE,MAAM,eAAe,GAAQ,cAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvD,eAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,mCAAmC,CAAC,IAAI,MAAM,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QACxH,OAAO,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IACpC,CAAC;CACJ,CAAA;AA1BY,OAAO;IADnB,sBAAU,EAAE;GACA,OAAO,CA0BnB;AA1BY,0BAAO"}
@@ -1,19 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2021-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import { injectable } from 'inversify';
12
-
13
- @injectable()
14
- export class Sanitizer {
15
-
16
- sanitize(arg: string): string {
17
- return arg.replace(/[\/]/g, '+').replace(/[\,]/g, '.').replace(/[\:]/g, '-').replace(/[\'\"]/g, '').replace(/[^a-z0-9\+\-\.\(\)\[\]\_]/gi, '_');
18
- }
19
- }