Skip to content

emulator: StartTestServer takes *testing.T, so a benchmark cannot use it #605

Closed

Description

@scttfrdmn

Substrate needs a testing.TB entry point so benchmarks can drive the emulator.

What is blocked

emulator.StartTestServer(t *testing.T) (emulator/testing.go:50) is *testing.T-specific, but everything it uses t for is on testing.TB: t.Helper(), t.Fatalf() and t.Cleanup(). Nothing in the body needs *testing.T — I checked all three call sites in v0.96.0.

The consequence is that a *testing.B cannot start a substrate server at all, and no cast bridges it (testing.TB has an unexported method, so *testing.B cannot be converted to *testing.T).

Downstream, objectfs wraps this in internal/testaws.Start(t *testing.T), which is how nearly every test in that project reaches a real S3 endpoint over real HTTP with no credentials. A benchmark of objectfs's FUSE read path therefore has to fall back to an in-memory types.Backend — which is exactly the kind of mock that harness exists to avoid, and which makes an uncached-read benchmark measure a map lookup where production measures an HTTP round trip.

Suggested change

Widen the parameter:

func StartTestServer(tb testing.TB) *TestServer

*testing.T callers are unaffected — *testing.T satisfies testing.TB — so this is source-compatible for every existing caller. TestServer.ResetState(t *testing.T) at emulator/testing.go:138 has the same shape and could widen in the same change.

bucketNameFor-style helpers on the consumer side use t.Name(), which is also on testing.TB, so nothing further is needed for objectfs to follow suit.

Version

Observed on v0.93.0 (the version objectfs pins) and confirmed unchanged in v0.96.0.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions