TeamCity上的并行赛普拉斯测试

问题描述 投票:0回答:1

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

通过配置方式,我们将回购/测试连接到dashboard.cypress.io中的组织。与仪表板键一起,我们在TeamCity构建步骤中通过npm run调用Cypress,并在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和编号的自定义组合,以使其唯一。

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中,我在构建日志中看到以下输出,这似乎表明赛普拉斯正在正确传递并行配置:

[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代理上串行运行。

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

我特别担心其中之一:

  • 我缺少的TeamCity配置(我找不到关于TeamCity / Cypress集成的TeamCity或Cypress方面的特定文档)
  • 我上面的赛普拉斯配置中有一个明显的遗漏,希望有某种陌生人可以指出。
continuous-integration teamcity integration-testing cypress
1个回答
0
投票

我不确定您的方法。但是其他选项很少。

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

https://github.com/SgSridhar/cypress-docker-parallel-tests/blob/master/package.json#L25

我已经对此加阵了一段时间。赛普拉斯github动作似乎是以您想要的任何模式运行测试的最佳选择。

https://github.com/SgSridhar/cypress-docker-parallel-tests/commit/d49db3edfe1ee59bc42d990c708152d98350f411/checks?check_suite_id=375441436

我建议采取github行动方法。您可以节省大量时间。

© www.soinside.com 2019 - 2024. All rights reserved.