GithubHelp home page GithubHelp logo

Comments (20)

jmhodges avatar jmhodges commented on June 3, 2024

(The comment about the hostnames are misleading other than the value returned by os.Hostname is not something you can look up. It was a bad hypothesis that failed under checks with dig to verify)

from rules_webtesting.

joshbruning avatar joshbruning commented on June 3, 2024

I recommend investigating replacing os.Hostname fallback with "localhost" fallback in the short term; I can check that that doesn't cause issues with our Linux workstations tomorrow.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Yep, that works!

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Thank you!

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

So, here's something cool. I tried this on a different machine on my network, and the code fails. I made a ticket against the Go repository but I'm not actually sure the Go resolver is behaving incorrectly.

Here's that ticket: golang/go#20904

Does just using localhost work for y'all or is this hostname lookup still needed?

from rules_webtesting.

joshbruning avatar joshbruning commented on June 3, 2024

Using localhost works for us in every environment we currently have (which are all Linux); for most of the history of this code in Google, we just used localhost for these addresses. We used fqdn code in test procedures for referring to the web server, though, as the browser in our VMs needed to reach it. The fqdn logic was added later when needed for another feature.

(We have a disused mac mini that we could probably experiment on...)

Thanks for filing the ticket.

I would assume the Java fqdn method works correctly on your machines?
http://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getCanonicalHostName--

I'm not opposed to an environment variable that forces localhost in the meantime if that unblocks you.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Hm, wasn't sure what you address or hostname for me to use to create the InetAddress. I went with a few different ones and found one that was different. Lmk if you had something else in mind.

import java.net.InetAddress;

public class Foo {
    public static void main(String[] args) throws Exception {
        InetAddress addr = InetAddress.getByAddress(new byte[]{127,0,0,1});
        System.out.println(addr.getCanonicalHostName());

        addr = InetAddress.getByName("localhost");
        System.out.println(addr.getCanonicalHostName());

        addr = InetAddress.getLocalHost();
        System.out.println(addr.getCanonicalHostName());
    }
}

outputs

localhost
localhost
homeportal

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Oh! You meant InetAddress.getByName("iMac"), of course.

That prints out homeportal, too.

from rules_webtesting.

joshbruning avatar joshbruning commented on June 3, 2024

Sorry, forgot that wasn't a static method... Meant InetAddress.getLocalHost().getCanonicalHostName() which should result in "homeportal" per your experimentation. getCanonicalHostName would ideally return the fqdn of your machine... Looks like Go maintainers are following up.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Yeah, if it's happening in both places, maybe it's a platform bug.

btw, I made that patch for that env var but I'm not sure how to pass an env var to the go_web_test_suite target. I'd rather avoid having to put --action_env in my bazelrc and the env var in my bash_profile if I can because it feels a little easy to forget about.

But maybe that's the only option when using an env var?

from rules_webtesting.

joshbruning avatar joshbruning commented on June 3, 2024

You can either:

  1. rename the environment variable to mean the opposite and make localhost use default in project (SERVE_ON_FQDN or some better name)
  2. https://github.com/bazelbuild/rules_webtesting/blob/master/web/internal/web_test.sh.template - check for presence of some SERVE_ON_LOCALHOST-like environment variable; if not present, set to a truthy default.

I probably prefer option 2 just b/c we already branch the shell script template internally.

I think it's OK to use localhost by default for this project and let anyone requiring FQDN (no one yet) to opt-in as the logic is currently causing issues for mac - and I don't believe any of the VM stuff or optional features requiring fqdn for remote browsers are open sourced at this point.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

I don't quite follow option 2's description. Would a different env var be set and looked at in the Go code?

from rules_webtesting.

joshbruning avatar joshbruning commented on June 3, 2024

Recently back from vacation... More details...

in the web_test.sh.template, was thinking:

if [[ -z "$SERVE_ON_LOCALHOST" ]]; then
export SERVE_ON_LOCALHOST=true
fi

Then there is go/launcher/cmdhelper which would allow something like:
if cmdhelper.IsTruthyEnv("SERVE_ON_LOCALHOST") {
return "localhost"
}


Also would be fine with always returning "localhost" for Mac platform for now.

Feel free to make whatever change makes this work for you by default - without having to pass any additional options or customize your blazerc (as long as there is some env var way for us to switch it off). Or feel free to request that I just make a change and I can throw something passable together.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Okay, I've not gotten any closer on this. I don't know why we couldn't use localhost everywhere?

Also, could this be reopened?

from rules_webtesting.

Ubehebe avatar Ubehebe commented on June 3, 2024

I just ran into this issue. A web_test target I'd written suddenly started timing out with no code changes. @jmhodges, thanks for your excellent documentation here and in golang/go#20904.

In my case, I was able to remove the offending name server from my OS's DNS configuration, and the test passed. But I'm strongly in favor of using localhost by default wherever possible. DNS configuration is a complex source of nondeterminism. If users of rules_webtesting want that nondeterminism, IMO it should be opt-in rather than opt-out.

@jmhodges is your fork suitable for merging? I'm reasonably good at SkyStarlark and can help out.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

It's not been updated recently, unfortunately. I didn't do anything other than the minimum required to get FQDN to always return "localhost", though.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Also, you might want to make a new ticket since this one is closed and they don't seem to be commenting on it

from rules_webtesting.

Ubehebe avatar Ubehebe commented on June 3, 2024

@joshbruning would you mind reopening this issue? I could file a new one, but it would refer to most of the discussion here.

In any case, I'll try to send a PR soon.

from rules_webtesting.

jmhodges avatar jmhodges commented on June 3, 2024

Ping

from rules_webtesting.

DrMarcII avatar DrMarcII commented on June 3, 2024

Is this still an issue for you?

from rules_webtesting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.