Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

148 [DEV] added dockerized jepsen environment #237

Merged
merged 12 commits into from
May 3, 2017
Prev Previous commit
148 [DEV] added universal relative path to build script
tonycox committed May 2, 2017
commit 8b3b15a89191641ab56e12bd9ec9e930e8453101
4 changes: 3 additions & 1 deletion lagerta-jepsen/README.md
Original file line number Diff line number Diff line change
@@ -22,4 +22,6 @@ docker exec -it jepsen-control bash
docker exec jepsen-control bin/bash -c "cd /jepsen-0.1.4/jepsen && lein test"
```

All tests placed in src/test and written on [clojure](https://clojure.org/)
All tests placed in ./src, on docker container placed in /lagerta/src

written on [clojure](https://clojure.org/)
34 changes: 20 additions & 14 deletions lagerta-jepsen/docker/build.sh
Original file line number Diff line number Diff line change
@@ -32,29 +32,35 @@ ERROR(){
}

exists ssh-keygen || { ERROR "Please install ssh-keygen"; exit 1; }
if [ ! -f ./secret ]; then
mkdir -p -m 755 ./secret

SCRIPT_PATH=`realpath $0`
SCRIPT_FOLDER_PATH=`dirname ${SCRIPT_PATH}`

if [ ! -f ${SCRIPT_FOLDER_PATH}/secret ]; then
mkdir -p -m 755 ${SCRIPT_FOLDER_PATH}/secret
fi
if [ ! -f ./secret/node.env ]; then
if [ ! -f ${SCRIPT_FOLDER_PATH}/secret/node.env ]; then
INFO "Generating key pair"
ssh-keygen -t rsa -N "" -f ./secret/id_rsa -C "epam.com"
ssh-keygen -t rsa -N "" -f ${SCRIPT_FOLDER_PATH}/secret/id_rsa -C "epam.com"

INFO "Generating ./secret/control.env"
echo '# generated by lagerta-jepsen/docker/build.sh' > ./secret/control.env
echo '# NOTE: \\n is expressed as ↩' >> ./secret/control.env
echo SSH_PRIVATE_KEY="$(cat ./secret/id_rsa | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/↩/g')" >> ./secret/control.env
echo SSH_PUBLIC_KEY=$(cat ./secret/id_rsa.pub) >> ./secret/control.env
INFO 'Generating '${SCRIPT_FOLDER_PATH}'/secret/control.env'
echo '# generated by '${SCRIPT_PATH} > ${SCRIPT_FOLDER_PATH}/secret/control.env
echo '# NOTE: \\n is expressed as ↩' >> ${SCRIPT_FOLDER_PATH}/secret/control.env
echo SSH_PRIVATE_KEY="$(cat ${SCRIPT_FOLDER_PATH}/secret/id_rsa | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/↩/g')" >> ${SCRIPT_FOLDER_PATH}/secret/control.env
echo SSH_PUBLIC_KEY=$(cat ${SCRIPT_FOLDER_PATH}/secret/id_rsa.pub) >> ${SCRIPT_FOLDER_PATH}/secret/control.env

INFO "Generating ./secret/node.env"
echo '# generated by lagerta-jepsen/docker/build.sh' > ./secret/node.env
echo AUTHORIZED_KEYS=$(cat ./secret/id_rsa.pub) >> ./secret/node.env
INFO 'Generating '${SCRIPT_FOLDER_PATH}'/secret/node.env'
echo '# generated by '${SCRIPT_PATH} > ${SCRIPT_FOLDER_PATH}/secret/node.env
echo AUTHORIZED_KEYS=$(cat ${SCRIPT_FOLDER_PATH}/secret/id_rsa.pub) >> ${SCRIPT_FOLDER_PATH}/secret/node.env
else
INFO "No need to generate key pair"
fi

exists docker || { ERROR "Please install docker"; exit 1; }
exists docker-compose || { ERROR "Please install docker-compose"; exit 1; }

INFO "Cleaning images"
docker rmi -f java-base jepsen-control
INFO "Building images"
docker build -t java-base --network host base/.
docker build -t jepsen-control --network host jepsen-control/.
docker build -t java-base --network host ${SCRIPT_FOLDER_PATH}/base/.
docker build -t jepsen-control --network host ${SCRIPT_FOLDER_PATH}/jepsen-control/.
2 changes: 2 additions & 0 deletions lagerta-jepsen/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ services:
hostname: control
networks:
- default
expose:
- 8080

node:
image: java-base
9 changes: 4 additions & 5 deletions lagerta-jepsen/docker/jepsen-control/Dockerfile
Original file line number Diff line number Diff line change
@@ -23,14 +23,13 @@ FROM java-base
ARG JEPSEN_VERSION=0.1.4
ENV LEIN_ROOT true

RUN wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && \
mv lein /usr/bin && \
chmod +x /usr/bin/lein
ADD https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein /usr/bin
RUN chmod +x /usr/bin/lein

# install jepsen
ADD https://github.com/jepsen-io/jepsen/archive/${JEPSEN_VERSION}.tar.gz /jepsen
RUN chmod +x jepsen && tar xfz jepsen && rm -f jepsen
RUN cd /jepsen-${JEPSEN_VERSION}/jepsen && lein install
RUN chmod +x jepsen && tar xfz jepsen && rm -f jepsen && \
cd /jepsen-${JEPSEN_VERSION}/jepsen && lein install

# configure ssh
ADD ./init.sh /init.sh