mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
* Feat(utils): Enhance unit test coverage and quality for pkg/utils (#6884) * feat(env): Add comprehensive unit tests for environment management This commit introduces a comprehensive suite of unit tests for the environment management functions in `pkg/utils/env`. Key changes include: - Refactoring the test setup to use `TestMain` for better test environment control. - Adding new test cases for `CreateEnv`, `GetEnvByName`, `ListEnvs`, `SetCurrentEnv`, `SetEnvLabels`, and `DeleteEnv`. These tests improve the overall test coverage and ensure the correctness and reliability of environment-related operations. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(errors): Add unit tests for error handling utilities This commit introduces new unit tests for the error handling utilities located in `pkg/utils/errors/`. Specifically, new test files have been added for: - `crd_test.go`: Tests for CRD-related error checks. - `list_test.go`: Tests for error list aggregation. - `reason_test.go`: Tests for specific error reasons like label conflicts and CUE path not found. - `resourcetracker_test.go`: Tests for resource tracker errors. These additions improve the test coverage and ensure the robustness of KubeVela's error handling mechanisms. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * refactor(schema): Refactor ui_schema_test.go to use testify/assert and add new test cases This commit refactors `pkg/utils/schema/ui_schema_test.go` to improve its readability and maintainability. Key changes include: - Migrating from Ginkgo/Gomega to testify/assert for assertions. - Restructuring `TestGetDefaultUIType` into a table-driven test. - Adding new comprehensive test cases for `Condition_Validate` function. These changes enhance the test suite for UI schema utilities, making it more robust and easier to extend. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * refactor(system): Refactor system_test.go and add comprehensive unit tests This commit refactors `pkg/utils/system/system_test.go` to improve its structure, readability, and test coverage. Key changes include: - Converting existing tests to a table-driven format using `testify/assert`. - Adding new comprehensive test cases for: - `CreateIfNotExist` - `GetVelaHomeDir` - `GetDirectoryFunctions` (e.g., `GetCapCenterDir`, `GetCapabilityDir`) - `InitFunctions` (e.g., `InitCapabilityDir`, `InitCapCenterDir`, `InitDirs`) - `BindEnvironmentVariables` These changes enhance the test suite for system utilities, ensuring their correctness and robustness. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(types): Add unit tests for QL types This commit introduces new unit tests for the types defined in `pkg/utils/types`, specifically focusing on types related to KubeVela Query Language (QL). New test cases cover: - `ServiceEndpoint.String()`: Verifies the string representation of service endpoints, including various protocols, ports, and paths. - `AppliedResource.GroupVersionKind()`: Ensures correct extraction of GroupVersionKind from applied resources. - `ResourceTreeNode.GroupVersionKind()`: Verifies correct extraction of GroupVersionKind from resource tree nodes. These tests improve the coverage and reliability of core data structures used in KubeVela. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(util): Add and refactor unit tests for utility functions This commit introduces new unit tests and refactors existing ones within the `pkg/utils/util` package. Key changes include: - **`pkg/utils/util/cmd_test.go`**: Adds comprehensive tests for `IOStreams` and its print functions, as well as `NewDefaultIOStreams` and `NewTestIOStreams`. - **`pkg/utils/util/factory_test.go`**: Refactors the `GenerateLeaderElectionID` test to a table-driven format and adds new tests for `computeDiscoverCacheDir` and `RestConfigGetter` methods, ensuring the correctness of Kubernetes client configuration and discovery. These additions and refactorings enhance the test coverage and reliability of core utility functions. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(utils): Add and refactor unit tests for json, jwt, parse, and strings utilities This commit introduces new unit tests and refactors existing ones across several utility packages within `pkg/utils/`. Key changes include: - **`pkg/utils/json`**: Adds tests for `StrictUnmarshal` to ensure proper JSON unmarshaling. - **`pkg/utils/jwt`**: Adds tests for JWT token subject extraction and certificate subject retrieval. - **`pkg/utils/parse`**: Expands test coverage for URL parsing functions (`Parse`, `ParseGitlab`). - **`pkg/utils/strings`**: Refactors existing tests to a table-driven format and adds tests for box drawing string generation. These additions and refactorings significantly improve the test coverage and reliability of KubeVela's utility functions. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * fix(tests): Address test and error handling issues This commit addresses several issues identified in unit tests and error handling utilities, improving test reliability and code safety. Key fixes and improvements include: - **`pkg/utils/errors`**: - Added nil check to `IsCuePathNotFound` to prevent panics. - Corrected `fmt.Errorf` usage to `errors.New` in `reason_test.go` (SA1006 fix). - Used `assert.EqualError` for clearer error message comparisons in `resourcetracker_test.go`. - **`pkg/utils/jwt_test.go`**: Marked `generateTestCert` as a test helper using `t.Helper()` for better error reporting. - **`pkg/utils/system_test.go`**: - Removed unused `verifyCleanup` field. - Modified `TestGetVelaHomeDir` to use a temporary home directory, preventing destructive operations on the user's system. - **`pkg/utils/util/cmd_test.go`**: Swapped `assert.Equal` arguments to follow `expected, actual` convention. These changes enhance the robustness and correctness of the test suite and related utility functions. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * chore(tests): Apply gofmt and import ordering to test files This commit applies standard Go formatting (`gofmt`) and corrects import ordering in several test files. Affected files: - `pkg/utils/schema/ui_schema_test.go`: Added missing newline at EOF. - `pkg/utils/system/system_test.go`: Corrected import ordering. - `pkg/utils/util/factory_test.go`: Corrected import ordering. These changes ensure consistency with project coding standards. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> --------- Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: upgrades ga versions Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> # Conflicts: # .github/workflows/unit-test.yml Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: upgrades ga versions in go workflow Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * test: updates fluxcd negative test case criteria Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: update action versions in workflow files Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * test: add upgrade e2e and unit test workflows for KubeVela Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: simplify upgrade test workflows by removing redundant steps and enhancing installation process Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Feat: automate KubeVela installation by fetching the latest release version Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: remove fix/upgrade-test branch from workflow triggers Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: add new actions for system info and unit testing diagnostics Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: implement Kubevela K8s upgrade e2e and unit test actions with diagnostics Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: create Kubevela test environment setup action with system dependencies and Ginkgo framework Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: implement Kubevela K8s upgrade multicluster e2e test action with coverage reporting and diagnostics Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: update workflow triggers to include and exclude fix/upgrade-test branch Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Feat: Support Native Cue in HealthPolicy and CustomStatus (#6859) * Feat: Support Native Cue in HealthPolicy and CustomStatus Signed-off-by: Brian Kane <briankane1@gmail.com> * Feat: Support Native Cue in HealthPolicy and CustomStatus - Fix PR Comments & Bugs Signed-off-by: Brian Kane <briankane1@gmail.com> --------- Signed-off-by: Brian Kane <briankane1@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Feat: Consolidate Health & Status and Pass Status Context Data (#6860) Signed-off-by: Brian Kane <briankane1@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * <type>: <description> <jira number> [optional body] [optional footer] Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: remove author information from Kubevela test environment setup action Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: add fix/upgrade-test branch to workflow triggers and streamline unit test steps Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: add KinD setup step for unit tests and remove fix/upgrade-test branch from e2e triggers Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: add GitHub actions for deploying current branch and installing latest KubeVela release Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * chore: rename test YAML files for consistency Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: update GitHub actions to use specific checkout version and streamline deployment steps Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: enhance GitHub actions for Kubevela tests with Codecov integration and cleanup Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * fix: improve e2e profile cleanup logic in test workflows Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: add GitHub Action for setting up Kind cluster for E2E testing Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Optimised Github workflow Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: update action.yaml to enhance KinD cluster setup with configurable version and optional naming Signed-off-by: Chaitanya Reddy Onteddu <chaitanyareddy0702@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Add sudo command Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Revert check windows Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Add sudo to action Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Change branch trigger filters Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * Chore: Revert changes from rebase Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * refactor: optimizes github actions Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: update action.yaml to install kubectl and helm using direct downloads Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * fix: update Kubernetes version in e2e multicluster test workflow Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: updates upgrade test triggers Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: updates upgrade test triggers Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> * feat: enhance action.yaml to support architecture detection and improve Helm installation Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: semmet95 <singhamitch@outlook.com> --------- Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> Signed-off-by: semmet95 <singhamitch@outlook.com> Signed-off-by: Vishal Kumar <vishal210893@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Amit Singh <singhamitch@outlook.com> Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com> Signed-off-by: Brian Kane <briankane1@gmail.com> Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanya Reddy Onteddu <chaitanyareddy0702@gmail.com> Co-authored-by: AshvinBambhaniya2003 <156189340+AshvinBambhaniya2003@users.noreply.github.com> Co-authored-by: Vishal Kumar <vishal210893@gmail.com> Co-authored-by: Brian Kane <briankane1@gmail.com> Co-authored-by: Reetika Malhotra <rmalhotra@guidewire.com> Co-authored-by: Chaitanya Reddy Onteddu <chaitanyareddy0702@gmail.com> Co-authored-by: Amit Singh <singhamitch@outlook.com> Co-authored-by: Chaitanyareddy0702 <78363486+Chaitanyareddy0702@users.noreply.github.com>