Is there a way to set a /etc/hosts setting below or an equivalent one in a RPM spec file? The rubygem-mysq2 RPM package's unit test needs the setting to run SSL tests in the %check process of the rubygem-mysql2.spec file.
``` $ cat /etc/hosts ... 127.0.0.1 mysql2gem.example.com ```
As a reference, here are the upstream mysql2 project's settings. https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2... https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2...
Related PR on Fedora: https://src.fedoraproject.org/rpms/rubygem-mysql2/pull-request/14
Thanks for your help!
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.
On Thu, Dec 22, 2022 at 10:52 AM Jun Aruga (he / him) jaruga@redhat.com wrote:
Is there a way to set a /etc/hosts setting below or an equivalent one in a RPM spec file? The rubygem-mysq2 RPM package's unit test needs the setting to run SSL tests in the %check process of the rubygem-mysql2.spec file.
$ cat /etc/hosts ... 127.0.0.1 mysql2gem.example.com
As a reference, here are the upstream mysql2 project's settings.
https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2...
https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2...
Related PR on Fedora: https://src.fedoraproject.org/rpms/rubygem-mysql2/pull-request/14
Thanks for your help!
-- Jun | He - Him | Timezone: UTC+1 or 2, Czech Republic See https://www.worldtimebuddy.com/czech-republic-prague-to-utc for the timezone. _______________________________________________ packaging mailing list -- packaging@lists.fedoraproject.org To unsubscribe send an email to packaging-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.... Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
Yeah. If I ran "rpmbuild --rebuild package.src.rpm" and discovered it was running sudo commands to muck with /etc/hosts on my local environment, I'd get pretty upset.
On Mon, Dec 26, 2022 at 12:34 PM Jeremy McMillan jeremy.mcmillan@gmail.com wrote:
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.
On Thu, Dec 22, 2022 at 10:52 AM Jun Aruga (he / him) jaruga@redhat.com wrote:
Is there a way to set a /etc/hosts setting below or an equivalent one in a RPM spec file? The rubygem-mysq2 RPM package's unit test needs the setting to run SSL tests in the %check process of the rubygem-mysql2.spec file.
$ cat /etc/hosts ... 127.0.0.1 mysql2gem.example.com
As a reference, here are the upstream mysql2 project's settings. https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2... https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2...
Related PR on Fedora: https://src.fedoraproject.org/rpms/rubygem-mysql2/pull-request/14
Thanks for your help!
-- Jun | He - Him | Timezone: UTC+1 or 2, Czech Republic See https://www.worldtimebuddy.com/czech-republic-prague-to-utc for the timezone. _______________________________________________ packaging mailing list -- packaging@lists.fedoraproject.org To unsubscribe send an email to packaging-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.... Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
packaging mailing list -- packaging@lists.fedoraproject.org To unsubscribe send an email to packaging-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.... Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
On Thu, Dec 22, 2022 at 5:52 PM Jun Aruga (he / him) jaruga@redhat.com wrote:
Is there a way to set a /etc/hosts setting below or an equivalent one in a RPM spec file? The rubygem-mysq2 RPM package's unit test needs the setting to run SSL tests in the %check process of the rubygem-mysql2.spec file.
$ cat /etc/hosts ... 127.0.0.1 mysql2gem.example.com
As a reference, here are the upstream mysql2 project's settings. https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2... https://github.com/brianmario/mysql2/blob/7f6f33a6e0bd652d5e7087edb6e5d00df2...
Related PR on Fedora: https://src.fedoraproject.org/rpms/rubygem-mysql2/pull-request/14
It looks like the upstream tests only use this weird setup because they use containers?
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).
Fabio
V Thu, Dec 22, 2022 at 05:51:50PM +0100, Jun Aruga (he / him) napsal(a):
Is there a way to set a /etc/hosts setting below or an equivalent one in a RPM spec file? The rubygem-mysq2 RPM package's unit test needs the setting to run SSL tests in the %check process of the rubygem-mysql2.spec file.
$ cat /etc/hosts ... 127.0.0.1 mysql2gem.example.com
Another reason not to do it: example.com. domain is reserved for documentation purposes. Please do not use in any code or configuration.
-- Petr
V Thu, Dec 22, 2022 at 05:51:50PM +0100, Jun Aruga (he / him) napsal(a):
Another reason not to do it: example.com. domain is reserved for documentation purposes. Please do not use in any code or configuration.
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.)
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/bab4969264250abca836e85a9c332c42be... and it is also used in the SSL related unit tests. https://github.com/brianmario/mysql2/blob/bab4969264250abca836e85a9c332c42be...
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
packaging@lists.fedoraproject.org