parent
b4a3e565e8
commit
3327d590a6
@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kill redis
|
||||
sudo killall redis-server
|
||||
# Drop all databases
|
||||
databases=$(psql -U postgres -t -c "select datname from pg_database where datname like 'carto_db_test_%'")
|
||||
touch databases.log
|
||||
echo $databases >> databases.log
|
||||
touch databases_new.log
|
||||
sed -e 's/\s\+/\n/g' databases.log > databases_new.log
|
||||
|
||||
while read -r line
|
||||
do
|
||||
psql -U postgres -t -c "drop database $line" >> cleaner.log
|
||||
done < databases_new.log
|
||||
|
||||
|
||||
# Drop all user databases
|
||||
databases=$(psql -U postgres -t -c "select datname from pg_database where datname like 'cartodb_test_user_%'")
|
||||
touch user_databases.log
|
||||
echo $databases >> user_databases.log
|
||||
touch user_databases_new.log
|
||||
sed -e 's/\s\+/\n/g' user_databases.log > user_databases_new.log
|
||||
|
||||
while read -r line
|
||||
do
|
||||
psql -U postgres -t -c "drop database \"$line\"" >> cleaner.log
|
||||
done < user_databases_new.log
|
||||
|
||||
rm user_databases.log
|
||||
rm users_databases_new.log
|
||||
|
||||
# Drop all testing databases
|
||||
databases=$(psql -U postgres -t -c "select datname from pg_database where datname like 'cartodb_user_%'")
|
||||
touch user_databases.log
|
||||
echo $databases >> user_databases.log
|
||||
touch user_databases_new.log
|
||||
sed -e 's/\s\+/\n/g' user_databases.log > user_databases_new.log
|
||||
|
||||
while read -r line
|
||||
do
|
||||
psql -U postgres -t -c "drop database \"$line\"" >> cleaner.log
|
||||
done < user_databases_new.log
|
||||
|
||||
# Cleanup
|
||||
rm databases.log
|
||||
rm databases_new.log
|
||||
rm user_databases.log
|
||||
rm users_databases_new.log
|
||||
|
||||
echo "# Cleaner finished"
|
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Jesus Vazquez
|
||||
# executor.sh: This scripts executes the rspec recieved by param and stores it in specsuccess.log or specfailed.log
|
||||
# depending on the execution result.
|
||||
|
||||
lock() {
|
||||
touch config/$1.lock;
|
||||
}
|
||||
|
||||
unlock() {
|
||||
rm config/$1 >> executor.log 2>&1;
|
||||
}
|
||||
|
||||
# Return first database.yml free
|
||||
redis_file() {
|
||||
for redisfile in $(ls config -1| grep -v 'lock' | grep redis)
|
||||
do
|
||||
if [ ! -f config/$redisfile.lock ]; then
|
||||
# echo $redisfile;
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
fecha=$(date)
|
||||
# (hack) Choose a redis port for the execution
|
||||
redis_file
|
||||
# Lock the redis file
|
||||
lock $redisfile;
|
||||
|
||||
# Choose redis-server port
|
||||
port=$(cat config/$redisfile)
|
||||
|
||||
# Run the rspec
|
||||
# Some dirty logic here
|
||||
if [[ $1 == *"services/importer"* ]] || [[ $1 == *"services/platform-limits/spec/unit/"* ]] || [[ $1 == *"services/wms/spec/unit/wms_spec.rb"* ]] || [[ $1 == *"services/datasources"* ]] || [[ $1 == *"spec/models/overlay/collection_spec.rb"* ]]; then
|
||||
RAILS_ENV=test PARALLEL=true RAILS_DATABASE_FILE=database_${2}.yml REDIS_PORT=$port bundle exec rspec $1 >> $port.log 2>&1;
|
||||
else
|
||||
RAILS_ENV=test PARALLEL=true RAILS_DATABASE_FILE=database_${2}.yml REDIS_PORT=$port bundle exec rspec spec/rspec_configuration.rb $1 >> $port.log 2>&1;
|
||||
fi
|
||||
|
||||
# Give some feedback
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished: $1 Port: $port";
|
||||
echo "$1" >> specsuccess.log;
|
||||
else
|
||||
echo "Finished (FAILED): $1 Port: $port";
|
||||
echo "$1" >> specfailed.log;
|
||||
fi
|
||||
# Unlock file
|
||||
unlock $redisfile.lock;
|
||||
}
|
||||
|
||||
# Init
|
||||
main $1 $2];
|
||||
exit 0;
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Jesus Vazquez
|
||||
truncate -s 0 specfull.txt
|
||||
cat Makefile.parallel| grep -v '# S' | grep -v '# Pending' | grep 'rb' | sed -e 's/^\s*//' -e '/^$/d' | \
|
||||
sed '/^#/ d' | sed 's/\\//' | sed 's/\s.*$//' > temp.txt
|
||||
|
||||
i=6001;
|
||||
while read -r line
|
||||
do
|
||||
echo "$line $i" >> specfull.txt;
|
||||
i=$((i+1))
|
||||
done < temp.txt
|
||||
|
||||
echo "# Speclist has been created"
|
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Jesus Vazquez
|
||||
# reporter.sh: This script is the exit point for the tests execution. It reads from specfailed.log
|
||||
# the amount of tests that have failed. If there are none it sends a success status but if there are
|
||||
# 1 or more it sends a failure status to warn the developer
|
||||
|
||||
filename="specfailed.log"
|
||||
|
||||
lines=$(cat $filename | wc -l)
|
||||
|
||||
if [ "$lines" -eq "0" ];
|
||||
then
|
||||
echo "Tests were OK";
|
||||
# TODO
|
||||
# gsu "Backend tests were OK" "Backend" success
|
||||
exit 0; #OK
|
||||
else
|
||||
while read line;
|
||||
do
|
||||
# For each error cat its log file
|
||||
logfile=$(echo $line | grep -o '[0-9][0-9][0-9][0-9].log')
|
||||
# cat $logfile;
|
||||
# Give feedback to github
|
||||
# spec=$(echo $line | sed 's/\s.*$//')
|
||||
# echo "GSU with spec $spec" TODO
|
||||
# gsu "$spec failed" "$spec" failure TODO
|
||||
|
||||
done < $filename
|
||||
# TODO
|
||||
# gsu "Backend tests failed" "Backend" failure
|
||||
exit 1; # ERROR
|
||||
fi
|
||||
|
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Jesus Vazquez
|
||||
# secondTry
|
||||
# This is a hack for those specs that failed in the parallel execution.
|
||||
# Here we can check if they failed because they can't run in parallel
|
||||
# or because the PR code is wrong
|
||||
|
||||
# Requisites
|
||||
cp config/database.yml.sample config/database.yml
|
||||
|
||||
# Start
|
||||
failedSpecs=$(cat specfailed.log | wc -l)
|
||||
|
||||
if [ "$failedSpecs" -eq "0" ];
|
||||
then
|
||||
exit 0;
|
||||
else
|
||||
specs=$(cat specfailed.log | sed ':a;N;$!ba;s/\n/ /g')
|
||||
fi
|
||||
|
||||
echo "Giving a second try to the next specs"
|
||||
cat specfailed.log
|
||||
|
||||
RAILS_ENV=test bundle exec rspec $specs
|
||||
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
truncate -s 0 specfailed.log # Here is where the hack takes place. If im the second try we dont have errors then we're OK
|
||||
else
|
||||
exit 0; # The reporter script will output the failed specs
|
||||
fi
|
@ -1,80 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Jesus Vazquez
|
||||
# wrapper.sh: This script creates as much database.yml configuration files as we specify by param. It also
|
||||
# starts redis server on database.yml specified port.
|
||||
rm config/database_*
|
||||
rm config/redis_*
|
||||
#sudo killall redis-server
|
||||
truncate -s 0 *.log
|
||||
|
||||
# Start redis servers
|
||||
port=6001
|
||||
for i in $(seq 1 $1);
|
||||
do
|
||||
# Start redis server
|
||||
if [ ! -d "/tmp/redis-$port" ]; then
|
||||
mkdir /tmp/redis-$port
|
||||
fi
|
||||
touch redis.conf.test
|
||||
truncate -s 0 redis.conf.test
|
||||
echo "port $port" >> redis.conf.test
|
||||
echo "daemonize yes" >> redis.conf.test
|
||||
echo "pidfile /tmp/redis-test-$port.tmp" >> redis.conf.test
|
||||
echo "timeout 300" >> redis.conf.test
|
||||
echo "dbfilename redis_test.rdb" >> redis.conf.test
|
||||
echo "dir /tmp/redis-$port" >> redis.conf.test
|
||||
echo "loglevel debug" >> redis.conf.test
|
||||
echo "logfile /tmp/redis-$port/stdout" >> redis.conf.test
|
||||
cat redis.conf.test | redis-server - 2>&1
|
||||
rm redis.conf.test
|
||||
touch config/redis_$port;
|
||||
echo $port >> config/redis_$port;
|
||||
sleep 0.5; # Let redis server start
|
||||
|
||||
# Increase port
|
||||
port=$((port+1))
|
||||
done;
|
||||
if [ ! -d "/tmp/redis-6335" ]; then
|
||||
mkdir /tmp/redis-6335
|
||||
fi
|
||||
|
||||
# Start default redis on port 6335
|
||||
touch redis.conf.test
|
||||
truncate -s 0 redis.conf.test
|
||||
echo "port 6335" >> redis.conf.test
|
||||
echo "daemonize yes" >> redis.conf.test
|
||||
echo "pidfile /tmp/redis-test-6335.tmp" >> redis.conf.test
|
||||
echo "timeout 300" >> redis.conf.test
|
||||
echo "dbfilename redis_test.rdb" >> redis.conf.test
|
||||
echo "dir /tmp/redis-6335" >> redis.conf.test
|
||||
echo "loglevel debug" >> redis.conf.test
|
||||
echo "logfile /tmp/redis-6335/stdout" >> redis.conf.test
|
||||
cat redis.conf.test | redis-server - 2>&1
|
||||
rm redis.conf.test
|
||||
# ps -eaf | grep -v "grep" | grep redis-server >> wrapper.log 2>&1
|
||||
|
||||
# Create databases
|
||||
|
||||
# Read database name
|
||||
databaseName="carto_db_test"
|
||||
dbAdmin="postgres"
|
||||
specCount=$(cat specfull.txt | wc -l)
|
||||
specCount=$((specCount+6000))
|
||||
startPort=6001
|
||||
# Iterate and create one database per spec
|
||||
for j in $(seq $startPort $specCount)
|
||||
do
|
||||
# Get database owner
|
||||
owner=$(psql -U $dbAdmin -t -c "select r.rolname from pg_database d, pg_roles r where d.datname='carto_db_test' and d.datdba = r.oid")
|
||||
newDatabase="${databaseName}_${j}";
|
||||
# Create the database with specific owner and template
|
||||
$(psql -U $dbAdmin -t -c "create database $newDatabase with owner $owner template $databaseName;") >> wrapper.log 2>&1
|
||||
# Create the database.yml file
|
||||
echo "# Creating database_$j.yml file" >> wrapper.log 2>&1
|
||||
sed -e s/carto_db_test/carto_db_test_$j/g config/database.yml.sample > config/database_$j.yml
|
||||
done
|
||||
|
||||
touch specfailed.log
|
||||
touch specsuccess.log
|
||||
echo "# Wrapper finished"
|
||||
|
Loading…
Reference in new issue