get_all.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash -e
  2. # Copyright 2020 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Downloads all logs from a CQ run. You can find the task ID by e.g. clicking
  6. # through to the CQ run from gerrit and finding, e.g. the line
  7. #
  8. # Swarming Task: 4cb6401085894f10
  9. #
  10. # This will create a .txt for the main log and create subdir for the ID and put
  11. # one .txt file in there for each subtask's log.
  12. #
  13. # Usage:
  14. # get_all.sh <output_dir> <task ID>
  15. base_dir=$1
  16. shift
  17. id=$1
  18. shift
  19. bindir=$(dirname $0)
  20. function get_ids() {
  21. perl -lne 'print $1 if m#shard \#0\]\(https://chromium-swarm.appspot.com/user/task/([0-9a-f]*)#;' "$1" | sort | uniq
  22. }
  23. log=$("$bindir"/get_one.sh "$base_dir" "$id")
  24. dir="$base_dir/$id"
  25. running=0
  26. for id in $(get_ids "$log" ); do
  27. if [ "$running" -gt 32 ]; then
  28. echo >&2 waiting $running
  29. wait -n
  30. running=$(($running - 1))
  31. fi
  32. echo >&2 getting $id
  33. "$bindir"/get_one.sh "$dir" "$id" &
  34. running=$(($running + 1))
  35. done
  36. while [ "$running" -gt 0 ]; do
  37. echo >&2 waiting $running
  38. wait -n
  39. running=$(($running - 1))
  40. done