-
Notifications
You must be signed in to change notification settings - Fork 317
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
[ci-visibility] Add get known tests request #4015
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const request = require('../../exporters/common/request') | ||
const id = require('../../id') | ||
const log = require('../../log') | ||
|
||
function getKnownTests ({ | ||
url, | ||
isEvpProxy, | ||
evpProxyPrefix, | ||
isGzipCompatible, | ||
env, | ||
service, | ||
repositoryUrl, | ||
sha, | ||
osVersion, | ||
osPlatform, | ||
osArchitecture, | ||
runtimeName, | ||
runtimeVersion, | ||
custom | ||
}, done) { | ||
const options = { | ||
path: '/api/v2/ci/libraries/tests', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
timeout: 20000, | ||
url | ||
} | ||
|
||
if (isGzipCompatible) { | ||
options.headers['accept-encoding'] = 'gzip' | ||
} | ||
|
||
if (isEvpProxy) { | ||
options.path = `${evpProxyPrefix}/api/v2/ci/libraries/tests` | ||
options.headers['X-Datadog-EVP-Subdomain'] = 'api' | ||
} else { | ||
const apiKey = process.env.DATADOG_API_KEY || process.env.DD_API_KEY | ||
if (!apiKey) { | ||
return done(new Error('Skippable suites were not fetched because Datadog API key is not defined.')) | ||
} | ||
|
||
options.headers['dd-api-key'] = apiKey | ||
} | ||
|
||
const data = JSON.stringify({ | ||
data: { | ||
id: id().toString(10), | ||
type: 'ci_app_libraries_tests_request', | ||
attributes: { | ||
configurations: { | ||
'os.platform': osPlatform, | ||
'os.version': osVersion, | ||
'os.architecture': osArchitecture, | ||
'runtime.name': runtimeName, | ||
'runtime.version': runtimeVersion, | ||
custom | ||
}, | ||
service, | ||
env, | ||
repository_url: repositoryUrl, | ||
sha | ||
} | ||
} | ||
}) | ||
|
||
request(data, options, (err, res) => { | ||
if (err) { | ||
done(err) | ||
} else { | ||
try { | ||
const { data: { attributes: { test_full_names: knownTests } } } = JSON.parse(res) | ||
log.debug(() => `Number of received known tests: ${Object.keys(knownTests).length}`) | ||
done(null, knownTests) | ||
} catch (err) { | ||
done(err) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
module.exports = { getKnownTests } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, but it's a bit difficult to know why this is needed without any publisher. Generally speaking it's a pattern that should be avoided, so just pointing it out to make sure other options were evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point. The changes are considerable so I split the PRs, leaving this is as a noop, which isn't great. The usage will become clear very soon though, as I have the changes ready :)