Skip to content

Commit 99eb93b

Browse files
authored
Merge pull request #110 from dedis/guanyu/dockerfiles
Uses docker files for testing
2 parents 53d81ed + 851bdef commit 99eb93b

File tree

12 files changed

+567
-126
lines changed

12 files changed

+567
-126
lines changed

.github/workflows/go_integration_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
./memcoin --config /tmp/node3 start --postinstall --promaddr :9102 --proxyaddr :9082 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2003 --public //localhost:2003 &
4040
4141
- name: Run the setup
42-
run: ./setupnNode.sh 3
42+
run: ./setupnNode.sh -n 3 -d false
4343

4444

4545
- name: Test integration & benchmark with coverage

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ web/app/node_modules
66
.idea
77

88
memcoin
9+
10+
*.log
11+
12+
nodedata/
13+
914
deb-package/dist/**
15+

Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:1
2+
3+
##
4+
## Build
5+
##
6+
FROM golang:1.17.7-alpine AS build
7+
8+
ENV PATH="${GOPATH}/bin:${PATH}"
9+
ENV LLVL=info
10+
11+
COPY . /d-voting
12+
WORKDIR /d-voting/dela/cli/crypto
13+
RUN go install
14+
15+
WORKDIR /d-voting/cli/memcoin/
16+
RUN go install
17+
18+
EXPOSE 2001
19+
WORKDIR /d-voting
20+
# CMD memcoin --config /tmp/node1 start --port 2001
21+
22+
23+
24+
25+

README.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Then you should be able to run the setup script:
137137
With this other script you can choose the number of nodes that you want to set up:
138138

139139
```sh
140-
./setupnNode.sh 3
140+
./setupnNode.sh -n 3
141141
```
142142

143143
This script will setup the nodes and services. If you restart do not forget to
@@ -152,7 +152,7 @@ rm -rf /tmp/node{1,2,3}
152152
## Automate the previous setup using `tmux`
153153

154154
If you have `tmux` installed, you can start a `tmux` session that will
155-
execute the above setup by running in the project root `./runNode.sh 3`. This
155+
execute the above setup by running in the project root `./runNode.sh -n 3`. This
156156
command takes as argument the number of nodes.
157157
Once the session is started, you can move around the panes with
158158
`Ctrl+B` followed by arrow keys or by `N`. You can also have an overview of the windows
@@ -165,7 +165,7 @@ then delete the node data (i.e. the files `/tmp/node{1,2,3}`).
165165

166166
## Run the scenario test
167167

168-
If nodes are running and `setup.sh` or `setupnNode.sh 3` has been called, you can run a test
168+
If nodes are running and `setup.sh` or `./setupnNode.sh -n 3` has been called, you can run a test
169169
scenario:
170170

171171
```sh
@@ -185,6 +185,34 @@ Public key: `adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3`
185185

186186
Secret key: `28912721dfd507e198b31602fb67824856eb5a674c021d49fdccbe52f0234409`
187187

188+
## Run the scenario test with docker
189+
Use the following commands to launch and set up nodes, and start the scenario test with user defined number of nodes.
190+
191+
First build the docker image `docker build -t node .`
192+
193+
Afterwards use the following commands, replace 4 by the desired nb of nodes :
194+
195+
```sh
196+
./runNode.sh -n 4 -a true -d true
197+
./setupnNode.sh -n 4 -d true
198+
199+
NNODES=4 KILLNODE=true go test -v -run ^TestScenario$ github.com/dedis/d-voting/integration -count=1
200+
```
201+
202+
Here we set KILLNODE=true or false to decide whether kill and restart a node during the election process. By default, it's set to false.
203+
204+
To end the session, run `./kill_test.sh`.
205+
206+
To launch multiple test and get statistics, run `./autotest.sh -n 10 -r 15`.
207+
208+
N.B. run following commands to get help
209+
```sh
210+
./runNode.sh -h
211+
./setupnNode.sh -h
212+
./autotest.sh -h
213+
```
214+
215+
188216
# Use the frontend
189217

190218
See README in `web/`.

autotest.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#! /bin/sh
2+
3+
# This script uses runNode.sh, setupnNode.sh, kill_test.sh to launch multiple
4+
# times of scenario test with user defined number of nodes. The results of log are kept in directory named logkill$i
5+
6+
7+
POSITIONAL_ARGS=()
8+
9+
while [[ $# -gt 0 ]]; do
10+
case $1 in
11+
-h|--help)
12+
echo "This script uses runNode.sh, setupnNode.sh, kill_test.sh to launch multiple times of scenario test with user defined number of nodes. The results of log are kept in directory named logkill "
13+
echo ""
14+
echo "Options:"
15+
echo "-h | --help program help (this file)"
16+
echo "-n | --node number of d-voting nodes"
17+
echo "-r | --run_time set how many times we want to run the test"
18+
exit 0
19+
;;
20+
-n|--node)
21+
N_NODE="$2"
22+
shift # past argument
23+
shift # past value
24+
;;
25+
-r|--run_time)
26+
RUN_TIMES="$2"
27+
shift # past argument
28+
shift # past value
29+
;;
30+
-*|--*)
31+
echo "Unknown option $1"
32+
exit 1
33+
;;
34+
*)
35+
POSITIONAL_ARGS+=("$1") # save positional arg
36+
shift # past argument
37+
;;
38+
esac
39+
done
40+
41+
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
42+
43+
44+
vals=($(seq 1 1 $RUN_TIMES))
45+
for i in "${vals[@]}"
46+
do
47+
echo "Test $i with $N_NODE nodes"
48+
# Launch nodes
49+
./runNode.sh -n $N_NODE -a false -d true
50+
sleep 3
51+
# Setup block chain
52+
./setupnNode.sh -n $N_NODE -d true
53+
sleep 3
54+
# Start scenario test and keep logs
55+
NNODES=$N_NODE go test -v -run ^TestScenario$ github.com/dedis/d-voting/integration -count=1 | tee ./log/log/gotest.log
56+
sleep 3
57+
# Stop the test
58+
./kill_test.sh
59+
# move log to a new directory named logkill
60+
mv log/log log/logkill$i
61+
done
62+
63+
echo "Test $RUN_TIMES times test and succeeded $(grep -c ok ./log/log*/gotest.log| awk 'BEGIN{FS=":"}{x+=$2}END{print x}') times"

0 commit comments

Comments
 (0)