Skip to content

tests: four build tags carry code nothing compiles, and three of them are broken #240

Closed

Description

@scttfrdmn

go vet ./... — what CI runs — builds only the untagged configuration. Every file behind a build tag is therefore unverified, and the tags in this repo are not a small set:

tag files go vet -tags=<tag> ./...
posix tests/posix_test.go MockBackend redeclared in this block — #197
aws_s3 tests/aws_s3_test.go not enough arguments in call to s.backend.PutObject
benchmark test/benchmarks/cache_test.go undefined: fmt.Itoa
integration tests/integration/{localstack_test.go,mocks.go} not enough arguments in call to s.backend.PutObject
distributed tests/distributed_test.go clean
e2e tests/e2e_test.go clean

The two PutObject failures are the same breakage: the method gained a map[string]string metadata parameter and these call sites were never updated, because nothing builds them. fmt.Itoa has never existed — that file has not compiled since it was written.

The gate is the actual fix. Repairing four files leaves the mechanism that let them rot. Add a matrix step that runs go vet once per tag, so a tagged file that stops compiling fails a PR the way an untagged one does. Vet rather than test: several of these suites need credentials or an endpoint and correctly skip without one, but compiling them needs nothing.

Per-file resolution, which is not uniform:

  • aws_s3 — fix and keep. This is the real-AWS suite CLAUDE.md asks for (AWS_PROFILE=aws AWS_REGION=us-west-2), and it skips cleanly without OBJECTFS_TEST_BUCKET.
  • benchmark — fmt.Itoa → strconv.Itoa. Mechanical.
  • integration — delete, don't repair. It is a LocalStack suite, and CLAUDE.md says integration tests hit real AWS with no LocalStack; nothing sets the AWS_ENDPOINT_URL it requires, so it has never run even when it compiled. Its companion mocks.go asserts only that pkg/optimization's interfaces are satisfied by mocks written for that assertion — and pkg/optimization has zero importers outside these two files, so the whole tag tests that a dead package's interfaces are self-consistent. What it was for is now covered by internal/testaws (a real S3 endpoint in-process) and internal/difftest.
  • posix — tests: posix_test.go has never compiled — MockBackend redeclared under -tags=posix #197 already asks the prior question: whether the tag should exist at all, given internal/difftest superseded it. Resolve there; this issue's gate is what keeps the answer honest either way.

Verification: go vet -tags=<tag> ./... clean for every tag that survives, each in its own CI matrix cell, and a deliberately-broken tagged file fails the PR.

