Repository navigation
test: add IBM Bob provider smoke coverage #24019
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
Open
sudharshanibm
wants to merge
1
commit into
eclipse-che:main
Choose a base branch
from
sudharshanibm:enable-bob-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+274
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
241 changes: 241 additions & 0 deletions
241
tests/e2e/specs/miscellaneous/BobProviderSmokeTest.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,241 @@ | ||
| /** ******************************************************************* | ||
| * copyright (c) 2026 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 { e2eContainer } from '../../configs/inversify.config'; | ||
| import { CLASSES, TYPES } from '../../configs/inversify.types'; | ||
| import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; | ||
| import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; | ||
| import { LoginTests } from '../../tests-library/LoginTests'; | ||
| import { registerRunningWorkspace } from '../MochaHooks'; | ||
| import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; | ||
| import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; | ||
|
|
||
| import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences'; | ||
| import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace'; | ||
| import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; | ||
| import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; | ||
| import { KubernetesCommandLineToolsExecutor, ContainerTerminal } from '../../utils/KubernetesCommandLineToolsExecutor'; | ||
| import { ShellString } from 'shelljs'; | ||
| import { expect } from 'chai'; | ||
| import { Logger } from '../../utils/Logger'; | ||
| import { ApiUrlResolver } from '../../utils/workspace/ApiUrlResolver'; | ||
| import { CheApiRequestHandler } from '../../utils/request-handlers/CheApiRequestHandler'; | ||
| import { AxiosResponse } from 'axios'; | ||
| import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api'; | ||
|
|
||
| interface BobRunResult { | ||
| status: string; | ||
| last_message: string; | ||
| stats: { tool_calls: number }; | ||
| } | ||
|
|
||
| suite(`IBM Bob Provider Smoke Test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { | ||
| const stackName: string = 'Empty Workspace'; | ||
| const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); | ||
| const apiUrlResolver: ApiUrlResolver = e2eContainer.get(CLASSES.ApiUrlResolver); | ||
| const requestHandler: CheApiRequestHandler = e2eContainer.get(CLASSES.CheApiRequestHandler); | ||
| const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); | ||
| const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); | ||
| const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); | ||
| const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences); | ||
| const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace); | ||
| const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); | ||
| const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); | ||
| const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( | ||
| CLASSES.KubernetesCommandLineToolsExecutor | ||
| ); | ||
| const containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal); | ||
|
|
||
| const providerName: string = 'IBM Bob CLI'; | ||
| const providerId: string = 'ibm/bob'; | ||
| const apiKey: string = BASE_TEST_CONSTANTS.TS_AI_PROVIDER_API_KEY; | ||
| const envVarName: string = 'BOB_API_KEY'; | ||
|
|
||
| let loggedIn: boolean = false; | ||
| let providerKeyAlreadyPresent: boolean = false; | ||
| let createdProviderKey: boolean = false; | ||
| let workspaceName: string = ''; | ||
| let workspaceContainer: string = ''; | ||
|
|
||
| suiteSetup('Login', async function (): Promise<void> { | ||
| if (!apiKey) { | ||
| this.skip(); | ||
| } | ||
| await loginTests.loginIntoChe(); | ||
| loggedIn = true; | ||
| await userPreferences.openUserPreferencesPage(); | ||
| await userPreferences.openAiProviderKeysTab(); | ||
| providerKeyAlreadyPresent = await userPreferences.isAiProviderKeyPresent(providerId); | ||
| if (providerKeyAlreadyPresent) { | ||
| Logger.info('Using the existing Bob key without replacing it'); | ||
| } | ||
| }); | ||
|
|
||
| suite('Add AI Provider API key', function (): void { | ||
| test('Navigate to AI Provider Keys tab', async function (): Promise<void> { | ||
| await userPreferences.openUserPreferencesPage(); | ||
| await userPreferences.waitAiProviderKeysTab(); | ||
| await userPreferences.openAiProviderKeysTab(); | ||
| }); | ||
|
|
||
| test(`Add ${providerName} API key`, async function (): Promise<void> { | ||
| if (providerKeyAlreadyPresent) { | ||
| this.skip(); | ||
| } | ||
| await userPreferences.addAiProviderKey(providerName, apiKey); | ||
| createdProviderKey = true; | ||
| }); | ||
|
|
||
| test(`Verify ${providerName} key is present in the list`, async function (): Promise<void> { | ||
| await userPreferences.waitAiProviderKeyPresent(providerId); | ||
|
|
||
| const actualEnvVarName: string = await userPreferences.getAiProviderEnvVarName(providerId); | ||
| expect(actualEnvVarName).to.equal(envVarName); | ||
| }); | ||
| }); | ||
|
|
||
| suite('Verify AI Provider on Create Workspace page', function (): void { | ||
| test('Navigate to Create Workspace page', async function (): Promise<void> { | ||
| await dashboard.clickCreateWorkspaceButton(); | ||
| await createWorkspace.waitPage(); | ||
| }); | ||
|
|
||
| test('Verify AI Provider section is visible', async function (): Promise<void> { | ||
| await createWorkspace.waitAiProviderSectionVisible(); | ||
| }); | ||
|
|
||
| test('Expand "Choose an AI Provider" section', async function (): Promise<void> { | ||
| await createWorkspace.expandChooseAiProviderSection(); | ||
| }); | ||
|
|
||
| test(`Verify ${providerName} provider card is visible`, async function (): Promise<void> { | ||
| await createWorkspace.waitAiProviderCardVisible(providerId); | ||
| }); | ||
|
|
||
| test('Verify "Key configured" badge is displayed', async function (): Promise<void> { | ||
| await createWorkspace.waitAiProviderKeyConfiguredBadgeVisible(providerId); | ||
| }); | ||
| }); | ||
|
|
||
| suite('Create workspace and verify AI tool', function (): void { | ||
| test(`Create and open ${stackName}`, async function (): Promise<void> { | ||
| const workspaceApiUrl: string = await apiUrlResolver.getWorkspacesApiUrl(); | ||
| kubernetesCommandLineToolsExecutor.namespace = workspaceApiUrl.split('/').slice(-2)[0]; | ||
| containerTerminal.namespace = kubernetesCommandLineToolsExecutor.namespace; | ||
| await createWorkspace.setCreateNewWorkspaceCheckbox(true); | ||
| await createWorkspace.selectAiProvider(providerId); | ||
| const parentHandle: string = await browserTabsUtil.getCurrentWindowHandle(); | ||
| await createWorkspace.clickOnSampleNoEditorSelection(stackName); | ||
| await browserTabsUtil.waitAndSwitchToAnotherWindow(parentHandle); | ||
| }); | ||
|
|
||
| test('Obtain workspace name from workspace loader page', async function (): Promise<void> { | ||
| await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); | ||
| workspaceName = WorkspaceHandlingTests.getWorkspaceName(); | ||
| }); | ||
|
|
||
| test('Register running workspace', function (): void { | ||
| registerRunningWorkspace(workspaceName); | ||
| }); | ||
|
|
||
| test('Allocate the memory required by Bob', async function (): Promise<void> { | ||
| const url: string = await apiUrlResolver.getWorkspaceApiUrl(workspaceName); | ||
| const response: AxiosResponse = await requestHandler.get(url); | ||
| const components: V1alpha2DevWorkspaceSpecTemplateComponents[] = response.data.spec.template.components; | ||
| const index: number = components.findIndex( | ||
| (component: V1alpha2DevWorkspaceSpecTemplateComponents): boolean => | ||
| component.container !== undefined && !component.name.endsWith('-injector') | ||
| ); | ||
| expect(index, 'a workspace development container should exist').to.be.greaterThan(-1); | ||
| workspaceContainer = components[index].name; | ||
| await requestHandler.patch(url, [ | ||
| { op: 'add', path: `/spec/template/components/${index}/container/memoryLimit`, value: '4Gi' } | ||
| ]); | ||
| }); | ||
|
|
||
| test('Wait workspace readiness', async function (): Promise<void> { | ||
| await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); | ||
| }); | ||
|
|
||
| test('Connect to workspace container', function (): void { | ||
| kubernetesCommandLineToolsExecutor.workspaceName = workspaceName; | ||
| kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
| kubernetesCommandLineToolsExecutor.getPodAndContainerNames(); | ||
| }); | ||
|
|
||
| test('Verify bob binary is available in workspace', function (): void { | ||
| const output: ShellString = containerTerminal.execInContainerCommand( | ||
| 'command -v bob && test -x /injected-tools/bob-cli/bin/node', | ||
| workspaceContainer | ||
| ); | ||
| expect(output.code, 'bob binary should be present in the workspace').to.equal(0); | ||
| }); | ||
|
|
||
| test(`Verify ${envVarName} environment variable is set`, function (): void { | ||
| const output: ShellString = containerTerminal.execInContainerCommand(`test -n "$${envVarName}"`, workspaceContainer); | ||
| expect(output.code, `${envVarName} environment variable should be set`).to.equal(0); | ||
| }); | ||
|
|
||
| test('Verify bob starts and reports version', function (): void { | ||
| const output: ShellString = containerTerminal.execInContainerCommandWithTimeout('bob --version 2>&1', workspaceContainer, '30'); | ||
| expect(output.code, 'bob --version should exit with code 0').to.equal(0); | ||
| expect(output.stdout, 'bob should return version info').to.match(/\d+\.\d+\.\d+/); | ||
| expect(output.stdout.toLowerCase(), 'bob --version should not contain errors').to.not.contain('error'); | ||
| }); | ||
|
|
||
| test('Verify Bob completes an authenticated request', function (): void { | ||
| // bob run reads stdin until EOF; oc exec -i otherwise keeps it open. | ||
| const command: string = | ||
| 'bob run --accept-license --trust --disable-mcp --disable-subagents --format json --max-turns 1 "Reply with exactly BOB_WORKSPACE_OK. Do not use tools." </dev/null'; | ||
| const output: ShellString = containerTerminal.execInContainerCommandWithTimeout(command, workspaceContainer, '120'); | ||
| expect(output.code, 'Bob inference should succeed with the injected key').to.equal(0); | ||
| const result: BobRunResult = JSON.parse(output.stdout); | ||
| expect(result.status).to.equal('success'); | ||
| expect(result.last_message.trim()).to.equal('BOB_WORKSPACE_OK'); | ||
| }); | ||
|
|
||
| test('Verify Bob can execute a shell tool in the workspace', function (): void { | ||
| const resultFile: string = `/tmp/bob-cli-smoke-${Date.now()}`; | ||
| const command: string = `bob run --accept-license --trust --disable-mcp --disable-subagents --max-turns 3 --format json "Execute this command using a shell tool: printf BOB_SHELL_OK > ${resultFile}" </dev/null`; | ||
| const output: ShellString = containerTerminal.execInContainerCommandWithTimeout(command, workspaceContainer, '120'); | ||
| expect(output.code, 'Bob shell tool execution should succeed').to.equal(0); | ||
| const result: BobRunResult = JSON.parse(output.stdout); | ||
| expect(result.status).to.equal('success'); | ||
| expect(result.stats.tool_calls).to.be.greaterThan(0); | ||
| const fileOutput: ShellString = containerTerminal.execInContainerCommand(`cat ${resultFile}`, workspaceContainer); | ||
| expect(fileOutput.code).to.equal(0); | ||
| expect(fileOutput.stdout).to.equal('BOB_SHELL_OK'); | ||
| }); | ||
| }); | ||
|
|
||
| suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> { | ||
| if (loggedIn) { | ||
| await dashboard.openDashboard(); | ||
| await browserTabsUtil.closeAllTabsExceptCurrent(); | ||
| } | ||
| }); | ||
|
|
||
| suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> { | ||
| if (workspaceName) { | ||
| await testWorkspaceUtil.stopAndDeleteWorkspaceByName(workspaceName); | ||
| } | ||
| }); | ||
|
|
||
| suiteTeardown('Delete only the key created by this test', async function (): Promise<void> { | ||
| if (createdProviderKey) { | ||
| await userPreferences.openUserPreferencesPage(); | ||
| await userPreferences.openAiProviderKeysTab(); | ||
| await userPreferences.deleteAiProviderKeys(providerName); | ||
| } | ||
| }); | ||
|
|
||
| suiteTeardown('Unregister running workspace', function (): void { | ||
| registerRunningWorkspace(''); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Script executed:
Repository: eclipse-che/che
Length of output: 2572
Script executed:
Repository: eclipse-che/che
Length of output: 33485
Script executed:
Repository: eclipse-che/che
Length of output: 235
Script executed:
Repository: eclipse-che/che
Length of output: 1677
Script executed:
Repository: eclipse-che/che
Length of output: 5575
Web query:
"bulk-delete-ai-key-button" "delete-ai-key-warning-checkbox" eclipse che dashboardResult:
Script executed:
Repository: eclipse-che/che
Length of output: 26353
Script executed:
Repository: eclipse-che/che
Length of output: 9031
Script executed:
Repository: eclipse-che/che
Length of output: 9452
Script executed:
Repository: eclipse-che/che
Length of output: 1975
Scope teardown to the Bob key.
If another provider key appears after the test creates Bob’s key, select-all opens a multi-key dialog. The single-provider confirmation locator then times out, leaving Bob’s key in place.
Add a provider-scoped delete method to
UserPreferences. Select only the row forproviderIdand wait for that row to disappear.