尝试从 Jenkins 管道 运行 脚本时获取 SessionNotCreatedError

Getting SessionNotCreatedError when trying to run scripts from Jenkins pipeline

我正在尝试 运行 我在 jenkins 管道上的量角器脚本,并在它尝试访问 Selenium 地址时获取 SessionNotCreatedError。当我 运行 在本地使用相同时,它工作正常。不确定发生了什么。

Conf.js 脚本

let domainName = util.domainName;
exports.config = {
  seleniumAddress: 'http://selenium-hub:4444/wd/hub', //for testing in the pipeline
  directConnect: false, // Set to true for local testing, or provide a link to a running selenium grid.
  // specs: ['e2e/**/mailbox-test.js', 'e2e/**/email-dumps-test.js'],
  specs: ['e2e/**/*-test.js'],
  capabilities: {
    browserName: 'chrome',
    acceptInsecureCerts: true,
    'goog:chromeOptions': {
      w3c: false,
      args: [
        '--no-sandbox',
        '--headless',
        '--disable-gpu',
        '--window-size=1200,1200',
        '--disable-dev-shm-usage',
        '--allow-insecure-localhost',
        '--allow-running-insecure-content',
        '--ignore_ssl',
        '--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
      ],
    },
  },

  allScriptsTimeout: 600000,
  baseUrl: eaUrl,
  framework: 'jasmine',

  jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 600000,
    stackTrace: false
  },

Jenkins 输出错误

[15:32:21] D/launcher - Protractor version: 5.4.2 10:31:59 [15:32:21] D/launcher - Your base url for tests is https://ea-webapp-int-raven.ocp-nonprod.ice.dhs.gov/ 10:31:59 [15:32:21] I/launcher - Running 1 instances of WebDriver 10:31:59 [15:32:21] I/hosted - Using the selenium server at http://selenium-hub:4444/wd/hub 10:37:05 [15:37:21] E/launcher - Could not start a new session. New session request timed out 10:37:05 Build info: version: '4.1.2', revision: '9a5a329c5a' 10:37:05 System info: host: 'eb3088c85a9d', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.53.1.el7.x86_64', java.version: '11.0.13' 10:37:05 Driver info: driver.version: unknown 10:37:05 [15:37:21] E/launcher - SessionNotCreatedError: Could not start a new session. New session request timed out 10:37:05 Build info: version: '4.1.2', revision: '9a5a329c5a' 10:37:05 System info: host: 'eb3088c85a9d', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.53.1.el7.x86_64', java.version: '11.0.13' 10:37:05 Driver info: driver.version: unknown 10:37:05
at Object.throwDecodedError (/app/test/node_modules/selenium-webdriver/lib/error.js:514:15) 10:37:05 at parseHttpResponse (/app/test/node_modules/selenium-webdriver/lib/http.js:519:13) 10:37:05 at doSend.then.response (/app/test/node_modules/selenium-webdriver/lib/http.js:441:30) 10:37:05 at process._tickCallback (internal/process/next_tick.js:68:7) 10:37:05 From: Task: WebDriver.createSession() 10:37:05 at Function.createSession (/app/test/node_modules/selenium-webdriver/lib/webdriver.js:769:24) 10:37:05 at Function.createSession (/app/test/node_modules/selenium-webdriver/chrome.js:761:15) 10:37:05 at createDriver (/app/test/node_modules/selenium-webdriver/index.js:170:33) 10:37:05
at Builder.build (/app/test/node_modules/selenium-webdriver/index.js:626:16) 10:37:05
at Hosted.getNewDriver (/app/test/node_modules/protractor/built/driverProviders/driverProvider.js:53:33) 10:37:05 at Runner.createBrowser (/app/test/node_modules/protractor/built/runner.js:195:43) 10:37:05
at q.then.then (/app/test/node_modules/protractor/built/runner.js:339:29) 10:37:05
at _fulfilled (/app/test/node_modules/q/q.js:834:54) 10:37:05 at /app/test/node_modules/q/q.js:863:30 10:37:05 at Promise.promise.promiseDispatch (/app/test/node_modules/q/q.js:796:13) 10:37:05 [15:37:21] E/launcher - Process exited with error code 199 10:37:05 10:37:05 exitStatus=$? 10:37:05 10:37:05 # Allow the Jenkin pipeline to access and archive any test output. 10:37:05 chmod -R 777 ./test_output/

我正在添加我的观察结果,因为其他人如果遇到类似问题可能会需要,这也可能对他们有所帮助。在使用我的 docker 安装脚本对 Jenkins 中的控制台输出进行了长时间调查之后,我注意到我们正在尝试安装最新版本的 selenium hub 和 chrome 节点,但是 docker命令不包含 SE_EVENT_BUS_HOST 信息。从

更改我的代码后

docker 运行 -d --name selenium-node-chrome -e HUB_HOST=selenium-hub --shm-size="2g" nexus2.xxx.com:18443/selenium/node-chrome

docker 运行 -d --name selenium-node-chrome -e SE_EVENT_BUS_HOST=selenium-hub --shm-size="2g" - e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 nexus2.xxx.com:18443/selenium/node-chrome

然后它开始为我工作。