> On 24 Oct 2020, at 05.57, Craig Silverstein <csilv...@khanacademy.org> wrote: > > As a way of distributing our go-test run across multiple machines, we are > exploring a client-server architecture. The way we'd like it to work is that > a "go test client" runs on the client machine(s), and repeatedly does the > following: > 1) make an http GET request to "http://<server>/more_tests" > -- the http response is a list of go package specs (e.g. `./web/`, > `./web/internal`) > 2) run the tests in those specs via the equivalent of `go test` > 3) make another request to /more_tests > 4) when /more_tests responds with an empty list, meaning no more tests, > the client emits the test status/summary information > -- it would also be ok to emit the test status/summary for each run, > rather than just at the end > > I could put this client code "above" go test, and (2) could literally be just > exec-ing `go test <package>`. But in my experimenting the overhead of > calling `go test` is quite high: `go test -count 1 <pkg1>; go test -count 1 > <pkg2>` is 50% slower than `go test -count1 <pkg1> <pkg2>`. > > So I'd like to put the client code "inside" go test somehow. But I don't > have a good idea how to do that, especially in a way that doesn't depend on > go internals. Alternately, if there is some way to reduce the overhead of > calling `go test` -- I don't know where all the time is going -- that would > be a good solution too. Any ideas/suggestions? >
Based on my understanding, my suggestion is you should separate between Go tools (the one that execute "go test") and your test tools (the one that fetch which packages need to tests, run the actual test, and emits the result back to server), not embedded inside the *_test.go files, for the following reason: "go test" should be able to run without depends on test server. Assume that we created a tool called "go-distributed-test" that client executed on the root of repository, $ go-distributed-test /path/to/go-module Client: GET http://<server>/more_tests Server: pkgA,pkgA/B,pkgC => pkgs Client: FOR EACH pkg in pkgs DO (1) result := "go test "+ $pkg; (2) POST /$pkg/$result DONE On step (1), you can read and store the program exit status with their output (stdout and stderr). I hope that helps. I am not going ask _why_ but seems like you got an interesting project to build :) Regards, Shulhan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/FCC123AA-4B2E-4234-9F10-9F76CFF5AE28%40gmail.com.