Skip to content

Commit 9891200

Browse files
authored
Merge pull request #203 from dedis/albert
Script to run the whole system in 1 command
2 parents 563b903 + 217fa60 commit 9891200

File tree

6 files changed

+458
-393
lines changed

6 files changed

+458
-393
lines changed

.github/workflows/go_scenario_test.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ jobs:
3232
- name: Install memcoin
3333
run: make build
3434

35-
- name: Start 3 nodes
36-
run: |
37-
./memcoin --config /tmp/node1 start --postinstall --promaddr :9100 --proxyaddr :9080 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2001 --public //localhost:2001 --routing tree &
38-
./memcoin --config /tmp/node2 start --postinstall --promaddr :9101 --proxyaddr :9081 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2002 --public //localhost:2002 --routing tree &
39-
./memcoin --config /tmp/node3 start --postinstall --promaddr :9102 --proxyaddr :9082 --proxykey adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3 --listen tcp://0.0.0.0:2003 --public //localhost:2003 --routing tree &
40-
41-
- name: Run the setup
42-
run: ./setupnNode.sh -n 3 -d false
35+
- name: Start and setup 3 nodes
36+
run: ./runSystems.sh -n 3 --docker false --backend false --frontend false --attach false
4337

4438
- name: Run the scenario Test
4539
run: go test -timeout 7m -run TestScenario ./integration/...

README.md

+80-57
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,27 @@ results.
355355
<a href="https://www.epfl.ch/labs/dedis/wp-content/uploads/2022/07/report-2022-1-capucine-badr-d-voting-frontend.pdf">Report</a>,
356356
<a href="https://www.epfl.ch/labs/dedis/wp-content/uploads/2022/07/presentation-2022-1-capucine-badr-d-voting-frontend.pdf">Presentation</a>
357357
</td>
358+
</tr>
359+
<tr>
360+
<td>Fall 2022</td>
361+
<td>Students: Amine Benaziz, Albert Troussard<br>Supervisor: Noémien Kocher, Pierluca Borso<br>Assistant: Emilien Duc</td></td>
362+
<td></td>
363+
<td>
364+
</td>
365+
</tr>
366+
<tr>
367+
<td>Fall 2022</td>
368+
<td>Students: Ahmed Elalamy, Ghita Tagemouati, Khadija Tagemouati<br>Supervisor: Noémien Kocher</td></td>
369+
<td></td>
370+
<td>
371+
</td>
372+
</tr>
373+
<tr>
374+
<td>Fall 2022</td>
375+
<td>Students: Chen Chang Lew<br>Supervisor: Noémien Kocher, Pierluca Borso</td></td>
376+
<td></td>
377+
<td>
378+
</td>
358379
</tr>
359380
</table>
360381

@@ -375,85 +396,70 @@ added to you path (like with `export PATH=$PATH:/Users/david/go/bin`).
375396

376397
3: [Install tmux](https://github.com/tmux/tmux/wiki/Installing)
377398

378-
# Setup a simple system with 3 nodes
379-
380-
If you are using Windows and cannot use tmux, you need to do the actions of the
381-
scripts in point _1_ and _2_ manually: open 3 terminal sessions and run the
382-
commands from the section _Run the nodes_ below (1 command LLVL=info memcoin etc.
383-
per terminal and then launch the setup script in another terminal). You can then
384-
follow the instructions below starting from point _3_.
399+
# Setup a simple system with 5 nodes (Linux and MacOS)
385400

386-
1: Run 3 nodes
401+
If you are using Windows and cannot use tmux, you need to follow the instructions in [this](#Setup-a-simple-system-with-5-nodes-(Windows))
402+
section.
387403

404+
1: Only for the first time
388405
```sh
389-
./runNode.sh -n 3
406+
cd web/backend
407+
npm install
408+
cp config.env.template config.env
409+
cd ../frontend
410+
npm install
411+
cd ../..
390412
```
391413

392-
This will run 4 terminal sessions. You can navigate by hitting
393-
<kbd>CTRL</kbd>+<kbd>B</kbd> and then <kbd>S</kbd>. Use the arrows to select a
394-
window.
414+
2: Then run the following script to start and setup the nodes and the web server:
395415

396-
2: Launch the setup
397416

398-
From the first terminal sessions, run:
399417

400418
```sh
401-
./setupnNode.sh -n 3
419+
./runSystems.sh -n 5
402420
```
403421

404-
3: Launch the web backend
422+
This will run 8 terminal sessions. You can navigate by hitting
423+
<kbd>CTRL</kbd>+<kbd>B</kbd> and then <kbd>S</kbd>. Use the arrows to select a
424+
window.
405425

406-
From a new terminal session, run:
407426

408-
```sh
409-
cd web/backend
410-
# if this is the first time, run `npm install` and `cp config.env.template config.env` first
411-
npm start
412-
```
427+
3: Stop nodes
428+
If you want to stop the system, you can use the following command:
413429

414-
4: Launch the web frontend
430+
(If you forgot, this will be done automatically when you start a new system)
415431

416-
From a new terminal session, run:
417-
418-
```sh
419-
cd web/frontend
420-
# if this is the first time, run `npm install` first
421-
REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start
422-
```
423-
424-
Note that you need to be on EPFL's network to login with Tequila. Additionally,
425-
once logged with Tequila, update the redirect URL and replace
426-
`dvoting-dev.dedis.ch` with `localhost`. Once logged, you can create an
427-
form.
428-
429-
5: Stop nodes
430432

431433
```sh
432434
./kill_test.sh
433435
```
434436

435-
6: Troubleshoot
437+
4: Troubleshoot
436438

437439
If while running
438440

439441
```sh
440-
npm start
442+
./runSystems.sh -n 5
441443
```
442444

443-
in the web backend folder, you get this error:
445+
You get this error:
444446

445447
```sh
446448
Error: listen EADDRINUSE: address already in use :::5000
447449
```
448450

449-
then run this instead:
451+
then in the file runSystems.sh, replace the line:
450452

451453
```sh
452-
PORT=4000 npm start
454+
tmux send-keys -t $s:{end} "cd web/backend && npm start" C-m
455+
```
456+
with
457+
```sh
458+
tmux send-keys -t $s:{end} "cd web/backend && PORT=4000 npm start" C-m
453459
#or any other available port
454460
```
455461

456-
and in the web/frontend/src/setupProxy.js file, change :
462+
And in the web/frontend/src/setupProxy.js file, change :
457463

458464
```sh
459465
target: 'http://localhost:5000',
@@ -465,7 +471,7 @@ with
465471
target: 'http://localhost:4000',
466472
```
467473

468-
# Run the nodes
474+
# Setup a simple system with 3 nodes (Windows)
469475

470476
In three different terminal sessions, from the root folder:
471477

@@ -502,24 +508,36 @@ remove the old state:
502508
rm -rf /tmp/node{1,2,3}
503509
```
504510

505-
# Testing
511+
3: Launch the web backend
512+
513+
From a new terminal session, run:
514+
515+
```sh
516+
cd web/backend
517+
# if this is the first time, run `npm install` and `cp config.env.template config.env` first
518+
npm start
519+
```
506520

507-
## Automate the previous setup using `tmux`
521+
4: Launch the web frontend
508522

509-
If you have `tmux` installed, you can start a `tmux` session that will
510-
execute the above setup by running in the project root `./runNode.sh -n 3`.
511-
This command takes as argument the number of nodes.
512-
Once the session is started, you can move around the panes with
513-
`Ctrl+B` followed by arrow keys or by `N`. You can also have an overview of the
514-
windows with `Ctrl+B` followed by `S`.
523+
From a new terminal session, run:
515524

516-
To end the session, run `./kill_test.sh`,
517-
which will kill each window then the `tmux` session (which you can do manually
518-
with `Ctrl+D`), then delete the node data (i.e. the files `/tmp/node{1,2,3}`).
525+
```sh
526+
cd web/frontend
527+
# if this is the first time, run `npm install` first
528+
REACT_APP_PROXY=http://localhost:9081 REACT_APP_NOMOCK=on npm start
529+
```
530+
531+
Note that you need to be on EPFL's network to login with Tequila. Additionally,
532+
once logged with Tequila, update the redirect URL and replace
533+
`dvoting-dev.dedis.ch` with `localhost`. Once logged, you can create an
534+
form.
535+
536+
# Testing
519537

520538
## Run the scenario test
521539

522-
If nodes are running and `setup.sh` or `./setupnNode.sh -n 3` has been called,
540+
If nodes are running and `setup.sh` or `./runSystem.sh -n 3 --backend false --frontend false` (for this test you don't want the user interface so the web components are not needed) has been called,
523541
you can run a test scenario:
524542

525543
```sh
@@ -540,7 +558,10 @@ Public key: `adbacd10fdb9822c71025d6d00092b8a4abb5ebcb673d28d863f7c7c5adaddf3`
540558

541559
Secret key: `28912721dfd507e198b31602fb67824856eb5a674c021d49fdccbe52f0234409`
542560

543-
## Run the scenario test with docker
561+
<!---
562+
Currently not working
563+
564+
## Run the scenario test with docker
544565
545566
Use the following commands to launch and set up nodes, and start the scenario
546567
test with user defined number of nodes.
@@ -571,6 +592,8 @@ N.B. run following commands to get help
571592
./autotest.sh -h
572593
```
573594
595+
-->
596+
574597
# Use the frontend
575598

576599
See README in `web/`.

kill_test.sh

+50
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,55 @@
22

33
# This script kills the tmux session started in start_test.sh and
44
# removes all the data pertaining to the test.
5+
FRONTEND=true
6+
BACKEND=true
7+
8+
while [[ $# -gt 0 ]]; do
9+
case $1 in
10+
-h | --help)
11+
echo "This script is creating n dela voting nodes"
12+
echo "Options:"
13+
echo "-h | --help program help (this file)"
14+
echo "-f | --frontend kill the frontend true/false, by default true"
15+
echo "-b | --backend kill the backend true/false, by default true"
16+
exit 0
17+
;;
18+
-f | --frontend)
19+
FRONTEND="$2"
20+
shift # past argument
21+
shift # past value
22+
;;
23+
-b | --backend)
24+
BACKEND="$2"
25+
shift # past argument
26+
shift # past value
27+
;;
28+
-* | --*)
29+
echo "Unknown option $1"
30+
exit 1
31+
;;
32+
*)
33+
POSITIONAL_ARGS+=("$1") # save positional arg
34+
shift # past argument
35+
;;
36+
esac
37+
done
38+
39+
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
40+
41+
set -o errexit
42+
43+
command -v tmux >/dev/null 2>&1 || {
44+
echo >&2 "tmux is not on your PATH!"
45+
exit 1
46+
}
47+
48+
if [ "$FRONTEND" = true ]; then
49+
tmux send-keys -t $s:{end} C-c
50+
tmux kill-window -t $s:{end}
51+
fi
52+
if [ "$BACKEND" = true ]; then
53+
tmux send-keys -t $s:{end} C-c
54+
fi
555

656
rm -rf /tmp/node* && tmux kill-session -t d-voting-test

0 commit comments

Comments
 (0)