首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker -异步回调中的量角器测试没有在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超时内调用。

Docker -异步回调中的量角器测试没有在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超时内调用。
EN

Stack Overflow用户
提问于 2017-06-23 10:34:11
回答 1查看 659关注 0票数 1

我编写了6个e2e测试,使用量角器作为我的Angular2应用程序。这些测试在我的windows 10系统上运行良好。测试是一致的,并且一直都是通过的。

现在,我正试图在CentOS坞容器中运行相同的测试。测试结果不一致。他们一直在失败。

我说错了

超时-异步回调在jasmine.DEFAULT_TIMEOUT_INTERVAL.指定的超时内没有被调用。

我增加了外出时间,我给了browser.wait(直到需要的位置),我增加了分配给docker的计算资源( CPU-3,内存-3328 of )。似乎什么都没起作用。

代码语言:javascript
运行
复制
 // Protractor configuration file, see link for more information  

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      'args': [ '--no-sandbox']
    }

  },
  directConnect: false,
  baseUrl: 'http://localhost:3200/',
  framework: 'jasmine2',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {
      // NOOP
    }
  },
  beforeLaunch: function() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
  },
  onPrepare() {
    browser.driver.manage().window().maximize();
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

其中一个测试

代码语言:javascript
运行
复制
// create a user and he should be able to login after creation
  it('should add a new user and log him in successfully', () => {
    browser.wait(until.presenceOf(userCreate.forename, 5000, 'Timed out'));
    const forename = 'newUserFore' + generateRandom.generateRandom();
    const surename = 'newUserSur' + generateRandom.generateRandom();
    const username = 'newUserUser2' + generateRandom.generateRandom();
    const password = 'Pass@123' + generateRandom.generateRandom();

    userCreate.addUserWithPassword(forename, surename, username, password);
    // select language
    userCreate.selectDropdownByNumber(userCreate.mylang, 1);
    // select role
    userCreate.selectDropdownByNumber(userCreate.myrole, 1);
    // click add
    userCreate.addUserButton.click();
    browser.wait(until.presenceOf(userCreate.successMessage, 5000, 'Timed out'));
    expect(userCreate.successMessage.getText()).toContain('User saved successfully!');
    // cancelbutton
    userCreate.cancelbutton.click();
    browser.wait(until.presenceOf(userOverview.addUserButton, 5000, 'Timed out'));
    // logout
    indexPage = homePage.menu.navigateTo(MenuOption.LOGOUT, until);
    // click on login button on first page
    loginPage = indexPage.loginButtonClickedOnBasePage();
    // login with the credentials
    browser.wait(until.presenceOf(loginPage.loginTitle, 5000, 'Timed out'));
    loginPage.login(username, password);
    browser.wait(until.presenceOf(menu, 5000, 'Timed out'));
    expect(menu.isDisplayed()).toBe(true);
  });

函数测试文件,首先启动服务器,然后运行ui。

代码语言:javascript
运行
复制
     #!/usr/bin/env bash
    echo  "API: Ensuring the port $API_SERVER_PORT is freed."
    fuser -k -n tcp $API_SERVER_PORT


    echo " Starting the server in detached mode. This will take about 5 minutes the first time  "
    cd ../api && mvn spring-boot:run  -D server.port=$API_SERVER_PORT >> api-start.log 2>&1 &

    # Wait for the server to come up..
    while ! (ncat -w 1 127.0.0.1 $API_SERVER_PORT </dev/null >/dev/null 2>&1); do sleep 1; done
    echo "Server started on port $API_SERVER_PORT"


    echo "UI: Ensuring the port $UI_SERVER_PORT is freed."
    fuser -k -n tcp $UI_SERVER_PORT

    npm start >> ui-start.log 2>&1 &

    while ! (ncat -w 1 127.0.0.1 $UI_SERVER_PORT </dev/null >/dev/null 2>&1); do sleep 1; done
    echo "Angular app is running on port $UI_SERVER_PORT , startup logs is in start.log".

    protractor container.protractor.conf.js
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-13 17:11:59

您是否尝试过将主机的/dev/shm安装到容器中?

https://github.com/SeleniumHQ/docker-selenium#running-the-images

这显然是一个众所周知的解决办法,以防止selenium与Chrome或Firefox在Docker中崩溃。selenium崩溃并不是立即显现出来的,它只是通过茉莉超时来表达。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44719296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档