Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
74 changes: 2 additions & 72 deletions tests/alias.test/runit
Original file line number Diff line number Diff line change
@@ -1,73 +1,3 @@
#!/usr/bin/env bash
bash -n "$0" | exit 1
#!/bin/bash

# remote db config
REM_CDB2_OPTIONS="--cdb2cfg ${SECONDARY_CDB2_CONFIG}"

output=run.log
echo "Populating remote database" >> $output
cdb2sql --tabs ${REM_CDB2_OPTIONS} $SECONDARY_DBNAME default - >> $output 2>&1 << EOF
create table t1(a int)\$\$
insert into t1 select * from generate_series(1,10)
EOF

echo "Creating aliases" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
put alias t1_alias1 'LOCAL_${SECONDARY_DBNAME}.t1'
put alias t1_alias2 'LOCAL_${SECONDARY_DBNAME}.t1'
put alias t1_alias3 'LOCAL_${SECONDARY_DBNAME}.t1'
exec procedure sys.cmd.send('stat alias')
EOF

echo "Trying to overwrite alias should fail" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
put alias t1_alias1 'LOCAL_${SECONDARY_DBNAME}.blah'
EOF

echo "Create alias to non-existent remote table should succeed" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
put alias invalid_alias 'LOCAL_${SECONDARY_DBNAME}.blah'
select * from invalid_alias
EOF

echo "Select using alias name" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
select * from t1_alias1
select * from t1_alias2
select * from t1_alias3
EOF


echo "Dropping an alias" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
put alias t1_alias1 ''
exec procedure sys.cmd.send('stat alias')
EOF

echo "Select using deleted alias" >> $output
cdb2sql --tabs ${CDB2_OPTIONS} $DBNAME default - >> $output 2>&1 << EOF
select * from t1_alias1
EOF

#get rid of remdb name
sed "s/${SECONDARY_DBNAME}/remdb/g" $output > run.log.actual

testcase_output=$(cat run.log.actual)
expected_output=$(cat output.log.actual)
if [[ "$testcase_output" != "$expected_output" ]]; then

# print message
echo " ^^^^^^^^^^^^"
echo "The above testcase (${testcase}) has failed!!!"
echo " "
echo "Use 'diff <expected-output> <my-output>' to see why:"
echo "> diff ${PWD}/{output.log.actual,run.log.actual}"
echo " "
diff output.log.actual run.log.actual
echo " "

# quit
exit 1
fi

echo "Testcase passed."
exit 0
33 changes: 2 additions & 31 deletions tests/allow_incoherent_sql.test/runit
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
#!/usr/bin/env bash
bash -n "$0" | exit 1
#!/bin/bash

set -e

[ -z "${CLUSTER}" ] && { echo "Test only suitable for a clustered setup"; exit 0; }

# Force a replicant to go incoherent
master=`cdb2sql --tabs ${CDB2_OPTIONS} ${DBNAME} default 'exec procedure sys.cmd.send("bdb cluster")' | grep MASTER | awk '{print $1}' | cut -d':' -f1`
host=`cdb2sql --tabs ${CDB2_OPTIONS} ${DBNAME} default 'select comdb2_host()'`
cdb2sql ${CDB2_OPTIONS} ${DBNAME} --host $host 'exec procedure sys.cmd.send("on rep_delay")'
cdb2sql ${CDB2_OPTIONS} ${DBNAME} --host $master 'exec procedure sys.cmd.send("pushnext")'

set +e
for i in `seq 1 60`; do
cdb2sql ${CDB2_OPTIONS} ${DBNAME} --host $master 'exec procedure sys.cmd.send("bdb cluster")' | grep $host | grep -i incoherent
if [ $? = 0 ]; then
break
fi
sleep 1
done

cdb2sql ${CDB2_OPTIONS} ${DBNAME} --host $master 'exec procedure sys.cmd.send("bdb cluster")' | grep $host | grep -i incoherent
if [ $? != 0 ]; then
echo 'Took too long to go incoherent!' >&2
exit 1
fi

set -e
# Because we specifically allow running a query on an incoherent node,
# the command below should succeed.
cdb2sql ${CDB2_OPTIONS} ${DBNAME} --host $host 'SELECT 1'
exit 0
225 changes: 2 additions & 223 deletions tests/analyze.test/runit
Original file line number Diff line number Diff line change
@@ -1,224 +1,3 @@
#!/usr/bin/env bash
bash -n "$0" | exit 1
#!/bin/bash

source $TESTSROOTDIR/tools/runstepper.sh

# debug=1

# args
a_dbn=$1

TMPDIR=${TMPDIR:-/tmp}
export PATH=${PATH}:.

# find input files
files=$( find . -type f -name \*.req | sort )

# counter
nfiles=0

# last batch
last_batch=

# post-process
pproc=cat

# testcase output
testcase_output=

# expected output
expected_output=

