Skip to content

Commit 5b46416

Browse files
[test optimization] Fix attempt to fix logic in playwright (#7325)
1 parent 6b0ccd2 commit 5b46416

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

integration-tests/playwright/playwright.spec.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,12 @@ versions.forEach((version) => {
13141314
test => test.meta[TEST_NAME].startsWith('attempt to fix should attempt to fix')
13151315
)
13161316

1317-
if (isDisabled) {
1317+
if (isDisabled && !isAttemptingToFix) {
13181318
assert.strictEqual(attemptedToFixTests.length, 2)
13191319
assert.ok(attemptedToFixTests.every(test =>
13201320
test.meta[TEST_MANAGEMENT_IS_DISABLED] === 'true'
13211321
))
1322-
// if the test is disabled, there will be no retries
1322+
// if the test is disabled and not attempting to fix, there will be no retries
13231323
return
13241324
}
13251325

@@ -1329,6 +1329,20 @@ versions.forEach((version) => {
13291329
assert.strictEqual(attemptedToFixTests.length, 2)
13301330
}
13311331

1332+
if (isDisabled) {
1333+
const numDisabledTests = attemptedToFixTests.filter(test =>
1334+
test.meta[TEST_MANAGEMENT_IS_DISABLED] === 'true'
1335+
).length
1336+
// disabled tests with attemptToFix still run and are retried
1337+
assert.strictEqual(numDisabledTests, 2 * (ATTEMPT_TO_FIX_NUM_RETRIES + 1))
1338+
// disabled tests with attemptToFix should not be skipped - they should run with pass/fail status
1339+
const skippedDisabledTests = attemptedToFixTests.filter(test =>
1340+
test.meta[TEST_MANAGEMENT_IS_DISABLED] === 'true' &&
1341+
test.meta[TEST_STATUS] === 'skip'
1342+
).length
1343+
assert.strictEqual(skippedDisabledTests, 0, 'disabled tests with attemptToFix should not be skipped')
1344+
}
1345+
13321346
if (isQuarantined) {
13331347
const numQuarantinedTests = attemptedToFixTests.filter(test =>
13341348
test.meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true'

packages/datadog-instrumentations/src/playwright.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,11 @@ function dispatcherRunWrapper (run) {
484484

485485
function dispatcherRunWrapperNew (run) {
486486
return function (testGroups) {
487-
// Filter out disabled tests from testGroups before they get scheduled
487+
// Filter out disabled tests from testGroups before they get scheduled,
488+
// unless they have attemptToFix (in which case they should still run and be retried)
488489
if (isTestManagementTestsEnabled) {
489490
testGroups.forEach(group => {
490-
group.tests = group.tests.filter(test => !test._ddIsDisabled)
491+
group.tests = group.tests.filter(test => !test._ddIsDisabled || test._ddIsAttemptToFix)
491492
})
492493
// Remove empty groups
493494
testGroups = testGroups.filter(group => group.tests.length > 0)
@@ -911,14 +912,16 @@ addHook({
911912
const fileSuitesWithManagedTestsToProjects = new Map()
912913
for (const test of allTests) {
913914
const testProperties = getTestProperties(test)
914-
// Disabled tests are skipped and not retried
915+
// Disabled tests are skipped unless they have attemptToFix
915916
if (testProperties.disabled) {
916917
test._ddIsDisabled = true
917-
test.expectedStatus = 'skipped'
918-
// setting test.expectedStatus to 'skipped' does not work for every case,
919-
// so we need to filter out disabled tests in dispatcherRunWrapperNew,
920-
// so they don't get to the workers
921-
continue
918+
if (!testProperties.attemptToFix) {
919+
test.expectedStatus = 'skipped'
920+
// setting test.expectedStatus to 'skipped' does not work for every case,
921+
// so we need to filter out disabled tests in dispatcherRunWrapperNew,
922+
// so they don't get to the workers
923+
continue
924+
}
922925
}
923926
if (testProperties.quarantined) {
924927
test._ddIsQuarantined = true
@@ -947,6 +950,7 @@ addHook({
947950
(test) => test._ddIsAttemptToFix,
948951
[
949952
(test) => test._ddIsQuarantined && '_ddIsQuarantined',
953+
(test) => test._ddIsDisabled && '_ddIsDisabled',
950954
'_ddIsAttemptToFix',
951955
'_ddIsAttemptToFixRetry'
952956
],

0 commit comments

Comments
 (0)