aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/.gitignore10
-rw-r--r--src/integration-tests/Makefile.am90
-rw-r--r--src/integration-tests/confs/c_bootstrap_server.conf92
-rw-r--r--src/integration-tests/confs/c_nat_client.conf72
-rw-r--r--src/integration-tests/confs/c_no_nat_client.conf105
-rw-r--r--src/integration-tests/confs/c_no_nat_client_2.conf119
-rw-r--r--src/integration-tests/confs/test_defaults.conf76
-rw-r--r--src/integration-tests/gnunet_pyexpect.py.in94
-rw-r--r--src/integration-tests/gnunet_testing.py.in381
-rw-r--r--src/integration-tests/hostkeys/c_bootstrap_server1
-rw-r--r--src/integration-tests/hostkeys/c_nat_client1
-rw-r--r--src/integration-tests/hostkeys/c_no_nat_client1
-rw-r--r--src/integration-tests/hostkeys/c_no_nat_client_21
-rwxr-xr-xsrc/integration-tests/test_integration_bootstrap_and_connect.py.in212
-rwxr-xr-xsrc/integration-tests/test_integration_clique.py.in236
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect.py.in215
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect_nat.py.in223
-rwxr-xr-xsrc/integration-tests/test_integration_reconnect.py.in237
-rwxr-xr-xsrc/integration-tests/test_integration_reconnect_nat.py.in237
19 files changed, 0 insertions, 2403 deletions
diff --git a/src/integration-tests/.gitignore b/src/integration-tests/.gitignore
deleted file mode 100644
index 46915b2a4..000000000
--- a/src/integration-tests/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
1gnunet_testing.py
2gnunet_pyexpect.py
3gnunet_pyexpect.pyc
4gnunet_testing.pyc
5test_integration_bootstrap_and_connect.py
6test_integration_clique.py
7test_integration_disconnect_nat.py
8test_integration_disconnect.py
9test_integration_reconnect_nat.py
10test_integration_reconnect.py
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am
deleted file mode 100644
index 59daff4f6..000000000
--- a/src/integration-tests/Makefile.am
+++ /dev/null
@@ -1,90 +0,0 @@
1# This Makefile.am is in the public domain
2AM_CPPFLAGS = -I$(top_srcdir)/src/include
3
4if USE_COVERAGE
5 AM_CFLAGS = --coverage -O0
6 XLIB = -lgcov
7endif
8
9noinst_SCRIPTS = \
10 gnunet_testing.py \
11 gnunet_pyexpect.py
12
13if HAVE_PYTHON
14check_SCRIPTS = \
15 # test_integration_bootstrap_and_connect.py \
16 # test_integration_disconnect.py \
17 # test_integration_disconnect_nat.py \
18 # test_integration_reconnect.py \
19 # test_integration_reconnect_nat.py
20# test_integration_clique.py
21endif
22
23
24if ENABLE_TEST_RUN
25AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
26TESTS = \
27 $(check_SCRIPTS)
28endif
29
30SUFFIXES = .py.in .py
31.py.in.py:
32 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/$< > $@
33 chmod +x $@
34
35gnunet_testing.py: gnunet_testing.py.in Makefile
36 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/gnunet_testing.py.in > gnunet_testing.py
37 chmod +x gnunet_testing.py
38
39gnunet_pyexpect.py: gnunet_pyexpect.py.in Makefile
40 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/gnunet_pyexpect.py.in > gnunet_pyexpect.py
41 chmod +x gnunet_pyexpect.py
42
43test_integration_bootstrap_and_connect.py: test_integration_bootstrap_and_connect.py.in Makefile
44 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_bootstrap_and_connect.py.in > test_integration_bootstrap_and_connect.py
45 chmod +x test_integration_bootstrap_and_connect.py
46
47test_integration_disconnect.py: test_integration_disconnect.py.in Makefile
48 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_disconnect.py.in > test_integration_disconnect.py
49 chmod +x test_integration_disconnect.py
50
51test_integration_disconnect_nat.py: test_integration_disconnect_nat.py.in Makefile
52 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_disconnect_nat.py.in > test_integration_disconnect_nat.py
53 chmod +x test_integration_disconnect_nat.py
54
55test_integration_reconnect.py: test_integration_reconnect.py.in Makefile
56 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_reconnect.py.in > test_integration_reconnect.py
57 chmod +x test_integration_reconnect.py
58
59test_integration_reconnect_nat.py: test_integration_reconnect_nat.py.in Makefile
60 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_reconnect_nat.py.in > test_integration_reconnect_nat.py
61 chmod +x test_integration_reconnect_nat.py
62
63test_integration_clique.py: test_integration_clique.py.in Makefile
64 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_integration_clique.py.in > test_integration_clique.py
65 chmod +x test_integration_clique.py
66
67
68EXTRA_DIST = \
69 gnunet_testing.py.in \
70 gnunet_pyexpect.py.in \
71 test_integration_bootstrap_and_connect.py.in \
72 test_integration_disconnect.py.in \
73 test_integration_disconnect_nat.py.in \
74 test_integration_reconnect.py.in \
75 test_integration_reconnect_nat.py.in \
76 test_integration_clique.py.in \
77 confs/test_defaults.conf \
78 confs/c_bootstrap_server.conf \
79 confs/c_nat_client.conf \
80 confs/c_no_nat_client_2.conf \
81 confs/c_no_nat_client.conf \
82 hostkeys/c_bootstrap_server \
83 hostkeys/c_no_nat_client \
84 hostkeys/c_no_nat_client_2 \
85 hostkeys/c_nat_client
86
87CLEANFILES = \
88 $(check_SCRIPTS) \
89 gnunet_pyexpect.py \
90 gnunet_testing.py
diff --git a/src/integration-tests/confs/c_bootstrap_server.conf b/src/integration-tests/confs/c_bootstrap_server.conf
deleted file mode 100644
index 59f2bb949..000000000
--- a/src/integration-tests/confs/c_bootstrap_server.conf
+++ /dev/null
@@ -1,92 +0,0 @@
1@INLINE@ test_defaults.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/c_bootstrap_server/
5
6[PEER]
7PRIVATE_KEY = hostkeys/c_bootstrap_server
8
9
10[transport]
11UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-8
12PORT = 20011
13PLUGINS = tcp
14
15[transport-tcp]
16PORT = 20010
17ADVERTISED_PORT = 20010
18
19[hostlist]
20OPTIONS = -p
21SERVERs =
22
23[nat]
24BEHIND_NAT = NO
25DISABLEV6 = NO
26UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-4
27PORT = 20070
28
29[nat-auto]
30UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-4
31PORT = 20076
32
33[arm]
34UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-4
35PORT = 20004
36
37[dns]
38UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-5
39
40[core]
41UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-3
42PORT = 20003
43
44[ats]
45UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-9
46PORT = 20012
47
48[cadet]
49UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-13
50PORT = 20016
51
52[datastore]
53UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-11
54PORT = 20014
55
56[resolver]
57UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-14
58PORT = 20017
59
60[dht]
61UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-1
62PORT = 20000
63
64[nat]
65BEHIND_NAT = NO
66
67[fs]
68UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-6
69PORT = 20005
70
71[gns]
72UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-15
73PORT = 20018
74
75[dv]
76UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-16
77PORT = 20019
78
79[vpn]
80UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-15
81
82[peerinfo]
83UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-10
84PORT = 20013
85
86[statistics]
87UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-2
88PORT = 20001
89
90[nse]
91UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-12
92PORT = 20015
diff --git a/src/integration-tests/confs/c_nat_client.conf b/src/integration-tests/confs/c_nat_client.conf
deleted file mode 100644
index 550bd38f7..000000000
--- a/src/integration-tests/confs/c_nat_client.conf
+++ /dev/null
@@ -1,72 +0,0 @@
1@INLINE@ test_defaults.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/c_nat_client/
5
6[PEER]
7PRIVATE_KEY = hostkeys/c_nat_client
8
9
10[transport]
11UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-50
12PORT = 20065
13PLUGINS = tcp
14
15[transport-tcp]
16PORT = 0
17ADVERTISED_PORT = 20064
18
19[transport-udp]
20PORT = 0
21
22[hostlist]
23SERVERS = http://localhost:8080/
24
25[nat]
26BEHIND_NAT = YES
27DISABLEV6 = NO
28UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-46
29PORT = 20071
30
31[nat-auto]
32UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-46
33PORT = 20077
34
35[arm]
36UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-46
37PORT = 20058
38
39[core]
40UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-45
41PORT = 20057
42
43[ats]
44UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-51
45PORT = 20066
46
47[datastore]
48UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-53
49PORT = 20068
50
51[resolver]
52UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-56
53PORT = 20071
54
55[dht]
56UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-43
57PORT = 20054
58
59[fs]
60UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-48
61PORT = 20059
62
63[dv]
64UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_nat_c-1
65
66[peerinfo]
67UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-52
68PORT = 20067
69
70[nse]
71UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-54
72PORT = 20069 \ No newline at end of file
diff --git a/src/integration-tests/confs/c_no_nat_client.conf b/src/integration-tests/confs/c_no_nat_client.conf
deleted file mode 100644
index 4573df601..000000000
--- a/src/integration-tests/confs/c_no_nat_client.conf
+++ /dev/null
@@ -1,105 +0,0 @@
1@INLINE@ test_defaults.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/c_no_nat_client/
5
6[PEER]
7PRIVATE_KEY = hostkeys/c_no_nat_client
8
9[transport]
10PLUGINS = tcp
11UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-22
12PORT = 20029
13
14[transport-tcp]
15PORT = 20028
16ADVERTISED_PORT = 20028
17
18[hostlist]
19SERVERS = http://localhost:8080/
20
21[nat]
22BEHIND_NAT = NO
23DISABLEV6 = NO
24UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-18
25PORT = 20072
26
27[nat-auto]
28UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-18
29PORT = 20074
30
31[arm]
32UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-18
33PORT = 20022
34
35[namestore]
36START_ON_DEMAND = YES
37
38[dns]
39UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-19
40
41[consensus]
42START_ON_DEMAND = YES
43
44[core]
45UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-17
46PORT = 20021
47
48[ats]
49UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-23
50WAN_QUOTA_IN = 64 KiB
51WAN_QUOTA_OUT = 64 KiB
52PORT = 20030
53
54[cadet]
55UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-27
56PORT = 20034
57
58[datastore]
59UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-25
60PORT = 20032
61
62[resolver]
63UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-28
64PORT = 20035
65
66[dht]
67UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-15
68PORT = 20018
69
70[dhtcache]
71DATABASE = heap
72QUOTA = 50 MB
73
74[gnunet-nat-server]
75PORT = 20020
76
77[fs]
78UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-20
79PORT = 20023
80
81[vpn]
82UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-29
83
84[dv]
85UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_no_nat_c-1
86
87[peerinfo]
88UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-24
89PORT = 20031
90
91[statistics]
92UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-16
93PORT = 20019
94
95[nse]
96UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-26
97PORT = 20033
98
99[gns]
100UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-35
101PORT = 20038
102
103[dv]
104UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-36
105PORT = 20039
diff --git a/src/integration-tests/confs/c_no_nat_client_2.conf b/src/integration-tests/confs/c_no_nat_client_2.conf
deleted file mode 100644
index a7d9a436f..000000000
--- a/src/integration-tests/confs/c_no_nat_client_2.conf
+++ /dev/null
@@ -1,119 +0,0 @@
1@INLINE@ test_defaults.conf
2
3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/c_no_nat_client_2/
5
6[PEER]
7PRIVATE_KEY = hostkeys/c_no_nat_client_2
8
9
10[transport]
11PLUGINS = tcp
12UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-22
13PORT = 20039
14
15[transport-tcp]
16PORT = 20038
17ADVERTISED_PORT = 20038
18
19[transport-udp]
20PORT = 20027
21BROADCAST_INTERVAL = 30 s
22
23[hostlist]
24SERVERS = http://localhost:8080/
25
26[nat]
27BEHIND_NAT = NO
28DISABLEV6 = NO
29PORT = 20073
30UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-18
31
32[nat-auto]
33PORT = 20075
34UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-18
35
36
37[arm]
38UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-18
39PORT = 20022
40
41[namestore]
42START_ON_DEMAND = YES
43
44[dns]
45UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-19
46
47[consensus]
48START_ON_DEMAND = YES
49
50[lockmanager]
51START_ON_DEMAND = YES
52
53[core]
54UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-17
55PORT = 20021
56
57[ats]
58UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-23
59WAN_QUOTA_IN = 64 KiB
60WAN_QUOTA_OUT = 64 KiB
61PORT = 20030
62
63[cadet]
64UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-27
65PORT = 20034
66
67[datastore]
68UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-25
69PORT = 20032
70
71[resolver]
72UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-28
73PORT = 20035
74
75[dht]
76UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-15
77PORT = 20018
78
79[dhtcache]
80DATABASE = heap
81QUOTA = 50 MB
82
83[gnunet-nat-server]
84PORT = 20020
85
86[fs]
87UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-20
88PORT = 20023
89
90[vpn]
91UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-29
92
93[dv]
94UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_no_nat_c-1
95
96[peerinfo]
97UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-24
98USE_INCLUDED_HELLOS = YES
99PORT = 20031
100
101[statistics]
102UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-16
103PORT = 20019
104
105[template]
106PORT = 20024
107UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-template-21
108
109[nse]
110UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-26
111PORT = 20033
112
113[gns]
114UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-35
115PORT = 20038
116
117[dv]
118UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-36
119PORT = 20039
diff --git a/src/integration-tests/confs/test_defaults.conf b/src/integration-tests/confs/test_defaults.conf
deleted file mode 100644
index 3ccdc2946..000000000
--- a/src/integration-tests/confs/test_defaults.conf
+++ /dev/null
@@ -1,76 +0,0 @@
1@INLINE@ ../../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../../contrib/conf/gnunet/no_autostart_above_core.conf
3
4[fs]
5IMMEDIATE_START = YES
6
7[datastore]
8START_ON_DEMAND = YES
9
10[dht]
11START_ON_DEMAND = YES
12
13[nse]
14START_ON_DEMAND = YES
15
16[cadet]
17START_ON_DEMAND = YES
18
19[hostlist]
20IMMEDIATE_START = YES
21
22[topology]
23IMMEDIATE_START = YES
24
25[peerinfo]
26USE_INCLUDED_HELLOS = NO
27
28[transport-tcp]
29USE_LOCALADDR = YES
30
31[transport-udp]
32BROADCAST = NO
33BROADCAST_RECEIVE = no
34USE_LOCALADDR = YES
35
36[nat]
37BEHIND_NAT = NO
38EXTERNAL_ADDRESS = 127.0.0.1
39INTERNAL_ADDRESS = 127.0.0.1
40BINDTO = 127.0.0.1
41RETURN_LOCAL_ADDRESSES = YES
42
43[hostlist]
44SERVERS =
45
46[dns]
47UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-47
48ACCEPT_FROM = 127.0.0.1;
49ACCEPT_FROM6 = ::1;
50PROVIDE_EXIT = NO
51
52[ats]
53WAN_QUOTA_IN = unlimited
54WAN_QUOTA_OUT = unlimited
55ATS_MIN_INTERVAL = 15000
56ATS_EXEC_INTERVAL = 30000
57
58[datastore]
59UNIX_MATCH_UID = YES
60QUOTA = 100 MB
61BLOOMFILTER = $GNUNET_TEST_HOME/fs/bloomfilter
62
63[dhtcache]
64DATABASE = sqlite
65QUOTA = 1 MB
66
67[fs]
68INDEXDB = $GNUNET_TEST_HOME/idxinfo.lst
69IDENTITY_DIR = $GNUNET_TEST_HOME/identities/
70STATE_DIR = $GNUNET_TEST_HOME/persistence/
71UPDATE_DIR = $GNUNET_TEST_HOME/updates/
72TRUST = $GNUNET_TEST_HOME/data/credit/
73
74[datacache-mysql]
75DATABASE = gnunet
76CONFIG = ~/.my.cnf
diff --git a/src/integration-tests/gnunet_pyexpect.py.in b/src/integration-tests/gnunet_pyexpect.py.in
deleted file mode 100644
index b8ce52f00..000000000
--- a/src/integration-tests/gnunet_pyexpect.py.in
+++ /dev/null
@@ -1,94 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20# Testcase for gnunet-peerinfo
21
22import os
23import re
24import subprocess
25import sys
26import shutil
27import time
28
29
30class pexpect(object):
31 def __init__(self):
32 super(pexpect, self).__init__()
33
34 def spawn(self, stdin, arglist, *pargs, **kwargs):
35 env = kwargs.pop('env', None)
36 if env is None:
37 env = os.environ.copy()
38 # This messes up some testcases, disable log redirection
39 env.pop('GNUNET_FORCE_LOGFILE', None)
40 self.proc = subprocess.Popen(arglist, *pargs, env=env, **kwargs)
41 if self.proc is None:
42 print("Failed to spawn a process {0}".format(arglist))
43 sys.exit(1)
44 if stdin is not None:
45 self.stdo, self.stde = self.proc.communicate(stdin)
46 else:
47 self.stdo, self.stde = self.proc.communicate()
48 return self.proc
49
50 def expect(self, s, r, flags=0):
51 stream = self.stdo if s == 'stdout' else self.stde
52 if isinstance(r, str):
53 if r == "EOF":
54 if len(stream) == 0:
55 return True
56 else:
57 print(
58 "Failed to find `{1}' in {0}, which is `{2}' ({3})".
59 format(s, r, stream, len(stream))
60 )
61 sys.exit(2)
62 raise ValueError(
63 "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'"
64 .format(r)
65 )
66 m = r.search(stream, flags)
67 if not m:
68 print(
69 "Failed to find `{1}' in {0}, which is is `{2}'".format(
70 s, r.pattern, stream
71 )
72 )
73 sys.exit(2)
74 stream = stream[m.end():]
75 if s == 'stdout':
76 self.stdo = stream
77 else:
78 self.stde = stream
79 return m
80
81 def read(self, s, size=-1):
82 stream = self.stdo if s == 'stdout' else self.stde
83 result = ""
84 if size < 0:
85 result = stream
86 new_stream = ""
87 else:
88 result = stream[0:size]
89 new_stream = stream[size:]
90 if s == 'stdout':
91 self.stdo = new_stream
92 else:
93 self.stde = new_stream
94 return result
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
deleted file mode 100644
index 828f6ff42..000000000
--- a/src/integration-tests/gnunet_testing.py.in
+++ /dev/null
@@ -1,381 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2017, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20# Functions for integration testing
21
22import os
23import subprocess
24import sys
25import shutil
26import time
27from gnunet_pyexpect import pexpect
28import logging
29
30logger = logging.getLogger()
31handler = logging.StreamHandler()
32formatter = logging.Formatter(
33 '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
34)
35handler.setFormatter(formatter)
36logger.addHandler(handler)
37logger.setLevel(logging.DEBUG)
38
39
40class Check(object):
41 def __init__(self, test):
42 self.fulfilled = False
43 self.conditions = list()
44 self.test = test
45
46 def add(self, condition):
47 self.conditions.append(condition)
48
49 def run(self):
50 fulfilled = True
51 pos = 0
52 neg = 0
53 for c in self.conditions:
54 if (False == c.check()):
55 fulfilled = False
56 neg += 1
57 else:
58 pos += 1
59 return fulfilled
60
61 def run_blocking(self, timeout, pos_cont, neg_cont):
62 execs = 0
63 res = False
64 while ((False == res) and (execs < timeout)):
65 res = self.run()
66 time.sleep(1)
67 execs += 1
68 if ((False == res) and (execs >= timeout)):
69 logger.debug('Check had timeout after %s seconds', str(timeout))
70 neg_cont(self)
71 elif ((False == res) and (execs < timeout)):
72 if (None != neg_cont):
73 neg_cont(self)
74 else:
75 if (None != pos_cont):
76 pos_cont(self)
77 return res
78
79 def run_once(self, pos_cont, neg_cont):
80 execs = 0
81 res = False
82 res = self.run()
83 if ((res == False) and (neg_cont != None)):
84 neg_cont(self)
85 if ((res == True) and (pos_cont != None)):
86 pos_cont(self)
87 return res
88
89 def evaluate(self, failed_only):
90 pos = 0
91 neg = 0
92 for c in self.conditions:
93 if (False == c.evaluate(failed_only)):
94 neg += 1
95 else:
96 pos += 1
97 logger.debug(
98 '%s out of %s conditions fulfilled', str(pos), str(pos + neg)
99 )
100 return self.fulfilled
101
102 def reset(self):
103 self.fulfilled = False
104 for c in self.conditions:
105 c.fulfilled = False
106
107
108class Condition(object):
109 def __init__(self):
110 self.fulfilled = False
111 self.type = 'generic'
112
113 def __init__(self, type):
114 self.fulfilled = False
115 self.type = type
116
117 def check(self):
118 return False
119
120 def evaluate(self, failed_only):
121 if ((self.fulfilled == False) and (failed_only == True)):
122 logger.debug(
123 '%s condition for was %s', str(self.type), str(self.fulfilled)
124 )
125 elif (failed_only == False):
126 logger.debug(
127 '%s condition for was %s', str(self.type), str(self.fulfilled)
128 )
129 return self.fulfilled
130
131
132class FileExistCondition(Condition):
133 def __init__(self, file):
134 self.fulfilled = False
135 self.type = 'file'
136 self.file = file
137
138 def check(self):
139 if (self.fulfilled == False):
140 res = os.path.isfile(self.file)
141 if (res == True):
142 self.fulfilled = True
143 return True
144 else:
145 return False
146 else:
147 return True
148
149 def evaluate(self, failed_only):
150 if ((self.fulfilled == False) and (failed_only == True)):
151 logger.debug(
152 '%s confition for file %s was %s', str(self.type), self.file,
153 str(self.fulfilled)
154 )
155 elif (failed_only == False):
156 logger.debug(
157 '%s confition for file %s was %s', str(self.type), self.file,
158 str(self.fulfilled)
159 )
160 return self.fulfilled
161
162
163class StatisticsCondition(Condition):
164 def __init__(self, peer, subsystem, name, value):
165 self.fulfilled = False
166 self.type = 'statistics'
167 self.peer = peer
168 self.subsystem = subsystem
169 self.name = name
170 self.value = str(value)
171 self.result = -1
172
173 def check(self):
174 if (self.fulfilled == False):
175 self.result = self.peer.get_statistics_value(
176 self.subsystem, self.name
177 )
178 if (self.result == self.value):
179 self.fulfilled = True
180 return True
181 else:
182 return False
183 else:
184 return True
185
186 def evaluate(self, failed_only):
187 if (self.fulfilled == False):
188 fail = " FAIL!"
189 op = " != "
190 else:
191 fail = ""
192 op = " == "
193 if (((self.fulfilled == False) and (failed_only == True))
194 or (failed_only == False)):
195 logger.debug(
196 '%s %s condition in subsystem %s: %s: (expected/real value) %s %s %s %s',
197 self.peer.id[:4].decode("utf-8"), self.peer.cfg,
198 self.subsystem.ljust(12), self.name.ljust(30), self.value, op,
199 self.result, fail
200 )
201 return self.fulfilled
202
203
204# Specify two statistic values and check if they are equal
205class EqualStatisticsCondition(Condition):
206 def __init__(self, peer, subsystem, name, peer2, subsystem2, name2):
207 self.fulfilled = False
208 self.type = 'equalstatistics'
209 self.peer = peer
210 self.subsystem = subsystem
211 self.name = name
212 self.result = -1
213 self.peer2 = peer2
214 self.subsystem2 = subsystem2
215 self.name2 = name2
216 self.result2 = -1
217
218 def check(self):
219 if (self.fulfilled == False):
220 self.result = self.peer.get_statistics_value(
221 self.subsystem, self.name
222 )
223 self.result2 = self.peer2.get_statistics_value(
224 self.subsystem2, self.name2
225 )
226 if (self.result == self.result2):
227 self.fulfilled = True
228 return True
229 else:
230 return False
231 else:
232 return True
233
234 def evaluate(self, failed_only):
235 if (((self.fulfilled == False) and (failed_only == True))
236 or (failed_only == False)):
237 logger.debug(
238 '%s %s %s == %s %s %s %s %s', self.peer.id[:4],
239 self.subsystem.ljust(12), self.name.ljust(30), self.result,
240 self.peer2.id[:4], self.subsystem2.ljust(12),
241 self.name2.ljust(30), self.result2
242 )
243 return self.fulfilled
244
245
246class Test(object):
247 def __init__(self, testname, verbose):
248 self.peers = list()
249 self.verbose = verbose
250 self.name = testname
251 srcdir = "../.."
252 gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts")
253 if gnunet_pyexpect_dir not in sys.path:
254 sys.path.append(gnunet_pyexpect_dir)
255 self.gnunetarm = ''
256 self.gnunetstatistics = ''
257 if os.name == 'posix':
258 self.gnunetarm = 'gnunet-arm'
259 self.gnunetstatistics = 'gnunet-statistics'
260 self.gnunetpeerinfo = 'gnunet-peerinfo'
261 elif os.name == 'nt':
262 self.gnunetarm = 'gnunet-arm.exe'
263 self.gnunetstatistics = 'gnunet-statistics.exe'
264 self.gnunetpeerinfo = 'gnunet-peerinfo.exe'
265 if os.name == "nt":
266 shutil.rmtree(os.path.join(os.getenv("TEMP"), testname), True)
267 else:
268 shutil.rmtree("/tmp/" + testname, True)
269
270 def add_peer(self, peer):
271 self.peers.append(peer)
272
273 def p(self, msg):
274 if (self.verbose == True):
275 print(msg)
276
277
278class Peer(object):
279 def __init__(self, test, cfg_file):
280 if (False == os.path.isfile(cfg_file)):
281 # print(("Peer cfg " + cfg_file + ": FILE NOT FOUND"))
282 logger.debug('Peer cfg %s : FILE NOT FOUND', cfg_file)
283 self.id = "<NaN>"
284 self.test = test
285 self.started = False
286 self.cfg = cfg_file
287
288 def __del__(self):
289 if (self.started == True):
290 # print('ERROR! Peer using cfg ' + self.cfg + ' was not stopped')
291 logger.debug('ERROR! Peer using cfg %s was not stopped', self.cfg)
292 ret = self.stop()
293 if (False == ret):
294 # print('ERROR! Peer using cfg ' +
295 # self.cfg +
296 # ' could not be stopped')
297 logger.debug(
298 'ERROR! Peer using cfg %s could not be stopped', self.cfg
299 )
300 self.started = False
301 return ret
302 else:
303 return False
304
305 def start(self):
306 os.unsetenv("XDG_CONFIG_HOME")
307 os.unsetenv("XDG_DATA_HOME")
308 os.unsetenv("XDG_CACHE_HOME")
309 self.test.p("Starting peer using cfg " + self.cfg)
310 try:
311 server = subprocess.Popen([
312 self.test.gnunetarm, '-sq', '-c', self.cfg
313 ])
314 server.communicate()
315 except OSError:
316 # print("Can not start peer")
317 logger.debug('Can not start peer')
318 self.started = False
319 return False
320 self.started = True
321 test = ''
322 try:
323 server = pexpect()
324 server.spawn(
325 None, [self.test.gnunetpeerinfo, '-c', self.cfg, '-s'],
326 stdout=subprocess.PIPE,
327 stderr=subprocess.STDOUT
328 )
329 test = server.read("stdout", 1024)
330 except OSError:
331 # print("Can not get peer identity")
332 logger.debug('Can not get peer identity')
333 test = (test.split(b'`')[1])
334 self.id = test.split(b'\'')[0]
335 return True
336
337 def stop(self):
338 if (self.started == False):
339 return False
340 self.test.p("Stopping peer using cfg " + self.cfg)
341 try:
342 server = subprocess.Popen([
343 self.test.gnunetarm, '-eq', '-c', self.cfg
344 ])
345 server.communicate()
346 except OSError:
347 # print("Can not stop peer")
348 logger.debug('Can not stop peer')
349 return False
350 self.started = False
351 return True
352
353 def get_statistics_value(self, subsystem, name):
354 server = pexpect()
355 server.spawn(
356 None, [
357 self.test.gnunetstatistics, '-c', self.cfg, '-q', '-n', name,
358 '-s', subsystem
359 ],
360 stdout=subprocess.PIPE,
361 stderr=subprocess.STDOUT
362 )
363 # server.expect ("stdout", re.compile (r""))
364 test = server.read("stdout", 10240)
365 tests = test.partition(b'\n')
366 # On W32 GNUnet outputs with \r\n, rather than \n
367 if os.name == 'nt' and tests[1] == b'\n' and tests[0][-1] == b'\r':
368 tests = (tests[0][:-1], tests[1], tests[2])
369 tests = tests[0]
370 result = tests.decode("utf-8").strip()
371 logger.debug(
372 'running gnunet-statistics %s for %s "/" %s yields %s', self.cfg,
373 name, subsystem, result
374 )
375 if (result.isdigit() == True):
376 return result
377 else:
378 logger.debug(
379 'Invalid statistics value: %s is not a number!', result
380 )
381 return -1
diff --git a/src/integration-tests/hostkeys/c_bootstrap_server b/src/integration-tests/hostkeys/c_bootstrap_server
deleted file mode 100644
index 937f09e51..000000000
--- a/src/integration-tests/hostkeys/c_bootstrap_server
+++ /dev/null
@@ -1 +0,0 @@
1«´\{€ìº–„âÒq@AP­³­”I$Õ1Šrî˜ \ No newline at end of file
diff --git a/src/integration-tests/hostkeys/c_nat_client b/src/integration-tests/hostkeys/c_nat_client
deleted file mode 100644
index 70350b89f..000000000
--- a/src/integration-tests/hostkeys/c_nat_client
+++ /dev/null
@@ -1 +0,0 @@
1äÅ»ªP yÑûc½q‰®j[U1úúÑÕГæ¿aŽl \ No newline at end of file
diff --git a/src/integration-tests/hostkeys/c_no_nat_client b/src/integration-tests/hostkeys/c_no_nat_client
deleted file mode 100644
index e0a97bc2b..000000000
--- a/src/integration-tests/hostkeys/c_no_nat_client
+++ /dev/null
@@ -1 +0,0 @@
1;ÇÒå‰ ÜÅhßVCji¾•ŽeÙ?œ€se^-W¹t \ No newline at end of file
diff --git a/src/integration-tests/hostkeys/c_no_nat_client_2 b/src/integration-tests/hostkeys/c_no_nat_client_2
deleted file mode 100644
index c393f73e4..000000000
--- a/src/integration-tests/hostkeys/c_no_nat_client_2
+++ /dev/null
@@ -1 +0,0 @@
1Ĥ×O7†y`öظ‚ø:ŸÌŠá1´RWFtÏÉpÇ \ No newline at end of file
diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in
deleted file mode 100755
index 441523dfe..000000000
--- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in
+++ /dev/null
@@ -1,212 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21
22import signal
23import sys
24import os
25import subprocess
26import re
27import shutil
28import time
29from gnunet_testing import Peer
30from gnunet_testing import Test
31from gnunet_testing import Check
32from gnunet_testing import Condition
33from gnunet_testing import *
34
35#
36# This test tests if a fresh peer bootstraps from a hostlist server and then
37# successfully connects to the server
38#
39# Conditions for successful exit:
40# Both peers have 1 connected peer in transport, core, topology, fs
41
42#
43# This test tests if a fresh peer bootstraps from a hostlist server and then
44# successfully connects to the server
45#
46# Conditions for successful exit:
47# Both peers have 1 connected peer in transport, core, topology, fs
48
49# definitions
50
51testname = "test_integration_bootstrap_and_connect"
52verbose = False
53check_timeout = 180
54
55if os.name == "nt":
56 tmp = os.getenv("TEMP")
57 signals = [signal.SIGTERM, signal.SIGINT]
58else:
59 tmp = "/tmp"
60 signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
61
62
63def cleanup_onerror(function, path, excinfo):
64 import stat
65 if not os.path.exists(path):
66 pass
67 elif not os.access(path, os.W_OK):
68 # Is the error an access error ?
69 os.chmod(path, stat.S_IWUSR)
70 function(path)
71 else:
72 raise
73
74
75def cleanup():
76 retries = 10
77 path = os.path.join(tmp, "c_bootstrap_server")
78 test.p("Removing " + path)
79 while ((os.path.exists(path)) and (retries > 0)):
80 shutil.rmtree((path), False, cleanup_onerror)
81 time.sleep(1)
82 retries -= 1
83 if (os.path.exists(path)):
84 test.p("Failed to remove " + path)
85
86 retries = 10
87 path = os.path.join(tmp, "c_no_nat_client")
88 test.p("Removing " + path)
89 while ((os.path.exists(path)) and (retries > 0)):
90 shutil.rmtree((path), False, cleanup_onerror)
91 time.sleep(1)
92 retries -= 1
93 if (os.path.exists(path)):
94 test.p("Failed to remove " + path)
95
96
97def success_cont(check):
98 global success
99 success = True
100 print('Peers connected successfully')
101
102
103def fail_cont(check):
104 global success
105 success = False
106 print('Peers did not connect')
107 check.evaluate(True)
108
109
110def check():
111 check = Check(test)
112 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
113 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
114 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
115 check.add(StatisticsCondition(client, 'dht', '# peers connected', 1))
116 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
117
118 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
119 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
120 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
121 check.add(StatisticsCondition(server, 'dht', '# peers connected', 1))
122 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
123
124 check.run_blocking(check_timeout, success_cont, fail_cont)
125
126
127#
128# Test execution
129#
130
131
132def SigHandler(signum=None, frame=None):
133 global success
134 global server
135 global client
136
137 print('Test was aborted!')
138 if (None != server):
139 server.stop()
140 if (None != client):
141 client.stop()
142 cleanup()
143 sys.exit(success)
144
145
146def run():
147 global success
148 global test
149 global server
150 global client
151
152 server = None
153 client = None
154 success = False
155
156 for sig in signals:
157 signal.signal(sig, SigHandler)
158
159 test = Test('test_integration_bootstrap_and_connect.py', verbose)
160 cleanup()
161
162 server = Peer(test, './confs/c_bootstrap_server.conf')
163 client = Peer(test, './confs/c_no_nat_client.conf')
164
165 if (True != server.start()):
166 print('Failed to start server')
167 if (None != server):
168 server.stop()
169 if (None != server):
170 client.stop()
171 cleanup()
172 sys.exit(success)
173
174 # Give the server time to start
175 time.sleep(5)
176
177 if (True != client.start()):
178 print('Failed to start client')
179 if (None != server):
180 server.stop()
181 if (None != server):
182 client.stop()
183 cleanup()
184 sys.exit(success)
185
186 if ((client.started == True) and (server.started == True)):
187 test.p('Peers started, running check')
188 time.sleep(5)
189 check()
190 server.stop()
191 client.stop()
192
193 cleanup()
194
195 if (success == False):
196 print('Test failed')
197 return False
198 else:
199 return True
200
201
202try:
203 run()
204except (KeyboardInterrupt, SystemExit):
205 print('Test interrupted')
206 server.stop()
207 client.stop()
208 cleanup()
209if (success == False):
210 sys.exit(1)
211else:
212 sys.exit(0)
diff --git a/src/integration-tests/test_integration_clique.py.in b/src/integration-tests/test_integration_clique.py.in
deleted file mode 100755
index 65df632f0..000000000
--- a/src/integration-tests/test_integration_clique.py.in
+++ /dev/null
@@ -1,236 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21#
22# This test starts 3 peers (nated, server, no nat)and expects bootstrap
23# and a connected clique
24#
25# Conditions for successful exit:
26# Both peers have 2 connected peers in transport, core, topology, fs and dht
27
28import sys
29import signal
30import os
31import subprocess
32import re
33import shutil
34import time
35from gnunet_testing import Peer
36from gnunet_testing import Test
37from gnunet_testing import Check
38from gnunet_testing import Condition
39from gnunet_testing import *
40
41if os.name == "nt":
42 tmp = os.getenv("TEMP")
43else:
44 tmp = "/tmp"
45
46# definitions
47
48testname = "test_integration_clique"
49verbose = True
50check_timeout = 180
51
52
53def cleanup_onerror(function, path, excinfo):
54 import stat
55 if not os.path.exists(path):
56 pass
57 elif not os.access(path, os.W_OK):
58 # Is the error an access error ?
59 os.chmod(path, stat.S_IWUSR)
60 function(path)
61 else:
62 raise
63
64
65def cleanup():
66 retries = 10
67 path = os.path.join(tmp, "c_bootstrap_server")
68 test.p("Removing " + path)
69 while ((os.path.exists(path)) and (retries > 0)):
70 shutil.rmtree((path), False, cleanup_onerror)
71 time.sleep(1)
72 retries -= 1
73 if (os.path.exists(path)):
74 test.p("Failed to remove " + path)
75 retries = 10
76 path = os.path.join(tmp, "c_no_nat_client")
77 test.p("Removing " + path)
78 while ((os.path.exists(path)) and (retries > 0)):
79 shutil.rmtree((path), False, cleanup_onerror)
80 time.sleep(1)
81 retries -= 1
82 if (os.path.exists(path)):
83 test.p("Failed to remove " + path)
84 retries = 10
85 path = os.path.join(tmp, "c_nat_client")
86 test.p("Removing " + path)
87 while ((os.path.exists(path)) and (retries > 0)):
88 shutil.rmtree((path), False, cleanup_onerror)
89 time.sleep(1)
90 retries -= 1
91 if (os.path.exists(path)):
92 test.p("Failed to remove " + path)
93
94
95def success_cont(check):
96 global success
97 success = True
98 print('Connected clique successfully')
99
100
101def fail_cont(check):
102 global success
103 success = False
104 check.evaluate(True)
105 print('Failed to connect clique')
106
107
108def check_connect():
109 check = Check(test)
110 check.add(StatisticsCondition(client, 'transport', '# peers connected', 2))
111 check.add(StatisticsCondition(client, 'core', '# peers connected', 2))
112 check.add(StatisticsCondition(client, 'topology', '# peers connected', 2))
113 check.add(StatisticsCondition(client, 'dht', '# peers connected', 2))
114 check.add(StatisticsCondition(client, 'fs', '# peers connected', 2))
115
116 check.add(
117 StatisticsCondition(client_nat, 'transport', '# peers connected', 2)
118 )
119 check.add(StatisticsCondition(client_nat, 'core', '# peers connected', 2))
120 check.add(
121 StatisticsCondition(client_nat, 'topology', '# peers connected', 2)
122 )
123 check.add(StatisticsCondition(client_nat, 'dht', '# peers connected', 2))
124 check.add(StatisticsCondition(client_nat, 'fs', '# peers connected', 2))
125
126 check.add(StatisticsCondition(server, 'transport', '# peers connected', 2))
127 check.add(StatisticsCondition(server, 'core', '# peers connected', 2))
128 check.add(StatisticsCondition(server, 'topology', '# peers connected', 2))
129 check.add(StatisticsCondition(server, 'dht', '# peers connected', 2))
130 check.add(StatisticsCondition(server, 'fs', '# peers connected', 2))
131
132 check.run_blocking(check_timeout, success_cont, fail_cont)
133
134
135#
136# Test execution
137#
138
139
140def SigHandler(signum=None, frame=None):
141 global success
142 global server
143 global client
144 global client_nat
145
146 print('Test was aborted!')
147 if (None != server):
148 server.stop()
149 if (None != client):
150 client.stop()
151 if (None != client_nat):
152 client_nat.stop()
153 cleanup()
154 sys.exit(success)
155
156
157def run():
158 global success
159 global test
160 global server
161 global client
162 global client_nat
163
164 success = False
165 server = None
166 client = None
167 client_nat = None
168 test = Test('test_integration_clique', verbose)
169 cleanup()
170
171 server = Peer(test, './confs/c_bootstrap_server.conf')
172 if (True != server.start()):
173 print('Failed to start server')
174 if (None != server):
175 server.stop()
176 cleanup()
177 sys.exit(success)
178
179 # Server has to settle down
180 time.sleep(5)
181
182 client = Peer(test, './confs/c_no_nat_client.conf')
183 if (True != client.start()):
184 print('Failed to start client')
185 if (None != server):
186 server.stop()
187 if (None != client):
188 client.stop()
189 cleanup()
190 sys.exit(success)
191
192 # Server has to settle down
193 time.sleep(5)
194
195 client_nat = Peer(test, './confs/c_nat_client.conf')
196 if (True != client_nat.start()):
197 print('Failed to start client_nat')
198 if (None != server):
199 server.stop()
200 if (None != client):
201 client.stop()
202 if (None != client_nat):
203 client_nat.stop()
204 cleanup()
205 sys.exit(success)
206
207 if ((client.started == True) and (client_nat.started == True)
208 and (server.started == True)):
209 test.p('Peers started, running check')
210 check_connect()
211
212 server.stop()
213 client.stop()
214 client_nat.stop()
215
216 cleanup()
217
218 if (success == False):
219 print('Test failed')
220 return False
221 else:
222 return True
223
224
225try:
226 run()
227except (KeyboardInterrupt, SystemExit):
228 print('Test interrupted')
229 server.stop()
230 client.stop()
231 client_nat.stop()
232 cleanup()
233if (success == False):
234 sys.exit(1)
235else:
236 sys.exit(0)
diff --git a/src/integration-tests/test_integration_disconnect.py.in b/src/integration-tests/test_integration_disconnect.py.in
deleted file mode 100755
index c942042c4..000000000
--- a/src/integration-tests/test_integration_disconnect.py.in
+++ /dev/null
@@ -1,215 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2017 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21
22import sys
23import signal
24import os
25import subprocess
26import re
27import shutil
28import time
29from gnunet_testing import Peer
30from gnunet_testing import Test
31from gnunet_testing import Check
32from gnunet_testing import Condition
33from gnunet_testing import *
34
35#
36# This test tests if a fresh peer bootstraps from a hostlist server and then
37# successfully connects to the server. When both peers are connected
38# in transport, core, topology, fs, the server is shutdown
39#
40# Conditions for successful exit:
41# Client peer has 0 connected peer in transport, core, topology, dht, fs
42
43#definitions
44
45testname = "test_integration_disconnect"
46verbose = True
47check_timeout = 180
48
49if os.name == "nt":
50 tmp = os.getenv("TEMP")
51 signals = [signal.SIGTERM, signal.SIGINT]
52else:
53 tmp = "/tmp"
54 signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
55
56
57def cleanup_onerror(function, path, excinfo):
58 import stat
59 if not os.path.exists(path):
60 pass
61 elif not os.access(path, os.W_OK):
62 # Is the error an access error ?
63 os.chmod(path, stat.S_IWUSR)
64 function(path)
65 else:
66 raise
67
68
69def cleanup():
70 shutil.rmtree(
71 os.path.join(tmp, "c_bootstrap_server"), False, cleanup_onerror
72 )
73 shutil.rmtree(os.path.join(tmp, "c_no_nat_client"), False, cleanup_onerror)
74
75
76def success_disconnect_cont(check):
77 print('Peers disconnected successfully')
78 global success
79 success = True
80
81
82def fail_disconnect_cont(check):
83 global success
84 success = False
85 print('Peers failed to disconnect')
86 check.evaluate(True)
87
88
89def check_disconnect():
90 test.p('Shutting down bootstrap server')
91 server.stop()
92 check = Check(test)
93 check.add(StatisticsCondition(client, 'transport', '# peers connected', 0))
94 check.add(StatisticsCondition(client, 'core', '# peers connected', 0))
95 check.add(StatisticsCondition(client, 'topology', '# peers connected', 0))
96 check.add(StatisticsCondition(client, 'dht', '# peers connected', 0))
97 check.add(StatisticsCondition(client, 'fs', '# peers connected', 0))
98 check.run_blocking(
99 check_timeout, success_disconnect_cont, fail_disconnect_cont
100 )
101
102
103def success_connect_cont(check):
104 print('Peers connected successfully')
105 check_disconnect()
106
107
108def fail_connect_cont(check):
109 global success
110 success = False
111 print('Peers failed to connected!')
112 check.evaluate(True)
113
114
115def check_connect():
116 check = Check(test)
117 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
118 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
119 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
120 check.add(StatisticsCondition(server, 'dht', '# peers connected', 1))
121 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
122
123 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
124 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
125 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
126 check.add(StatisticsCondition(client, 'dht', '# peers connected', 1))
127 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
128
129 check.run_blocking(check_timeout, success_connect_cont, fail_connect_cont)
130
131
132#
133# Test execution
134#
135
136
137def SigHandler(signum=None, frame=None):
138 global success
139 global server
140 global client
141
142 print('Test was aborted!')
143 if (None != server):
144 server.stop()
145 if (None != client):
146 client.stop()
147 cleanup()
148 sys.exit(success)
149
150
151def run():
152 global success
153 global test
154 global server
155 global client
156
157 server = None
158 client = None
159 success = False
160
161 for sig in signals:
162 signal.signal(sig, SigHandler)
163
164 test = Test('test_integration_bootstrap_and_connect.py', verbose)
165 cleanup()
166
167 server = Peer(test, './confs/c_bootstrap_server.conf')
168 client = Peer(test, './confs/c_no_nat_client.conf')
169
170 if (True != server.start()):
171 print('Failed to start server')
172 if (None != server):
173 server.stop()
174 cleanup()
175 sys.exit(success)
176
177 # Give the server time to start
178 time.sleep(5)
179
180 if (True != client.start()):
181 print('Failed to start client')
182 if (None != server):
183 server.stop()
184 if (None != client):
185 client.stop()
186 cleanup()
187 sys.exit(success)
188
189 if ((client.started == True) and (server.started == True)):
190 test.p('Peers started, running check')
191 time.sleep(5)
192 check_connect()
193 server.stop()
194 client.stop()
195
196 cleanup()
197
198 if (success == False):
199 print('Test failed')
200 return False
201 else:
202 return True
203
204
205try:
206 run()
207except (KeyboardInterrupt, SystemExit):
208 print('Test interrupted')
209 server.stop()
210 client.stop()
211 cleanup()
212if (success == False):
213 sys.exit(1)
214else:
215 sys.exit(0)
diff --git a/src/integration-tests/test_integration_disconnect_nat.py.in b/src/integration-tests/test_integration_disconnect_nat.py.in
deleted file mode 100755
index 2f10818cc..000000000
--- a/src/integration-tests/test_integration_disconnect_nat.py.in
+++ /dev/null
@@ -1,223 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21
22import sys
23import signal
24import os
25import subprocess
26import re
27import shutil
28import time
29from gnunet_testing import Peer
30from gnunet_testing import Test
31from gnunet_testing import Check
32from gnunet_testing import Condition
33from gnunet_testing import *
34
35#
36# This test tests if a fresh peer bootstraps from a hostlist server and then
37# successfully connects to the server. When both peers are connected
38# in transport, core, topology, fs, the server is shutdown
39#
40# Conditions for successful exit:
41# Client peer has 0 connected peer in transport, core, topology, dht, fs
42
43# definitions
44
45testname = "test_integration_disconnect"
46verbose = True
47check_timeout = 180
48
49if os.name == "nt":
50 tmp = os.getenv("TEMP")
51 signals = [signal.SIGTERM, signal.SIGINT]
52else:
53 tmp = "/tmp"
54 signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
55
56
57def cleanup_onerror(function, path, excinfo):
58 import stat
59 if not os.path.exists(path):
60 pass
61 elif not os.access(path, os.W_OK):
62 # Is the error an access error ?
63 os.chmod(path, stat.S_IWUSR)
64 function(path)
65 else:
66 raise
67
68
69def cleanup():
70 shutil.rmtree(
71 os.path.join(tmp, "c_bootstrap_server"), False, cleanup_onerror
72 )
73 shutil.rmtree(os.path.join(tmp, "c_nat_client"), False, cleanup_onerror)
74
75
76def success_disconnect_cont(check):
77 print('Peers disconnected successfully')
78 global success
79 success = True
80
81
82def fail_disconnect_cont(check):
83 global success
84 success = False
85 print('Peers failed to disconnect')
86 check.evaluate(True)
87
88
89def check_disconnect():
90 global server
91 global nat_client
92 test.p('Shutting down nat client')
93 nat_client.stop()
94 check = Check(test)
95 check.add(StatisticsCondition(server, 'transport', '# peers connected', 0))
96 check.add(StatisticsCondition(server, 'core', '# peers connected', 0))
97 check.add(StatisticsCondition(server, 'topology', '# peers connected', 0))
98 check.add(StatisticsCondition(server, 'dht', '# peers connected', 0))
99 check.add(StatisticsCondition(server, 'fs', '# peers connected', 0))
100 check.run_blocking(
101 check_timeout, success_disconnect_cont, fail_disconnect_cont
102 )
103
104
105def success_connect_cont(check):
106 print('Peers connected successfully')
107 check_disconnect()
108
109
110def fail_connect_cont(check):
111 global success
112 success = False
113 print('Peers failed to connected!')
114 check.evaluate(True)
115
116
117def check_connect():
118 global server
119 global nat_client
120 check = Check(test)
121 check.add(
122 StatisticsCondition(nat_client, 'transport', '# peers connected', 1)
123 )
124 check.add(StatisticsCondition(nat_client, 'core', '# peers connected', 1))
125 check.add(
126 StatisticsCondition(nat_client, 'topology', '# peers connected', 1)
127 )
128 check.add(StatisticsCondition(nat_client, 'dht', '# peers connected', 1))
129 check.add(StatisticsCondition(nat_client, 'fs', '# peers connected', 1))
130
131 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
132 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
133 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
134 check.add(StatisticsCondition(server, 'dht', '# peers connected', 1))
135 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
136
137 check.run_blocking(check_timeout, success_connect_cont, fail_connect_cont)
138
139
140#
141# Test execution
142#
143
144
145def SigHandler(signum=None, frame=None):
146 global success
147 global server
148 global nat_client
149
150 print('Test was aborted!')
151 if (None != server):
152 server.stop()
153 if (None != nat_client):
154 nat_client.stop()
155 cleanup()
156 sys.exit(success)
157
158
159def run():
160 global success
161 global test
162 global server
163 global nat_client
164
165 server = None
166 nat_client = None
167 success = False
168
169 for sig in signals:
170 signal.signal(sig, SigHandler)
171
172 test = Test('test_integration_bootstrap_and_connect.py', verbose)
173 cleanup()
174
175 server = Peer(test, './confs/c_bootstrap_server.conf')
176 nat_client = Peer(test, './confs/c_nat_client.conf')
177
178 if (True != server.start()):
179 print('Failed to start server')
180 if (None != server):
181 server.stop()
182 cleanup()
183 sys.exit(success)
184
185 # Give the server time to start
186 time.sleep(5)
187
188 if (True != nat_client.start()):
189 print('Failed to start nat_client')
190 if (None != server):
191 server.stop()
192 if (None != nat_client):
193 nat_client.stop()
194 cleanup()
195 sys.exit(success)
196
197 if ((nat_client.started == True) and (server.started == True)):
198 test.p('Peers started, running check')
199 time.sleep(5)
200 check_connect()
201 server.stop()
202 nat_client.stop()
203
204 cleanup()
205
206 if (success == False):
207 print('Test failed')
208 return False
209 else:
210 return True
211
212
213try:
214 run()
215except (KeyboardInterrupt, SystemExit):
216 print('Test interrupted')
217 server.stop()
218 nat_client.stop()
219 cleanup()
220if (success == False):
221 sys.exit(1)
222else:
223 sys.exit(0)
diff --git a/src/integration-tests/test_integration_reconnect.py.in b/src/integration-tests/test_integration_reconnect.py.in
deleted file mode 100755
index 97dc94502..000000000
--- a/src/integration-tests/test_integration_reconnect.py.in
+++ /dev/null
@@ -1,237 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2017 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21
22import sys
23import os
24import subprocess
25import re
26import shutil
27import time
28import signal
29from gnunet_testing import Peer
30from gnunet_testing import Test
31from gnunet_testing import Check
32from gnunet_testing import Condition
33from gnunet_testing import *
34
35#
36# This test tests if a fresh peer bootstraps from a hostlist server and then
37# successfully connects to the server. When both peers are connected
38# in transport, core, topology, fs, botth peers are shutdown and restarted
39#
40# Conditions for successful exit:
41# Both peers have 1 connected peer in transport, core, topology, fs after restart
42
43#definitions
44
45testname = "test_integration_restart"
46verbose = True
47check_timeout = 180
48
49if os.name == "nt":
50 tmp = os.getenv("TEMP")
51 signals = [signal.SIGTERM, signal.SIGINT]
52else:
53 tmp = "/tmp"
54 signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
55
56
57def cleanup_onerror(function, path, excinfo):
58 import stat
59 if not os.path.exists(path):
60 pass
61 elif not os.access(path, os.W_OK):
62 # Is the error an access error ?
63 os.chmod(path, stat.S_IWUSR)
64 function(path)
65 else:
66 raise
67
68
69def cleanup():
70 retries = 10
71 path = os.path.join(tmp, "c_bootstrap_server")
72 test.p("Removing " + path)
73 while ((os.path.exists(path)) and (retries > 0)):
74 shutil.rmtree((path), False, cleanup_onerror)
75 time.sleep(1)
76 retries -= 1
77 if (os.path.exists(path)):
78 test.p("Failed to remove " + path)
79
80 retries = 10
81 path = os.path.join(tmp, "c_no_nat_client")
82 test.p("Removing " + path)
83 while ((os.path.exists(path)) and (retries > 0)):
84 shutil.rmtree((path), False, cleanup_onerror)
85 time.sleep(1)
86 retries -= 1
87 if (os.path.exists(path)):
88 test.p("Failed to remove " + path)
89
90
91def success_restart_cont(check):
92 global success
93 print('Peers connected successfully after restart')
94 server.stop()
95 client.stop()
96 success = True
97
98
99def fail_restart_cont(check):
100 global success
101 success = False
102 print('Peers failed to connect after restart')
103 check.evaluate(True)
104
105
106def success_connect_cont(check):
107 print('Peers connected successfully')
108 server.stop()
109 client.stop()
110
111 time.sleep(5)
112
113 test.p('Restarting client & server')
114 server.start()
115 client.start()
116
117 check = Check(test)
118 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
119 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
120 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
121 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
122
123 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
124 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
125 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
126 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
127
128 check.run_blocking(check_timeout, success_restart_cont, fail_restart_cont)
129
130
131def fail_connect_cont(check):
132 global success
133 success = False
134 print('Peers failed to connect')
135 check.evaluate(True)
136
137
138def check_connect():
139 check = Check(test)
140 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
141 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
142 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
143 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
144
145 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
146 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
147 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
148 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
149
150 check.run_blocking(check_timeout, success_connect_cont, fail_connect_cont)
151
152
153#
154# Test execution
155#
156
157
158def SigHandler(signum=None, frame=None):
159 global success
160 global server
161 global client
162
163 print('Test was aborted!')
164 if (None != server):
165 server.stop()
166 if (None != client):
167 client.stop()
168 cleanup()
169 sys.exit(success)
170
171
172def run():
173 global success
174 global test
175 global server
176 global client
177
178 success = False
179 server = None
180 client = None
181
182 for sig in signals:
183 signal.signal(sig, SigHandler)
184
185 test = Test('test_integration_disconnect', verbose)
186 cleanup()
187 server = Peer(test, './confs/c_bootstrap_server.conf')
188 server.start()
189
190 client = Peer(test, './confs/c_no_nat_client.conf')
191 client.start()
192
193 if (True != server.start()):
194 print('Failed to start server')
195 if (None != server):
196 server.stop()
197 if (None != server):
198 client.stop()
199 cleanup()
200 sys.exit(success)
201
202 # Give the server time to start
203 time.sleep(5)
204
205 if (True != client.start()):
206 print('Failed to start client')
207 if (None != server):
208 server.stop()
209 if (None != server):
210 client.stop()
211 cleanup()
212 sys.exit(success)
213
214 check_connect()
215
216 server.stop()
217 client.stop()
218 cleanup()
219
220 if (success == False):
221 print('Test failed')
222 return True
223 else:
224 return False
225
226
227try:
228 run()
229except (KeyboardInterrupt, SystemExit):
230 print('Test interrupted')
231 server.stop()
232 client.stop()
233 cleanup()
234if (success == False):
235 sys.exit(1)
236else:
237 sys.exit(0)
diff --git a/src/integration-tests/test_integration_reconnect_nat.py.in b/src/integration-tests/test_integration_reconnect_nat.py.in
deleted file mode 100755
index 7624e7b38..000000000
--- a/src/integration-tests/test_integration_reconnect_nat.py.in
+++ /dev/null
@@ -1,237 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20#
21
22import sys
23import os
24import subprocess
25import re
26import shutil
27import time
28import signal
29from gnunet_testing import Peer
30from gnunet_testing import Test
31from gnunet_testing import Check
32from gnunet_testing import Condition
33from gnunet_testing import *
34
35#
36# This test tests if a fresh peer bootstraps from a hostlist server and then
37# successfully connects to the server. When both peers are connected
38# in transport, core, topology, fs, botth peers are shutdown and restarted
39#
40# Conditions for successful exit:
41# Both peers have 1 connected peer in transport, core, topology, fs after restart
42
43# definitions
44
45testname = "test_integration_restart"
46verbose = True
47check_timeout = 180
48
49if os.name == "nt":
50 tmp = os.getenv("TEMP")
51 signals = [signal.SIGTERM, signal.SIGINT]
52else:
53 tmp = "/tmp"
54 signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
55
56
57def cleanup_onerror(function, path, excinfo):
58 import stat
59 if not os.path.exists(path):
60 pass
61 elif not os.access(path, os.W_OK):
62 # Is the error an access error ?
63 os.chmod(path, stat.S_IWUSR)
64 function(path)
65 else:
66 raise
67
68
69def cleanup():
70 retries = 10
71 path = os.path.join(tmp, "c_bootstrap_server")
72 test.p("Removing " + path)
73 while ((os.path.exists(path)) and (retries > 0)):
74 shutil.rmtree((path), False, cleanup_onerror)
75 time.sleep(1)
76 retries -= 1
77 if (os.path.exists(path)):
78 test.p("Failed to remove " + path)
79
80 retries = 10
81 path = os.path.join(tmp, "c_nat_client")
82 test.p("Removing " + path)
83 while ((os.path.exists(path)) and (retries > 0)):
84 shutil.rmtree((path), False, cleanup_onerror)
85 time.sleep(1)
86 retries -= 1
87 if (os.path.exists(path)):
88 test.p("Failed to remove " + path)
89
90
91def success_restart_cont(check):
92 global success
93 print('Peers connected successfully after restart')
94 server.stop()
95 client.stop()
96 success = True
97
98
99def fail_restart_cont(check):
100 global success
101 success = False
102 print('Peers failed to connect after restart')
103 check.evaluate(True)
104
105
106def success_connect_cont(check):
107 print('Peers connected successfully')
108 server.stop()
109 client.stop()
110
111 time.sleep(5)
112
113 test.p('Restarting client & server')
114 server.start()
115 client.start()
116
117 check = Check(test)
118 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
119 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
120 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
121 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
122
123 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
124 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
125 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
126 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
127
128 check.run_blocking(check_timeout, success_restart_cont, fail_restart_cont)
129
130
131def fail_connect_cont(check):
132 global success
133 success = False
134 print('Peers failed to connect')
135 check.evaluate(True)
136
137
138def check_connect():
139 check = Check(test)
140 check.add(StatisticsCondition(client, 'transport', '# peers connected', 1))
141 check.add(StatisticsCondition(client, 'core', '# peers connected', 1))
142 check.add(StatisticsCondition(client, 'topology', '# peers connected', 1))
143 check.add(StatisticsCondition(client, 'fs', '# peers connected', 1))
144
145 check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
146 check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
147 check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
148 check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
149
150 check.run_blocking(check_timeout, success_connect_cont, fail_connect_cont)
151
152
153#
154# Test execution
155#
156
157
158def SigHandler(signum=None, frame=None):
159 global success
160 global server
161 global client
162
163 print('Test was aborted!')
164 if (None != server):
165 server.stop()
166 if (None != client):
167 client.stop()
168 cleanup()
169 sys.exit(success)
170
171
172def run():
173 global success
174 global test
175 global server
176 global client
177
178 success = False
179 server = None
180 client = None
181
182 for sig in signals:
183 signal.signal(sig, SigHandler)
184
185 test = Test('test_integration_disconnect', verbose)
186 cleanup()
187 server = Peer(test, './confs/c_bootstrap_server.conf')
188 server.start()
189
190 client = Peer(test, './confs/c_nat_client.conf')
191 client.start()
192
193 if (True != server.start()):
194 print('Failed to start server')
195 if (None != server):
196 server.stop()
197 if (None != server):
198 client.stop()
199 cleanup()
200 sys.exit(success)
201
202 # Give the server time to start
203 time.sleep(5)
204
205 if (True != client.start()):
206 print('Failed to start client')
207 if (None != server):
208 server.stop()
209 if (None != server):
210 client.stop()
211 cleanup()
212 sys.exit(success)
213
214 check_connect()
215
216 server.stop()
217 client.stop()
218 cleanup()
219
220 if (success == False):
221 print('Test failed')
222 return True
223 else:
224 return False
225
226
227try:
228 run()
229except (KeyboardInterrupt, SystemExit):
230 print('Test interrupted')
231 server.stop()
232 client.stop()
233 cleanup()
234if (success == False):
235 sys.exit(1)
236else:
237 sys.exit(0)