-
Notifications
You must be signed in to change notification settings - Fork 71
Add E2E tests for Member Clusters in the dashboard #270
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Summary of Changes
Hello @SunsetB612, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request focuses on refactoring and updating the End-to-End (E2E) test suite for the dashboard. It removes outdated namespace-related tests and repurposes an existing namespace list test to cover cronjob listing functionality. Additionally, it introduces a new dependency, @kubernetes/client-node, which suggests an expansion of the dashboard's capabilities or testing approach. While the PR title mentions adding E2E tests for member clusters, the current changes primarily involve cleanup and re-scoping of existing tests rather than the introduction of new member cluster-specific tests.
Highlights
- E2E Test Suite Refactoring: Several existing E2E tests related to namespace management (creation, deletion, network error handling) have been removed, streamlining the test suite.
- Namespace List Test Repurposed to CronJob List Test: The E2E test previously responsible for listing namespaces has been renamed and updated to validate the display and functionality of the CronJob list in the dashboard.
- New Dependency Added: @kubernetes/client-node: The
@kubernetes/client-nodepackage has been added as a dependency, indicating potential future enhancements or more direct Kubernetes API interactions within the dashboard or its testing infrastructure.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request adds a new end-to-end test for the CronJob list page and removes several E2E tests related to namespaces. While adding new tests is great, the removal of existing tests for namespace creation, deletion, and network error handling is concerning. Please clarify if this functionality is now covered by other tests.
The PR title, "Add E2E tests for Member Clusters in the dashboard," does not seem to accurately reflect the changes. A more descriptive title would be helpful.
I've added a few review comments focusing on improving the new test's clarity and robustness, and a high-severity comment regarding a new dependency in package.json that might be better suited as a development dependency to avoid bloating the production bundle.
| "@karmada/i18n-tool": "workspace:*", | ||
| "@karmada/terminal": "workspace:*", | ||
| "@karmada/utils": "workspace:*", | ||
| "@kubernetes/client-node": "^1.3.0", |
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.
The @kubernetes/client-node package has been added to dependencies. This package is typically used for backend services. If it's only used for development purposes, such as in E2E tests for test setup, it should be moved to devDependencies. This will prevent it from being included in the production frontend bundle, which would unnecessarily increase the application's size. Please clarify its usage and move it if it's not a runtime dependency for the client application.
| */ | ||
|
|
||
| // apps/dashboard/e2e/namespace-list.spec.ts | ||
| // apps/dashboard/e2e/cronjob-list.spec.ts |
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.
| const statefulsetTab = page.locator('role=option[name="Cronjob"]'); | ||
| await statefulsetTab.waitFor({ state: 'visible', timeout: 30000 }); | ||
| await statefulsetTab.click(); | ||
|
|
||
| // 验证选中状态 | ||
| await expect(statefulsetTab).toHaveAttribute('aria-selected', 'true'); |
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.
The variable statefulsetTab is used to locate and interact with the "Cronjob" tab, which is misleading. For clarity and maintainability, it should be renamed to cronjobTab. Additionally, the comment on line 45 is in Chinese; please use English for consistency with the rest of the codebase.
| const statefulsetTab = page.locator('role=option[name="Cronjob"]'); | |
| await statefulsetTab.waitFor({ state: 'visible', timeout: 30000 }); | |
| await statefulsetTab.click(); | |
| // 验证选中状态 | |
| await expect(statefulsetTab).toHaveAttribute('aria-selected', 'true'); | |
| const cronjobTab = page.locator('role=option[name="Cronjob"]'); | |
| await cronjobTab.waitFor({ state: 'visible', timeout: 30000 }); | |
| await cronjobTab.click(); | |
| // Verify selected state | |
| await expect(cronjobTab).toHaveAttribute('aria-selected', 'true'); |
| await expect(statefulsetTab).toHaveAttribute('aria-selected', 'true'); | ||
|
|
||
|
|
||
| // 验证 StatefulSet 列表表格可见 |
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.
| const table = page.locator('table'); | ||
| await expect(table).toBeVisible({ timeout: 30000 }); |
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.
This test only verifies that a <table> element is visible. To make the test more robust, consider adding an assertion to check for the presence of expected content, such as table headers (e.g., 'Name', 'Namespace'). This would help ensure that the table is not just rendered but also correctly populated.
|
/hold |
cb9b1b9 to
d77203a
Compare
d77203a to
b2c4512
Compare
b2c4512 to
4840ff0
Compare
4840ff0 to
db3579a
Compare
db3579a to
05c40cb
Compare
|
/unhold |
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.
Thanks~
| * Generate test Member Cluster kubeconfig YAML with timestamp | ||
| * Note: The Member Cluster creation page expects kubeconfig format, not Cluster resource format | ||
| */ | ||
| export function generateTestMemberClusterYaml() { |
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.
It is recommended to rename it to generateTestClusterKubeConfig.
| */ | ||
| export function generateTestMemberClusterYaml() { | ||
| const timestamp = Date.now(); | ||
| return `apiVersion: v1 |
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.
A bit curious, can we join the cluster without needing the cluster's certificate and key?
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.
@XiShanYongYe-Chang here in the kubeconfig, specify insecure-skip-tls-verify: true in cluster field
ui/apps/dashboard/e2e/member clusters/member-cluster-create.spec.ts
Outdated
Show resolved
Hide resolved
ui/apps/dashboard/e2e/member clusters/member-cluster-create.spec.ts
Outdated
Show resolved
Hide resolved
ui/apps/dashboard/e2e/member clusters/member-cluster-create.spec.ts
Outdated
Show resolved
Hide resolved
| * Generate test Member Cluster resource YAML with timestamp in Cluster resource format | ||
| * Note: This generates a Cluster resource that can be created via Karmada API | ||
| */ | ||
| export function generateTestMemberClusterResourceYaml() { |
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.
I feel that this method can be abstracted to be more general, independent of specific resource types.
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.
That makes sense. Though since each resource has pretty different YAML fields, maybe keeping it specific is fine for now?
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.
ok
ui/apps/dashboard/e2e/member clusters/member-cluster-delete.spec.ts
Outdated
Show resolved
Hide resolved
ui/apps/dashboard/e2e/member clusters/member-cluster-edit.spec.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: SunsetB612 <[email protected]>
05c40cb to
0bc94a9
Compare
|
Thanks~ |
|
/assign |
| export async function createK8sMemberCluster(yamlContent: string): Promise<void> { | ||
| try { | ||
| const k8sApi = createKarmadaCustomObjectsApiClient(); | ||
| const yamlObject = parse(yamlContent) as any; |
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.
here we can use const yamlObject = parse(yamlContent) as Record<string, any>; as a tradeoff, a better way is to generate the corresponding typescript definition based on the membercluster api resource
| }); | ||
|
|
||
| } catch (error: any) { | ||
| throw new Error(`Failed to create member cluster: ${error.message}`); |
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.
fix lint problem // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
| // Member Cluster not found - already deleted, this is fine | ||
| return; | ||
| } | ||
| throw new Error(`Failed to delete member cluster: ${error.message}`); |
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.
ditto
| export function getMemberClusterNameFromResourceYaml(yamlContent: string): string { | ||
| const yamlObject = parse(yamlContent); | ||
| // For Cluster resource format, get the name from metadata.name | ||
| const memberClusterName = _.get(yamlObject, 'metadata.name'); |
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.
ditto
| export function getMemberClusterNameFromYaml(yamlContent: string): string { | ||
| const yamlObject = parse(yamlContent); | ||
| // For kubeconfig format, get the cluster name from clusters[0].name | ||
| const memberClusterName = _.get(yamlObject, 'clusters[0].name'); |
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.
ditto
|
@SunsetB612 another suggestion is that, for the folder name, use |
I didn't notice that. 👍 |
No description provided.