siso: fix reproxy test error on recent go

with recent version of go, execute/reproxyexec.TestRun_LocalFallback
fails like this:

ukai@ukai ...infra/build/siso % go version
go version go1.22-20240109-RC01 cl/597041403 +dcbe772469 X:fieldtrack,boringcrypto linux/amd64
ukai@ukai ...infra/build/siso % CGO_ENABLED=0 go test ./execute/reproxyexec -run '.*LocalFallback'
--- FAIL: TestRun_LocalFallback (0.02s)
    reproxyexec_test.go:236: fake reproxy at 127.0.0.1:46193
    reproxyexec_test.go:290: hashFS.IOMetrics.Stats(): diff -want +got:
          iometrics.Stats{
                Ops:     2,
                OpsErrs: 0,
                ROps:    1,
        -       RBytes:  15,
        +       RBytes:  0,
                RErrs:   0,
                WOps:    0,
                ... // 2 identical fields
          }
    reproxytest.go:66: Serve finished: accept tcp 127.0.0.1:46193: use of closed network connection
FAIL
FAIL    infra/build/siso/execute/reproxyexec    0.046s
FAIL

This is because localFile embeds *os.File
and io.Copy might use *os.File's Read method rather than
localFile's Read method.
This is because go dev implements WriteTo on *os.File
and io.Copy uses WriteTo if available.

go 1.21: https://go.dev/play/p/FK8_HO_3jjQ
go dev: https://go.dev/play/p/FK8_HO_3jjQ?v=gotip

No need to embed *os.File here, so use field rather than embed
and make sure user of of localFile uses localFile's Read/Close method
rather than *os.File's method.

Change-Id: I4b139c2814c30e28007d1c8b22f9faa69e9c694b
Reviewed-on: https://chromium-review.googlesource.com/c/infra/infra/+/5220966
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Cr-Commit-Position: refs/heads/main@{#62462}
1 file changed
tree: bbed0877e8878b4ace6ed7417107fcdb6bdd5206
  1. 3pp/
  2. appengine/
  3. appengine_module/
  4. bootstrap/
  5. build/
  6. chromeperf/
  7. crdx/
  8. doc/
  9. docker/
  10. go/
  11. infra/
  12. node/
  13. packages/
  14. python_pb2/
  15. rbe/
  16. recipes/
  17. test/
  18. utils/
  19. .gitallowed
  20. .gitattributes
  21. .gitignore
  22. .gitmodules
  23. .style.yapf
  24. .vpython
  25. .vpython3
  26. .yapfignore
  27. codereview.settings
  28. CONTRIBUTING.md
  29. DEPS
  30. LICENSE
  31. navbar.md
  32. OWNERS
  33. PRESUBMIT.py
  34. README.md
  35. run.py
  36. test.py
  37. WATCHLISTS
  38. WHITESPACE
README.md

infra.git repository

Welcome to the Chrome Infra repository!

Wondering where to start? Check out General Chrome Infrastructure documentation. In particular, to check out this repo and the rest of the infrastructure code, follow the instructions here. The rest of this page is specific to this repo.

Entry points

  • run.py: wrapper script to run programs contained in subdirectories without having to deal with sys.path modifications.
  • test.py: multi-purpose script to run tests.
  • packages/infra_libs/: generally useful functions and classes
  • infra/services/: standalone programs intended to be run as daemons.
  • infra/tools: command-line tools, intended to be run by developers.
  • appengine/: many Chrome-infra-managed AppEngine applications.
  • infra/experimental: for, well, experimental stuff. Once they are stabilized and reviewed, they should be moved in a more permanent place.

Miscellaneous technical stuff

  • bootstrap/: utilities to set up a proper Python virtual environment.
  • utils/: purpose? utils?
  • Need to bump infra/deployed to pick up changes?
    • git push origin <updated hash>:deployed
    • mail chrome-troopers@, include:
      • previously deployed hash (for quick rollback)
      • the hash you just pushed
      • the list of CLs that made this push necessary
      • the output of the git push command

Integrating tests with test.py

If you've added a new module, run your tests with test.py:

  1. Create a .coveragerc file in the root directory of the module you want to test. Take a look at another .coveragerc to see what to include in that.
  2. Create a “test” directory in the root directory of the module you want to test. Move your *_test.py files to this directory.

Double-check that your tests are getting picked up when you want them to be: ./test.py test <path-to-package>.

Tests still not getting picked up by test.py? Double-check to make sure you have __init__.py files in each directory of your module so Python recognizes it as a package.

Style

The preferred style is PEP8 with two-space indent; that is, the Chromium Python style, except functions use lowercase_with_underscores. Use yapf (git cl format) to autoformat new code.