Home | History | Annotate | Download | only in site_utils
      1 #!/bin/bash
      2 #
      3 # Copyright 2014 The Chromium OS Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 # The purpose of this script is to be able to reset an autotest instance.
      8 # This means cleaning up the database and all log and results files.
      9 # The main use case for this is if the master ever fails and all shards need to
     10 # be reset.
     11 
     12 declare -a SERVICES=("apache2" "scheduler" "host-scheduler" "shard-client"
     13                      "gs_offloader" "gs_offloader_s")
     14 AUTOTEST_DIR=$(dirname $(dirname $0))
     15 
     16 function service_action {
     17   local s
     18   for s in "${SERVICES[@]}"; do
     19     if [[ -e "/etc/init/$s.conf" || -e "/etc/init.d/$s" ]]; then
     20       sudo service $s $1
     21     fi
     22   done
     23 }
     24 
     25 service_action stop
     26 
     27 ${AUTOTEST_DIR}/frontend/manage.py dbshell <<END
     28 DROP DATABASE chromeos_autotest_db;
     29 CREATE DATABASE chromeos_autotest_db;
     30 END
     31 
     32 ${AUTOTEST_DIR}/database/migrate.py sync -f
     33 ${AUTOTEST_DIR}/frontend/manage.py syncdb --noinput
     34 ${AUTOTEST_DIR}/frontend/manage.py syncdb --noinput
     35 
     36 sudo rm -rf ${AUTOTEST_DIR}/results/*
     37 sudo rm -rf ${AUTOTEST_DIR}/logs/*
     38 
     39 service_action start
     40