adding changes

This commit is contained in:
2021-08-10 12:43:11 -07:00
parent 6d957eea6e
commit 68f4ed383a
9 changed files with 184 additions and 130 deletions

View File

@@ -8,3 +8,7 @@ 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
CIC_DATA_DIR=config/
OUT_DIR=out
NUMBER_OF_USERS=10
META_URL=http://cic-meta-server:63380

View File

@@ -9,7 +9,7 @@ COPY package.json \
package-lock.json \
.
RUN --mount=type=cache,mode=0755,target=/root/node_modules npm install
RUN npm ci --production
COPY requirements.txt .

View File

@@ -3,7 +3,31 @@
if [[ $((RUN_MASK & 3)) -eq 3 ]]
then
>&2 echo -e "\033[;96mRUNNING\033[;39m RUN_MASK 3 - data seeding"
./scripts/run_ussd_user_imports.sh
contract_migration_complete=0
retry_count=0
retry_sleep=30 #seconds
retry_limit="$((${TIMEOUT_MINUTES:-10}*60/2))"
while [[ $contract_migration_complete -ne 1 ]]
do
if [[ -f "$CIC_DATA_DIR/.env" ]] && grep -q CIC_DECLARATOR_ADDRESS $CIC_DATA_DIR/.env
then
echo "🤜💥🤛 data-seeding found the output of contract-migration!"
source /tmp/cic/config/.env
env
contract_migration_complete=1
./scripts/run_ussd_user_imports.sh
elif [[ $retry_count -ge $retry_limit ]]
then
echo "😢 data-seeding timeout waiting for contract migration to finish." >&2
exit 1
else
echo "⏳ data-seeding waiting for contract-migration output $retry_count:$retry_limit ..."
((retry_count= $retry_count + $retry_sleep))
sleep $retry_sleep
fi
done
if [ $? -ne "0" ]; then
>&2 echo -e "\033[;31mFAILED\033[;39m RUN_MASK 3 - data seeding"
exit 1;

View File

@@ -0,0 +1,3 @@
#! /bin/bash
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

View File

@@ -3,30 +3,6 @@
set -u
set -e
contract_migration_complete=0
retry_count=0
retry_sleep=30 #seconds
retry_limit="$((${TIMEOUT_MINUTES:-10}*60/2))"
while [[ $contract_migration_complete -ne 1 ]]
do
if [[ -f "$CIC_DATA_DIR/.env" ]] && grep -q CIC_DECLARATOR_ADDRESS $CIC_DATA_DIR/.env
then
echo "🤜💥🤛 data-seeding found the output of contract-migration!"
source /tmp/cic/config/.env
env
contract_migration_complete=1
elif [[ $retry_count -ge $retry_limit ]]
then
echo "😢 data-seeding timeout waiting for contract migration to finish." >&2
exit 1
else
echo "⏳ data-seeding waiting for contract-migration output $retry_count:$retry_limit ..."
((retry_count= $retry_count + $retry_sleep))
sleep $retry_sleep
fi
done
while getopts ":n:o:g:" opt; do
case $opt in
@@ -66,14 +42,24 @@ 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 &
#nohup 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 > nohup.out 2> nohup.err < /dev/null &
#nohup 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
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
sleep 3600
echo "data importing finished!"
echo "run verify manually:"
echo "python verify.py -v -c config -r $CIC_REGISTRY_ADDRESS -p $ETH_PROVIDER --token-symbol $TOKEN_SYMBOL $OUT_DIR"

View File

@@ -154,21 +154,25 @@ for t in custodial_tests:
logg.info('activating custodial module'.format(t))
break
cols = os.get_terminal_size().columns
def to_terminalwidth(s):
ss = s.ljust(int(cols)-1)
ss += "\r"
return ss
def default_outfunc(s):
ss = to_terminalwidth(s)
sys.stdout.write(ss)
outfunc = default_outfunc
if logg.isEnabledFor(logging.DEBUG):
outfunc = logg.debug
#cols = os.get_terminal_size().columns
##disabled because:
#data-seeding_1 | Traceback (most recent call last):
#data-seeding_1 | File "verify.py", line 157, in <module>
#data-seeding_1 | cols = os.get_terminal_size().columns
#data-seeding_1 | OSError: [Errno 25] Inappropriate ioctl for device
#contract-migration_1 | DEBUG:create_account_script:register False
#def to_terminalwidth(s):
# ss = s.ljust(int(cols)-1)
# ss += "\r"
# return ss
#
#def default_outfunc(s):
# ss = to_terminalwidth(s)
# sys.stdout.write(ss)
#outfunc = default_outfunc
#if logg.isEnabledFor(logging.DEBUG):
outfunc = logg.debug
def send_ussd_request(address, data_dir):
upper_address = strip_0x(address).upper()