生成失败转发新会话时出错设置功能的虚拟机池为空浏览器名称:chrome

时间:2019-06-11 13:03:43

标签: selenium docker jenkins jenkins-pipeline pipeline

因此,我正在使用Jenkins运行测试,Pipeline脚本为我完成了所有工作,但是构建失败,原因是:
WebDriver::debugWebDriverLogs method has been called when webDriver is not set用于每个测试,并且在日志末尾也说:[Facebook\WebDriver\Exception\UnknownServerException] Error forwarding the new session Empty pool of VM for setup Capabilities {browserName: chrome}

我已尝试更改此部分:

就在我拉后: sh 'docker pull selenium/standalone-chrome'

从这里: 'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium'

进入:

'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-palladium'

管道脚本就是这个


    node {
       stage('Pull latest Docker repo') { 
          git credentialsId: 'xxxx',
              url: 'git@bitbucket.org:my/test-app.git'
       }
       stage('Install app') {
          sh 'docker-compose down'
          sh 'docker-compose build --no-cache mysql'
          echo "Will deploy from ${branch}";
          echo "BuildApp Param ${buildapp}";
          if (params.buildapp == true){
            sh 'docker-compose build --no-cache --build-arg BRANCH=${branch} apache'
          }
          sh 'docker-compose up -d'
       }
       stage('Set up Selenium') {
          try {
            sh 'docker rm selenium -f'
          }
          catch(exc) {
            echo 'No selenium container running'
          }
          sh 'docker pull selenium/standalone-chrome'
          sh 'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium'
       }
       stage('Load tests') { 
          dir("../") {}
          git credentialsId: 'xxxx',
              url: 'git@bitbucket.org:mytests.git'
       }
       stage('Run tests') {
          sh 'composer install'
          sh 'vendor/bin/codecept --debug run --steps tests/jenkins'
       }
    }```

    Expected results: for the build to run, as it is running over weekend and on Saturday morning it was OK, passing all the tests, Sunday and Monday morning failing with those errors and since then I am trying to figure out what is happening.

    Here is the output in Jenkins:

    ```Started by user 
    Running in Durability level: MAX_SURVIVABILITY
    [Pipeline] Start of Pipeline
    [Pipeline] node
    Running on Jenkins in /var/lib/jenkins/jobs/Autotest/workspace
    [Pipeline] {
    [Pipeline] stage
    [Pipeline] { (Pull latest Docker repo)
    [Pipeline] git
    using credential xxxx
     > git rev-parse --is-inside-work-tree # timeout=10
    Fetching changes from the remote Git repository
     > git config remote.origin.url git@my/test-app.git
     # timeout=10
    Fetching upstream changes from git@bitbucket.org:my/test-app.git
     > git --version # timeout=10
    using GIT_SSH to set credentials Jenkins Portal Tests Repo
     > git fetch --tags --progress git@bitbucket.org:mydocker.git +refs/heads/*:refs/remotes/origin/*
     > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 20cdc207dc87e736983d6b28b5a81853c7c37f70 (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 20cdc207dc87e736983d6b28b5a81853c7c37f70
     > git branch -a -v --no-abbrev # timeout=10
     > git branch -D master # timeout=10
     > git checkout -b master 20cdc207dc87e736983d6b28b5a81853c7c37f70
    Commit message: "Got rid of the WORKDIR"
     > git rev-list --no-walk 20cdc207dc87e736983d6b28b5a81853c7c37f70 # timeout=10
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Install app)
    [Pipeline] sh
    + docker-compose down
    Stopping workspace_apache_1 ... 
    Stopping workspace_mysql_1  ... 
    [2A[2K
    Stopping workspace_apache_1 ... [32mdone[0m
    [2B[1A[2K
    Stopping workspace_mysql_1  ... [32mdone[0m
    [1BRemoving workspace_apache_1 ... 
    Removing workspace_mysql_1  ... 
    [1A[2K
    Removing workspace_mysql_1  ... [32mdone[0m
    [1B[2A[2K
    Removing workspace_apache_1 ... [32mdone[0m
    [2BRemoving network workspace_frontend
    Removing network workspace_backend
    [Pipeline] sh
    + docker-compose build --no-cache mysql
    Building mysql
    Step 1/2 : FROM mysql:5.7.24
     ---> ba7a93aae2a8
    Step 2/2 : ADD mysql.cnf /etc/mysql/mysql.conf.d/mysql.cnf
     ---> ba3aa48cc1b5
    Successfully built ba3aa48cc1b5
    Successfully tagged workspace_mysql:latest
    [Pipeline] echo
    Will deploy from feature/jenkins-autotests
    [Pipeline] echo
    BuildApp Param false
    [Pipeline] sh
    + docker-compose up -d
    Creating network "workspace_frontend" with the default driver
    Creating network "workspace_backend" with the default driver
    Creating workspace_mysql_1 ... 
    Creating workspace_mysql_1
    [1A[2K
    Creating workspace_mysql_1 ... [32mdone[0m
    [1BCreating workspace_apache_1 ... 
    Creating workspace_apache_1
    [1A[2K
    Creating workspace_apache_1 ... [32mdone[0m
    [1B[Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Set up Selenium)
    [Pipeline] sh
    + docker rm selenium -f
    selenium
    [Pipeline] sh
    + docker pull selenium/standalone-chrome
    Using default tag: latest
    latest: Pulling from selenium/standalone-chrome
    Digest: sha256:e10140556650edfd1000bba6c58053f4c97c0826ef785858ed1afa6f82284e23
    Status: Image is up to date for selenium/standalone-chrome:latest
    [Pipeline] sh
    + docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium
    WARNING: Published ports are discarded when using host network mode
    3f379a0da28bfcf7f7912a05d757b6115773292c1a426199325f75cfae97988d
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Load tests)
    [Pipeline] dir
    Running in /var/lib/jenkins/jobs/Autotest
    [Pipeline] {
    [Pipeline] }
    [Pipeline] // dir
    [Pipeline] git
    using credential xxxx
     > git rev-parse --is-inside-work-tree # timeout=10
    Fetching changes from the remote Git repository
     > git config remote.origin.url git@bitbucket.org:my/test-app.git
    # timeout=10
    Fetching upstream changes from git@bitbucket.org:app/portal-tests.git
     > git --version # timeout=10
    using GIT_SSH to set credentials Jenkins Portal Tests Repo
     > git fetch --tags --progress git@bitbucket.org:app/portal-tests.git +refs/heads/*:refs/remotes/origin/*
     > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 1b4abdc36d9ca1339770d92efc5fad172cca3bc7 (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 1b4abdc36d9ca1339770d92efc5fad172cca3bc7
     > git branch -a -v --no-abbrev # timeout=10
     > git branch -D master # timeout=10
     > git checkout -b master 1b4abdc36d9ca1339770d92efc5fad172cca3bc7
    Commit message: "Commented out the test to not run anymore"
     > git rev-list --no-walk 1b4abdc36d9ca1339770d92efc5fad172cca3bc7 # timeout=10
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Run tests)
    [Pipeline] sh
    + composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Nothing to install or update
    Generating autoload files
    [Pipeline] sh
    + vendor/bin/codecept --debug run --steps tests/jenkins
    Codeception PHP Testing Framework v2.5.2
    Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
    Running with seed: 


    [1mJenkins Tests (48) [22m-----------------------------------------
    Modules: [32mWebDriver, \Helper\Acceptance[39m
    ------------------------------------------------------------
    [35;1mtest1:[39;22m test1
    Signature: [32mtest1[39m
    Test: [32mtests/acceptance/test1.php[39m
    [33mScenario --[39m
    [36m  WebDriver::debugWebDriverLogs method has been called when webDriver is not set[39m
    [36m  WebDriver::_saveScreenshot method has been called when webDriver is not set[39m
    [36m  WebDriver::_savePageSource method has been called when webDriver is not set[39m
    [36m  Screenshot and page source were saved into '/var/lib/jenkins/jobs/Autotest/workspace/tests/_output/' dir[39m
    [31;1m ERROR [39;22m

[37;41;1m Test [39;49;22m tests/acceptance/test1.php
[37;41;1m                                                                                                                                                        [39;49;22m
[37;41;1m  [Facebook\WebDriver\Exception\UnknownServerException] Error forwarding the new session Empty pool of VM for setup Capabilities {browserName: chrome}  [39;49;22m
[37;41;1m                                                                                                                                                        [39;49;22m
#1  /var/lib/jenkins/jobs/Autotest/workspace/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:114
#2  /var/lib/jenkins/jobs/Autotest/workspace/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:326
#3  /var/lib/jenkins/jobs/Autotest/workspace/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126
#4  /var/lib/jenkins/jobs/Autotest/workspace/vendor/symfony/event-dispatcher/EventDispatcher.php:212
#5  /var/lib/jenkins/jobs/Autotest/workspace/vendor/symfony/event-dispatcher/EventDispatcher.php:44```

3 个答案:

答案 0 :(得分:0)

我认为这与这部分有关:

+ docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium
WARNING: Published ports are discarded when using host network mode

但是有趣的是,自上次通过构建以来,我还没有碰过它。

答案 1 :(得分:0)

在上一遍到现在之间,代码接收或其他作曲家软件包是否已更新?

jenkins节点是否每次都在同一起点上?

答案 2 :(得分:0)

我想我已经解决了:

sudo netstat -tulpn | grep :4444 

这是我正在使用的端口,其结果是:

tcp6       0      0 120.0.1.1:4444          :::*                    LISTEN      1739/java

我这样做是为了杀死进程

sudo kill 1739

现在测试再次运行。

谢谢您的帮助。