Let the CLI prevent adding incorrect Subnets.
[tinc] / test / import-export.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 echo [STEP] Initialize three nodes
6
7 tinc foo <<EOF
8 init foo
9 set DeviceType dummy
10 set Port 30000
11 set Address localhost
12 EOF
13
14 tinc bar <<EOF
15 init bar
16 set DeviceType dummy
17 set Port 0
18 EOF
19
20 tinc baz <<EOF
21 init baz
22 set DeviceType dummy
23 set Port 0
24 EOF
25
26 echo [STEP] Test import, export and exchange commands
27
28 tinc foo export | tinc bar exchange | tinc foo import
29
30 echo [STEP] Test export-all and exchange-all
31
32 tinc foo export-all | tinc baz exchange | tinc foo import
33 tinc foo exchange-all </dev/null | tinc bar import
34
35 echo [STEP] Test equivalence of host config files
36
37 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAR/hosts/foo"
38 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAZ/hosts/foo"
39 diff -w "$DIR_FOO/hosts/bar" "$DIR_BAR/hosts/bar"
40 diff -w "$DIR_FOO/hosts/bar" "$DIR_BAZ/hosts/bar"
41 diff -w "$DIR_FOO/hosts/baz" "$DIR_BAR/hosts/baz"
42 diff -w "$DIR_FOO/hosts/baz" "$DIR_BAZ/hosts/baz"
43
44 echo [STEP] Check whether the nodes can connect to each other
45
46 create_script foo tinc-up '
47   tinc bar add ConnectTo foo
48   tinc baz add ConnectTo foo
49 '
50
51 create_script foo hosts/bar-up
52 create_script foo hosts/baz-up
53
54 start_tinc foo
55
56 wait_script foo tinc-up
57
58 start_tinc bar
59 start_tinc baz
60
61 wait_script foo hosts/bar-up
62 wait_script foo hosts/baz-up
63
64 require_nodes foo 3
65 require_nodes bar 3
66 require_nodes baz 3