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

Task/APPENG-2738: NIM Cypress E2E tests #3298

Merged
merged 36 commits into from
Oct 30, 2024

Conversation

dmartinol
Copy link
Contributor

Description

Adding Cypress UI tests to cover the NIM Model use cases from all the supported pages and tabs:

  • Show/Hide NVIDIA NIM model serving platform
  • Deploy NVIDIA NIM models
  • List NVIDIA NIM models
  • Delete NVIDIA NIM model

How Has This Been Tested?

Running npm run test:cypress-ci command.

Test Impact

Increases code coverage of UI code for all the components impacted by the NIM models.

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@openshift-ci openshift-ci bot added the needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI label Oct 4, 2024
Copy link
Contributor

openshift-ci bot commented Oct 4, 2024

Hi @dmartinol. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lokeshrangineni
Copy link
Contributor

lokeshrangineni commented Oct 4, 2024

Below check on the PR is currently failing, but it seems to be passing in our local environment. It might be worth re-running the check to determine if it's a legitimate issue.

https://github.com/opendatahub-io/odh-dashboard/actions/runs/11182131290/job/31087701260?pr=3298

faling cypress file as per above check - applications/notebookServer.cy.ts

on local it is successful

image

@andrewballantyne
Copy link
Member

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests. and removed needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI labels Oct 4, 2024
Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.88%. Comparing base (f3cb0a4) to head (a9007d5).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3298      +/-   ##
==========================================
+ Coverage   85.13%   85.88%   +0.75%     
==========================================
  Files        1338     1338              
  Lines       30118    30123       +5     
  Branches     8269     8270       +1     
==========================================
+ Hits        25641    25872     +231     
+ Misses       4477     4251     -226     

see 29 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3cb0a4...a9007d5. Read the comment docs.

Copy link
Member

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial feedback. I'll finish up the review on Monday.

frontend/src/__mocks__/mockNimResource.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress.config.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts Outdated Show resolved Hide resolved
frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts Outdated Show resolved Hide resolved
Copy link
Member

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments -- I tried to avoid making the same comment multiple times, but I may have missed the mark on that. General themes should be applied to all tests.

@TomerFi
Copy link
Contributor

TomerFi commented Oct 23, 2024

@andrewballantyne , shall I rebase to resolve the new conflicts?

TomerFi and others added 13 commits October 29, 2024 10:00
…render nim and all other cards on overview and model tab when there are no ServingRuntimes configured.
Signed-off-by: Daniele Martinoli <[email protected]>
Signed-off-by: Daniele Martinoli <[email protected]>
 * when combination of configurations to enable nim models are not configured properly.
…here are deployments and no deployments. (#9)

* Moved the utility method to nimUtils.ts
Signed-off-by: Tomer Figenblat <[email protected]>
TomerFi and others added 13 commits October 29, 2024 10:01
Signed-off-by: Tomer Figenblat <[email protected]>
- Use JSON object instead of string in mocking of NIM images configmap
- Remove experiementalStudio cypres config param
- Add mock for NIM project

Co-authored-by: Daniele Martinoli <[email protected]>
Co-authored-by: lokeshrangineni <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
- Add nim-serving interception to odh intercept type safety mechanism
- Add accelerators interception to odh intercept type safety mechanism

Co-authored-by: Daniele Martinoli <[email protected]>
Co-authored-by: lokeshrangineni <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
Co-authored-by: Daniele Martinoli <[email protected]>
Co-authored-by: lokeshrangineni <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
…odelServingNim.cy.ts

Co-authored-by: Andrew Ballantyne <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
}

