-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
update_summaries.sh
executable file
·109 lines (87 loc) · 3.55 KB
/
update_summaries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed 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.
set -exu
# dataset table to query for build info
readonly BUILD_DATASET_TABLE="${BUILD_DATASET_TABLE:-"kubernetes-public:k8s_infra_kettle.all"}"
# dataset to write temp results to for triage
readonly TRIAGE_DATASET_TABLE="${TRIAGE_DATASET_TABLE:-"k8s-gubernator:temp.triage"}"
# gcs bucket to write temporary results to
readonly TRIAGE_TEMP_GCS_PATH="${TRIAGE_TEMP_GCS_PATH:-"gs://k8s-gubernator/triage_tests"}"
# gcs uri to write final triage results to
readonly TRIAGE_GCS_PATH="${TRIAGE_GCS_PATH:-"gs://k8s-gubernator/triage"}"
# the gcp project against which to bill bq usage
readonly TRIAGE_BQ_USAGE_PROJECT="${TRIAGE_BQ_USAGE_PROJECT:-"k8s-gubernator"}"
cd "$(dirname "$0")"
start=$(date +%s)
if [[ -e ${GOOGLE_APPLICATION_CREDENTIALS-} ]]; then
echo "activating service account with credentials at: ${GOOGLE_APPLICATION_CREDENTIALS}"
gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
fi
gcloud config set project "${TRIAGE_BQ_USAGE_PROJECT}"
bq show <<< $'\n'
date
# populate triage_builds.json with build metadata
bq --project_id="${TRIAGE_BQ_USAGE_PROJECT}" --headless --format=json query --max_rows 1000000 \
"select
path,
timestamp_to_sec(started) started,
elapsed,
tests_run,
tests_failed,
result,
executor,
job,
number
from
[${BUILD_DATASET_TABLE}]
where
timestamp_to_sec(started) > TIMESTAMP_TO_SEC(DATE_ADD(CURRENT_DATE(), -14, 'DAY'))
and job != 'ci-kubernetes-coverage-unit'" \
> triage_builds.json
# populate ${TRIAGE_DATASET_TABLE} with test failures
bq --project_id="${TRIAGE_BQ_USAGE_PROJECT}" query --allow_large_results --headless --max_rows 0 --replace --destination_table "${TRIAGE_DATASET_TABLE}" \
"select
timestamp_to_sec(started) started,
path build,
test.name name,
test.failure_text failure_text
from
[${BUILD_DATASET_TABLE}]
where
test.failed
and timestamp_to_sec(started) > TIMESTAMP_TO_SEC(DATE_ADD(CURRENT_DATE(), -14, 'DAY'))
and job != 'ci-kubernetes-coverage-unit'"
gsutil rm "${TRIAGE_TEMP_GCS_PATH}/shard_*.json.gz" || true
bq extract --compression GZIP --destination_format NEWLINE_DELIMITED_JSON "${TRIAGE_DATASET_TABLE}" "${TRIAGE_TEMP_GCS_PATH}/shard_*.json.gz"
mkdir -p triage_tests
gsutil cp -r "${TRIAGE_TEMP_GCS_PATH}/*" triage_tests/
gzip -df triage_tests/*.gz
# gsutil cp "${TRIAGE_BUCKET}/failure_data.json failure_data_previous.json
mkdir -p slices
/triage \
--builds triage_builds.json \
--output failure_data.json \
--output_slices slices/failure_data_PREFIX.json \
${NUM_WORKERS:+"--num_workers=${NUM_WORKERS}"} \
triage_tests/*.json
gsutil_cp() {
gsutil -h 'Cache-Control: no-store, must-revalidate' -m cp -Z "$@"
}
gsutil_cp failure_data.json "${TRIAGE_GCS_PATH}/"
gsutil_cp slices/*.json "${TRIAGE_GCS_PATH}/slices/"
gsutil_cp failure_data.json "${TRIAGE_GCS_PATH}/history/$(date -u +%Y%m%d).json"
stop=$(date +%s)
elapsed=$(( stop - start ))
echo "Finished in $(( elapsed / 60))m$(( elapsed % 60))s"