#!/bin/sh ## ## TEST.sh ## Login : ## Started on Thu Nov 29 22:59:10 2007 Uli Fouquet ## $Id$ ## ## Copyright (C) 2007 Uli Fouquet ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## ## ## This is a test script, to check the scripts, that generate SQL ## compatible output from logfiles. The output can be feeded to PostGres DB. ## ## Simply run ## ## ./TEST.sh ## ## and hope that everything works. ## ## This scipt tests only the output format of scripts. It does not send ## data to the database or similar. ## PYZ2=../usr/local/lib/z2log.py PYACCESS=../usr/local/lib/zaccess-nginx.py AWKZEVENTS=../usr/local/lib/zevents.awk Z2LOG=Z2.log ACCESSLOG1=access.log ACCESSLOG2=access-staff.log EVENTLOG1=event.log EVENTLOG2=event-staff.log echo "CHECKING EVENTLOG-PARSER OUTPUT 1" cat $EVENTLOG1 | gawk -v SQL=1 -f $AWKZEVENTS > $EVENTLOG1.result diff $EVENTLOG1.test $EVENTLOG1.result RESULT=$? if [ $RESULT -ne 0 ]; then echo "FAILED" echo "Expected output in "$EVENTLOG1.test echo "Wrong output in "$EVENTLOG1.result else echo "OK" fi echo "CHECKING EVENTLOG-PARSER OUTPUT 2" cat $EVENTLOG2 | gawk -v SQL=1 -f $AWKZEVENTS > $EVENTLOG2.result diff $EVENTLOG2.test $EVENTLOG2.result RESULT=$? if [ $RESULT -ne 0 ]; then echo "FAILED" echo "Expected output in "$EVENTLOG2.test echo "Wrong output in "$EVENTLOG2.result else echo "OK" fi echo "CHECKING Z2-LOG-PARSER OUTPUT" cat $Z2LOG | python $PYZ2 > $Z2LOG.result diff $Z2LOG.test $Z2LOG.result RESULT=$? if [ $RESULT -ne 0 ]; then echo "FAILED" echo "Expected output in "$Z2LOG.test echo "Wrong output in "$Z2LOG.result else echo "OK" fi echo "CHECKING ACCESSPARSER OUTPUT 1" cat $ACCESSLOG1 | python $PYACCESS > $ACCESSLOG1.result diff $ACCESSLOG1.test $ACCESSLOG1.result RESULT=$? if [ $RESULT -ne 0 ]; then echo "FAILED" echo "Expected output in "$ACCESSLOG1.test echo "Wrong output in "$ACCESSLOG1.result else echo "OK" fi echo "CHECKING ACCESSPARSER OUTPUT 2" cat $ACCESSLOG2 | python $PYACCESS > $ACCESSLOG2.result diff $ACCESSLOG2.test $ACCESSLOG2.result RESULT=$? if [ $RESULT -ne 0 ]; then echo "FAILED" else echo "OK" fi