0

I am trying to run webdriver update from jenkins. I am downloading geckoDriver and chromeDriver. Chrome driver is downloading and unzipping properly. But gecko driver download is not working. However this is working fine from local. Issue occurs only in jenkins

Command used:

node_modules/protractor/bin/webdriver-manager update --ignore_ssl --proxy=http://proxy --versions.gecko=v0.25.0 --versions.chrome=78.0.3904.105

Firefox version in server: 60.9.0

Error:

[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:13] I/config_source - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml 'http://proxy...' -H 'host:chromedriver.storage.googleapis.com'
[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:13] I/config_source - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json 'http://proxy.../repos/mozilla/geckodriver/releases' -H 'host:api.github.com'
[16:23:13] I/http_utils - ignoring SSL certificate
[16:23:14] I/downloader - curl -ok /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip 'http://proxy.../78.0.3904.70/chromedriver_linux64.zip' -H 'host:chromedriver.storage.googleapis.com'
[16:23:14] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[16:23:14] I/update - chromedriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[16:23:16] I/http_utils - ignoring SSL certificate
[16:23:17] E/downloader - tunneling socket could not be established, statusCode=403
[16:23:17] I/update - geckodriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0.tar.gz
[16:23:17] I/update - geckodriver: unzipping geckodriver-v0.25.0.tar.gz
(node:42561) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename '/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver' -> '/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0'
    at Object.renameSync (fs.js:598:3)
    at unzip (/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js:240:8)
    at files_1.FileManager.downloadFile.then.downloaded (/var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js:205:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:42561) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:42561) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When i manually downloaded the driver files and added inside node_modules/selenium location, webdriver-manager update is successful. But the tunneling socket error was still present. Logs below:

[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/http_utils - ignoring SSL certificate
[16:30:00] I/update - chromedriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip
[16:30:00] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[16:30:00] I/update - chromedriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[16:30:00] I/update - chromedriver: chromedriver_78.0.3904.105 up to date
[16:30:02] E/downloader - tunneling socket could not be established, statusCode=403
[16:30:02] I/update - geckodriver: file exists /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0.tar.gz
[16:30:02] I/update - geckodriver: unzipping geckodriver-v0.25.0.tar.gz
[16:30:02] I/update - geckodriver: setting permissions to 0755 for /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0
[16:30:02] I/update - geckodriver: geckodriver-v0.25.0 up to date

But ng e2e is failing with the below error:

[16:30:03] I/launcher - Running 1 instances of WebDriver

[16:30:03] I/direct - Using FirefoxDriver directly...
[16:30:03] E/launcher - spawn /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0 EACCES
[16:30:03] E/launcher - Error: spawn /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0 EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
[16:30:03] E/launcher - Process exited with error code 199
npm ERR! code ELIFECYCLE
npm ERR! errno 1

I am using directconnect=true in protractor conf.js

Can someone please check what i am doing wrong here?

Buvi
  • 21
  • 1
  • 8
  • Why are you ignoring the SSL certificate? – Sankalan Parajuli Dec 30 '19 at 11:16
  • @SankalanParajuli I had this added when i was getting proxy issue. Even without --ignore_ssl, this is failing – Buvi Dec 30 '19 at 11:41
  • You are unable to access the gekkodriver package you have specified with a permission error. That means the web socket that you are connecting to as a jenkins user does not have the permission to get that file over the network. Can you ssh into the jenkins container and then see if you can curl the URL from there? – Sankalan Parajuli Dec 30 '19 at 11:59
  • Yes @SankalanParajuli. I am able to curl the url and download the file directly from jenkins ssh. – Buvi Dec 30 '19 at 12:18
  • But i have temporarily bypassed that issue by manually downloading and copying the file in my jenkins server location. The actual issue is that my e2e is not getting run. I tried the below combinations 1. directConnect=true and geckoDriver="node_modules gecko driver location" with webdriverUpdate=false in ng e2e command 2. directConnect=false with webdriverUpdate=true in ng e2e command – Buvi Dec 30 '19 at 12:19
  • Proxies are hard. I'm not 100% sure if that feature worked. I would look at https://stackoverflow.com/questions/42911197/webdriver-manager-update-config-json-absolute-paths/42964134#42964134 about update-config.json. You can fake in the update-config.json file and get protractor to find the gecko driver binary. – cnishina Feb 07 '20 at 05:55

2 Answers2

1

There are a few things that you can try here:

1) If your tests are running inside a container, you will have to disable the dev-shm usage by adding a "--disable-dev-shm-usage" flag in your capabilities. Or you can mount the dev/shm as a volume when you run your tests.

2) You can set Marionette to true in your browser capabilities for firefox.

3) Run the container as root so that it runs as a privilaged user

4) Run the tests using ./node_modules/protractor/bin/protractor protractor.conf.js instead of using ng e2e

5) Update the webdriver packages using ./node_modules/protractor/bin/webdriver-manager update --ignore_ssl --proxy=http://proxy --versions.gecko=v0.25.0 --versions.chrome=78.0.3904.105

6) Try adding these lines to your entrypoint for the docker image:

#!/bin/bash
uid=$(stat -c %u ${PWD})
gid=$(stat -c %g ${PWD})

groupadd -o -g $gid protractor
useradd -m -o -u $uid -g $gid protractor

sudo -u protractor npm run test

Still I cannot say if one of these steps would solve your problem.

  • Thanks @Sankalan. I tried options 2,3 and 5. It is not working. Could you please tell me the usage of "--disable-dev-shm-usage"? The point is that everything is working fine in local. The issue is happening only in Jenkins server – Buvi Dec 31 '19 at 03:03
  • I tried option 4 as well. Running testing with either ng e2e or protractor.conf.js is working fine in local. But dev has the same issue. – Buvi Dec 31 '19 at 03:19
  • Usually there is an in memory file system virtually created which makes things fast. This can also cause unknown issues with docker so disabling it removes some of the problems. To use it, you will have to mount it as a volume when you run your docker container. – Sankalan Parajuli Dec 31 '19 at 04:11
  • Oh I think the issue is that you haven't given execute permissions to the gekko driver file you manually installed for the jenkins user. Try giving execute permission to the Jenkins user? – Sankalan Parajuli Dec 31 '19 at 04:13
  • Also see if you can get it to work by changing the firefox version. There is some incompatibility with some of the versions of gekko driver. – Sankalan Parajuli Dec 31 '19 at 04:18
  • No the gecko driver which is copied has all permissions (owner, group and public) all read, write and execute permissions – Buvi Dec 31 '19 at 04:20
  • Firefox version installed in Jenkins is 60.9.0 and the gecko driver versions i tried are v0.25.0 and v0.26.0 – Buvi Dec 31 '19 at 04:21
  • Damn Buvi I am so out of ideas right now. Will need to look into the problem personally to be able to advice any further. Sorry – Sankalan Parajuli Dec 31 '19 at 04:31
  • I have edited my comment, I want you to try one more thing. Let me know if that works. – Sankalan Parajuli Dec 31 '19 at 05:00
  • Thanks Sankalan. But i am not generating a docker image. I am building the project and deploying the build folder inside running tomcat server -> webapps folder. – Buvi Dec 31 '19 at 05:27
0

I had same problem when I was doing this in a docker container. The 'tar' and 'gzip' packages weren't installed. The problem got resolved after I installed these packages.

Rahul
  • 963
  • 9
  • 14