mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[QA][Code Coverage] Upload a new Team Assignment on every ci run (#71175)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
b7bb193cd5
commit
c918d2d355
11 changed files with 188 additions and 0 deletions
|
@ -13,6 +13,7 @@ kibanaPipeline(timeoutMinutes: 240) {
|
|||
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
|
||||
catchError {
|
||||
kibanaCoverage.runTests()
|
||||
kibanaTeamAssign.load('team_assignment', "### Upload Team Assignment JSON")
|
||||
handleIngestion(TIME_STAMP)
|
||||
}
|
||||
handleFail()
|
||||
|
|
21
scripts/load_team_assignment.js
Normal file
21
scripts/load_team_assignment.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/code_coverage/ingest_coverage/team_assignment').uploadTeamAssignmentJson();
|
8
src/dev/code_coverage/docs/team_assignment/README.md
Normal file
8
src/dev/code_coverage/docs/team_assignment/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Team Assignment Ingestion Pipeline
|
||||
|
||||
Team assignment will occur once per ci run.
|
||||
Team assignment uses an ingest pipeline.
|
||||
|
||||
The coverage user has the coverage admin role.
|
||||
|
||||
This role must have the rights depicted below 
|
Binary file not shown.
After Width: | Height: | Size: 226 KiB |
|
@ -32,3 +32,4 @@ export const TEAM_ASSIGNMENT_PIPELINE_NAME = process.env.PIPELINE_NAME || 'team_
|
|||
export const CODE_COVERAGE_CI_JOB_NAME = 'elastic+kibana+code-coverage';
|
||||
export const RESEARCH_CI_JOB_NAME = 'elastic+kibana+qa-research';
|
||||
export const CI_JOB_NAME = process.env.COVERAGE_JOB_NAME || RESEARCH_CI_JOB_NAME;
|
||||
export const RESEARCH_CLUSTER_ES_HOST = process.env.ES_HOST || 'http://localhost:9200';
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { fromNullable } from '../either';
|
||||
|
||||
const ROOT = resolve(__dirname, '../../../../..');
|
||||
const resolveFromRoot = resolve.bind(null, ROOT);
|
||||
const path = `
|
||||
src/dev/code_coverage/ingest_coverage/team_assignment/ingestion_pipeline_painless.json`;
|
||||
const resolved = resolveFromRoot(path.trimStart());
|
||||
const getContents = (scriptPath) => readFileSync(scriptPath, 'utf8');
|
||||
|
||||
export const fetch = () => fromNullable(resolved).map(getContents);
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { run } from '@kbn/dev-utils';
|
||||
import { TEAM_ASSIGNMENT_PIPELINE_NAME } from '../constants';
|
||||
import { fetch } from './get_data';
|
||||
import { noop } from '../utils';
|
||||
import { update } from './update_ingest_pipeline';
|
||||
|
||||
export const uploadTeamAssignmentJson = () => run(execute, { description });
|
||||
|
||||
const updatePipeline = update(TEAM_ASSIGNMENT_PIPELINE_NAME);
|
||||
|
||||
function execute({ flags, log }) {
|
||||
if (flags.verbose) log.verbose(`### Verbose logging enabled`);
|
||||
|
||||
fetch().fold(noop, updatePipeline(log));
|
||||
}
|
||||
|
||||
function description() {
|
||||
return `
|
||||
|
||||
Upload the latest team assignment pipeline def from src,
|
||||
to the cluster.
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
node scripts/load_team_assignment.js --verbose
|
||||
|
||||
`;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { createFailError } from '@kbn/dev-utils';
|
||||
import { RESEARCH_CLUSTER_ES_HOST } from '../constants';
|
||||
import { pretty, green } from '../utils';
|
||||
|
||||
const { Client } = require('@elastic/elasticsearch');
|
||||
|
||||
const node = RESEARCH_CLUSTER_ES_HOST;
|
||||
const client = new Client({ node });
|
||||
|
||||
export const update = (id) => (log) => async (body) => {
|
||||
try {
|
||||
await client.ingest.putPipeline({ id, body });
|
||||
log.verbose(`### Ingestion Pipeline ID: ${green(id)}`);
|
||||
log.verbose(`### Payload Partial: \n${body.slice(0, 600)}...`);
|
||||
} catch (e) {
|
||||
throw createFailError(`${pretty(e.meta)}`);
|
||||
}
|
||||
};
|
15
src/dev/code_coverage/shell_scripts/assign_teams.sh
Normal file
15
src/dev/code_coverage/shell_scripts/assign_teams.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "### Code Coverage Team Assignment"
|
||||
echo ""
|
||||
|
||||
PIPELINE_NAME=$1
|
||||
export PIPELINE_NAME
|
||||
|
||||
ES_HOST="https://${USER_FROM_VAULT}:${PASS_FROM_VAULT}@${HOST_FROM_VAULT}"
|
||||
export ES_HOST
|
||||
|
||||
node scripts/load_team_assignment.js --verbose
|
||||
|
||||
echo "### Code Coverage Team Assignment - Complete"
|
||||
echo ""
|
25
vars/kibanaTeamAssign.groovy
Normal file
25
vars/kibanaTeamAssign.groovy
Normal file
|
@ -0,0 +1,25 @@
|
|||
def loadIngestionPipeline(ingestionPipelineName, title) {
|
||||
kibanaPipeline.bash("""
|
||||
source src/dev/ci_setup/setup_env.sh
|
||||
yarn kbn bootstrap --prefer-offline
|
||||
|
||||
. src/dev/code_coverage/shell_scripts/assign_teams.sh '${ingestionPipelineName}'
|
||||
""", title)
|
||||
}
|
||||
|
||||
def loadWithVault(ingestionPipelineName, 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') {
|
||||
loadIngestionPipeline(ingestionPipelineName, title)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def load(ingestionPipelineName, title) {
|
||||
loadWithVault(ingestionPipelineName, title)
|
||||
}
|
||||
|
||||
return this
|
Loading…
Add table
Add a link
Reference in a new issue