github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/contrib/scripts/goldendata-queries.sh (about) 1 #!/bin/bash 2 3 pushd $GOPATH/src/github.com/dgraph-io/dgraph/contrib/scripts/queries &> /dev/null 4 5 function run_index_test { 6 local max_attempts=${ATTEMPTS-5} 7 local timeout=${TIMEOUT-1} 8 local attempt=0 9 local exitCode=0 10 11 X=$1 12 GREPFOR=$2 13 ANS=$3 14 echo "Running test: ${X}" 15 while (( $attempt < $max_attempts )) 16 do 17 set +e 18 N=`curl -s -H 'Content-Type: application/graphql+-' localhost:8180/query -XPOST -d @${X}.in` 19 exitCode=$? 20 21 set -e 22 23 if [[ $exitCode == 0 ]] 24 then 25 break 26 fi 27 28 echo "Failure! Retrying in $timeout.." 1>&2 29 sleep $timeout 30 attempt=$(( attempt + 1 )) 31 timeout=$(( timeout * 2 )) 32 done 33 34 NUM=$(echo $N | python -m json.tool | grep $GREPFOR | wc -l) 35 if [[ ! "$NUM" -eq "$ANS" ]]; then 36 echo "Index test failed: ${X} Expected: $ANS Got: $NUM" 37 exit 1 38 else 39 echo -e "Index test passed: ${X}\n" 40 fi 41 } 42 43 echo -e "Running some queries and checking count of results returned." 44 run_index_test basic name 138676 45 run_index_test allof_the name 25431 46 run_index_test allof_the_a name 367 47 run_index_test allof_the_first name 4383 48 run_index_test releasedate release_date 137858 49 run_index_test releasedate_sort release_date 137858 50 run_index_test releasedate_sort_first_offset release_date 2315 51 run_index_test releasedate_geq release_date 60991 52 run_index_test gen_anyof_good_bad name 1103 53 54 popd &> /dev/null 55