[QA][Code Coverage] Drop dead code (#127057)

* [QA][Code Coverage] Drop dead code

We've some code no longer used,
that was used when code coverage was
orchestrated in Jenkins.

Since we use Buildkite instead,
we can drop this code.

* Updated the docs to reflect we
no longer use Jenkins and use
Buildkite instead.

* Updated doc per review and dropped the bit about 4 indexes,
since we no longer need the other R & D job.
This commit is contained in:
Tre 2022-03-15 11:57:09 +00:00 committed by GitHub
parent 7594603ac4
commit 1ab04243a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 439 deletions

View file

@ -1,60 +0,0 @@
#!/bin/groovy
library 'kibana-pipeline-library'
kibanaLibrary.load() // load from the Jenkins instance
kibanaPipeline(timeoutMinutes: 300) {
catchErrors {
def timestamp = new Date(currentBuild.startTimeInMillis).format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC"))
withEnv([
"TIME_STAMP=${timestamp}",
'CODE_COVERAGE=1', // Enables coverage. Needed for multiple ci scripts, such as remote.ts, test/scripts/*.sh, schema.js, etc.
]) {
workers.base(name: 'coverage-worker', size: 'xl', ramDisk: false, bootstrapped: false) {
catchError {
kibanaPipeline.bash("""
echo '${TIME_STAMP}'
""", "### Print Canonical Time Stamp")
kibanaCoverage.runTests()
handleIngestion(TIME_STAMP)
}
handleFail()
}
}
kibanaPipeline.sendMail()
}
}
def handleIngestion(timestamp) {
def previousSha = handlePreviousSha()
kibanaPipeline.downloadCoverageArtifacts()
kibanaCoverage.prokLinks("### Process HTML Links")
kibanaCoverage.collectVcsInfo("### Collect VCS Info")
kibanaCoverage.generateReports("### Merge coverage reports")
kibanaCoverage.uploadCombinedReports()
kibanaCoverage.uploadCoverageStaticSite(timestamp)
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), '### Generate Team Assignments && Ingest')
}
def handlePreviousSha() {
def previous = kibanaCoverage.downloadPrevious('### Download OLD Previous')
kibanaCoverage.uploadPrevious('### Upload NEW Previous')
return previous
}
def handleFail() {
def buildStatus = buildUtils.getBuildStatus()
if (params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
slackNotifications.sendFailedBuild(
channel: '#kibana-qa',
username: 'Kibana QA'
)
}
}
def teamAssignmentsPath() {
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
}

View file

