Skip to content
Snippets Groups Projects

Specify explicit non-numeric hosts in tests

Closed Антон Фетисов requested to merge afetisov/fix-test-connect into master

Summary

All-numeric domains are now considered invalid, since they introduce confusion: one can assume that an all-numeric domain is a port, and the server should bind to localhost with that port.

The specific change to domain parsing happens in a future MR. This commit fixes the tests in preparation for it.

Note that all-numeric top-level domains are considered invalid according to RFC 952 and RFC 1123. In fact, the top-level domain label must be alphabetic, but we do not place that restriction, since local domains could have arbitrary format.

  • test: in some tests, don't check for specific error messages

Checking for specific error messages is fragile. Any cosmetic change to the message, such as fixing a typo or enabling coloured output, causes test breakage. It also prevents us from designing any better errors, or including backtrace or source trace in error messages. We also shouldn't depend on the specific error being returned. For example, connecting to an invalid host can return various errors, including timeout errors or host resolution errors, and the errors may depend on the specifics of OS and network connectivity (e.g. a network error can change a DNS resolution error into a DNS timeout).

Instead, use regular expressions to check for presence of errors, without depending on the specific text.

  • test: clear mutex poisoning in env tests

Mutex is held for the duration of the whole tests, and poisons if the test panics, making all other env tests fail with PoisonError. Panicking tests is expected behaviour during development. We don't introduce any inconsistency by clearing the poison, since the only invariant that the mutex protects is that tests don't concurrently access the environment (which must be blocked for the whole test duration, since tests depend on the specific change order of env variables) and that the environment is unconditionally restored when the test terminates, including panics.

  • refactor: allow pgproto::new_listener to work with any ToSocketAddrs address

  • Cherry-pick to: none
  • Docs follow-up: not necessary
  • Changelog is updated
Edited by Антон Фетисов

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading