本文介绍了在TeamCity上进行并行赛普拉斯测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前有一个包含24个 integration / *。js 文件的存储库。我们已经通过TeamCity CI工作流程成功运行了赛普拉斯测试,但是,我无法使这些测试并行运行。

We currently have a repo containing 24 integration/*.js files. We are successfully running Cypress tests via our TeamCity CI workflow, however, I am unable to get the tests to run in parallel.

通过配置方式,我们可以在dashboard.cypress.io中将回购/测试连接到组织。连同仪表板键一起,我们通过 npm run 在我们的 package.json scripts {}

By way of configuration, we have the repo/tests wired up to an org in dashboard.cypress.io. Along with the dashboard key, we are calling Cypress in a TeamCity build step via npm run with the following configs in our package.json scripts{} :

"cypress:run:qa": "cypress run -c cypress.qa.json --record --key xyxyxyx-xyxyx-xyxyx-xyxyx-xyxyxyxyxyxy --parallel --config baseUrl=\"https://some.url.com\" --ci-build-id=%BUILD_ID_CYPRESS%"

正在传递%BUILD_ID_CYPRESS%环境变量以上是TeamCity版本ID和编号的自定义组合,以使其具有唯一性。

The %BUILD_ID_CYPRESS% environment var being passed in above is a custom combination of the TeamCity build ID and number, to make it unique.

package.json 列出了以下依赖项:

"devDependencies": {
    "cypress": "^3.3.2",
    "cypress-plugin-retries": "^1.2.0"
  },
  "dependencies": {
    "ldclient-electron": "^1.0.1",
    "ldclient-js": "^2.10.0",
    "ldclient-node": "^5.7.4"
  }

cypress.qa.json 配置文件的内容为:

{
  "projectId": "*redacted*",
  "baseUrl": "https://some.url.com",
  "numTestsKeptInMemory": 50,
  "port": 3002,
  "reporter": "teamcity",
  "reporterOptions": null,
  "watchForFileChanges": true,
  "viewportWidth": 1280,
  "viewportHeight": 720,
  "defaultCommandTimeout": 30000,
  "execTimeout": 90000,
  "taskTimeout": 90000,
  "pageLoadTimeout": 60000,
  "requestTimeout": 60000,
  "responseTimeout": 60000,
  "screenshotsFolder": "cypress/screenshots",
  "trashAssetsBeforeRuns": true,
  "videoCompression": 32,
  "videosFolder": "cypress/videos",
  "video": true,
  "videoUploadOnPasses": false,
  "env": {
    "retryAttempts": "2",
    "*redacted URL Name*": "https://some.otherURL.com/someSubDirectory/"

  }

  }

在TeamCity中,我在构建日志中看到以下输出,这似乎表明赛普拉斯正在正确传递并行配置:

In TeamCity, I see the following output in the build log, which seems to indicate that the Cypress is passing along the parallel configs correctly:

[15:48:08]  [Step 8/11] ================================================================================
[15:48:08]  [Step 8/11] 
[15:48:08]  [Step 8/11]   (Run Starting)
[15:48:08]  [Step 8/11] 
[15:48:09]  [Step 8/11]   â"Œâ"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"�
[15:48:09]  [Step 8/11]   â"‚ Cypress:  3.4.0                                                            â"‚
[15:48:09]  [Step 8/11]   â"‚ Browser:  Electron 61 (headless)                                           â"‚
[15:48:09]  [Step 8/11]   â"‚ Specs:    24 found (**spec names redacted*** â"‚
[15:48:09]  [Step 8/11]   â"‚ Params:   Group: false, Parallel: true                                     â"‚
[15:48:09]  [Step 8/11]   â"‚ Run URL:  https://dashboard.cypress.io/#/projects/*redactedProjID*/runs/26           â"‚
[15:48:09]  [Step 8/11]   â""â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"˜
[15:48:09]  [Step 8/11] 
[15:48:09]  [Step 8/11] 2019-07-23T15:48:10.502Z cypress:server:record before spec run { spec: undefined }
[15:48:09]  [Step 8/11] 2019-07-23T15:48:10.503Z cypress:server:api request to url: POST https://api.cypress.io/runs/*redactedGUID*/instances with params: {"body":{"spec":null,"groupId":"win32-Electron-61-abcabcabc","machineId":"**RedactedMachineID","platform":{"osCpus":[{"model":"Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz","speed":2400,"times":{"user":*redacted*,"nice":0,"sys":*redacted*,"idle":*redacted*,"irq":*redacted*}},{"model":"Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz","speed":2400,"times":{"user":*redacted*,"nice":0,"sys":*redacted*,"idle":8866723484,"irq":517593}}],"osName":"win32","osMemory":{"free":956882944,"total":4294557696},"osVersion":"6.3.9600","browserName":"Electron","browserVersion":"61.0.3163.100"}},"headers":{"x-route-version":"5","x-os-name":"win32","x-cypress-version":"3.4.0"}} and token: undefined
[15:48:09]  [Step 8/11] 2019-07-23T15:48:10.624Z cypress:server:api response { spec: 'cypress\\integration\\*redacted*.js', instanceId: '*redactedGUID*', claimedInstances: 1, totalInstances: 24, estimatedWallClockDuration: 675698 }

但是,相同的 machineId ,所有这些测试均在同一TeamCity代理上依次运行。

However, the same machineId is repeated through the log output of each subsequent test run, all of which run serially on the same TeamCity agent.

我们对Cypress中的测试分组并没有做任何花哨的事情,也没有看到其他特别独特的东西,但是Cypress的运行继续按顺序执行。

We are not doing anything fancy with test grouping in Cypress, nor anything else particularly unique, that I can see, but the Cypress runs continue to execute serially.

我特别担心其中之一:


  • TeamCity配置I丢失了(我找不到关于TeamCity / Cypress集成的TeamCity或Cypress方面的特定文档)

  • 我的Cypress配置中明显有遗漏,希望有些陌生人可以喊出来。

推荐答案

我不确定您的方法。但是还有其他选择。

I am not sure of your approach. But there are few other options.

一种方法是在TC上使用docker-compose运行测试。这是一个示例项目。该脚本将为您的项目创建一个docker映像并运行该映像的多个实例。

One way is to run tests using docker-compose on TC. Here is an example project. This script will create a docker image for your project and run multiple instances of your image.

我已经花了很长时间了。赛普拉斯github动作似乎是在您想要的任何模式下运行测试的最佳选择。

I have been spiking on this for a while. Cypress github actions seems to be the best choice to run tests in any mode you want.

我建议采用github action方法。您可以节省大量时间。

I would recommend to take github actions approach. You can save tons of time.

这篇关于在TeamCity上进行并行赛普拉斯测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 13:25