539232ab474d8977cddb9b9ce3007dfe33414749
[policy/parent.git] / integration / src / main / scripts / reports / pf_status_report.sh
1 #!/bin/bash
2
3 # ============LICENSE_START================================================
4 # ONAP
5 # =========================================================================
6 # Copyright (C) 2022 Nordix Foundation.
7 # =========================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END==================================================
20 #
21
22 function health_check() {
23     health_dir="$1"
24
25     health_report_temp_file=$(mktemp)
26
27     report_month=$( \
28         curl -s "https://logs.onap.org/onap-integration/daily/$health_dir"/ | \
29         grep href | \
30         sort | \
31         tail -1 | \
32         sed -e 's/^.*href="//' \
33             -e 's/\/".*$//'
34     )
35
36     report_last_health=$( \
37         curl -s "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/" | \
38         grep href | \
39         sort | \
40         tail -1 | \
41         sed -e 's/^.*href="//' \
42             -e 's/\/".*$//'
43     )
44
45     curl -s --output "$health_report_temp_file" \
46         "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/$report_last_health/xtesting-healthcheck/full/full/report.html"
47
48     if file "$health_report_temp_file" | grep -q gzip
49     then
50         health_check_result=$(
51             gunzip -c "$health_report_temp_file" | \
52                 grep 'window.output\["stats"\]' | \
53                 sed 's/},{/}\n{/g' | \
54                 grep health-policy | \
55                 sed -e 's/{//g' \
56                     -e 's/}//g' \
57                     -e 's/"//g' \
58                     -e 's/label://' | \
59              awk -F',' '{printf("%s,%s,%s\n", $3,$4,$2)}'
60         )
61
62         report_day="${report_last_health%%_*}"
63         report_hour_minute="${report_last_health#*_}"
64         report_hour_minute="${report_hour_minute/-/:}"
65         printf "$health_dir,$report_month-$report_day $report_hour_minute,$health_check_result\n"
66         printf "\thttps://logs.onap.org/onap-integration/daily/$health_dir/$report_month/$report_last_health/xtesting-healthcheck/full/full/report.html\n"
67     else
68         printf "$health_dir,$report_month-$report_day $report_hour_minute,result not available\n"
69         printf "\thttps://logs.onap.org/onap-integration/daily/$health_dir/$report_month/$report_last_health/xtesting-healthcheck/full/full/report.html\n"
70     fi
71 }
72
73 echo ""
74 echo "health checks"
75 echo "-------------"
76
77 health_check onap-daily-dt-oom-master
78 health_check onap-daily-dt-oom-jakarta
79 health_check onap-daily-dt-oom-istanbul
80 health_check onap_daily_pod4_master
81
82 jenkins_report_temp_file=$(mktemp)
83
84 curl -s https://jenkins.onap.org/view/policy/ |
85     sed -e 's/<tr id=/\n<tr id=/g' \
86         -e 's/><td data=/\n><td data=/g' |
87     grep 'tr id=' |
88     sed -e 's/"//g' \
89         -e 's/<tr id=//' \
90         -e 's/class= //' |
91     grep '^job_' > "$jenkins_report_temp_file"
92
93 echo ""
94 echo "failing jobs"
95 echo "------------"
96
97 grep "job-status-red" "$jenkins_report_temp_file" |
98     grep -v stage |
99     cut -f1 -d' ' |
100     sed 's/_/\//' |
101     awk '{printf("https://jenkins.onap.org/%s\n", $1)}'
102
103 echo ""
104 echo "warning jobs"
105 echo "------------"
106
107 grep "job-status-yellow" "$jenkins_report_temp_file" |
108     grep -v clm |
109     cut -f1 -d' ' |
110     sed 's/_/\//' |
111     awk '{printf("https://jenkins.onap.org/%s\n", $1)}'
112
113 echo ""
114 echo "invalid jobs"
115 echo "------------"
116 grep -v -E "(job-status-red|job-status-yellow|job-status-blue)" "$jenkins_report_temp_file" |
117     cut -f1 -d' ' |
118     sed 's/_/\//' |
119     awk '{printf("https://jenkins.onap.org/%s\n", $1)}'
120
121 echo ""
122 echo "bugs"
123 echo "----"
124 curl -s https://jira.onap.org/issues/?jql=PROJECT%20%3D%20POLICY%20AND%20issuetype%20%3D%20Bug%20AND%20status%20!%3D%20Closed%20ORDER%20BY%20key%20ASC |
125     grep 'data-issue-table-model-state' |
126     sed -e 's/&quot/\"/g' \
127         -e 's/.*";jiraHasIssues";:true,";page";:[0-9]*,";pageSize";:[0-9]*,";startIndex";:[0-9]*,";table";:\[//' \
128         -e 's/,";title";:";";,";total";:[0-9]*,";url";:";";,";sortBy";:\].*$//' \
129         -e 's/}}/}}\n/g' |
130     grep 'POLICY-' |
131     sed -e 's/^.*key=/key=/g' \
132         -e 's/";:";/=/g' \
133         -e 's/";,";/,/g' \
134         -e 's/^.*key=/key=/g' \
135         -e 's/";:{";description=.*$//' \
136         -e 's/key=POLICY-\([0-9]*\),/https:\/\/jira.onap.org\/browse\/POLICY-\1 /'
137