blob: 45fd1cc9777abb82ae5702eb81f7a528b4422fc1 [file] [log] [blame]
Jakob Juelich101a9aa2014-09-24 15:39:25 -07001#!/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
12declare -a SERVICES=("apache2" "scheduler" "host-scheduler" "shard-client"
13 "gs_offloader" "gs_offloader_s")
14AUTOTEST_DIR=$(dirname $(dirname $0))
15
16function 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
25service_action stop
26
27${AUTOTEST_DIR}/frontend/manage.py dbshell <<END
28DROP DATABASE chromeos_autotest_db;
29CREATE DATABASE chromeos_autotest_db;
30END
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
36sudo rm -rf ${AUTOTEST_DIR}/results/*
37sudo rm -rf ${AUTOTEST_DIR}/logs/*
38
39service_action start