@ -1,31 +1,46 @@
# Massage and Ingest Code Coverage Json Summary and Send to ES
## Currently, we have 4 indexes
## Currently, we have 2 indexes
### 2 for the Code Coverage Job
https://kibana-ci.elastic.co/job/elastic+kibana+code-coverage/
https://buildkite.com/elastic/kibana-code-coverage-main
1. kibana_code_coverage
2. kibana_total_code_coverage
### 2 for the R & D Job
https://kibana-ci.elastic.co/job/elastic+kibana+qa-research/
1. qa_research_code_coverage
2. qa_research_total_code_coverage
## How it works
It starts with this jenkins pipeline file:
It starts with buildkite
.ci/Jenkinsfile_coverage#L60
At the time of this writing, the code coverage job steps are:
```yaml
env:
CODE_COVERAGE: '1'
NODE_ENV: 'test'
DISABLE_MISSING_TEST_REPORT_ERRORS: 'true'
steps:
# .. MYRIAD STEPS BEFORE CODE COVERAGE BEGINS ..
- command: .buildkite/scripts/steps/code_coverage/ingest.sh
label: 'Merge and Ingest'
agents:
queue: n2-4
depends_on:
- jest
- oss-cigroup
- default-cigroup
timeout_in_minutes: 60
key: ingest
- wait: ~
continue_on_failure: true
```
src/dev/code_coverage/shell_scripts/ingest_coverage.sh ${BUILD_NUMBER} ${env.BUILD_URL}
```
The ingestion system is hard coded to look for 3 coverage summary files...all json.
From there, an event stream is created, that massages the data to an output format in json that is ingested.
At the end of `.buildkite/scripts/steps/code_coverage/ingest.sh` is:
`echo "--- Ingest results to Kibana stats cluster"`.
The code that comes after that echo statement starts the process.
## Configuration

View file

@ -1,87 +0,0 @@
String path = doc['coveredFilePath.keyword'].value;
if (path.contains('/apm')) return "APM";
else if (path.contains('/canvas')) return "Canvas";
else if (path.contains('/maps')) return "Maps";
else if (path.contains('map_')) return "Maps";
else if (path.contains('/ml')) return "ML";
else if (path.contains('/transform')) return "ML";
else if (path.contains('/infra')) return "Infra";
else if (path.contains('/siem')) return "SIEM";
else if (path.contains('/endpoint')) return "Endpoint";
else if (path.contains('logstash')) return "Logstash";
else if (path.contains('beat')) return "Beats";
else if (path.contains('uptime')) return "Observability";
else if (path.contains('observability')) return "Observability";
else if (path.contains('tutorials')) return "Observability";
else if (path.contains('/code')) return "Code";
else if (path.contains('/cross_cluster_replication')) return "Elasticsearch UI";
else if (path.contains('/index_lifecycle_management')) return "Elasticsearch UI";
else if (path.contains('/index_management')) return "Elasticsearch UI";
else if (path.contains('/license_management')) return "Elasticsearch UI";
else if (path.contains('/management')) return "Elasticsearch UI";
else if (path.contains('/licensing')) return "Elasticsearch UI";
else if (path.contains('/public/management'))return "Elasticsearch UI";
else if (path.contains('/remote_clusters')) return "Elasticsearch UI";
else if (path.contains('/searchprofiler')) return "Elasticsearch UI";
else if (path.contains('/searchprofiler')) return "Elasticsearch UI";
else if (path.contains('/snapshot_restore')) return "Elasticsearch UI";
else if (path.contains('/rollup')) return "Elasticsearch UI";
else if (path.contains('/watcher')) return "Elasticsearch UI";
else if (path.contains('/watcher')) return "Elasticsearch UI";
else if (path.contains('/file_upload')) return "Elasticsearch UI";
else if (path.contains('grokdebugger')) return "Elasticsearch UI";
else if (path.contains('es_ui_shared')) return "Elasticsearch UI";
else if (path.contains('kibana/x-pack/legacy/server/lib')) return "Elasticsearch UI";
else if (path.contains('/public/field_editor')) return "Kibana App";
else if (path.contains('dashboard')) return "Kibana App";
else if (path.contains('discover')) return "Kibana App";
else if (path.contains('graph')) return "Kibana App";
else if (path.contains('timelion')) return "Kibana App";
else if (path.contains('/lens/')) return "Kibana App";
else if (path.contains('/core_plugins')) return "Kibana App";
else if (path.contains('/vislib')) return "Kibana App";
else if (path.contains('/visualize')) return "Kibana App";
else if (path.contains('/public/vis/')) return "Kibana App";
else if (path.contains('/kbn-es')) return "Kibana App";
else if (path.contains('kuery')) return "Kibana App";
else if (path.contains('url_shortening')) return "Kibana App";
else if (path.contains('sample_data')) return "Kibana App";
else if (path.contains('/home')) return "Kibana App";
else if (path.contains('/accessibility')) return "Kibana App";
else if (path.contains('/timeseries')) return "Kibana App";
else if (path.contains('/point_series')) return "Kibana App";
else if (path.contains('security')) return "Kibana Security";
else if (path.contains('privilege')) return "Kibana Security";
else if (path.contains('/spaces')) return "Kibana Security";
else if (path.contains('monitoring')) return "Stack Monitoring";
else if (path.contains('/es_archiver')) return "Kibana Operations";
else if (path.contains('/dev/build')) return "Kibana Operations";
else if (path.contains('/kbn-test')) return "Kibana Operations";
else if (path.contains('upgrade')) return "Kibana Operations";
else if (path.contains('/kbn-dev-utils')) return "Kibana Operations";
else if (path.contains('optimize')) return "Kibana Operations";
else if (path.contains('test_utils')) return "Kibana Operations";
else if (path.contains('kbn-babel-preset')) return "Kibana Operations";
else if (path.contains('kibana/server/routes')) return "Kibana Operations";
else if (path.contains('kibana/src/legacy/server/')) return "Kibana Operations";
else if (path.contains('kibana/scripts/')) return "Kibana Operations";
else if (path.contains('kibana/packages/')) return "Kibana Operations";
else if (path.contains('kibana/src/setup_node_env')) return "Kibana Operations";
else if (path.contains('/kbn-ui-framework')) return "Kibana Design";
else if (path.contains('/ui/ui')) return "Kibana Design";
else if (path.contains('/eui')) return "Kibana Design";
else if (path.contains('/kbn-es-query')) return "Kibana App Arch";
else if (path.contains('/kbn-ui-framework')) return "Kibana App Arch";
else if (path.contains('/kbn-interpreter')) return "Kibana App Arch";
else if (path.contains('courier')) return "Kibana App Arch";
else if (path.contains('kbn-config-schema')) return "Kibana Platform";
else if (path.contains('kibana/src/legacy/utils')) return "Kibana Platform";
else if (path.contains('saved_objects')) return "Kibana Platform";
else if (path.contains('/reporting')) return "Kibana Stack Services";
else if (path.contains('telemetry')) return "Kibana Stack Services";
else if (path.contains('/kbn-i18n')) return "Kibana Stack Services";
else if (path.contains('/kbn-analytics')) return "Kibana Stack Services";
else if (path.contains('/task_manager')) return "Kibana Stack Services";
else if (path.contains('alert')) return "Kibana Stack Services";
else if (path.contains('actions')) return "Kibana Stack Services";
else return "unknown";

View file

@ -1,248 +0,0 @@
def downloadPrevious(title) {
def vaultSecret = 'secret/gce/elastic-bekitzur/service-account/kibana'
withGcpServiceAccount.fromVaultSecret(vaultSecret, 'value') {
kibanaPipeline.bash('''
gsutil -m cp -r gs://elastic-bekitzur-kibana-coverage-live/previous_pointer/previous.txt . || echo "### Previous Pointer NOT FOUND?"
if [ -e ./previous.txt ]; then
mv previous.txt downloaded_previous.txt
echo "### downloaded_previous.txt"
cat downloaded_previous.txt
fi
''', title)
def previous = sh(script: 'cat downloaded_previous.txt', label: '### Capture Previous Sha', returnStdout: true).trim()
return previous
}
}
def uploadPrevious(title) {
def vaultSecret = 'secret/gce/elastic-bekitzur/service-account/kibana'
withGcpServiceAccount.fromVaultSecret(vaultSecret, 'value') {
kibanaPipeline.bash('''
collectPrevious() {
PREVIOUS=$(git log --pretty=format:%h -1)
echo "### PREVIOUS: ${PREVIOUS}"
echo $PREVIOUS > previous.txt
}
collectPrevious
gsutil cp previous.txt gs://elastic-bekitzur-kibana-coverage-live/previous_pointer/
''', title)
}
}
def uploadCoverageStaticSite(timestamp) {
def uploadPrefix = "gs://elastic-bekitzur-kibana-coverage-live/"
def uploadPrefixWithTimeStamp = "${uploadPrefix}${timestamp}/"
uploadBaseWebsiteFiles(uploadPrefix)
uploadCoverageHtmls(uploadPrefixWithTimeStamp)
}
def uploadBaseWebsiteFiles(prefix) {
[
'src/dev/code_coverage/www/index.html',
'src/dev/code_coverage/www/404.html'
].each { uploadWithVault(prefix, it) }
}
def uploadCoverageHtmls(prefix) {
[
'target/kibana-coverage/functional-combined',
'target/kibana-coverage/jest-combined',
].each { uploadWithVault(prefix, it) }
}
def uploadWithVault(prefix, path) {
def vaultSecret = 'secret/gce/elastic-bekitzur/service-account/kibana'
withGcpServiceAccount.fromVaultSecret(vaultSecret, 'value') {
kibanaPipeline.bash("""
gsutil -m cp -r -a public-read -z js,css,html ${path} '${prefix}'
""", "### Upload files to GCS with vault, path: ${path}")
}
}
def prokLinks(title) {
kibanaPipeline.bash('''
cat << EOF > src/dev/code_coverage/www/index_partial_2.html
<a class="nav-link" href="https://kibana-coverage.elastic.dev/${TIME_STAMP}/jest-combined/index.html">Latest Jest</a>
<a class="nav-link" href="https://kibana-coverage.elastic.dev/${TIME_STAMP}/functional-combined/index.html">Latest FTR</a>
</nav>
</div>
</header>
<main role="main" class="inner cover">
<!-- <h1 class="cover-heading"> - Master Branch</h1>-->
<p class="lead">Use Kibana Stats to mine coverage data</p>
<p class="lead">
<a href="https://kibana-stats.elastic.dev/app/kibana#/dashboard/58b8db70-62f9-11ea-8312-7f2d69b79843?_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-7d%2Cto%3Anow))" class="btn btn-lg btn-primary">Dashboard</a>
</p>
</main>
<footer class="mastfoot mt-auto">
<div class="inner">
<p>Please slack us at <a href="https://app.slack.com/client/T0CUZ52US/C0TR0FAET">#kibana-qa</a> if you've questions</p>
</div>
</footer>
</div>
</body>
</html>
EOF
''', title)
kibanaPipeline.bash('''
cat src/dev/code_coverage/www/index_partial.html > src/dev/code_coverage/www/index.html
cat src/dev/code_coverage/www/index_partial_2.html >> src/dev/code_coverage/www/index.html
echo "### Prok'd Index File: ..."
cat src/dev/code_coverage/www/index.html
''', "### Combine Index Partials")
}
def collectVcsInfo(title) {
kibanaPipeline.bash('''
predicate() {
x=$1
if [ -n "$x" ]; then
return
else
echo "### 1 or more variables that Code Coverage needs, are undefined"
exit 1
fi
}
CMD="git log --pretty=format"
XS=("${GIT_BRANCH}" \
"$(${CMD}":%h" -1)" \
"$(${CMD}":%an" -1)" \
"$(${CMD}":%s" -1)")
touch VCS_INFO.txt
for X in "${!XS[@]}"; do
{
predicate "${XS[X]}"
echo "${XS[X]}" >> VCS_INFO.txt
}
done
echo "### VCS_INFO:"
cat VCS_INFO.txt
''', title
)
}
def generateReports(title) {
kibanaPipeline.bash("""
source src/dev/ci_setup/setup_env.sh true
. src/dev/code_coverage/shell_scripts/extract_archives.sh
. src/dev/code_coverage/shell_scripts/merge_functional.sh
. src/dev/code_coverage/shell_scripts/copy_jest_report.sh
# zip functional combined report
tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional-combined/*
""", title)
}
def uploadCombinedReports() {
kibanaPipeline.bash("""
ls -laR target/kibana-coverage/
""", "### List Combined Reports"
)
kibanaPipeline.uploadGcsArtifact(
"kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/coverage/combined",
'kibana-functional-coverage.tar.gz'
)
}
def ingestData(jobName, buildNum, buildUrl, previousSha, teamAssignmentsPath, title) {
kibanaPipeline.bash("""
source src/dev/ci_setup/setup_env.sh
yarn kbn bootstrap
# Using existing target/kibana-coverage folder
. src/dev/code_coverage/shell_scripts/generate_team_assignments_and_ingest_coverage.sh '${jobName}' ${buildNum} '${buildUrl}' '${previousSha}' '${teamAssignmentsPath}'
""", title)
}
def ingestWithVault(jobName, buildNum, buildUrl, previousSha, teamAssignmentsPath, title) {
def vaultSecret = 'secret/kibana-issues/prod/coverage/elasticsearch'
withVaultSecret(secret: vaultSecret, secret_field: 'host', variable_name: 'HOST_FROM_VAULT') {
withVaultSecret(secret: vaultSecret, secret_field: 'username', variable_name: 'USER_FROM_VAULT') {
withVaultSecret(secret: vaultSecret, secret_field: 'password', variable_name: 'PASS_FROM_VAULT') {
ingestData(jobName, buildNum, buildUrl, previousSha, teamAssignmentsPath, title)
}
}
}
}
def ingest(jobName, buildNumber, buildUrl, timestamp, previousSha, teamAssignmentsPath, title) {
withEnv([
"TIME_STAMP=${timestamp}",
]) {
ingestWithVault(jobName, buildNumber, buildUrl, previousSha, teamAssignmentsPath, title)
}
}
def prepareKibana() {
kibanaPipeline.notifyOnError {
runbld("./test/scripts/jenkins_code_coverage.sh", "Verify tests")
}
}
def runTests() {
parallel([
'kibana-intake-agent': workers.intake('kibana-intake', './test/scripts/jenkins_unit.sh'),
'kibana-oss-agent' : workers.functional(
'kibana-oss-tests',
{ prepareKibana() },
ossProks()
),
'kibana-xpack-agent' : workers.functional(
'kibana-xpack-tests',
{ prepareKibana() },
xpackProks()
),
])
}
def ossProks() {
return [
'oss-ciGroup1' : kibanaPipeline.ossCiGroupProcess(1),
'oss-ciGroup2' : kibanaPipeline.ossCiGroupProcess(2),
'oss-ciGroup3' : kibanaPipeline.ossCiGroupProcess(3),
'oss-ciGroup4' : kibanaPipeline.ossCiGroupProcess(4),
'oss-ciGroup5' : kibanaPipeline.ossCiGroupProcess(5),
'oss-ciGroup6' : kibanaPipeline.ossCiGroupProcess(6),
'oss-ciGroup7' : kibanaPipeline.ossCiGroupProcess(7),
'oss-ciGroup8' : kibanaPipeline.ossCiGroupProcess(8),
'oss-ciGroup9' : kibanaPipeline.ossCiGroupProcess(9),
'oss-ciGroup10': kibanaPipeline.ossCiGroupProcess(10),
'oss-ciGroup11': kibanaPipeline.ossCiGroupProcess(11),
]
}
def xpackProks() {
return [
'xpack-ciGroup1' : kibanaPipeline.xpackCiGroupProcess(1),
'xpack-ciGroup2' : kibanaPipeline.xpackCiGroupProcess(2),
'xpack-ciGroup3' : kibanaPipeline.xpackCiGroupProcess(3),
'xpack-ciGroup4' : kibanaPipeline.xpackCiGroupProcess(4),
'xpack-ciGroup5' : kibanaPipeline.xpackCiGroupProcess(5),
'xpack-ciGroup6' : kibanaPipeline.xpackCiGroupProcess(6),
'xpack-ciGroup7' : kibanaPipeline.xpackCiGroupProcess(7),
'xpack-ciGroup8' : kibanaPipeline.xpackCiGroupProcess(8),
'xpack-ciGroup9' : kibanaPipeline.xpackCiGroupProcess(9),
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-ciGroup11': kibanaPipeline.xpackCiGroupProcess(11),
'xpack-ciGroup12': kibanaPipeline.xpackCiGroupProcess(12),
'xpack-ciGroup13': kibanaPipeline.xpackCiGroupProcess(13),
]
}
return this

View file

@ -176,18 +176,6 @@ def uploadGcsArtifact(uploadPrefix, pattern) {
)
}
def downloadCoverageArtifacts() {
def storageLocation = "gs://kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/coverage/"
def targetLocation = "/tmp/downloaded_coverage"
sh "mkdir -p '${targetLocation}' && gsutil -m cp -r '${storageLocation}' '${targetLocation}'"
}
def uploadCoverageArtifacts(prefix, pattern) {
def uploadPrefix = "kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/coverage/${prefix}"
uploadGcsArtifact(uploadPrefix, pattern)
}
def withGcsArtifactUpload(workerName, closure) {
def uploadPrefix = "kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/${workerName}"
def ARTIFACT_PATTERNS = [
@ -227,11 +215,6 @@ def withGcsArtifactUpload(workerName, closure) {
}
}
})
if (env.CODE_COVERAGE) {
sh 'tar -czf kibana-coverage.tar.gz target/kibana-coverage/**/*'
uploadGcsArtifact("kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/coverage/${workerName}", 'kibana-coverage.tar.gz')
}
}
def publishJunit() {

View file

@ -1,13 +0,0 @@
def generateTeamAssignments(teamAssignmentsPath, title) {
kibanaPipeline.bash("""
source src/dev/ci_setup/setup_env.sh
yarn kbn bootstrap
# Build team assignments dat file
node scripts/generate_team_assignments.js --verbose --dest '${teamAssignmentsPath}'
cat '${teamAssignmentsPath}'
""", title)
}
return this