From c7e88ff2bedcd76f6f9746b6213535e89bfc192d Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 25 Feb 2019 17:32:06 +0100 Subject: [PATCH 1/6] Add automatic backend deploy and integration test to gitlab CI --- .gitlab-ci.yml | 23 ++++++++++++++++++ contrib/scripts/backend-deploy-and-test.sh | 27 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 contrib/scripts/backend-deploy-and-test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cefeef3..c9345942 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - test + - backend-deploy-and-test build: stage: build @@ -25,3 +26,25 @@ integration-test: tags: - blockbook script: make test-integration ARGS="-run='TestIntegration/(bcash|bgold|bitcoin|dash|dogecoin|litecoin|vertcoin|zcash)=main/'" + +backend-deploy-and-test-bitcoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin bitcoin=main debug.log + +backend-deploy-and-test-bitcoin_testnet: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin_testnet.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin=test testnet3/debug.log diff --git a/contrib/scripts/backend-deploy-and-test.sh b/contrib/scripts/backend-deploy-and-test.sh new file mode 100755 index 00000000..87b8d174 --- /dev/null +++ b/contrib/scripts/backend-deploy-and-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $# -lt 1 ] +then + echo "Usage: $(basename $(readlink -f $0)) coin [coin_test] [backend log file]" 1>&2 + exit 1 +fi + +COIN=$1 +COIN_TEST=$2 +LOGFILE=$3 + +[ -z "${BACKEND_TIMEOUT}" ] && BACKEND_TIMEOUT=15s +[ -z "${COIN_TEST}" ] && COIN_TEST="${COIN}=main" +[ -z "${LOGFILE}" ] && LOGFILE=debug.log + +rm build/*.deb +make "deb-backend-${COIN}" + +PACKAGE=$(ls "./build/backend-${COIN}*.deb") +[ -z "${PACKAGE}" ] && echo "Package not found" && exit 1 + +sudo /usr/bin/dpkg -i "${PACKAGE}" || exit 1 +sudo /bin/systemctl restart "backend-${COIN}" || exit 1 +timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" +make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" + From e7fc52760ebb60c0f6a2fadaacb8ad84cd039a0a Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 25 Feb 2019 18:40:12 +0100 Subject: [PATCH 2/6] Add service name to backend deploy and integration test --- .gitlab-ci.yml | 4 ++-- contrib/scripts/backend-deploy-and-test.sh | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9345942..2cdd1e72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,7 @@ backend-deploy-and-test-bitcoin: - configs/coins/bitcoin.json tags: - blockbook - script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin bitcoin=main debug.log + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin backend-deploy-and-test-bitcoin_testnet: stage: backend-deploy-and-test @@ -47,4 +47,4 @@ backend-deploy-and-test-bitcoin_testnet: - configs/coins/bitcoin_testnet.json tags: - blockbook - script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin=test testnet3/debug.log + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin-testnet bitcoin=test testnet3/debug.log diff --git a/contrib/scripts/backend-deploy-and-test.sh b/contrib/scripts/backend-deploy-and-test.sh index 87b8d174..9eff289c 100755 --- a/contrib/scripts/backend-deploy-and-test.sh +++ b/contrib/scripts/backend-deploy-and-test.sh @@ -1,27 +1,33 @@ #!/bin/bash -if [ $# -lt 1 ] +if [ $# -ne 1 ] && [ $# -ne 4 ] then - echo "Usage: $(basename $(readlink -f $0)) coin [coin_test] [backend log file]" 1>&2 + echo -e "Usage:\n\n$(basename $(readlink -f $0)) coin service_name coin_test backend_log_file\n\nor\n\n$(basename $(readlink -f $0)) coin\nin which case service_name, coin_test and backend_log_file are derived from coin or default" 1>&2 exit 1 fi COIN=$1 -COIN_TEST=$2 -LOGFILE=$3 +SERVICE=$2 +COIN_TEST=$3 +LOGFILE=$4 [ -z "${BACKEND_TIMEOUT}" ] && BACKEND_TIMEOUT=15s +[ -z "${SERVICE}" ] && SERVICE="${COIN}" [ -z "${COIN_TEST}" ] && COIN_TEST="${COIN}=main" [ -z "${LOGFILE}" ] && LOGFILE=debug.log +echo "Running: $(basename $(readlink -f $0)) ${COIN} ${SERVICE} ${COIN_TEST} ${LOGFILE}" + rm build/*.deb make "deb-backend-${COIN}" -PACKAGE=$(ls "./build/backend-${COIN}*.deb") +PACKAGE=$(ls ./build/backend-${SERVICE}*.deb) [ -z "${PACKAGE}" ] && echo "Package not found" && exit 1 sudo /usr/bin/dpkg -i "${PACKAGE}" || exit 1 -sudo /bin/systemctl restart "backend-${COIN}" || exit 1 -timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" -make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" +sudo /bin/systemctl restart "backend-${SERVICE}" || exit 1 +echo "Waiting for backend startup for ${BACKEND_TIMEOUT}" +timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" + +make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" From 9382c7a9c0a9eb2e5cb761ea17bb34787b07d564 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 25 Feb 2019 17:32:06 +0100 Subject: [PATCH 3/6] Add automatic backend deploy and integration test to gitlab CI --- .gitlab-ci.yml | 23 ++++++++++++++++++ contrib/scripts/backend-deploy-and-test.sh | 27 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 contrib/scripts/backend-deploy-and-test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cefeef3..c9345942 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - test + - backend-deploy-and-test build: stage: build @@ -25,3 +26,25 @@ integration-test: tags: - blockbook script: make test-integration ARGS="-run='TestIntegration/(bcash|bgold|bitcoin|dash|dogecoin|litecoin|vertcoin|zcash)=main/'" + +backend-deploy-and-test-bitcoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin bitcoin=main debug.log + +backend-deploy-and-test-bitcoin_testnet: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin_testnet.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin=test testnet3/debug.log diff --git a/contrib/scripts/backend-deploy-and-test.sh b/contrib/scripts/backend-deploy-and-test.sh new file mode 100755 index 00000000..87b8d174 --- /dev/null +++ b/contrib/scripts/backend-deploy-and-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $# -lt 1 ] +then + echo "Usage: $(basename $(readlink -f $0)) coin [coin_test] [backend log file]" 1>&2 + exit 1 +fi + +COIN=$1 +COIN_TEST=$2 +LOGFILE=$3 + +[ -z "${BACKEND_TIMEOUT}" ] && BACKEND_TIMEOUT=15s +[ -z "${COIN_TEST}" ] && COIN_TEST="${COIN}=main" +[ -z "${LOGFILE}" ] && LOGFILE=debug.log + +rm build/*.deb +make "deb-backend-${COIN}" + +PACKAGE=$(ls "./build/backend-${COIN}*.deb") +[ -z "${PACKAGE}" ] && echo "Package not found" && exit 1 + +sudo /usr/bin/dpkg -i "${PACKAGE}" || exit 1 +sudo /bin/systemctl restart "backend-${COIN}" || exit 1 +timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" +make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" + From bcd4b8ed4fb9f688add0915dc6046587df6d9fd2 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 25 Feb 2019 18:40:12 +0100 Subject: [PATCH 4/6] Add service name to backend deploy and integration test --- .gitlab-ci.yml | 4 ++-- contrib/scripts/backend-deploy-and-test.sh | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9345942..2cdd1e72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,7 @@ backend-deploy-and-test-bitcoin: - configs/coins/bitcoin.json tags: - blockbook - script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin bitcoin=main debug.log + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin backend-deploy-and-test-bitcoin_testnet: stage: backend-deploy-and-test @@ -47,4 +47,4 @@ backend-deploy-and-test-bitcoin_testnet: - configs/coins/bitcoin_testnet.json tags: - blockbook - script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin=test testnet3/debug.log + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin-testnet bitcoin=test testnet3/debug.log diff --git a/contrib/scripts/backend-deploy-and-test.sh b/contrib/scripts/backend-deploy-and-test.sh index 87b8d174..9eff289c 100755 --- a/contrib/scripts/backend-deploy-and-test.sh +++ b/contrib/scripts/backend-deploy-and-test.sh @@ -1,27 +1,33 @@ #!/bin/bash -if [ $# -lt 1 ] +if [ $# -ne 1 ] && [ $# -ne 4 ] then - echo "Usage: $(basename $(readlink -f $0)) coin [coin_test] [backend log file]" 1>&2 + echo -e "Usage:\n\n$(basename $(readlink -f $0)) coin service_name coin_test backend_log_file\n\nor\n\n$(basename $(readlink -f $0)) coin\nin which case service_name, coin_test and backend_log_file are derived from coin or default" 1>&2 exit 1 fi COIN=$1 -COIN_TEST=$2 -LOGFILE=$3 +SERVICE=$2 +COIN_TEST=$3 +LOGFILE=$4 [ -z "${BACKEND_TIMEOUT}" ] && BACKEND_TIMEOUT=15s +[ -z "${SERVICE}" ] && SERVICE="${COIN}" [ -z "${COIN_TEST}" ] && COIN_TEST="${COIN}=main" [ -z "${LOGFILE}" ] && LOGFILE=debug.log +echo "Running: $(basename $(readlink -f $0)) ${COIN} ${SERVICE} ${COIN_TEST} ${LOGFILE}" + rm build/*.deb make "deb-backend-${COIN}" -PACKAGE=$(ls "./build/backend-${COIN}*.deb") +PACKAGE=$(ls ./build/backend-${SERVICE}*.deb) [ -z "${PACKAGE}" ] && echo "Package not found" && exit 1 sudo /usr/bin/dpkg -i "${PACKAGE}" || exit 1 -sudo /bin/systemctl restart "backend-${COIN}" || exit 1 -timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" -make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" +sudo /bin/systemctl restart "backend-${SERVICE}" || exit 1 +echo "Waiting for backend startup for ${BACKEND_TIMEOUT}" +timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" + +make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" From 0e7714dfd185762b6394956e5d50059ba53b334b Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Tue, 26 Feb 2019 11:05:19 +0100 Subject: [PATCH 5/6] Add automatic backend deploy and integration test for all our coins --- .gitlab-ci.yml | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cdd1e72..cd3ae980 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,28 @@ integration-test: - blockbook script: make test-integration ARGS="-run='TestIntegration/(bcash|bgold|bitcoin|dash|dogecoin|litecoin|vertcoin|zcash)=main/'" +backend-deploy-and-test-bcash: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bcash.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bcash + +backend-deploy-and-test-bgold: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bgold.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bgold + backend-deploy-and-test-bitcoin: stage: backend-deploy-and-test only: @@ -38,6 +60,61 @@ backend-deploy-and-test-bitcoin: - blockbook script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin +backend-deploy-and-test-dash: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/dash.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh dash + +backend-deploy-and-test-dogecoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/dogecoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh dogecoin + +backend-deploy-and-test-litecoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/litecoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh litecoin + +backend-deploy-and-test-vertcoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/vertcoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh vertcoin + +backend-deploy-and-test-zcash: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/zcash.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh zcash + backend-deploy-and-test-bitcoin_testnet: stage: backend-deploy-and-test only: @@ -48,3 +125,14 @@ backend-deploy-and-test-bitcoin_testnet: tags: - blockbook script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin-testnet bitcoin=test testnet3/debug.log + +backend-deploy-and-test-ethereum_testnet_ropsten: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/ethereum_testnet_ropsten.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh ethereum_testnet_ropsten ethereum-testnet-ropsten ethereum=test ethereum_testnet_ropsten.log From 22e73c44cc7c643a603e2bbde89e1981e7622082 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Tue, 26 Feb 2019 11:14:22 +0100 Subject: [PATCH 6/6] Fix ethereum_testnet_ropsten integration test --- tests/rpc/rpc.go | 2 ++ tests/rpc/testdata/ethereum_testnet_ropsten.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/rpc/rpc.go b/tests/rpc/rpc.go index 6bb07233..e8722062 100644 --- a/tests/rpc/rpc.go +++ b/tests/rpc/rpc.go @@ -37,6 +37,7 @@ type TestData struct { BlockHeight uint32 `json:"blockHeight"` BlockHash string `json:"blockHash"` BlockTime int64 `json:"blockTime"` + BlockSize int `json:"blockSize"` BlockTxs []string `json:"blockTxs"` TxDetails map[string]*bchain.Tx `json:"txDetails"` } @@ -314,6 +315,7 @@ func testGetBlockHeader(t *testing.T, h *TestHandler) { Hash: h.TestData.BlockHash, Height: h.TestData.BlockHeight, Time: h.TestData.BlockTime, + Size: h.TestData.BlockSize, } got, err := h.Chain.GetBlockHeader(h.TestData.BlockHash) diff --git a/tests/rpc/testdata/ethereum_testnet_ropsten.json b/tests/rpc/testdata/ethereum_testnet_ropsten.json index a550e3f9..8584c644 100644 --- a/tests/rpc/testdata/ethereum_testnet_ropsten.json +++ b/tests/rpc/testdata/ethereum_testnet_ropsten.json @@ -2,6 +2,7 @@ "blockHeight": 2870000, "blockHash": "0xeccd6b0031015a19cb7d4e10f28590ba65a6a54ad1baa322b50fe5ad16903895", "blockTime": 1521515026, + "blockSize": 2729, "blockTxs": [ "0x17ee235fc0359155b25419e0e4c65d9c500df6e71e8288d6ef020d04cc2f2cb3", "0xe6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d", @@ -18,7 +19,6 @@ ], "txDetails": { "0x7f0d140329941f120b5b3fc751e30adeb87b2aebbfce5adcd0216604a34b6cc0": { - "hex": "7b226e6f6e6365223a223078333632306136222c226761735072696365223a223078313261303566323030222c22676173223a22307835323038222c22746f223a22307831623137626331326166623635643563346238316139666632613037366234326131396661616136222c2276616c7565223a223078646530623662336137363430303030222c22696e707574223a223078222c2268617368223a22307837663064313430333239393431663132306235623366633735316533306164656238376232616562626663653561646364303231363630346133346236636330222c22626c6f636b4e756d626572223a223078326263616630222c2266726f6d223a22307838316237653038663635626466353634383630366338393939386139636338313634333937363437222c227472616e73616374696f6e496e646578223a22307862222c2276223a2230783162222c2272223a22307862666662323864633865373939383833366639356664616139396433626435666635346365663562313839636462383537333537666161326431616231393136222c2273223a22307833616462316365313264396664306538616662373064386639346534636538356137666639346465333966623636333139363638363435663464643138646432227d", "txid": "0x7f0d140329941f120b5b3fc751e30adeb87b2aebbfce5adcd0216604a34b6cc0", "blocktime": 1521515026, "time": 1521515026,