e2e.sh 3.41 KB
Newer Older
1
2
3
4
5
#!/usr/bin/env bash

set -e

#Always compile ytsync
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
6
make
7
8
9
10
11

#OVERRIDE this in your .env file if running from mac. Check docker-compose.yml for details
export LOCAL_TMP_DIR="/var/tmp"

#Private Variables Set in local installations: SLACK_TOKEN,YOUTUBE_API_KEY,AWS_S3_ID,AWS_S3_SECRET,AWS_S3_REGION,AWS_S3_BUCKET
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
12
touch -a .env && set -o allexport; source ./.env; set +o allexport
13
14
15
16
17
18
19
20
21
22
23
24
echo "LOCAL_TMP_DIR=$LOCAL_TMP_DIR"
# Compose settings - docker only
export SLACK_CHANNEL="ytsync-travis"
export LBRY_API_TOKEN="ytsyntoken"
export LBRY_WEB_API="http://localhost:15400"
export LBRYNET_ADDRESS="http://localhost:15100"
export LBRYCRD_STRING="tcp://lbry:lbry@localhost:15200"
export LBRYNET_USE_DOCKER=true
export REFLECT_BLOBS=false
export CLEAN_ON_STARTUP=true
export REGTEST=true
# Local settings
ci's avatar
ci committed
25
26
27
export BLOBS_DIRECTORY="$(pwd)/e2e/blobsfiles"
export LBRYNET_DIR="$(pwd)/e2e/persist/.lbrynet/.local/share/lbry/lbrynet/"
export LBRYNET_WALLETS_DIR="$(pwd)/e2e/persist/.lbrynet/.local/share/lbry/lbryum"
28
29
export TMP_DIR="/var/tmp"

ci's avatar
ci committed
30
#ensure that docker can be run and managed from the user
ci's avatar
ci committed
31
USER=$(whoami)
ci's avatar
ci committed
32
33
sudo usermod -aG docker "$USER"

Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
34
cd ./e2e
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
35
36
37
38
docker-compose stop
docker-compose rm -f
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
docker-compose pull
ci's avatar
ci committed
39
if [[ -d persist ]]; then rm -rf persist; fi
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
40
mkdir persist
ci's avatar
ci committed
41
mkdir -p blobsfiles
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
42
mkdir persist/.lbrynet
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
43
ls -lha ./persist
ci's avatar
ci committed
44
chmod u+rwx ./persist/.lbrynet
45
docker-compose up -d
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
46
printf 'waiting for internal apis'
ci's avatar
ci committed
47
until curl --output /dev/null --silent --head --fail http://localhost:15400; do
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
48
49
50
51
    printf '.'
    sleep 1
done
echo "successfully started..."
52

ci's avatar
ci committed
53
# make sure we have permission to mess with the volumes
ci's avatar
ci committed
54
sudo find ./persist -type d -exec chmod 777 {} \;
ci's avatar
ci committed
55
sudo chown "$USER": -R ./persist
ci's avatar
ci committed
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#Data Setup for test
#Add a ytsync user
ADDYTSYNCUSER='INSERT INTO user (given_name) VALUE("ytsync user")'
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTSYNCUSER"
#Insert an auth token for the user to be used by ytsync
ADDYTSYNCAUTHTOKEN='INSERT INTO auth_token (user_id, value) VALUE(1,"ytsyntoken")'
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTSYNCAUTHTOKEN"
#Give priveledges to ytsync user
ASSIGNGROOP='INSERT INTO user_groop (user_id, groop_id) VALUE( 1,3)'
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ASSIGNGROOP"

#Add youtuber to sync
ADDYTSYNCER='INSERT INTO user (given_name) VALUE("youtuber")'
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTSYNCER"
#Add their youtube channel to be synced
ADDYTCHANNEL="INSERT INTO youtube_data (user_id, status_token,desired_lbry_channel,channel_id,channel_name,status,google_id,google_token,created_at,source,total_videos,total_subscribers)
VALUE(2,'3qzGyuVjQaf7t4pKKu2Er1NRW2LJkeWw','@beamertest','UCCyr5j8akeu9j4Q7urV0Lqw','BeamerAtLBRY','queued',$GOOGLE_ID,'$GOOGLE_TOKEN','2019-08-01 00:00:00','sync',1,0)"
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTCHANNEL"


# Execute the test!
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
78
79
80
./../bin/ytsync --channelID="UCCyr5j8akeu9j4Q7urV0Lqw" #Force channel intended...just in case. This channel lines up with the api container
# Assert the status
status=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM youtube_data WHERE id=1')
ci's avatar
ci committed
81
if [[ $status != "synced" ]]; then
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
82
83
84
85
docker-compose logs --tail="all" lbrycrd
docker-compose logs --tail="all" walletserver
docker-compose logs --tail="all" lbrynet
docker-compose logs --tail="all" internalapis
Mark Beamer Jr's avatar
ci test    
Mark Beamer Jr committed
86
 exit 1; fi;