3 # Three nodes are initialized:
4 # latest : created from the latest commit that triggered this CI job
5 # tinc11 : from the latest tag in tinc 1.1 branch
6 # tinc10 : from the latest commit in tinc 1.0 branch
8 # The latter two are configured by using import/export/exchange.
9 # Since tinc 1.0 doesn't support that, host configs are copied to its hosts directory.
10 # Then nodes are connected and some light testing is performed to make sure they work together.
14 nodes='latest tinc11 tinc10'
18 [tinc10]='origin/master'
19 [tinc11]="$(git describe --abbrev=0 --match='release-*')"
24 [tinc10]='192.168.1.1'
25 [tinc11]='192.168.1.2'
26 [latest]='192.168.1.3'
35 tar -caf /tmp/tests.tar.gz /usr/local/etc || true
39 echo >&2 '################################################################################'
41 echo >&2 '################################################################################'
45 meson setup "$1" -D prefix="/opt/$1"
51 ./configure --prefix="/opt/$1"
58 header "Building tinc (ref $ref)"
60 git clone "$PWD" "$src/$ref" -b "compat-$ref"
63 if [[ -f meson.build ]]; then
66 build_autotools "$ref"
70 mkdir -p "/opt/$ref/var/run"
78 while ! ip netns exec "$from" ping -W1 -c1 "${addr[$to]}" >/dev/null; do
81 if [[ total -gt 60 ]]; then
82 echo >&2 "Network connection between $from and $to is not working"
86 echo >&2 "Network isn't ready yet..."
95 wait_network "$from" "$to"
97 header "Sending data between $from and $to"
99 ip netns exec "$from" \
100 iperf3 --time 1 --client "${addr[$to]}"
106 local output="$etc/$signer/signed"
108 header "Test signature verification between $signer and $verifier"
110 "$signer" sign >"$output" <<<"text message for node $signer to sign"
112 for peer in "$signer" '*'; do
113 "$verifier" verify "$peer" "$output"
114 "$verifier" verify "$peer" <"$output"
121 header "Checking node status for $node"
123 reachable="$("$node" dump reachable nodes | wc -l)"
124 echo >&2 "Node $node can reach $reachable nodes"
126 [[ $reachable == "$total_nodes" ]]
128 for peer in $nodes; do
129 echo >&2 -n "$node info $peer: "
130 "$node" info "$peer" | tee /dev/stderr | grep -E -q '(can reach itself|directly)'
135 /opt/latest/sbin/tinc -c $etc/latest "$@"
139 /opt/tinc11/sbin/tinc -c $etc/tinc11 "$@"
142 header 'Creating branches'
144 for node in $nodes; do
145 echo >&2 " $node: $(git rev-parse "compat-$node")"
146 git branch "compat-$node" "${refs[$node]}"
153 header 'Initializing node from the latest commit'
157 set Address localhost
160 set Subnet ${addr[latest]}
165 header 'Initializing node from the latest tag'
169 set Address localhost
172 set Subnet ${addr[tinc11]}
177 header 'Initializing node for tinc 1.0'
179 mkdir -p $etc/tinc10/hosts
181 cat >$etc/tinc10/tinc.conf <<EOF
188 cat >$etc/tinc10/hosts/tinc10 <<EOF
191 Subnet = ${addr[tinc10]}
194 /opt/tinc10/sbin/tincd -c $etc/tinc10 --generate-keys
196 trap archive EXIT INT TERM
198 header 'Creating network namespaces'
204 header 'Creating network configuration scripts'
206 for node in $nodes; do
207 tinc_up="$etc/$node/tinc-up"
209 cat >"$tinc_up" <<EOF
212 ip link set dev $node netns $node
213 ip netns exec $node ip addr add ${addr[$node]}/24 dev $node
214 ip netns exec $node ip link set $node up
215 ip netns exec $node ip link set lo up
216 ip netns exec $node iperf3 --server --daemon
222 header 'Exchanging host files'
224 # Not all configs are copied to make sure 'peer exchange' is working
225 # tinc10 <--> latest <--> tinc11
226 latest export | tinc11 exchange | latest import
227 cp $etc/tinc10/hosts/tinc10 $etc/latest/hosts/
228 cp $etc/latest/hosts/latest $etc/tinc10/hosts/
230 header "Starting nodes"
232 for node in $nodes; do
233 tincd="/opt/$node/sbin/tincd"
234 echo >&2 "Starting node $node ($tincd)"
239 --config "$etc/$node" \
240 --pidfile "$etc/$node/pid" \
241 --logfile "$etc/$node/log" \
245 header 'Running connectivity tests'
247 for client in $nodes; do
248 for server in $nodes; do
249 if [[ $client != "$server" ]]; then
250 test_network "$client" "$server"
255 test_node_status latest
256 test_node_status tinc11
258 test_sign_verify latest tinc11
259 test_sign_verify tinc11 latest