benonymus
:inet.gethostbyname(Kernel.to_charlist(parsed.host)) url checking seems to be failing ?randomly? in tests
Hey I am using
:inet.gethostbyname(Kernel.to_charlist(parsed.host))
as part of my checking for valid urls, and it seems to be failing randomly in some tests, sometimes all the tests pass, sometimes 1-2 fail and the error is coming from here.
I am using google.com as the url, but i tried with other ones and it tends to happen with most.
To be even more exact the tests fail because the fixtures can’t be inserted while in the other 250+ cases it can
Any thoughts why can this happen?
Marked As Solved
NobbZ
Then for some reason DNS was unable to resolve the hostname. This is not related to the BEAM, but to the upstream DNS server.
Also Liked
NobbZ
What do you mean by “fail”? If by failing you mean the returned value does not match {:ok, _}, please tell us what it is instead. It might help to resolve the issue.
dimitarvp
Sure, agreed. I didn’t address most of my comment towards you, sorry. Just now noticed I pressed the wrong button. ![]()
I was just pointing out that the OP is trying to solve the wrong problem, in my opinion.
benonymus
hey, thanks for all the responses, i did not know that i can or should adjust the behavior of my validation in case it is being run in test env.
if that is the case, how would one go about that? I am using it in a changeset function to validate url input from users.
On the same note, if I am not running it in test mode, how do i know for sure that it works in a way that i’d expect?
Also what i am most surprised by, is that it runs perfectly most of the time like 99.8%. My other idea was that it might have to do with not having the most stellar internet, since it only seems to happen when I am running the tests locally, in the deployment pipeline it hasn’t failed yet
. As for changing my dns, I am using that dns on router level, and I haven’t seen the tests fail since.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









