ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
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
#!/bin/bash
#
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
 
# The purpose of this script is to be able to reset an autotest instance.
# This means cleaning up the database and all log and results files.
# The main use case for this is if the master ever fails and all shards need to
# be reset.
 
declare -a SERVICES=("apache2" "scheduler" "host-scheduler" "shard-client"
                     "gs_offloader" "gs_offloader_s")
AUTOTEST_DIR=$(dirname $(dirname $0))
 
function service_action {
  local s
  for s in "${SERVICES[@]}"; do
    if [[ -e "/etc/init/$s.conf" || -e "/etc/init.d/$s" ]]; then
      sudo service $s $1
    fi
  done
}
 
service_action stop
 
${AUTOTEST_DIR}/frontend/manage.py dbshell <<END
DROP DATABASE chromeos_autotest_db;
CREATE DATABASE chromeos_autotest_db;
END
 
${AUTOTEST_DIR}/database/migrate.py sync -f
${AUTOTEST_DIR}/frontend/manage.py syncdb --noinput
${AUTOTEST_DIR}/frontend/manage.py syncdb --noinput
 
sudo rm -rf ${AUTOTEST_DIR}/results/*
sudo rm -rf ${AUTOTEST_DIR}/logs/*
 
service_action start