e2e ussd import user scripts

This commit is contained in:
2021-07-19 21:30:04 +00:00
parent ed2521b582
commit d5a8b77349
5 changed files with 85 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
ETH_PROVIDER=http://eth:8545
CELERY_BROKER_URL=redis://redis:6379
CELERY_RESULT_URL=redis://redis:6379
CIC_REGISTRY_ADDRESS=0xea6225212005e86a4490018ded4bf37f3e772161
TOKEN_SYMBOL=GFT
REDIS_HOST=redis
REDIS_PORT=6379
USER_USSD_HOST=cic-user-ussd-server
USER_USSD_PORT=9000
KEYSTORE_FILE_PATH=/root/keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c

View File

@@ -0,0 +1,54 @@
#! /bin/sh
set -u
set -e
while getopts ":n:o:g:" opt; do
case $opt in
n) NUMBER_OF_USERS="$OPTARG"
;;
o) OUT_DIR="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done
# using timeout because the timeout flag for celery inspect does not work
timeout 5 celery inspect ping -b $CELERY_BROKER_URL
if [[ $? -eq 124 ]]
then
>&2 echo "Celery workers not available. Is the CELERY_BROKER_URL ($CELERY_BROKER_URL) correct?"
exit 1
fi
if [[ -d $OUT_DIR ]]
then
echo "found existing OUT_DIR cleaning up..."
rm -rf $OUT_DIR
mkdir -p $OUT_DIR
else
echo "OUT_DIR does not exist creating it."
mkdir -p $OUT_DIR
fi
echo "creating accounts"
python create_import_users.py --dir $OUT_DIR $NUMBER_OF_USERS
echo "purging existing ussd tasks..."
celery -A cic_ussd.import_task purge -Q cic-import-ussd --broker $CELERY_BROKER_URL -f
echo "running import_balance in the background..."
python cic_ussd/import_balance.py -v -c config -p $ETH_PROVIDER \
-r $CIC_REGISTRY_ADDRESS --token-symbol $TOKEN_SYMBOL -y $KEYSTORE_FILE_PATH $OUT_DIR 2>&1 &
echo "import_balance pid: $!"
echo "importing accounts"
python cic_ussd/import_users.py -vv -c config --ussd-host $USER_USSD_HOST --ussd-port $USER_USSD_PORT --ussd-no-ssl out