browsertime icon indicating copy to clipboard operation
browsertime copied to clipboard

Provide an option so that we don't need to run sudo commands

Open julienw opened this issue 3 years ago • 11 comments

Feature/improvement

When running browsertime on Linux, commands are run using sudo. It's a bit surprising and not really nice. It would be good to:

  • explain what is executed using sudo in the console
  • have a possibility to skip these commands at all

julienw avatar Mar 31 '22 14:03 julienw

Hi @julienw can you show me how you run? You should be able to run without sudo but if you set connectivity using connectivity engine throttle, you need sudo rights to be able change network interface. That log message "Changing network interfaces needs sudo rights. Setting connectivity profile .." could be tuned though, do you have an idea how we can make that better?

soulgalore avatar Mar 31 '22 19:03 soulgalore

I cloned the browsertime repository, ran npm ci on it, and then simply use this command:

$ bin/browsertime.js -b firefox --firefox.binaryPath /home/julien/firefox-nightly/firefox https://profiler.firefox.com
[2022-04-01 14:38:46] INFO: Running tests using Firefox - 3 iteration(s)
[sudo] Mot de passe de julien : 

I also tried with --skipHar as I thought this could be related but this brought the same result.

This happens also with chrome:

$ bin/browsertime.js https://profiler.firefox.com
[2022-04-01 14:40:03] INFO: Running tests using Chrome - 3 iteration(s)
[sudo] Mot de passe de julien : 

So I'm not sure this is related to the connectivity engine throttle... The message you mention looks good enough to me.

julienw avatar Apr 01 '22 12:04 julienw

Ok, hmm, that shouldn't be a thing. Do you have other NodeJS projects installed that works fine? I'll have a try later this weekend.

soulgalore avatar Apr 01 '22 14:04 soulgalore

Yeah usually I have no problem running nodejs scripts :) I'm on a Debian Linux in case this helps, node v16.13.

julienw avatar Apr 01 '22 15:04 julienw

I finally ran it (by mistake: I ran sudo before and forgot :) ) and so got the executed programs in my system logs:

Apr  1 17:25:19 torri sudo:   julien : TTY=pts/5 ; PWD=/home/julien/travail/git/browsertime ; USER=root ; COMMAND=/usr/bin/systemd-resolve --flush-caches
Apr  1 17:25:19 torri sudo:   julien : TTY=pts/5 ; PWD=/home/julien/travail/git/browsertime ; USER=root ; COMMAND=/usr/sbin/service dnsmasq restart

julienw avatar Apr 01 '22 15:04 julienw

Then this is this code: https://github.com/sitespeedio/browsertime/blob/d55019ab041ad818295c8d940561217099e18ccc/lib/support/dns.js#L27-L38

julienw avatar Apr 01 '22 15:04 julienw

Argh I see, that is my fault. I pushed that some time ago and it would make more sense to only do that when you run throttle, let me fix that to the next release.

soulgalore avatar Apr 01 '22 18:04 soulgalore

This is fixed now, thanks @julienw for creating the bug!

soulgalore avatar Apr 06 '22 06:04 soulgalore

Thanks for the quick fix! Should we close the issue then?

julienw avatar Apr 06 '22 09:04 julienw

Yes wanted you to verify that it worked for you first :)

soulgalore avatar Apr 06 '22 10:04 soulgalore

Yep, it's all good now!

julienw avatar Apr 06 '22 11:04 julienw