Skip to content

LFX Mentorship'25 Term-3: Implement Comprehensive Unit & Integration Tests #106

@Alokxk

Description

@Alokxk

Objective:
This issue will track the progress for the LFX Mentorship Term-3 project focused on implementing a comprehensive testing framework for kubeslice-cli along with enhancing test coverage across the KubeSlice ecosystem & a fully automated CI/CD pipeline to ensure long-term stability and code quality.

Mentors: @gourishkb , @Rahul-D78
Mentee: @Alokzh

Plan

1. Project Understanding

  • Understand the functionality & interdependencies within the kubeslice-cli, kubeslice-controller & worker-operator components.
  • Analyze the current test coverage reports & existing test cases across all target repositories.
  • Align with mentors on the final testing strategy and conventions.

2. Testing Strategy

Target Repositories & Directories:

  • kubeslice-cli (Currently 0% coverage)
    • pkg/ - Core CLI functionality
    • pkg/internal/ - Internal utilities and helpers
    • util/ - Utility functions
    • cmd/ - CLI command implementations
  • worker-operator (Partial coverage - identifying gaps)
  • kubeslice-controller (Partial coverage - identifying gaps)

Testing Methodologies:

  • Unit Testing: For individual functions, methods & classes focusing on isolated code units using Go's standard testing package with stretchr/testify. It will be Co-located with source code as *_test.go files (Go standard practice)
  • Kind Clusters: For integration testing infrastructure
  • Integration Testing: Create tests/integration/ directory for CLI commands that interact with Kubernetes API using real Kubernetes API server
  • Mocking Strategy: Develop necessary mocks for external dependencies
  • Table-Driven Tests: Implement table-driven tests where possible to efficiently test multiple scenarios

CI/CD Infrastructure:

  • GitHub Actions: Enhanced workflows to run full test suite on every pull request
  • Coverage Reporting: Automated coverage tracking and reporting
  • Makefile Commands:
    • make test - Run complete test suite
    • make test-integration - Run only integration tests
    • make test-unit - Run only unit tests
    • make coverage - Generate coverage reports

3. Implementation Approach

Phase 1: Unit Testing Foundation (Weeks 1-7)

  • kubeslice-cli Unit Tests: Complete unit test coverage for all packages (pkg/, pkg/internal/, util/, cmd/)
  • Ecosystem Unit Tests: Identify and add missing unit tests in worker-operator and kubeslice-controller repositories
  • Knowledge Building: Learn integration testing concepts & prepare for Phase 2
  • Early Feedback: Submit regular PRs to get feedback on test quality and style

Phase 2: Integration Testing & Continued Ecosystem Enhancement (Weeks 8-12)

  • kubeslice-cli Integration Tests: End-to-end validation of CLI commands against real Kubernetes API server
  • Continued Ecosystem Work: Keep adding unit tests to worker-operator and kubeslice-controller based on identified gaps
  • CI/CD Enhancement: Complete GitHub Actions workflow optimization & automation
  • Documentation: Create comprehensive testing guide (TESTING.md)

4. Expected Outcomes

  • Complete Test Suite: kubeslice-cli with comprehensive unit & integration tests
  • Automated Testing: CI/CD pipeline ensuring code quality on every contribution
  • Ecosystem Improvement: Enhanced test coverage across key KubeSlice repositories

PR Tracking

Overall Coverage Improved by this project: TBD
Legend:

  • ⏳ - Under Review
  • ⬜ - No PR Raised
  • ✅ - Merged/Approved
  • ❌ - Closed

Week 1:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-cli util/executables.go 1.5% #107
kubeslice-cli util/print-util.go 0.7% #73
kubeslice-cli pkg/internal/values.go 2.4% #108
worker-operator pkg/cluster/node_reconciler.go 0.7% #451

Week 2:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-cli pkg/internal/helm-repo-add.go 0.9% #111
kubeslice-cli pkg/internal/project-manifest.go 0.5% #110
kubeslice-cli pkg/internal/worker.go 0.9% #109
kubeslice-cli pkg/cmd-util.go TBD TBD

Week 3:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-cli pkg/internal/verify-executables.go TBD TBD
kubeslice-cli pkg/internal/kubernetes-operation.go TBD TBD
kubeslice-cli pkg/internal/slice-config.go TBD TBD
kubeslice-cli pkg/internal/cluster-manifests.go TBD TBD
worker-operator pkg/events/events_recorder.go TBD TBD

Week 4:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-cli pkg/internal/kind-clusters.go TBD TBD
kubeslice-cli pkg/internal/controller.go TBD TBD
kubeslice-cli pkg/internal/enterprise.go TBD TBD
worker-operator pkg/hub/controller/slicegateway_controller.go TBD TBD
worker-operator pkg/hub/controller/serviceimport_controller.go TBD TBD

Week 5:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-cli pkg/internal/cert-manager-setup.go TBD TBD
kubeslice-cli pkg/internal/secrets.go TBD TBD
kubeslice-cli pkg/internal/get-network-info.go TBD TBD
worker-operator controllers/serviceexport/serviceexport.go TBD TBD
worker-operator controllers/serviceimport/serviceimport.go TBD TBD

Week 6:

Status Repository Target Files/Package Overall Coverage Increase PR
worker-operator controllers/serviceexport/utils.go TBD TBD
worker-operator controllers/serviceimport/utils.go TBD TBD
worker-operator controllers/slicegateway/reconciler.go TBD TBD
worker-operator pkg/gwsidecar/gwsidecar.go TBD TBD
worker-operator pkg/gatewayedge/gatewayedge.go TBD TBD

Week 7:

Status Repository Target Files/Package Overall Coverage Increase PR
kubeslice-controller controllers/worker/workersliceconfig_controller.go TBD TBD
kubeslice-controller controllers/worker/workerslicegateway_controller.go TBD TBD
kubeslice-controller controllers/worker/workerserviceimport_controller.go TBD TBD
kubeslice-controller controllers/controller/cluster_controller.go TBD TBD
kubeslice-controller controllers/controller/sliceqosconfig_controller.go TBD TBD
kubeslice-controller controllers/controller/serviceexportconfig_controller.go TBD TBD

This issue will be updated regularly with progress updates, new PRs and coverage improvements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions