mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
Dc integration approach (#52)
* updated Dockerfile-all-in-one Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * adjusted all-in-one.bash and monit conf to work with dockerized setup Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * integration tests pass inconsistently Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added timeout for integration test pass Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * add startup control logic, adjusted tests to wait for transactions Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added pre-config for docker-compose approach, removed remnants of old integration tests Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * reverted changes to pkg, split pre-config, added clean-shared service Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed path in all-in-one.bash Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added ipdb copyright notice Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * chmod planetmint-monit-config Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed entrypoint from Dockerfile-all-in-one Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added integration stage to travis matrix Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed unused secret Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
aaab849a98
commit
89a9caf597
@ -12,11 +12,9 @@ if [[ -n ${TOXENV} ]]; then
|
||||
elif [[ ${PLANETMINT_CI_ABCI} == 'enable' ]]; then
|
||||
docker-compose exec planetmint pytest -v -m abci
|
||||
elif [[ ${PLANETMINT_ACCEPTANCE_TEST} == 'enable' ]]; then
|
||||
./run-acceptance-test.sh
|
||||
./scripts/run-acceptance-test.sh
|
||||
elif [[ ${PLANETMINT_INTEGRATION_TEST} == 'enable' ]]; then
|
||||
chmod 600 id_ed25519
|
||||
./run-integration-test.sh
|
||||
./scripts/test.sh
|
||||
./scripts/run-integration-test.sh
|
||||
else
|
||||
docker-compose exec planetmint pytest -v --cov=planetmint --cov-report xml:htmlcov/coverage.xml
|
||||
fi
|
||||
|
@ -38,6 +38,9 @@ matrix:
|
||||
- python: 3.9
|
||||
env:
|
||||
- PLANETMINT_ACCEPTANCE_TEST=enable
|
||||
- python: 3.9
|
||||
env:
|
||||
- PLANETMINT_INTEGRATION_TEST=enable
|
||||
|
||||
|
||||
before_install: sudo .ci/travis-before-install.sh
|
||||
|
@ -1,30 +1,33 @@
|
||||
FROM alpine:3.9
|
||||
FROM python:3.9-slim
|
||||
LABEL maintainer "contact@ipdb.global"
|
||||
|
||||
ARG TM_VERSION=v0.34.15
|
||||
ARG TM_VERSION=0.34.15
|
||||
RUN mkdir -p /usr/src/app
|
||||
ENV HOME /root
|
||||
COPY . /usr/src/app/
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN apk --update add sudo bash \
|
||||
&& apk --update add python3 openssl ca-certificates git \
|
||||
&& apk --update add --virtual build-dependencies python3-dev vim build-essential cmake\
|
||||
libffi-dev openssl-dev build-base jq zsh-common \
|
||||
&& apk add --no-cache libstdc++ dpkg gnupg \
|
||||
&& pip3 install --upgrade pip cffi \
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y openssl ca-certificates git \
|
||||
&& apt-get install -y vim build-essential cmake jq zsh wget \
|
||||
&& apt-get install -y libstdc++6 \
|
||||
&& apt-get install -y openssh-client openssh-server \
|
||||
&& pip install --upgrade pip cffi \
|
||||
&& pip install -e . \
|
||||
&& apk del build-dependencies \
|
||||
&& rm -f /var/cache/apk/*
|
||||
&& apt-get autoremove
|
||||
|
||||
# Install mongodb and monit
|
||||
RUN apk --update add mongodb monit
|
||||
RUN apt-get install -y dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl
|
||||
RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add -
|
||||
RUN echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y mongodb-org monit
|
||||
|
||||
# Install Tendermint
|
||||
RUN wget https://github.com/tendermint/tendermint/releases/download/${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip \
|
||||
&& unzip tendermint_${TM_VERSION}_linux_amd64.zip \
|
||||
RUN wget https://github.com/tendermint/tendermint/releases/download/v${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.tar.gz \
|
||||
&& tar -xf tendermint_${TM_VERSION}_linux_amd64.tar.gz \
|
||||
&& mv tendermint /usr/local/bin/ \
|
||||
&& rm tendermint_${TM_VERSION}_linux_amd64.zip
|
||||
&& rm tendermint_${TM_VERSION}_linux_amd64.tar.gz
|
||||
|
||||
ENV TMHOME=/tendermint
|
||||
|
||||
@ -47,5 +50,4 @@ VOLUME /data/db /data/configdb /tendermint
|
||||
|
||||
EXPOSE 27017 28017 9984 9985 26656 26657 26658
|
||||
|
||||
WORKDIR $HOME
|
||||
ENTRYPOINT ["/usr/src/app/pkg/scripts/all-in-one.bash"]
|
||||
WORKDIR $HOME
|
4
Makefile
4
Makefile
@ -83,10 +83,10 @@ test-unit-watch: check-deps ## Run all tests and wait. Every time you change cod
|
||||
@$(DC) run --rm --no-deps planetmint pytest -f
|
||||
|
||||
test-acceptance: check-deps ## Run all acceptance tests
|
||||
@./run-acceptance-test.sh
|
||||
@./scripts/run-acceptance-test.sh
|
||||
|
||||
test-integration: check-deps ## Run all integration tests
|
||||
@./run-integration-test.sh
|
||||
@./scripts/run-integration-test.sh
|
||||
|
||||
cov: check-deps ## Check code coverage and open the result in the browser
|
||||
@$(DC) run --rm planetmint pytest -v --cov=planetmint --cov-report html
|
||||
|
78
docker-compose.integration.yml
Normal file
78
docker-compose.integration.yml
Normal file
@ -0,0 +1,78 @@
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
version: '2.2'
|
||||
|
||||
services:
|
||||
clean-shared:
|
||||
image: alpine
|
||||
command: ["/scripts/clean-shared.sh"]
|
||||
volumes:
|
||||
- ./integration/scripts/clean-shared.sh:/scripts/clean-shared.sh
|
||||
- shared:/shared
|
||||
|
||||
planetmint_1:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-all-in-one
|
||||
depends_on:
|
||||
- clean-shared
|
||||
expose:
|
||||
- "22"
|
||||
- "9984"
|
||||
- "9985"
|
||||
- "26656"
|
||||
- "26657"
|
||||
- "26658"
|
||||
environment:
|
||||
ME: "planetmint_1"
|
||||
OTHER: "planetmint_2"
|
||||
command: ["/usr/src/app/scripts/pre-config-planetmint.sh", "/usr/src/app/scripts/all-in-one.bash"]
|
||||
volumes:
|
||||
- ./integration/scripts:/usr/src/app/scripts
|
||||
- shared:/shared
|
||||
|
||||
planetmint_2:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-all-in-one
|
||||
depends_on:
|
||||
- clean-shared
|
||||
expose:
|
||||
- "22"
|
||||
- "9984"
|
||||
- "9985"
|
||||
- "26656"
|
||||
- "26657"
|
||||
- "26658"
|
||||
environment:
|
||||
ME: "planetmint_2"
|
||||
OTHER: "planetmint_1"
|
||||
command: ["/usr/src/app/scripts/pre-config-planetmint.sh", "/usr/src/app/scripts/all-in-one.bash"]
|
||||
volumes:
|
||||
- ./integration/scripts:/usr/src/app/scripts
|
||||
- shared:/shared
|
||||
|
||||
test:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: integration/python/Dockerfile
|
||||
depends_on:
|
||||
- planetmint_1
|
||||
- planetmint_2
|
||||
environment:
|
||||
ME: "test"
|
||||
PLANETMINT_ENDPOINT_1: planetmint_1
|
||||
PLANETMINT_ENDPOINT_2: planetmint_2
|
||||
command: ["/scripts/pre-config-test.sh", "/scripts/wait-for-planetmint.sh", "/scripts/test.sh", "pytest", "/src"]
|
||||
volumes:
|
||||
- ./integration/python/src:/src
|
||||
- ./integration/scripts:/scripts
|
||||
- shared:/shared
|
||||
|
||||
|
||||
|
||||
volumes:
|
||||
shared:
|
@ -1,3 +1,10 @@
|
||||
<!---
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
Planetmint and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
||||
# Integration test suite
|
||||
This directory contains the integration test suite for Planetmint.
|
||||
|
||||
|
@ -3,4 +3,5 @@ FROM python:3.9
|
||||
RUN mkdir -p /src
|
||||
RUN pip install --upgrade \
|
||||
pytest~=6.2.5 \
|
||||
planetmint-driver~=0.9.0
|
||||
planetmint-driver~=0.9.0
|
||||
RUN apt-get update && apt-get install -y openssh-client openssh-server
|
@ -22,10 +22,12 @@
|
||||
# We need some utils from the `os` package, we will interact with
|
||||
# env variables.
|
||||
import os
|
||||
import time
|
||||
|
||||
# For this test case we need import and use the Python driver
|
||||
from planetmint_driver import Planetmint
|
||||
from planetmint_driver.crypto import generate_keypair
|
||||
from planetmint_driver.exceptions import NotFoundError
|
||||
|
||||
def test_multiple_owners():
|
||||
# ## Set up a connection to the Planetmint integration test nodes
|
||||
@ -69,7 +71,14 @@ def test_multiple_owners():
|
||||
|
||||
# Let's retrieve the transaction from both nodes
|
||||
pm_itest1_tx = pm_itest1.transactions.retrieve(dw_id)
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(dw_id)
|
||||
pm_itest2_tx = {}
|
||||
# TODO: REPLACE WITH ASYNC OR POLL
|
||||
try:
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(dw_id)
|
||||
except NotFoundError:
|
||||
print('TOO FAST')
|
||||
time.sleep(3)
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(dw_id)
|
||||
|
||||
# Both retrieved transactions should be the same
|
||||
assert pm_itest1_tx == pm_itest2_tx
|
||||
@ -118,7 +127,14 @@ def test_multiple_owners():
|
||||
|
||||
# Retrieve the fulfilled transaction from both nodes
|
||||
pm_itest1_tx = pm_itest1.transactions.retrieve(fulfilled_transfer_tx['id'])
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(fulfilled_transfer_tx['id'])
|
||||
pm_itest2_tx
|
||||
# TODO: REPLACE WITH ASYNC OR POLL
|
||||
try:
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(fulfilled_transfer_tx['id'])
|
||||
except NotFoundError:
|
||||
print('TOO FAST')
|
||||
time.sleep(3)
|
||||
pm_itest2_tx = pm_itest2.transactions.retrieve(fulfilled_transfer_tx['id'])
|
||||
|
||||
# Now compare if both nodes returned the same transaction
|
||||
assert pm_itest1_tx == pm_itest2_tx
|
||||
|
17
integration/scripts/all-in-one.bash
Executable file
17
integration/scripts/all-in-one.bash
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
||||
# MongoDB configuration
|
||||
[ "$(stat -c %U /data/db)" = mongodb ] || chown -R mongodb /data/db
|
||||
|
||||
# Planetmint configuration
|
||||
/usr/src/app/scripts/planetmint-monit-config
|
||||
|
||||
nohup mongod --bind_ip_all > "$HOME/.planetmint-monit/logs/mongodb_log_$(date +%Y%m%d_%H%M%S)" 2>&1 &
|
||||
|
||||
# Start services
|
||||
monit -d 5 -I -B
|
9
integration/scripts/clean-shared.sh
Executable file
9
integration/scripts/clean-shared.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
rm /shared/planetmint*
|
||||
rm /shared/genesis.json
|
||||
rm /shared/id_rsa.pub
|
67
integration/scripts/election.sh
Executable file
67
integration/scripts/election.sh
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
# Show tendermint node id
|
||||
show_id () {
|
||||
tendermint --home=/tendermint show_node_id | tail -n 1
|
||||
}
|
||||
|
||||
# Show validator public key
|
||||
show_validator () {
|
||||
tendermint --home=/tendermint show_validator | tail -n 1
|
||||
}
|
||||
|
||||
# Elect new voting power for node
|
||||
elect_validator () {
|
||||
planetmint election new upsert-validator $1 $2 $3 --private-key /tendermint/config/priv_validator_key.json
|
||||
}
|
||||
|
||||
# Show election state
|
||||
show_election () {
|
||||
planetmint election show $1
|
||||
}
|
||||
|
||||
# Approve election
|
||||
approve_validator () {
|
||||
planetmint election approve $1 --private-key /tendermint/config/priv_validator_key.json
|
||||
}
|
||||
|
||||
# Fetch tendermint id and pubkey and create upsert proposal
|
||||
elect () {
|
||||
node_id=$(show_id)
|
||||
validator_pubkey=$(show_validator | jq -r .value)
|
||||
proposal=$(elect_validator $validator_pubkey $1 $node_id 2>&1 | grep SUCCESS)
|
||||
echo ${proposal##* }
|
||||
}
|
||||
|
||||
usage () {
|
||||
echo "usage: TODO"
|
||||
}
|
||||
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
show_id ) show_id
|
||||
;;
|
||||
show_validator ) show_validator
|
||||
;;
|
||||
elect ) shift
|
||||
elect $1
|
||||
;;
|
||||
show_election ) shift
|
||||
show_election $1
|
||||
;;
|
||||
approve ) shift
|
||||
approve_validator $1
|
||||
;;
|
||||
* ) usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exitcode=$?
|
||||
|
||||
exit $exitcode
|
36
integration/scripts/genesis.py
Executable file
36
integration/scripts/genesis.py
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
# TODO: CHANGE ME/OTHER VARIABLES
|
||||
def edit_genesis() -> None:
|
||||
ME = os.getenv('ME')
|
||||
OTHER = os.getenv('OTHER')
|
||||
|
||||
if ME == 'planetmint_1':
|
||||
file_name = '{}_genesis.json'.format(ME)
|
||||
other_file_name = '{}_genesis.json'.format(OTHER)
|
||||
|
||||
file = open(os.path.join('/shared', file_name))
|
||||
other_file = open(os.path.join('/shared', other_file_name))
|
||||
|
||||
genesis = json.load(file)
|
||||
other_genesis = json.load(other_file)
|
||||
|
||||
genesis['validators'] = genesis['validators'] + other_genesis['validators']
|
||||
|
||||
file.close()
|
||||
other_file.close()
|
||||
|
||||
with open(os.path.join('/shared', 'genesis.json'), 'w') as f:
|
||||
json.dump(genesis, f, indent=True)
|
||||
|
||||
return None
|
||||
|
||||
if __name__ == '__main__':
|
||||
edit_genesis()
|
208
integration/scripts/planetmint-monit-config
Executable file
208
integration/scripts/planetmint-monit-config
Executable file
@ -0,0 +1,208 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
set -o nounset
|
||||
|
||||
# Check if directory for monit logs exists
|
||||
if [ ! -d "$HOME/.planetmint-monit" ]; then
|
||||
mkdir -p "$HOME/.planetmint-monit"
|
||||
fi
|
||||
|
||||
monit_pid_path=${MONIT_PID_PATH:=$HOME/.planetmint-monit/monit_processes}
|
||||
monit_script_path=${MONIT_SCRIPT_PATH:=$HOME/.planetmint-monit/monit_script}
|
||||
monit_log_path=${MONIT_LOG_PATH:=$HOME/.planetmint-monit/logs}
|
||||
monitrc_path=${MONITRC_PATH:=$HOME/.monitrc}
|
||||
|
||||
function usage() {
|
||||
cat <<EOM
|
||||
|
||||
Usage: ${0##*/} [-h]
|
||||
|
||||
Configure Monit for Planetmint and Tendermint process management.
|
||||
|
||||
ENV[MONIT_PID_PATH] || --monit-pid-path PATH
|
||||
|
||||
Absolute path to directory where the the program's pid-file will reside.
|
||||
The pid-file contains the ID(s) of the process(es). (default: ${monit_pid_path})
|
||||
|
||||
ENV[MONIT_SCRIPT_PATH] || --monit-script-path PATH
|
||||
|
||||
Absolute path to the directory where the executable program or
|
||||
script is present. (default: ${monit_script_path})
|
||||
|
||||
ENV[MONIT_LOG_PATH] || --monit-log-path PATH
|
||||
|
||||
Absolute path to the directory where all the logs for processes
|
||||
monitored by Monit are stored. (default: ${monit_log_path})
|
||||
|
||||
ENV[MONITRC_PATH] || --monitrc-path PATH
|
||||
|
||||
Absolute path to the monit control file(monitrc). (default: ${monitrc_path})
|
||||
|
||||
-h|--help
|
||||
Show this help and exit.
|
||||
|
||||
EOM
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
arg="$1"
|
||||
case $arg in
|
||||
--monit-pid-path)
|
||||
monit_pid_path="$2"
|
||||
shift
|
||||
;;
|
||||
--monit-script-path)
|
||||
monit_script_path="$2"
|
||||
shift
|
||||
;;
|
||||
--monit-log-path)
|
||||
monit_log_path="$2"
|
||||
shift
|
||||
;;
|
||||
--monitrc-path)
|
||||
monitrc_path="$2"
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Check if directory for monit logs exists
|
||||
if [ ! -d "$monit_log_path" ]; then
|
||||
mkdir -p "$monit_log_path"
|
||||
fi
|
||||
|
||||
# Check if directory for monit pid files exists
|
||||
if [ ! -d "$monit_pid_path" ]; then
|
||||
mkdir -p "$monit_pid_path"
|
||||
fi
|
||||
|
||||
cat >${monit_script_path} <<EOF
|
||||
#!/bin/bash
|
||||
case \$1 in
|
||||
|
||||
start_planetmint)
|
||||
|
||||
pushd \$4
|
||||
nohup planetmint start > /dev/null 2>&1 &
|
||||
|
||||
echo \$! > \$2
|
||||
popd
|
||||
|
||||
;;
|
||||
|
||||
stop_planetmint)
|
||||
|
||||
kill -2 \`cat \$2\`
|
||||
rm -f \$2
|
||||
|
||||
;;
|
||||
|
||||
start_tendermint)
|
||||
|
||||
pushd \$4
|
||||
|
||||
nohup tendermint node \
|
||||
--p2p.laddr "tcp://0.0.0.0:26656" \
|
||||
--rpc.laddr "tcp://0.0.0.0:26657" \
|
||||
--proxy_app="tcp://0.0.0.0:26658" \
|
||||
--consensus.create_empty_blocks=false \
|
||||
--p2p.pex=false >> \$3/tendermint.out.log 2>> \$3/tendermint.err.log &
|
||||
|
||||
echo \$! > \$2
|
||||
popd
|
||||
|
||||
;;
|
||||
|
||||
stop_tendermint)
|
||||
|
||||
kill -2 \`cat \$2\`
|
||||
rm -f \$2
|
||||
|
||||
;;
|
||||
|
||||
esac
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x ${monit_script_path}
|
||||
|
||||
cat >${monit_script_path}_logrotate <<EOF
|
||||
#!/bin/bash
|
||||
case \$1 in
|
||||
|
||||
rotate_tendermint_logs)
|
||||
/bin/cp \$2 \$2.\$(date +%y-%m-%d)
|
||||
/bin/tar -cvf \$2.\$(date +%Y%m%d_%H%M%S).tar.gz \$2.\$(date +%y-%m-%d)
|
||||
/bin/rm \$2.\$(date +%y-%m-%d)
|
||||
/bin/cp /dev/null \$2
|
||||
;;
|
||||
|
||||
esac
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x ${monit_script_path}_logrotate
|
||||
|
||||
# Handling overwriting of control file interactively
|
||||
if [ -f "$monitrc_path" ]; then
|
||||
echo "$monitrc_path already exists."
|
||||
read -p "Overwrite[Y]? " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Overriding $monitrc_path"
|
||||
else
|
||||
read -p "Enter absolute path to store Monit control file: " monitrc_path
|
||||
eval monitrc_path="$monitrc_path"
|
||||
if [ ! -d "$(dirname $monitrc_path)" ]; then
|
||||
echo "Failed to save monit control file '$monitrc_path': No such file or directory."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# configure monitrc
|
||||
cat >${monitrc_path} <<EOF
|
||||
set httpd
|
||||
port 2812
|
||||
allow localhost
|
||||
|
||||
check process planetmint
|
||||
with pidfile ${monit_pid_path}/planetmint.pid
|
||||
start program "${monit_script_path} start_planetmint $monit_pid_path/planetmint.pid ${monit_log_path} ${monit_log_path}"
|
||||
restart program "${monit_script_path} start_planetmint $monit_pid_path/planetmint.pid ${monit_log_path} ${monit_log_path}"
|
||||
stop program "${monit_script_path} stop_planetmint $monit_pid_path/planetmint.pid ${monit_log_path} ${monit_log_path}"
|
||||
|
||||
check process tendermint
|
||||
with pidfile ${monit_pid_path}/tendermint.pid
|
||||
start program "${monit_script_path} start_tendermint ${monit_pid_path}/tendermint.pid ${monit_log_path} ${monit_log_path}"
|
||||
restart program "${monit_script_path} start_tendermint ${monit_pid_path}/tendermint.pid ${monit_log_path} ${monit_log_path}"
|
||||
stop program "${monit_script_path} stop_tendermint ${monit_pid_path}/tendermint.pid ${monit_log_path} ${monit_log_path}"
|
||||
depends on planetmint
|
||||
|
||||
check file tendermint.out.log with path ${monit_log_path}/tendermint.out.log
|
||||
if size > 200 MB then
|
||||
exec "${monit_script_path}_logrotate rotate_tendermint_logs ${monit_log_path}/tendermint.out.log $monit_pid_path/tendermint.pid"
|
||||
|
||||
check file tendermint.err.log with path ${monit_log_path}/tendermint.err.log
|
||||
if size > 200 MB then
|
||||
exec "${monit_script_path}_logrotate rotate_tendermint_logs ${monit_log_path}/tendermint.err.log $monit_pid_path/tendermint.pid"
|
||||
|
||||
EOF
|
||||
|
||||
# Setting permissions for control file
|
||||
chmod 0700 ${monitrc_path}
|
||||
|
||||
echo -e "Planetmint process manager configured!"
|
||||
set -o errexit
|
63
integration/scripts/pre-config-planetmint.sh
Executable file
63
integration/scripts/pre-config-planetmint.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
# Create ssh folder
|
||||
mkdir ~/.ssh
|
||||
|
||||
# Wait for test container pubkey
|
||||
while [ ! -f /shared/id_rsa.pub ]; do
|
||||
echo "WAIT FOR PUBKEY"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Add pubkey to authorized keys
|
||||
cat /shared/id_rsa.pub > ~/.ssh/authorized_keys
|
||||
|
||||
# Allow root user login
|
||||
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
|
||||
|
||||
# Restart ssh service
|
||||
service ssh restart
|
||||
|
||||
# Tendermint configuration
|
||||
tendermint init
|
||||
|
||||
# Write node id to shared folder
|
||||
NODE_ID=$(tendermint show_node_id | tail -n 1)
|
||||
echo $NODE_ID > /shared/${ME}_node_id
|
||||
|
||||
# Wait for other node id
|
||||
while [ ! -f "/shared/${OTHER}_node_id" ]; do
|
||||
echo "WAIT FOR NODE ID"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Write node ids to persistent peers
|
||||
OTHER_NODE_ID=$(cat /shared/${OTHER}_node_id)
|
||||
PEERS=$(echo "persistent_peers = \"${NODE_ID}@${ME}:26656, ${OTHER_NODE_ID}@${OTHER}:26656\"")
|
||||
sed -i "/persistent_peers = \"\"/c\\${PEERS}" /tendermint/config/config.toml
|
||||
|
||||
# Copy genesis.json to shared folder
|
||||
cp /tendermint/config/genesis.json /shared/${ME}_genesis.json
|
||||
|
||||
# Await config file of all services to be present
|
||||
while [ ! -f /shared/${OTHER}_genesis.json ]; do
|
||||
echo "WAIT FOR OTHER GENESIS"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Create genesis.json for nodes
|
||||
/usr/src/app/scripts/genesis.py
|
||||
|
||||
while [ ! -f /shared/genesis.json ]; do
|
||||
echo "WAIT FOR GENESIS"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Copy genesis.json to tendermint config
|
||||
cp /shared/genesis.json /tendermint/config/genesis.json
|
||||
|
||||
exec "$@"
|
16
integration/scripts/pre-config-test.sh
Executable file
16
integration/scripts/pre-config-test.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
# Create ssh folder
|
||||
mkdir ~/.ssh
|
||||
|
||||
# Create ssh keys
|
||||
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa
|
||||
|
||||
# Publish pubkey to shared folder
|
||||
cp ~/.ssh/id_rsa.pub /shared
|
||||
|
||||
exec "$@"
|
10
integration/scripts/test.sh
Executable file
10
integration/scripts/test.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
result=$(ssh -o "StrictHostKeyChecking=no" -i \~/.ssh/id_rsa root@planetmint_1 'bash -s' < scripts/election.sh elect 2)
|
||||
ssh -o "StrictHostKeyChecking=no" -i ~/.ssh/id_rsa root@planetmint_2 'bash -s' < scripts/election.sh approve $result
|
||||
|
||||
exec "$@"
|
28
integration/scripts/wait-for-planetmint.sh
Executable file
28
integration/scripts/wait-for-planetmint.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
# Only continue if all services are ready
|
||||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' planetmint_1:9984/api/v1)" != "200" ]]; do
|
||||
echo "WAIT FOR PLANETMINT"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' planetmint_1:26657)" != "200" ]]; do
|
||||
echo "WAIT FOR TENDERMINT"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' planetmint_2:9984/api/v1)" != "200" ]]; do
|
||||
echo "WAIT FOR PLANETMINT"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' planetmint_2:26657)" != "200" ]]; do
|
||||
echo "WAIT FOR TENDERMINT"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
exec "$@"
|
@ -16,4 +16,5 @@ nohup mongod --bind_ip_all > "$HOME/.planetmint-monit/logs/mongodb_log_$(date +%
|
||||
# Tendermint configuration
|
||||
tendermint init
|
||||
|
||||
monit -d 5 -I -B
|
||||
# Start services
|
||||
monit -d 5 -I -B
|
@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
||||
# Check if both integration test nodes are reachable
|
||||
check_status () {
|
||||
OK="200 OK"
|
||||
|
||||
STATUS_1=$(curl -I -s -X GET https://itest1.planetmint.io/ | head -n 1)
|
||||
STATUS_2=$(curl -I -s -X GET https://itest2.planetmint.io/ | head -n 1)
|
||||
|
||||
# Check if both response status codes return 200 OK
|
||||
if ! [[ "$STATUS_1" == *"$OK"* ]] || ! [[ "$STATUS_2" == *"$OK"* ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test () {
|
||||
docker-compose run --rm python-integration pytest /src
|
||||
}
|
||||
|
||||
teardown () {
|
||||
docker-compose down
|
||||
}
|
||||
|
||||
check_status
|
||||
run_test
|
||||
exitcode=$?
|
||||
teardown
|
||||
|
||||
exit $exitcode
|
19
scripts/run-integration-test.sh
Executable file
19
scripts/run-integration-test.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
run_test() {
|
||||
docker-compose -f docker-compose.integration.yml up test
|
||||
}
|
||||
|
||||
teardown () {
|
||||
docker-compose -f docker-compose.integration.yml down
|
||||
}
|
||||
|
||||
run_test
|
||||
exitcode=$?
|
||||
teardown
|
||||
|
||||
exit $exitcode
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
result=$(ssh -o StrictHostKeyChecking=accept-new root@64.225.106.52 -i id_ed25519 'bash -s' < scripts/election.sh elect 35)
|
||||
ssh -o StrictHostKeyChecking=accept-new root@64.225.105.60 -i id_ed25519 'bash -s' < scripts/election.sh approve $result
|
@ -1,4 +0,0 @@
|
||||
³.˜·ÚÇ9DDÔÒ@£Éê…ôÛïëŸÚŒžÛJÔá–©¹KÐ
çêØÝc÷‡‘^ª»…
|
||||
YÄ/õT |%²Å&âÔvfõ#Ä"â_®P’à#öS¡Ôè4ôiQSýún0‡4?vÞx…N! <20>5Ê;i óŸ÷WH¾P²"Šx§û5ÎÎ9Ç"Œ]i¦"³4ü—‚IòD8ðôÌ‹é¶Ðtý•ÊueŒaÎÿ;˜‡Ô©’ì¾`êÕ‹1Þ¬F·˜ÁXõëP<C3AB>E6ÏŠ×\ô"’Á$eÍO ˆó<CB86><¢õàPèÛ¡Sò&;i¤æ‰Õ¹2V 3Ÿ/ÐJD+;åT£–רL(œtêR9vEû¤ñ-+!ñÂZ±ðŒŠhÛf¸æ5ߤÓ8S.âúG4ÌnŠ«ÄÙáMQüÝ!_ãêzËÜú¶•‹Å`UULì’@·Í¡¼w‹ŸV3@ų?‡ø’)'Å>Û>K¤Cx%);Çä8
|
||||
n÷ÑŽ<C385>5ô¡ù<C2A1>ÆËvj],20ÒÈ<C392>§î;Ðç
mÜÇ(m‡s=©
|
||||
€¯µvK)5ˆT¢Q_ ¹Lð†D¶ƒ™:hüüÉ+<2B>
|
Loading…
x
Reference in New Issue
Block a user