# fastinit
function fastinit
{
# print debug trace
[[ "$debug" == "1" ]] && set -x

# args
typeset db=$1
typeset iter=$2
typeset tbl

# flagged?
if [[ ! -f $iter.fastinit ]]; then
return 0
fi

# fastinit
for tbl in $(cat $iter.fastinit) ; do
echo "$CDB2SQL_EXE ${CDB2_OPTIONS} $db default \"truncate $tbl\""
$CDB2SQL_EXE ${CDB2_OPTIONS} $db default "truncate $tbl"
done

return 0
}


# run tool
function runtool
{
# print debug trace
[[ "$debug" == "1" ]] && set -x

# args
typeset tool=$1
typeset args=$2
typeset db=$3
typeset log=$4

# run
echo "> $tool \"$args\" $db > $log 2>&1"
$tool "$args" $db > $log 2>&1
}

function comdb2dumpcsc {
$CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $a_dbn default "select name from sqlite_master where type='table' and name not like '%sqlite_stat%'"
}

function init {
for table in $(comdb2dumpcsc ); do
$CDB2SQL_EXE ${CDB2_OPTIONS} $a_dbn default "drop table $table"
done
$CDB2SQL_EXE ${CDB2_OPTIONS} $a_dbn default 'create table t1 {
schema
{
int a
int b
int c
int d
}

keys
{
dup "a" = a
dup "b" = b
dup "c" = c
dup "d" = d
}
}
'
$CDB2SQL_EXE ${CDB2_OPTIONS} $a_dbn default 'create table t2 {
schema
{
int a
int b
int c
int d
}

keys
{
dup "ab" = a + b
dup "bc" = b + c
dup "cd" = c + d
}
}
'
$CDB2SQL_EXE ${CDB2_OPTIONS} $a_dbn default 'create table t3 {
schema
{
int a
int b
int c
int d
}

keys
{
dup "abc" = a + b + c
dup "bcd" = b + c + d
}
}
'
}


init


# Iterate through input files
for testcase in $files ; do

# increment counter
let nfiles=nfiles+1

# cleanup testcase
testcase=${testcase##*/}

# see if the prefix has changed
new_batch=${testcase%%_*}

# set output
output=$testcase.res

# fastinit if requested
if [[ $new_batch != $last_batch ]] ; then

fastinit $a_dbn $new_batch
last_batch=$new_batch

fi

# Check for run-stepper
if [[ -f $new_batch.runstepper ]] ; then

runstepper $a_dbn $testcase $output 1

elif [[ -f $new_batch.tool ]] ; then

tool=$( cat $new_batch.tool )
args=$( cat $new_batch.args )
runtool $tool "$args" $a_dbn $output

else

# Be verbose
cmd="$CDB2SQL_EXE ${CDB2_OPTIONS} $a_dbn default - < $testcase > $output 2>&1"
echo $cmd

# run command
eval $cmd

fi

# post-process
if [[ -f $new_batch.post ]]; then

# zap file
> $output.postprocess

# collect post-processing tool
pproc=$(cat $new_batch.post)

# post-process output
$pproc $output >> $output.postprocess

# copy post-processed output to original
mv $output.postprocess $output
fi

# get testcase output
testcase_output=$(cat $output)

# get expected output
expected_output=$(cat $testcase.out)

# verify
if [[ "$testcase_output" != "$expected_output" ]]; then
# print message
echo " ^^^^^^^^^^^^"
echo "The above testcase (${testcase}) has failed!!!"
echo " "
echo "Use 'diff <expected-output> <my-output>' to see why:"
echo "> diff ${PWD}/{$testcase.out,$output}"
echo " "
diff $testcase.out $output
echo " "
exit 1

fi

done

echo "Testcase passed."
exit 0
27 changes: 2 additions & 25 deletions tests/analyze_exit.test/runit
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
# Verify that analyze commit correctly bails out on exit,
# and the database does not crash.
#!/bin/bash

#!/usr/bin/env bash
bash -n "$0" | exit 1

dbnm=$1

set -e

cdb2sql ${CDB2_OPTIONS} $dbnm default 'CREATE TABLE t (i INT)'
cdb2sql ${CDB2_OPTIONS} $dbnm default 'CREATE INDEX t_i ON t(i)'

sleep 1
cdb2sql ${CDB2_OPTIONS} $dbnm default 'INSERT INTO t VALUES (1), (2), (3)'

host=`cdb2sql --tabs ${CDB2_OPTIONS} $dbnm default 'select comdb2_host()'`
cdb2sql $dbnm --host $host "exec procedure sys.cmd.send('test_delay_analyze_commit 1')"
cdb2sql $dbnm --host $host 'analyze t 100' >output.actual 2>&1 &
sleep 5

cdb2sql $dbnm --host $host 'exec procedure sys.cmd.send("exit")'

wait

diff output.actual output.expected
exit 0
Loading
Loading