blob: 45fd1cc9777abb82ae5702eb81f7a528b4422fc1 [file] [log] [blame]
# 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
service_action stop
${AUTOTEST_DIR}/frontend/ dbshell <<END
DROP DATABASE chromeos_autotest_db;
CREATE DATABASE chromeos_autotest_db;
${AUTOTEST_DIR}/database/ sync -f
${AUTOTEST_DIR}/frontend/ syncdb --noinput
${AUTOTEST_DIR}/frontend/ syncdb --noinput
sudo rm -rf ${AUTOTEST_DIR}/results/*
sudo rm -rf ${AUTOTEST_DIR}/logs/*
service_action start