Activity

  1. added
    type: testing
    priority: medium
    area: tests
    effort: small
    area: ci-cd
    on Aug 3, 2026
  2. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Concrete evidence from #206, since this issue was filed on inspection rather than on an incident.

    Adding gossip authentication required a new required field on distributed.ClusterConfig, so every
    construction of that type had to be updated. internal/distributed and the rest of ./... caught
    their own call sites immediately. tests/distributed_test.go did not, because no CI job compiles
    -tags=distributed — I only found its eight call sites by grepping for the type by hand, and the
    first attempt at fixing them produced code that did not compile at all (a helper referenced before it
    existed, and one call site inside a *testing.B passing a t that does not exist there). None of
    that would have been visible on a pull request.

    Compiling it also surfaced a real defect that has been sitting in that file unobserved: the suite
    fails, and has been failing, with output that contradicts itself in the same run —

    distributed_test.go:515: Failed 10 out of 10 concurrent operations
    distributed_test.go:524: Concurrent test completed - Total ops: 10, Successful: 10, Failed: 0
    

    Ten operations failed and the statistics say ten succeeded. Filed as #269. That is a metrics defect
    in internal/distributed, not a test-only problem, and the only reason it went unnoticed is that
    nothing runs this tag.

    So the "three of them are broken" in the title is now four, and the cost is not hypothetical: a build
    tag nothing compiles is a place where both compile errors and genuine defects accumulate silently. A
    go vet -tags=... matrix would be cheap and would have caught the compile break; actually running the
    suites would have caught #269.

  3. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    New evidence for this, and a refinement to the proposed gate.

    -tags=distributed is listed above as vetting clean, and it does. It was nonetheless hiding six defects — #269, #272, #275, #277, #278, plus two tests asserting against their own misconfiguration — all now fixed in #279. Three of its tests had been failing for an unknown length of time with nobody watching.

    So go vet per tag is necessary but not sufficient. Four of those six were data races on the membership maps: they compile fine, they vet fine, and they are invisible without actually running the suite under -race. Two others were tests that passed their own assertions while asserting the wrong thing — TestMultiNodeCluster set no SeedNodes and so measured three isolated clusters of one, logging "Node i sees 1 nodes in cluster" three times as if that were the expected result.

    Vet-only would have kept this issue closed and the defects live.

    Suggested amendment: for the tags whose suites need nothing external, run them rather than only vetting them. distributed is the clear case — it binds only to 127.0.0.1 and needs no credentials, no bucket, and no endpoint, and the full suite completes in ~18s under -race locally. e2e is worth checking for the same property.

    So the matrix becomes two kinds of cell:

    • vet-only — tags whose suites need credentials or an endpoint (aws_s3), where compiling is all CI can do for free.
    • go test -count=1 -race — tags that are self-contained (distributed, and e2e if it is), where the compile check is the cheap part of what is available.

    distributed is green under -race as of #279 for the first time, so a gate added now starts from a passing baseline rather than needing the suite repaired first — which is the cheapest this will ever be to turn on.

  4. scttfrdmn commented on Aug 4, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in #351.

    The gap, measured on that branch. Injecting a type error into tests/e2e_test.go — one of the two tags this issue lists as clean — gives:

    command exit
    go build ./... 0
    go vet ./... 0
    go test ./tests/ 0, and it prints ok
    go vet -tags=e2e ./... 1

    That is the whole issue in four lines, and it is worth having the number rather than the argument: a broken tagged file is not merely untested, it is invisible to every command CI ran.

    Per-file, following this issue's guidance. aws_s3 fixed and kept — ten PutObject call sites, not the one at :139; nil for the metadata map, which pkg/types/interfaces.go:14 documents as valid and which this suite asserts nothing about. benchmark fixed — fmt.Itoa → strconv.Itoa. integration deleted, and the zero-importer claim about pkg/optimization verified before acting on it (grep -rln pkg/optimization returned exactly those two files), so the package went too — 284 lines of interfaces whose sole consumer tested their self-consistency. posix resolved in #197 as superseded.

    Two more broken things fell out, both in the same family and neither in the table above. The integration-ready-check pre-commit hook ran go test -tags=integration ./tests/... whenever AWS_ENDPOINT_URL was set, inferring LocalStack from an environment variable that means nothing of the kind — so the one place that did build this tag was gated on a condition no developer meets. And make test-integration ran go test -tags=integration ./test/integration/...: that directory has never existed, so the target failed with lstat ./test/integration/: no such file or directory for as long as git records it. Both removed. The integration tag survives — it marks real-AWS tests in internal/awsrates and internal/storage/s3.

    A seventh tag this issue's table omits: fuse_mount. It was the one already handled correctly (ci.yml:58-59, Makefile:316), and its bespoke step folds into the new matrix rather than staying special — six cells: aws_s3, benchmark, distributed, e2e, integration, fuse_mount. Vet not test, for the reason this issue gives.

    The gate needed a gate. A hand-maintained list of tags in a workflow file is exactly the kind of thing that goes stale, which is the defect this issue is about — so the list is checked against the tree. TestEveryBuildTagIsGated walks every //go:build line, strips the boolean operators ((linux || darwin) && fuse_mount is a real line here), discards the tags the toolchain selects on its own, and fails naming the file. TestGatedTagsStillExist is the converse and is deliberately not symmetric: a cell for a deleted tag does not fail, it passes, because go vet -tags=gone ./... selects no files and reports success. A green cell named after a suite that no longer exists is worse than a red one, so that is a failure too — and it is what keeps #197's answer honest in the direction this issue predicted.

    Verification, in the form this issue asks for ("a deliberately-broken tagged file fails the PR") plus four more: dropping e2e from the matrix, adding a cell for the now-deleted posix, adding a new //go:build sekrit file, and restoring the original fmt.Itoa defect each produce the intended failure. All six tags vet clean; full go test -race green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ci-cdarea: testseffort: smallpriority: mediumtype: testing

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions