Skip to content

test(performance): compare resolved temp paths in resolve target tests - #1163

Open
RyoKusnadi wants to merge 1 commit into
Starosdev:developfrom
RyoKusnadi:test/resolve-target-tempdir-symlink
Open

RyoKusnadi wants to merge 1 commit into
Starosdev:developfrom
RyoKusnadi:test/resolve-target-tempdir-symlink

Conversation

@RyoKusnadi

Copy link
Copy Markdown

Summary

Two tests in collector/pkg/performance/resolve_target_test.go fail on macOS because they compare an unresolved temp path with a resolved one. This fixes the expectations. Picked this up from my earlier comment in the issue.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Test-only change, no production code touched.

Related Issues

Fixes #1048

Changes Made

  • Problem: on a Mac, go test ./collector/... fails two tests. How it happens: t.TempDir() is under /var/folders/..., a symlink to /private/var/folders/.... resolveTargetPath returns the resolved path, the test expects the raw one. Linux has no symlink there, so CI never sees it.
  • Cause: TestResolveTargetPath_UsesConfiguredMountPoint and TestResolveTargetPath_ConfiguredMountPointBeatsDirectIOOptIn build the expected path from the raw t.TempDir().
  • Fix: a small resolvedPath helper (filepath.EvalSymlinks) used for the expected path. The configured mount point stays unresolved, so the tests still check that resolution happens.
  • Scope: the other TempDir uses in the package either already resolve (ResolvesConfiguredSymlink), compare with target itself, or only check fallbacks. mount_linux_test.go is Linux-only. resolveTargetPath is unchanged.

Testing

  • TestResolveTargetPath_UsesConfiguredMountPoint and ..._ConfiguredMountPointBeatsDirectIOOptIn: both failed before (/var/folders/... vs /private/var/folders/...) and pass now.

  • Ran go vet ./collector/pkg/performance/ and go test -count=1 ./collector/pkg/performance/, both pass. gofmt -l is clean.

  • Not run: the rest of the repo, and golangci-lint (it stops on the repo's vendor/modules.txt being out of sync with go.mod).

  • Environment: develop @ 3c71a47, go1.27.4, darwin/arm64.

  • I have tested this locally

  • I have added/updated tests that prove my fix/feature works

  • All existing tests pass

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings
  • No console.log, debug statements, or commented-out code

Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>

This branch has not been deployed

No deployments
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