Skip to content

Unit-tests and CI pipelines for them#20

Open
mrwesadex-flant wants to merge 12 commits into
mainfrom
unit-tests
Open

Unit-tests and CI pipelines for them#20
mrwesadex-flant wants to merge 12 commits into
mainfrom
unit-tests

Conversation

@mrwesadex-flant

@mrwesadex-flant mrwesadex-flant commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a hermetic unit-test suite for the framework's deterministic core logic and a mandatory CI pipeline that builds, vets and runs those tests on every push and PR. No production code under pkg//internal/ changes behavior — this PR is tests, CI wiring, tooling and docs.

What's included

CI / tooling

  • .github/workflows/unit-tests.ymlBuild, vet & unit test job: go build ./..., go vet ./..., and go test -race -shuffle=on -covermode=atomic scoped to ./internal/... ./pkg/... (e2e suites under ./tests/... stay off CI since they need real VMs/clusters/SSH). Uploads coverage.out as an artifact.
  • Makefilebuild / vet / test / cover / e2e / clean targets mirroring the CI commands so make test locally == the CI job.
  • .gitignore — ignore coverage.out / coverage.html.

Gitleaks

  • Renamed gitleaks-scan-on-pr.ymlgitleaks.yml and kept it pull_request-scoped (the upstream action's diff mode needs github.event.number, so it can't run on push).
  • gitleaks.toml — content-based allowlist ([extend] useDefault=true) for the base64("user:token") test fixture in the commander client tests. Chosen over a .gitleaksignore fingerprint because fingerprints are pinned to a commit SHA and break on rebase.

Unit tests (hermetic, table-driven — no SSH/cluster/network)

  • pkg/retry/retry_test.goDo / IsRetryable / IsSSHConnectionError / WithRetryAfter, including context-cancel and backoff paths.
  • pkg/kubernetes/{apply,modules,poll}_test.go — YAML doc splitting + env-var scanning, module graph topo-sort + cycle detection, readiness polling helpers.
  • pkg/cluster/vms_test.go — pure VM helpers (random suffix, etc.).
  • pkg/testkit/stress_tests_test.goConfig.Validate / DefaultConfig.
  • internal/config/types_yaml_test.goClusterNode / ClusterDefinition YAML unmarshal + validation.
  • internal/logger/level_test.goLevelToString round-trip.
  • internal/kubernetes/commander/client_test.go + client_http_test.go — mapper/base64/validation helpers and the full Commander HTTP client driven against an httptest.Server.

Docs

  • docs/TESTS_IMPLEMENTATION_PLAN.md, docs/WORKLOG.md, and CLAUDE.md (repo working guidance).

Test plan

  • go build ./...
  • go vet ./...
  • go test -race -shuffle=on ./internal/... ./pkg/...
  • golangci-lint (via CI Lint job)
  • Gitleaks scan green

Notes

  • Rebased onto latest main; no merge conflicts.
  • Only blocker to merge is the required review approval.

Drop the push trigger. The upstream action's diff mode needs
github.event.number (only present on pull_request); on push it builds an
empty refspec (+refs/pull//merge:...) and git fetch fails with exit 128.
The diff scan flags commit 5f1edc2, which introduced the base64("user:token")
test fixture before the inline gitleaks:allow comment was added, so the inline
suppression cannot hide it. Ignore the finding by fingerprint instead.
@github-code-quality

github-code-quality Bot commented Jun 23, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Go

Go / code-coverage/go

The overall coverage in the branch is 9%. The coverage in the branch is 2%.

Show a code coverage summary of the most impacted files.
File 60ef4b8 97bcd1a +/-
pkg/cluster/cluster.go 0% 0% 0%
pkg/testkit/stress-tests.go 0% 7% +7%
internal/logger/level.go 92% 100% +8%
pkg/kubernetes/poll.go 0% 13% +13%
pkg/kubernetes/apply.go 0% 17% +17%
pkg/cluster/vms.go 0% 19% +19%
pkg/kubernetes/modules.go 0% 20% +20%
internal/kubern...ander/client.go 0% 48% +48%
internal/config/types.go 11% 96% +85%
pkg/retry/retry.go 0% 94% +94%

Updated June 24, 2026 07:27 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

The .gitleaksignore fingerprint is pinned to a commit SHA, so rebasing
unit-tests onto main (5f1edc2 -> 35e9bc7) made it stop matching and the diff
scan flagged the base64 test fixture again. Add a content-based allowlist
(regexTarget=line) that extends the default ruleset and survives rebases.
main's golangci-lint config (pulled in by the rebase) flagged the unit-test
files: gocritic paramTypeCombine, gofmt, misspell (behaviour/cancelled),
ineffassign, and a staticcheck De Morgan simplification.
…ransition to a content-based allowlist in gitleaks.toml, which addresses false positives without relying on commit fingerprints.
Comment thread .github/workflows/unit-tests.yml Outdated
Comment thread docs/TESTS_IMPLEMENTATION_PLAN.md
main's go-checks.yml already runs lint, race-enabled unit tests and coverage
publishing, so a dedicated unit-tests.yml was redundant. Point the Makefile
header at go-checks.yml.
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
github.com/deckhouse/storage-e2e/internal/cluster 0%
github.com/deckhouse/storage-e2e/internal/config 45%
github.com/deckhouse/storage-e2e/internal/infrastructure/ssh 0%
github.com/deckhouse/storage-e2e/internal/kubernetes/commander 48%
github.com/deckhouse/storage-e2e/internal/kubernetes/deckhouse 0%
github.com/deckhouse/storage-e2e/internal/kubernetes/storage 0%
github.com/deckhouse/storage-e2e/internal/kubernetes/virtualization 0%
github.com/deckhouse/storage-e2e/internal/logger 51%
github.com/deckhouse/storage-e2e/internal/provisioning/dvp 7%
github.com/deckhouse/storage-e2e/pkg/cluster 4%
github.com/deckhouse/storage-e2e/pkg/clusterprovider 89%
github.com/deckhouse/storage-e2e/pkg/clusterprovider/registry 100%
github.com/deckhouse/storage-e2e/pkg/kubernetes 5%
github.com/deckhouse/storage-e2e/pkg/retry 94%
github.com/deckhouse/storage-e2e/pkg/storage-e2e 0%
github.com/deckhouse/storage-e2e/pkg/testkit 4%
Summary 9% (1168 / 12416)

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.

2 participants