-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Router code out of the main module etc. #380
Commits on Aug 18, 2023
-
Move Router code out of the main module.
It's currently very hard to unit test the methods of the Router type because it's so tightly coupled with program initialisation stuff in the main module. Moving it into its own module is the first step towards fixing this.
Configuration menu - View commit details
-
Copy full SHA for 11d00a5 - Browse repository at this point
Copy the full SHA 11d00a5View commit details
Commits on Aug 19, 2023
-
Extract the mongo startup script from the Makefile.
It's much easier to read and debug as a standalone shell script, plus we get shellcheck coverage. Hopefully this fixes the last of the mongo startup flakiness.
Configuration menu - View commit details
-
Copy full SHA for f9eff5a - Browse repository at this point
Copy the full SHA f9eff5aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ec7465 - Browse repository at this point
Copy the full SHA 6ec7465View commit details -
Configuration menu - View commit details
-
Copy full SHA for 586023d - Browse repository at this point
Copy the full SHA 586023dView commit details -
Move version.go out of main and use BuildInfo.
Move version.go from main to the router module (lib/) so that it can (later) be accessed from Router itself. Make it use standard debug.BuildInfo that the Go toolchain produced automatically, so we no longer have to mess about with shell scripts and linker flags. This eliminates some unnecessary differences between the Dockerfile and Makefile builds.
Configuration menu - View commit details
-
Copy full SHA for bf04cfe - Browse repository at this point
Copy the full SHA bf04cfeView commit details -
Always print the version info on startup.
It's useful to see the version string in the logs on startup.
Configuration menu - View commit details
-
Copy full SHA for eb84ce6 - Browse repository at this point
Copy the full SHA eb84ce6View commit details -
Configuration menu - View commit details
-
Copy full SHA for f2fd2f8 - Browse repository at this point
Copy the full SHA f2fd2f8View commit details -
Don't assume the default Prometheus registry.
Registering metrics in a global namespace is neither test-friendly nor concurrency-safe. There's also the potential for name clashes to cause panics on startup, which can even happen implicitly on import because we've been calling prometheus.MustRegister() from module init functions. Injecting a prometheus.Registerer will allow us to write proper integration tests (and be able to run them in parallel), rather than almost everything having to be an end-to-end test that forks and execs an external Router binary. Also don't export Prometheus objects from modules. Nothing outside the module should depend on implementation details of the module's metrics. The public interface for reading metrics within the same process is prometheus.Gatherer. For everything else, there's `/metrics`.
Configuration menu - View commit details
-
Copy full SHA for eab0792 - Browse repository at this point
Copy the full SHA eab0792View commit details -
Make metric var names less excessively verbose.
<insert mean joke about Java>
Configuration menu - View commit details
-
Copy full SHA for a3818f2 - Browse repository at this point
Copy the full SHA a3818f2View commit details -
Configuration menu - View commit details
-
Copy full SHA for cd02846 - Browse repository at this point
Copy the full SHA cd02846View commit details -
Configuration menu - View commit details
-
Copy full SHA for 98e6e0d - Browse repository at this point
Copy the full SHA 98e6e0dView commit details -
Pass NewRouter a struct instead of too many params.
NewRouter()'s parameter list was already getting out of hand. Copying it straight into struct Router for now just for the sake of convenience. Probably change that soon.
Configuration menu - View commit details
-
Copy full SHA for 68cf596 - Browse repository at this point
Copy the full SHA 68cf596View commit details -
Configuration menu - View commit details
-
Copy full SHA for d444d64 - Browse repository at this point
Copy the full SHA d444d64View commit details
Commits on Aug 20, 2023
-
Avoid automatically registering metrics globally.
Only the main module now touches the default Prometheus registry. We want to be able to refactor some of our unnecessarily-end-to-end tests into integration tests (in the true sense) and unit tests. To do that, we can't have components messing with global state. This also improves separation of concerns generally. For example, the triemux and handlers modules can no longer cause panics simply by being imported if there's a metric name clash.
Configuration menu - View commit details
-
Copy full SHA for e1d62af - Browse repository at this point
Copy the full SHA e1d62afView commit details -
Remove unnecessary envMap type from test helpers.
It's way simpler to use cmd.Env.
Configuration menu - View commit details
-
Copy full SHA for 4a1900f - Browse repository at this point
Copy the full SHA 4a1900fView commit details -
Bind servers under test to local loopback interface.
This eliminates the annoying "wants to accept incoming connections" popups on macOS.
Configuration menu - View commit details
-
Copy full SHA for 1b264cc - Browse repository at this point
Copy the full SHA 1b264ccView commit details -
Get rid of varargs in test helpers.
Unnecessary abstraction in test helpers can easily undermine the value of the tests. Get rid of unnecessary logic and just be explicit. Most of this was generated with some sed-foo.
Configuration menu - View commit details
-
Copy full SHA for 22d8a86 - Browse repository at this point
Copy the full SHA 22d8a86View commit details -
Configuration menu - View commit details
-
Copy full SHA for 46e13a6 - Browse repository at this point
Copy the full SHA 46e13a6View commit details -
Remove an unrelated test assertion.
In a test that's supposed to check whether reloading the route table works, asserting that the async reload request took < 5 ms is neither helpful nor tasty, unlike this other [recipe for flakes](https://bakewithsarah.com/chocolate-fudge-flake-cake/). Also don't request the reload twice; it's unnecessary and makes the test slightly less useful, e.g. it would fail to catch a bug where the reload fails the first time but succeeds on retry.
Configuration menu - View commit details
-
Copy full SHA for 341963e - Browse repository at this point
Copy the full SHA 341963eView commit details -
More deflaking: allow 1.5 poll intervals for reload.
The default poll interval is 2 s, so wait 3. This doesn't slow down the test; gomega.Eventually polls every 10 ms by default.
Configuration menu - View commit details
-
Copy full SHA for 7940707 - Browse repository at this point
Copy the full SHA 7940707View commit details -
`/stats` is disused and useless now that we have a Prometheus gauge for the route count. It didn't use to return anything else.
Configuration menu - View commit details
-
Copy full SHA for 73b9cd9 - Browse repository at this point
Copy the full SHA 73b9cd9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d3ad82c - Browse repository at this point
Copy the full SHA d3ad82cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 832ef3e - Browse repository at this point
Copy the full SHA 832ef3eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 46d2942 - Browse repository at this point
Copy the full SHA 46d2942View commit details