Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Fix Travis tests #4

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/connect_dcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

sleep 5

cat > /tmp/connect.erl <<- EOF
cat > /tmp/connect.erl <<- EOF
#!/usr/bin/env escript
%%! -smp enable -sname erlshell -setcookie antidote
main(_Args) ->
Expand Down
8 changes: 6 additions & 2 deletions test/docker-antidote-3dcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: "2.1"
services:
antidote1:
image: antidotedb/antidote:latest
container_name: antidote1
ports:
- "8087:8087"
environment:
Expand All @@ -10,22 +11,25 @@ services:

antidote2:
image: antidotedb/antidote:latest
container_name: antidote2
ports:
- "8088:8087"
environment:
NODE_NAME: "antidote@antidote2"
SHORT_NAME: "true"

antidote3:
image: antidotedb/antidote:latest
container_name: antidote3
ports:
- "8089:8087"
environment:
NODE_NAME: "antidote@antidote3"
SHORT_NAME: "true"

link:
image: erlang:19
image: erlang:21-slim
container_name: antidote_link
healthcheck:
test: ["CMD", "test", "-f", "/tmp/ready"]
interval: 3s
Expand Down
20 changes: 14 additions & 6 deletions test/fs_distributed_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@

echo "Start distributed file system test"

docker-compose -f ./test/docker-antidote-3dcs.yml down >/dev/null 2>&1
docker-compose -rmi all -f ./test/docker-antidote-3dcs.yml down >/dev/null 2>&1
docker-compose -f ./test/docker-antidote-3dcs.yml up -d #>/dev/null 2>&1
sleep 25

wait_antidote antidote1
wait_antidote antidote2
wait_antidote antidote3
while [ "healthy" != `docker inspect --format='{{ .State.Health.Status}}' antidote_link` ]; do
echo "Waiting for Antidote instances to form a cluster..."
sleep 2
done
sleep 3

rm -rf d1 d2 d3
mkdir -p d1 d2 d3
node ./src/antidote-fs.js -m d1 -a "localhost:8087" > /dev/null &
node ./src/antidote-fs.js -m d2 -a "localhost:8088" > /dev/null &
node ./src/antidote-fs.js -m d3 -a "localhost:8089" > /dev/null &
sleep 3
sleep 5

EXIT=0

Expand All @@ -24,8 +32,8 @@ echo hello there 2 > ./d2/test.txt
sleep 2
echo -n "File conflict.................."
if [[ -f ./d3/test.txt-CONFLICT_0 && -f ./d3/test.txt-CONFLICT_1 ]]
then ok;
else ko; EXIT=1;
then ok;
else ko; EXIT=1;
fi

# Directory naming conflict: merge directories
Expand All @@ -44,7 +52,7 @@ if [[ -d ./d3/dirC && \
-f ./d3/dirC/mydirAfile.txt &&
$(< ./d3/dirC/dirBB/mydirBBfile.txt) == $(echo "hello world B") &&
$(< ./d1/dirC/mydirAfile.txt) == $(echo "hello world A") ]]
then ok;
then ok;
else ko; EXIT=1;
fi

Expand Down
13 changes: 8 additions & 5 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash

start_single_instance() {
. ./test/utils.sh

start_single_instance() {
stop_remove_antidote_containers
echo "Starting single instance"
docker rm -fv $(docker ps -q -f ancestor=antidotedb/antidote) 2> /dev/null
docker run -d --rm -it -p "8087:8087" antidotedb/antidote > /dev/null
sleep 20
docker run -d --name antidote --rm -it -p "8087:8087" antidotedb/antidote:latest > /dev/null
wait_antidote antidote

rm -rf d1; mkdir d1
node ./src/antidote-fs.js -m d1 -a "localhost:8087" > /dev/null &
sleep 5
Expand All @@ -14,7 +17,7 @@ start_single_instance() {
stop_single_instance() {
echo "Stopping single instance"
fusermount -u ./d1
docker rm -fv $(docker ps -a -q) > /dev/null 2>&1
stop_remove_antidote_containers
echo "Single instance stopped"
}

Expand Down
16 changes: 15 additions & 1 deletion test/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

rnd_str() {
rnd_str() {
echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 1)
}

ok() { echo -e "${GREEN}OK${NC}"; }
ko() { echo -e "${RED}KO${NC}"; }

wait_antidote() {
while ! docker exec -it $1 grep "Application antidote started" /opt/antidote/log/console.log; do
echo "Waiting 2 seconds for $1 to start up..."
sleep 2
done
}

stop_remove_antidote_containers() {
# WARNING: this command stops and removes all containers derived by
# antidotedb/antidote!
docker rm -fv $(docker ps -q -f ancestor=antidotedb/antidote) 2> /dev/null
}