diff options
author | Erich Eckner <git@eckner.net> | 2018-10-17 14:07:13 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-17 14:07:13 +0200 |
commit | be78441ba08aac4e349a8be626918388b9a3e3ad (patch) | |
tree | b69145b916e5c1b6563344192ad0065131983461 /bin | |
parent | eecdfe1ea2e43b9f1d87ad6402c5603401146b45 (diff) | |
download | builder-be78441ba08aac4e349a8be626918388b9a3e3ad.tar.xz |
bin/build-master-status: statistics are now per-architecture
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/build-master-status | 269 |
1 files changed, 153 insertions, 116 deletions
diff --git a/bin/build-master-status b/bin/build-master-status index 5d84bb6..455eb8f 100755 --- a/bin/build-master-status +++ b/bin/build-master-status @@ -96,125 +96,162 @@ if [ -s "${tmp_dir}/todos" ]; then fi rm -f "${tmp_dir}/todos" +# TODO: accellerate this query by using "GROUP BY"? if [ ! -s "${work_dir}/build-master-sanity" ]; then # shellcheck disable=SC2016 { - printf 'INSERT IGNORE INTO `statistics` (' - printf '`%s`,' \ - 'stable_packages_count' \ - 'pending_tasks_count' \ - 'pending_packages_count' \ - 'staging_packages_count' \ - 'testing_packages_count' \ - 'tested_packages_count' \ - 'broken_tasks_count' \ - 'dependency_loops_count' \ - 'dependency_looped_tasks_count' \ - 'locked_tasks_count' \ - 'blocked_tasks_count' \ - 'next_tasks_count' | \ - sed 's/,$//' - printf ') VALUES (' - # stable_packages_count - printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' - printf ' `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - mysql_join_binary_packages_in_repositories_repositories - # shellcheck disable=SC2154 - printf ' WHERE `repositories`.`stability`=%s),' \ - "${repository_stability_ids__stable}" - # pending_tasks_count - printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' - printf ' `build_assignments`' - mysql_join_build_assignments_binary_packages - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s),' \ - "${repository_ids__any_build_list}" - # pending_packages_count - printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' - printf ' `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s),' \ - "${repository_ids__any_build_list}" - # staging_packages_count - printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' - printf ' `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - mysql_join_binary_packages_in_repositories_repositories - # shellcheck disable=SC2154 - printf ' WHERE `repositories`.`stability`=%s),' \ - "${repository_stability_ids__staging}" - # testing_packages_count - printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' - printf ' `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - mysql_join_binary_packages_in_repositories_repositories - # shellcheck disable=SC2154 - printf ' WHERE `repositories`.`stability`=%s' \ - "${repository_stability_ids__testing}" - printf ' AND NOT `binary_packages`.`is_tested`),' - # tested_packages_count - printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' - printf ' `binary_packages`' - mysql_join_binary_packages_binary_packages_in_repositories - mysql_join_binary_packages_in_repositories_repositories - printf ' WHERE `repositories`.`stability`=%s' \ - "${repository_stability_ids__testing}" - printf ' AND `binary_packages`.`is_tested`),' - # broken_tasks_count - printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' - printf ' `build_assignments`' - mysql_join_build_assignments_binary_packages - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ - "${repository_ids__any_build_list}" - printf ' AND `build_assignments`.`is_broken`),' - # dependency_loops_count - printf '(SELECT COUNT(DISTINCT `build_dependency_loops`.`loop`) FROM' - printf ' `build_dependency_loops`),' - # dependency_looped_tasks_count - printf '(SELECT COUNT(DISTINCT `build_dependency_loops`.`build_assignment`) FROM' - printf ' `build_dependency_loops`),' - # locked_tasks_count - printf '(SELECT COUNT(DISTINCT `build_slaves`.`currently_building`) FROM' - printf ' `build_slaves`' - mysql_join_build_slaves_build_assignments - mysql_join_build_assignments_binary_packages - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s),' \ - "${repository_ids__any_build_list}" - # blocked_tasks_count - printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' - printf ' `build_assignments`' - mysql_join_build_assignments_binary_packages - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ - "${repository_ids__any_build_list}" - printf ' AND `build_assignments`.`is_blocked` IS NOT NULL),' - # next_tasks_count - printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' - printf ' `build_assignments`' - mysql_join_build_assignments_binary_packages - mysql_join_binary_packages_binary_packages_in_repositories - printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ - "${repository_ids__any_build_list}" - printf ' AND (' - printf 'NOT EXISTS (' - printf 'SELECT 1 FROM `dependencies`' - mysql_join_dependencies_dependency_types - printf ' AND `dependency_types`.`relevant_for_building`' - mysql_join_dependencies_install_target_providers_with_versions - mysql_join_install_target_providers_binary_packages '' 'prov_bp' - mysql_join_binary_packages_binary_packages_in_repositories 'prov_bp' 'prov_bpir' - printf ' WHERE `prov_bpir`.`repository`=%s' \ - "${repository_ids__any_build_list}" - printf ' AND `dependencies`.`dependent`=`binary_packages`.`id`' - printf ') OR EXISTS (' - printf 'SELECT 1 FROM `build_dependency_loops`' - printf ' WHERE `build_dependency_loops`.`build_assignment`=`build_assignments`.`id`' - printf ')' - printf '))' - printf ');\n' + printf 'SELECT `architectures`.`id`' + printf ' FROM `architectures`;\n' } | \ + mysql_run_query 'unimportant' | \ + while read -r arch_id; do + printf 'INSERT IGNORE INTO `statistics` (' + printf '`%s`,' \ + 'stable_packages_count' \ + 'pending_tasks_count' \ + 'pending_packages_count' \ + 'staging_packages_count' \ + 'testing_packages_count' \ + 'tested_packages_count' \ + 'broken_tasks_count' \ + 'dependency_loops_count' \ + 'dependency_looped_tasks_count' \ + 'locked_tasks_count' \ + 'blocked_tasks_count' \ + 'next_tasks_count' \ + 'architecture' | \ + sed 's/,$//' + printf ') VALUES (' + # stable_packages_count + printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' + printf ' `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_in_repositories_repositories + # shellcheck disable=SC2154 + printf ' WHERE `repositories`.`stability`=%s' \ + "${repository_stability_ids__stable}" + printf ' AND `repositories`.`architecture`=%s),' \ + "${arch_id}" + # pending_tasks_count + printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' + printf ' `build_assignments`' + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # pending_packages_count + printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' + printf ' `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_build_assignments + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # staging_packages_count + printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' + printf ' `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_in_repositories_repositories + # shellcheck disable=SC2154 + printf ' WHERE `repositories`.`stability`=%s' \ + "${repository_stability_ids__staging}" + printf ' AND `repositories`.`architecture`=%s),' \ + "${arch_id}" + # testing_packages_count + printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' + printf ' `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_in_repositories_repositories + # shellcheck disable=SC2154 + printf ' WHERE `repositories`.`stability`=%s' \ + "${repository_stability_ids__testing}" + printf ' AND NOT `binary_packages`.`is_tested`' + printf ' AND `repositories`.`architecture`=%s),' \ + "${arch_id}" + # tested_packages_count + printf '(SELECT COUNT(DISTINCT `binary_packages`.`id`) FROM' + printf ' `binary_packages`' + mysql_join_binary_packages_binary_packages_in_repositories + mysql_join_binary_packages_in_repositories_repositories + printf ' WHERE `repositories`.`stability`=%s' \ + "${repository_stability_ids__testing}" + printf ' AND `binary_packages`.`is_tested`' + printf ' AND `repositories`.`architecture`=%s),' \ + "${arch_id}" + # broken_tasks_count + printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' + printf ' `build_assignments`' + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`is_broken`' + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # dependency_loops_count + printf '(SELECT COUNT(DISTINCT `build_dependency_loops`.`loop`) FROM' + printf ' `build_dependency_loops`' + mysql_join_build_dependency_loops_build_assignments + printf ' WHERE `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # dependency_looped_tasks_count + printf '(SELECT COUNT(DISTINCT `build_dependency_loops`.`build_assignment`) FROM' + printf ' `build_dependency_loops`' + mysql_join_build_dependency_loops_build_assignments + printf ' WHERE `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # locked_tasks_count + printf '(SELECT COUNT(DISTINCT `build_slaves`.`currently_building`) FROM' + printf ' `build_slaves`' + mysql_join_build_slaves_build_assignments + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # blocked_tasks_count + printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' + printf ' `build_assignments`' + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `build_assignments`.`is_blocked` IS NOT NULL' + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # next_tasks_count + printf '(SELECT COUNT(DISTINCT `build_assignments`.`id`) FROM' + printf ' `build_assignments`' + mysql_join_build_assignments_binary_packages + mysql_join_binary_packages_binary_packages_in_repositories + printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND (' + printf 'NOT EXISTS (' + printf 'SELECT 1 FROM `dependencies`' + mysql_join_dependencies_dependency_types + printf ' AND `dependency_types`.`relevant_for_building`' + mysql_join_dependencies_install_target_providers_with_versions + mysql_join_install_target_providers_binary_packages '' 'prov_bp' + mysql_join_binary_packages_binary_packages_in_repositories 'prov_bp' 'prov_bpir' + printf ' WHERE `prov_bpir`.`repository`=%s' \ + "${repository_ids__any_build_list}" + printf ' AND `dependencies`.`dependent`=`binary_packages`.`id`' + printf ') OR EXISTS (' + printf 'SELECT 1 FROM `build_dependency_loops`' + printf ' WHERE `build_dependency_loops`.`build_assignment`=`build_assignments`.`id`' + printf ')' + printf ')' + printf ' AND `build_assignments`.`architecture`=%s),' \ + "${arch_id}" + # architecture + printf '%s' \ + "${arch_id}" + printf ');\n' + done | \ mysql_run_query 'unimportant' fi |