From 77461f71af28260580f573351491433945c4f604 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Tue, 10 Dec 2019 15:45:29 -0500 Subject: [PATCH 1/2] Merge chainquery and lbry databases to account for claim table being required by internal-apis due to replication changes. --- e2e/chainqueryconfig.toml | 4 ++-- e2e/docker-compose.yml | 32 +++++++------------------------- e2e/e2e.sh | 6 +++--- e2e/init.sql | 3 +++ 4 files changed, 15 insertions(+), 30 deletions(-) create mode 100644 e2e/init.sql diff --git a/e2e/chainqueryconfig.toml b/e2e/chainqueryconfig.toml index 318a9ef..aad266f 100644 --- a/e2e/chainqueryconfig.toml +++ b/e2e/chainqueryconfig.toml @@ -13,12 +13,12 @@ lbrycrdurl="rpc://lbry:lbry@lbrycrd:29245" #MySQL DSN is required for chainquery to store information. #DEFAULT: "lbry:lbry@tcp(localhost:3306)/chainquery" #SUGGESTED: "lbry:lbry@unix(/var/run/mysqld/mysqld.sock)/chainquery" -mysqldsn="lbry:lbry@tcp(mysqlCQ:3306)/chainquery" +mysqldsn="lbry:lbry@tcp(mysql:3306)/chainquery" #API MySQL DSN is required for chainquery to expose a SQL query service #DEFAULT: "lbry:lbry@tcp(localhost:3306)/chainquery" #SUGGESTED: "lbry:lbry@unix(/var/run/mysqld/mysqld.sock)/chainquery" -apimysqldsn="lbry:lbry@tcp(mysqlCQ:3306)/chainquery" +apimysqldsn="lbry:lbry@tcp(mysql:3306)/chainquery" #API Host and Port is required for the API Server to bind and listen on. #DEFAULT: "0.0.0.0:6300" diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index ac78422..21f86af 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -80,11 +80,14 @@ services: - MYSQL_USER=lbry - MYSQL_PASSWORD=lbry - MYSQL_LOG_CONSOLE=true + volumes: + - "./init.sql:/docker-entrypoint-initdb.d/init.sql" + - "./chainquery/docker/my.cnf:/etc/mysql/conf.d/chainquery-optimizations.cnf" ################### ## Internal APIs ## ################### internalapis: - image: lbry/internal-apis:master + image: lbry/internal-apis:master #expand_publish restart: "no" ports: - "15400:8080" @@ -96,28 +99,7 @@ services: environment: - MYSQL_DSN=lbry:lbry@tcp(mysql:3306)/lbry - LBRYCRD_CONNECT=rpc://lbry:lbry@lbrycrd:29245 - - MYSQL_USER=lbry - - MYSQL_PASS=lbry - - MYSQL_DATABASE=lbry - entrypoint: wait-for-it -t 0 mysql:3306 -- wait-for-it -t 0 lbrycrd:29245 -- ./latest serve - ###################### - ## MySQL Chainquery ## - ###################### - mysqlCQ: - image: mysql/mysql-server:5.7.27 - restart: "no" - ports: - - "15600:3306" - expose: - - "3306" - environment: - - MYSQL_ALLOW_EMPTY_PASSWORD=true - - MYSQL_DATABASE=chainquery - - MYSQL_USER=lbry - - MYSQL_PASSWORD=lbry - - MYSQL_LOG_CONSOLE=true - volumes: - - "./chainquery/docker/my.cnf:/etc/mysql/conf.d/chainquery-optimizations.cnf" + entrypoint: wait-for-it -t 0 chainquery:6300 -- wait-for-it -t 0 lbrycrd:29245 -- ./latest serve ################ ## Chainquery ## ################ @@ -128,8 +110,8 @@ services: - 6300:6300 depends_on: - lbrycrd - - mysqlCQ + - mysql ## TODO: Uncomment this in a docker-compose.override.yml to allow for external configurations. volumes: - ./chainqueryconfig.toml:/etc/lbry/chainqueryconfig.toml - entrypoint: wait-for-it -t 0 lbrycrd:29245 -- wait-for-it -t 0 mysqlCQ:3306 -- start \ No newline at end of file + entrypoint: wait-for-it -t 0 lbrycrd:29245 -- wait-for-it -t 0 mysql:3306 -- start \ No newline at end of file diff --git a/e2e/e2e.sh b/e2e/e2e.sh index 3eb59c1..00b2d4e 100755 --- a/e2e/e2e.sh +++ b/e2e/e2e.sh @@ -58,8 +58,8 @@ status=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT sta videoStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM synced_video WHERE id=1') videoClaimID1=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') videoClaimID2=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') -videoClaimAddress1=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15600 -e 'SELECT claim_address FROM claim WHERE id=2') -videoClaimAddress2=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15600 -e 'SELECT claim_address FROM claim WHERE id=2') +videoClaimAddress1=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT claim_address FROM claim WHERE id=2') +videoClaimAddress2=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT claim_address FROM claim WHERE id=2') # Create Supports for published claim ./supporty/supporty @BeamerTest "${videoClaimID1}" "${videoClaimAddress1}" lbrycrd_regtest 1.0 ./supporty/supporty @BeamerTest "${videoClaimID2}" "${videoClaimAddress2}" lbrycrd_regtest 2.0 @@ -75,7 +75,7 @@ curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' 'http: # Check that the channel and the video are marked as transferred and that all supports are spent channelTransferStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT distinct transfer_state FROM youtube_data') videoTransferStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT distinct transferred FROM synced_video') -nrUnspentSupports=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15600 -e 'SELECT COUNT(*) FROM chainquery.support INNER JOIN output ON output.transaction_hash = support.transaction_hash_id AND output.vout = support.vout WHERE output.is_spent = 0') +nrUnspentSupports=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT COUNT(*) FROM chainquery.support INNER JOIN output ON output.transaction_hash = support.transaction_hash_id AND output.vout = support.vout WHERE output.is_spent = 0') if [[ $status != "synced" || $videoStatus != "published" || $channelTransferStatus != "2" || $videoTransferStatus != "1" || $nrUnspentSupports != "1" ]]; then echo "~~!!!~~~FAILED~~~!!!~~" echo "Channel Status: $status" diff --git a/e2e/init.sql b/e2e/init.sql new file mode 100644 index 0000000..9cd448b --- /dev/null +++ b/e2e/init.sql @@ -0,0 +1,3 @@ +CREATE DATABASE IF NOT EXISTS chainquery; +GRANT ALL PRIVILEGES ON chainquery.* TO 'lbry'@'%'; +FLUSH PRIVILEGES; \ No newline at end of file From f5d97957e7715fd29f8a439b2f94b00fcf27fbc7 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Tue, 10 Dec 2019 18:43:44 -0500 Subject: [PATCH 2/2] Fixed the e2e test. It wasn't checking the right claims and videos. Looks like a copy paste error. --- e2e/e2e.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/e2e.sh b/e2e/e2e.sh index 00b2d4e..e06e426 100755 --- a/e2e/e2e.sh +++ b/e2e/e2e.sh @@ -57,9 +57,9 @@ echo "successfully started..." status=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM youtube_data WHERE id=1') videoStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM synced_video WHERE id=1') videoClaimID1=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') -videoClaimID2=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') +videoClaimID2=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=2') videoClaimAddress1=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT claim_address FROM claim WHERE id=2') -videoClaimAddress2=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT claim_address FROM claim WHERE id=2') +videoClaimAddress2=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15500 -e 'SELECT claim_address FROM claim WHERE id=3') # Create Supports for published claim ./supporty/supporty @BeamerTest "${videoClaimID1}" "${videoClaimAddress1}" lbrycrd_regtest 1.0 ./supporty/supporty @BeamerTest "${videoClaimID2}" "${videoClaimAddress2}" lbrycrd_regtest 2.0