Skip to content

[test-optimization] [SDTEST-1821] Implement impacted tests detection #5543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
086cce5
Add Jest logic for Impacted Tests
Mariovido Apr 7, 2025
9cc1da3
Add logic to get modified tests
Mariovido Apr 7, 2025
02d9c9e
Fix wrong import and possible bug with null value
Mariovido Apr 7, 2025
2816685
Add tests for jest
Mariovido Apr 7, 2025
07ac906
Add more tests to jest
Mariovido Apr 8, 2025
d8d9c63
Add more coverage
Mariovido Apr 8, 2025
0058505
Merge branch 'master' into mario.vidal/impacted_tests
Mariovido Apr 10, 2025
38039c6
Update retry reason of impact test jest
Mariovido Apr 10, 2025
f1bb7b8
Fix isNew tagging
Mariovido Apr 14, 2025
d35ba5c
Add env var to disable backend request + capabilities tagging
Mariovido Apr 14, 2025
bb0b54c
Fix ci-visibility-exporter test
Mariovido Apr 14, 2025
0d30cea
Add support for mocha
Mariovido Apr 14, 2025
2638ea5
Add support for cucumber
Mariovido Apr 15, 2025
2435f9e
Modify tests
Mariovido Apr 15, 2025
f8d5d57
Fix testPath in mocha
Mariovido Apr 15, 2025
ff0d3e9
Add support for Cypress
Mariovido Apr 15, 2025
ce58841
Fix incompability with cypress older versions
Mariovido Apr 15, 2025
0b2daa1
Remove backend call + changes to tests
Mariovido Apr 24, 2025
e28870b
Merge branch 'master' into mario.vidal/impacted_tests
Mariovido Apr 24, 2025
037c5f5
Add support without granularity for Playwright
Mariovido Apr 24, 2025
3526816
Change mocha parameter
Mariovido Apr 24, 2025
bbdc98f
Fix EFD tests
Mariovido Apr 24, 2025
5ab1ee4
Add support without granularity for Vitest
Mariovido Apr 24, 2025
7e99d0c
Add capabilities tagging
Mariovido Apr 25, 2025
303c0ba
Update test
Mariovido Apr 25, 2025
b6ebc9b
Merge branch 'master' into mario.vidal/impacted_tests
Mariovido Apr 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion integration-tests/ci-visibility-intake.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const DEFAULT_SETTINGS = {
known_tests_enabled: false,
test_management: {
enabled: false
}
},
impacted_tests_enabled: false
}

const DEFAULT_SUITES_TO_SKIP = []
Expand All @@ -39,6 +40,9 @@ const DEFAULT_KNOWN_TESTS = ['test-suite1.js.test-name1', 'test-suite2.js.test-n
const DEFAULT_TEST_MANAGEMENT_TESTS = {}
const DEFAULT_TEST_MANAGEMENT_TESTS_RESPONSE_STATUS = 200

const DEFAULT_IMPACTED_TESTS = {}
const DEFAULT_IMPACTED_TESTS_RESPONSE_STATUS = 200

let settings = DEFAULT_SETTINGS
let suitesToSkip = DEFAULT_SUITES_TO_SKIP
let gitUploadStatus = DEFAULT_GIT_UPLOAD_STATUS
Expand All @@ -49,6 +53,8 @@ let knownTestsStatusCode = DEFAULT_KNOWN_TESTS_RESPONSE_STATUS
let waitingTime = 0
let testManagementResponse = DEFAULT_TEST_MANAGEMENT_TESTS
let testManagementResponseStatusCode = DEFAULT_TEST_MANAGEMENT_TESTS_RESPONSE_STATUS
let impactedTestsResponse = DEFAULT_IMPACTED_TESTS
let impactedTestsResponseStatusCode = DEFAULT_IMPACTED_TESTS_RESPONSE_STATUS

class FakeCiVisIntake extends FakeAgent {
setKnownTestsResponseCode (statusCode) {
Expand Down Expand Up @@ -91,6 +97,14 @@ class FakeCiVisIntake extends FakeAgent {
testManagementResponseStatusCode = newStatusCode
}

setImpactedTests (newImpactedTests) {
impactedTestsResponse = newImpactedTests
}

setImpactedTestsResponseCode (newStatusCode) {
impactedTestsResponseStatusCode = newStatusCode
}

async start () {
const app = express()
app.use(bodyParser.raw({ limit: Infinity, type: 'application/msgpack' }))
Expand Down Expand Up @@ -258,6 +272,23 @@ class FakeCiVisIntake extends FakeAgent {
})
})

app.post([
'/api/v2/ci/tests/diffs',
'/evp_proxy/:version/api/v2/ci/tests/diffs'
], (req, res) => {
res.setHeader('content-type', 'application/json')
const data = JSON.stringify({
data: {
attributes: impactedTestsResponse
}
})
res.status(impactedTestsResponseStatusCode).send(data)
this.emit('message', {
headers: req.headers,
url: req.url
})
})

return new Promise((resolve, reject) => {
const timeoutObj = setTimeout(() => {
reject(new Error('Intake timed out starting up'))
Expand All @@ -280,6 +311,8 @@ class FakeCiVisIntake extends FakeAgent {
infoResponse = DEFAULT_INFO_RESPONSE
testManagementResponseStatusCode = DEFAULT_TEST_MANAGEMENT_TESTS_RESPONSE_STATUS
testManagementResponse = DEFAULT_TEST_MANAGEMENT_TESTS
impactedTestsResponseStatusCode = DEFAULT_IMPACTED_TESTS_RESPONSE_STATUS
impactedTestsResponse = DEFAULT_IMPACTED_TESTS
this.removeAllListeners()
if (this.waitingTimeoutId) {
clearTimeout(this.waitingTimeoutId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { expect } = require('chai')

describe('impacted tests', () => {
it('can pass normally', () => {
expect(1 + 2).to.equal(3)
})

it('can fail', () => {
expect(1 + 2).to.equal(4)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { expect } = require('chai')

describe('impacted tests 2', () => {
it('can pass normally', () => {
expect(1 + 2).to.equal(3)
})

it('can fail', () => {
expect(1 + 2).to.equal(4)
})
})
Loading
Loading