Skip to content

Refactor to Go Workspaces and add more tests#30

Merged
karlkfi merged 25 commits into
masterfrom
karl-tests
May 9, 2026
Merged

Refactor to Go Workspaces and add more tests#30
karlkfi merged 25 commits into
masterfrom
karl-tests

Conversation

@karlkfi

@karlkfi karlkfi commented May 9, 2026

Copy link
Copy Markdown
Owner

This PR transitions the project to a Go workspace architecture using go.work, enabling better management of the multiple modules in this repository (kubexit and test-server). It also introduces a structured CI/CD pipeline via GitHub Actions, providing dedicated workflows for unit, integration, and end-to-end testing.

Key Changes

Architecture & Dependency Management

  • Go Workspace Transition: Implemented go.work to manage the root module, cmd/kubexit, and cmd/test-server as part of a single workspace. This simplifies development across multiple modules.
  • Dependency Updates: Upgraded various Go dependencies (e.g., pflag) and added essential utilities like errgroup and testify.
  • Module Cleanup: Introduced scripts/go-modules.sh to streamline the process of updating and removing unused Go modules across the workspace.

CI/CD Pipeline Enhancements

  • GitHub Actions Workflows: Established a robust testing pipeline with separate workflows for:
    • Unit Testing: (.github/workflows/unit-test.yaml) runs the project's unit test suite.
    • Integration Testing: (.github/workflows/integration-test.yaml) validates core functionality against Kubernetes-like environments.
    • End-to-End (E2E) Testing: (.github/workflows/e2e-test.yaml) provides full lifecycle validation of the kubexit process.
  • Improved Documentation: Updated .github/workflows/README.md and ci/e2e-test/README.md to guide developers through the new CI processes.

Core Logic & Testing Improvements

  • Refactored Kubernetes Watching: Improved the robustness of the watch mechanism in pkg/watch/watch.go by implementing a more reliable precondition check and refined event handling for pod lifecycle changes.
  • Expanded Test Coverage:
    • Added comprehensive new unit tests for the supervisor (pkg/supervisor/supervisor_test.go) and tombstone (pkg/tombstone/tombstone_test.go) packages.
    • Enhanced the integration test suite with new test cases in cmd/test-server.

Test Plan

  • Run unit tests via make test to ensure core logic remains intact.
  • Verify integration tests pass using the newly established integration workflow.
  • Confirm that the Go workspace structure correctly builds both kubexit and test-server binaries.

karlkfi added 17 commits April 25, 2026 18:08
- Update `WatchPod` to wait for cache synchronization using a sync context in `cmd/kubexit`.
- Refactor `pkg/watch/watch.go` to simplify event handling and improve error logging.
- Rewrite `pkg/watch/watch_test.go` to use channels for phase tracking and improved log redirection.
- Add `pkg/watch/test-server-pod.yaml` for standardized test pod creation.
@karlkfi karlkfi changed the title Add unit and integration tests Refactor to Go Workspaces and add more tests May 9, 2026
@karlkfi karlkfi merged commit d70e083 into master May 9, 2026
4 checks passed
@karlkfi karlkfi deleted the karl-tests branch May 9, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant