Folks, thanks for your responses!
Jeremy,
That's a bad idea. Changing systemwide hostname resolution for a
unit test has huge side effects for a disposable use case. Please don't do this.
It would be better to do something like mock gethostbyname() in a unit test mock resolver
.so and use runtime linker hints like LD_PRELOAD to make sure the unit test binary links
to the mock instead of the system resolver.
OK. I sent a PR not to use
mysql2gem.example.com, but to use
localhost. And applied the patch to the rubygem-mysql2 RPM spec file.
But I understand mocking a part of resolving hosting is even better.
https://github.com/brianmario/mysql2/pull/1296
Fabio,
It looks like the upstream tests only use this weird setup because
they use containers?
No, it's not only for the CI cases using containers but also cases
executed on the upstream GitHub Actions Ubuntu or MacOS. The domain is
used in all the cases of the upstream CI.
In the upstream source, the domain "mysql2gem.example.com" is used to
create the spec/ssl/* files, the SSL certification keys.
https://github.com/brianmario/mysql2/blob/bab4969264250abca836e85a9c332c4...
and it is also used in the SSL related unit tests.
https://github.com/brianmario/mysql2/blob/bab4969264250abca836e85a9c332c4...
For running the test suite in the Fedora package, it should be much
easier to patch the test sources to not connect to the
mysql2gem.example.com domain (which requires the /etc/hosts entry,
which you can't do in mock) but to "localhost" or "127.0.0.1"
(which
should always work).
Yeah we applied the patch not to connect to the
mysql2gem.example.com
domain, but to connect to the localhost domain.
Petr,
Another reason not to do it:
example.com. domain is reserved for
documentation purposes. Please do not use in any code or configuration.
OK. I will keep in mind the point.
Frank,
True, though the same RFC 2606 reserves[1] the ".test"
domain for exactly the purpose used here; the only real issue is that they should switch
from
example.com to example.test. (Or, really, ${ANYTHING}.test.)
Thanks for the primary source about how to use the testing domains!
Jun
--
Jun | He - Him | Timezone: UTC+1 or 2, Czech Republic
See <
https://www.worldtimebuddy.com/czech-republic-prague-to-utc> for
the timezone.