Skip to content

Commit

Permalink
Have database point to postgres 14 on n local host if running LAVA lo…
Browse files Browse the repository at this point in the history
…cally
  • Loading branch information
AndrewQuijano committed Aug 10, 2024
1 parent 646276a commit 1883c6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/lava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ RESET_DB() {
lf="$logs/dbwipe.log"
truncate "$lf"
progress "everything" 1 "Resetting lava db -- logging to $lf"
run_remote "$buildhost" "dropdb -U postgres -h database $db || true" "$lf"
run_remote "$buildhost" "createdb -U postgres -h database $db || true" "$lf"
run_remote "$buildhost" "psql -d $db -h database -f $lava/tools/lavaODB/generated/lava.sql -U postgres" "$lf"
run_remote "$buildhost" "dropdb -U postgres -h $dbhost $db || true" "$lf"
run_remote "$buildhost" "createdb -U postgres -h $dbhost $db || true" "$lf"
run_remote "$buildhost" "psql -d $db -h $dbhost -f $lava/tools/lavaODB/generated/lava.sql -U postgres" "$lf"
run_remote "$buildhost" "echo dbwipe complete" "$lf"
}

Expand Down Expand Up @@ -211,7 +211,7 @@ if [ $taint -eq 1 ]; then
# If we didn't just reset the DB, we need clear out any existing taint labels before running FBI
progress "everything" 1 "Clearing taint data from DB"
lf="$logs/dbwipe_taint.log"
run_remote "$buildhost" "psql -U postgres -h database -c \"delete from dua_viable_bytes; delete from labelset;\" $db" "$lf"
run_remote "$buildhost" "psql -U postgres -h $dbhost -c \"delete from dua_viable_bytes; delete from labelset;\" $db" "$lf"
fi
progress "everything" 1 "Taint step -- running panda and fbi"
for input in $inputs
Expand All @@ -222,14 +222,14 @@ if [ $taint -eq 1 ]; then
progress "everything" 1 "PANDA taint analysis prospective bug mining -- input $input -- logging to $lf"
run_remote "$buildhost" "$python $scripts/bug_mining.py $hostjson $project_name $input $curtail" "$lf"
echo -n "Num Bugs in db: "
bug_count=$(run_remote "$buildhost" "psql -At $db -U postgres -h database -c 'select count(*) from bug'")
bug_count=$(run_remote "$buildhost" "psql -At $db -U postgres -h $dbhost -c 'select count(*) from bug'")
if [ "$bug_count" = "0" ]; then
echo "FATAL ERROR: no bugs found"
exit 1
fi
echo "Found $bug_count bugs"
echo
run_remote "$buildhost" "psql $db -U postgres -h database -c 'select count(*), type from bug group by type order by type'"
run_remote "$buildhost" "psql $db -U postgres -h $dbhost -c 'select count(*), type from bug group by type order by type'"
done
tock
echo "bug_mining complete $time_diff seconds"
Expand Down
5 changes: 5 additions & 0 deletions scripts/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ scripts="$lava/scripts"
python="/usr/bin/python3"
pdb="/usr/bin/python3 -m pdb "
dockername="lava32"

db_host="database"
if [ "$buildhost" = "localhost" ]; then
dbhost="/var/run/postgresql/14-main.pg_stat_tmp"
fi

0 comments on commit 1883c6b

Please sign in to comment.