findNimModelReplicas() {
return cy.get('[id="model-server-replicas"]');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here -- another gap we already had.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll log a bug for this... this is a common component we failed to properly annotate, shouldn't be one you folks have to make use of. Leave as-is.

Comment on lines +36 to +42
findNimModelReplicasMinusButton() {
return this.find().find('button[aria-label="Minus"]').eq(1);
}

findNimModelReplicasPlusButton() {
return this.find().find('button[aria-label="Plus"]').eq(1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these have a chance of conflicting with the StorageSize +/-

Hopefully in the improvement issues I'll log we can make sure this is covered too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll log a bug for this... this is a common component we failed to properly annotate, shouldn't be one you folks have to make use of. Leave as-is.

Comment on lines +323 to +329
findServingRuntime() {
return this.find().find(`[data-label="Serving Runtime"]`);
}

findProject() {
return this.find().find(`[data-label=Project]`);
}
Copy link
Member

@andrewballantyne andrewballantyne Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although these are not likely to change, they feel like they might be brittle based on how the selectors are written.

No action needed atm, but I wonder if we can't log something to improve these gaps in the future.

Comment on lines +344 to +351
findDeployedModelServingRuntime(name: string) {
return cy
.findByTestId('section-overview')
.get('div')
.contains(name)
.parents('.odh-type-bordered-card .model-server')
.get('dd');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will select anything -- I can't find section-overview test id in the code outside of this selector.

Looking for classes and going through divs is definitely a fast-track to brittle tests. If you're trying to select an element specifically on a page, we need a better data-testid on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I does selects, the test works:

it('should list the deployed model in Overview tab', () => {
      initInterceptsToEnableNim({ hasAllModels: false });
      cy.interceptK8sList(InferenceServiceModel, mockK8sResourceList([mockNimInferenceService()]));
      cy.interceptK8sList(ServingRuntimeModel, mockK8sResourceList([mockNimServingRuntime()]));

      projectDetails.visit('test-project');

      // Card is visible
      projectDetailsOverviewTab
        .findDeployedModelServingRuntime('Test Name')
        .should('have.text', 'NVIDIA NIM');
    });

I couldn't find a testid on the deployed model card, using the parent based on the calsses was the only way I was able to select the card. Can you suggest something else please?

}
}

class KserveTableRow extends TableRow {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it doesn't belong here -- KServe Specific stuff in a projects file? Hmmm... I wonder if this doesn't belong better in the modelServing.ts page component file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we named it incorrectly, but we use it to select deployed model records from the models table in the Models tab. See test called should list the deployed model in Models tab.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewballantyne there's a decent amount of model serving related duplication between the projects page tests and the model serving page tests, since we have some of the same functionality in 3 places (project details overview tab, project details models tab, model serving page). It maybe should be cleaned up at the same time as some of the refactoring @lucferbux and @emilys314 have mentioned doing as part of the KServe Raw Deployment work.

initInterceptsToDeployModel(nimInferenceService);

projectDetails.visitSection('test-project', 'model-server');
cy.get('button[data-testid=deploy-button]').click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a gap in the page object -- you shouldn't need selectors in the test itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the project's models tab, when no models are deployed:

  • If only one type of platform is enabled, i.e. nim for our tests, the one and only deploy button's testid is deploy-button.
    image

  • If multiple platform are enabled, each button get's a its own testid, for nim it's nim-serving-deploy-button.
    image

Do you want to add a "findNim..", "findSingle...", "findMulti...", "findOnlyOne..."?

Copy link
Member

@andrewballantyne andrewballantyne Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm -- there are probably better ways to handle this. I'd need to take a look at the situation more closely to know what the best call is. Having a page selector for each seems a bit much; especially when only 1 will work at a given moment.

disableNIMModelServing: true,
});
projectDetailsOverviewTab.visit('test-project');
cy.findByTestId('model-serving-platform-button').should('not.exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial part should be in a page object -- you should be doing the .should off page object methods.

Copy link
Contributor

@TomerFi TomerFi Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the reason I did that here, in the comment below (and in a bunch of other places in this file 😃 ), is because both deploy buttons for single-serving and nim-serving have the same testid; in our test cases, only the nim-platform-card is available, so this works.

We can add object funcs like "findNimServingDeployButton" and "findSingleServingDeployButton", but it won't be pretty. Unless we can change the testid of one of the buttons...

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent => parent div has nvidia-nim-platform-card

});
projectDetailsOverviewTab.visit('test-project');
projectDetailsOverviewTab.findModelServingPlatform('nvidia-nim').should('not.exist');
cy.findByTestId('model-serving-platform-button').should('not.exist');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most definitely if you're repeating the selector.

co-authored-by: Andrew Ballantyne <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
@TomerFi
Copy link
Contributor

TomerFi commented Oct 30, 2024

@andrewballantyne - the changes to the infereceservice mock for supporting custom labels, as we talked about offline are here: 80af75e.

co-authored-by: Andrew Ballantyne <[email protected]>
Signed-off-by: Tomer Figenblat <[email protected]>
Copy link
Member

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold

Waiting to see if Tomer has something he wants to do here... there are other changes we can do but this is a lingering PR that I would like merged so we can keep building on it.

@openshift-ci openshift-ci bot added do-not-merge/hold This PR is hold for some reason lgtm labels Oct 30, 2024
Copy link
Contributor

openshift-ci bot commented Oct 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@andrewballantyne
Copy link
Member

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold This PR is hold for some reason label Oct 30, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 23c82ac into opendatahub-io:main Oct 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants