feat: Improve CLOUD_PARALLEL_GROUP_PARAMS_MISMATCH error message (#24799)

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
This commit is contained in:
Alejandro Estrada
2022-12-12 12:47:57 -05:00
committed by GitHub
parent eb76b57126
commit 7154fc8dcd
6 changed files with 155 additions and 7 deletions

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap" rel="stylesheet">
<style>
body {
font-family: "Courier Prime", Courier, monospace;
padding: 0 1em;
line-height: 1.4;
color: #eee;
background-color: #111;
}
pre {
padding: 0 0;
margin: 0 0;
font-family: "Courier Prime", Courier, monospace;
}
body {
margin: 5px;
padding: 0;
overflow: hidden;
}
pre {
white-space: pre-wrap;
word-break: break-word;
-webkit-font-smoothing: antialiased;
}
</style>
</head>
<body><pre><span style="color:#e05561">You passed the <span style="color:#de73ff">--parallel<span style="color:#e05561"> flag, but we do not parallelize tests across different environments.<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">This machine is sending different environment parameters than the first machine that started this parallel run.<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">The existing run is: <span style="color:#4ec4ff">https://cloud.cypress.io/project/abcd/runs/1<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">In order to run in parallel mode each machine must send identical environment parameters such as:<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> - <span style="color:#e05561"><span style="color:#4ec4ff">specs<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> - <span style="color:#e05561"><span style="color:#4ec4ff">osName<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> - <span style="color:#e05561"><span style="color:#4ec4ff">osVersion<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> - <span style="color:#e05561"><span style="color:#4ec4ff">browserName<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> - <span style="color:#e05561"><span style="color:#4ec4ff">browserVersion (major)<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">This machine sent the following parameters:<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666">{<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;osName&quot;: &quot;darwin&quot;,<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;osVersion&quot;: &quot;v1&quot;,<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;browserName&quot;: &quot;Electron.... (Expected: Electron)&quot;,<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;browserVersion&quot;: &quot;59.1.2.3.... (Expected: 64)&quot;,<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;differentSpecs&quot;: {<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;added&quot;: [<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;cypress/integration/foo_spec.js&quot;<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> ],<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> &quot;missing&quot;: []<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666"> }<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4f5666">}<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">https://on.cypress.io/parallel-group-params-mismatch<span style="color:#e6e6e6"></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
</pre></body></html>

View File

@@ -279,7 +279,37 @@ export const AllCypressErrors = {
https://on.cypress.io/parallel-disallowed`
},
CLOUD_PARALLEL_GROUP_PARAMS_MISMATCH: (arg1: {runUrl: string, parameters: any}) => {
CLOUD_PARALLEL_GROUP_PARAMS_MISMATCH: (arg1: {runUrl: string, parameters: any, payload: any }) => {
let params: any = arg1.parameters
if (arg1.payload?.differentParams) {
params = {}
_.map(arg1.parameters, (value, key) => {
if (key === 'specs' && arg1.payload.differentSpecs?.length) {
const addedSpecs: string[] = []
const missingSpecs: string[] = []
_.forEach(arg1.payload.differentSpecs, (s) => {
if (value.includes(s)) {
addedSpecs.push(s)
} else {
missingSpecs.push(s)
}
})
params['differentSpecs'] = {
added: addedSpecs,
missing: missingSpecs,
}
} else if (arg1.payload.differentParams[key]?.expected) {
params[key] = `${value}.... (Expected: ${(arg1.payload.differentParams[key].expected)})`
} else {
params[key] = value
}
})
}
return errTemplate`\
You passed the ${fmt.flag(`--parallel`)} flag, but we do not parallelize tests across different environments.
@@ -299,7 +329,7 @@ export const AllCypressErrors = {
This machine sent the following parameters:
${fmt.meta(arg1.parameters)}
${fmt.meta(params)}
https://on.cypress.io/parallel-group-params-mismatch`
},

View File

@@ -487,6 +487,40 @@ describe('visual error templates', () => {
'cypress/integration/app_spec.js',
],
},
payload: {},
},
],
differentParams: [
{
group: 'foo',
runUrl: 'https://cloud.cypress.io/project/abcd/runs/1',
ciBuildId: 'test-ciBuildId-123',
parameters: {
osName: 'darwin',
osVersion: 'v1',
browserName: 'Electron',
browserVersion: '59.1.2.3',
specs: [
'cypress/integration/app_spec.js',
'cypress/integration/foo_spec.js',
'cypress/integration/bar_spec.js',
],
},
payload: {
differentParams: {
browserName: {
detected: 'Chrome',
expected: 'Electron',
},
browserVersion: {
detected: '65',
expected: '64',
},
},
differentSpecs: [
'cypress/integration/foo_spec.js',
],
},
},
],
}

View File

@@ -203,11 +203,14 @@ This machine sent the following parameters:
{
"osName": "darwin",
"osVersion": "v1",
"browserName": "Electron",
"browserVersion": "59.1.2.3",
"specs": [
"cypress/e2e/app.cy.js"
]
"browserName": "Electron.... (Expected: Electron)",
"browserVersion": "59.1.2.3.... (Expected: 64)",
"differentSpecs": {
"added": [],
"missing": [
"cypress/integration/foo_spec.js"
]
}
}
https://on.cypress.io/parallel-group-params-mismatch

View File

@@ -466,6 +466,7 @@ const createRun = Promise.method((options = {}) => {
browserVersion,
specs,
},
payload,
})
}
case 'PARALLEL_DISALLOWED':

View File

@@ -1491,6 +1491,19 @@ describe('lib/cypress', () => {
code: 'PARALLEL_GROUP_PARAMS_MISMATCH',
payload: {
runUrl: 'https://cloud.cypress.io/runs/12345',
differentParams: {
browserName: {
detected: 'Chrome',
expected: 'Electron',
},
browserVersion: {
detected: '65',
expected: '64',
},
},
differentSpecs: [
'cypress/integration/foo_spec.js',
],
},
}