diff options
Diffstat (limited to 'src/integration-tests')
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 @@ | |||
1 | gnunet_testing.py | ||
2 | gnunet_pyexpect.py | ||
3 | gnunet_pyexpect.pyc | ||
4 | gnunet_testing.pyc | ||
5 | test_integration_bootstrap_and_connect.py | ||
6 | test_integration_clique.py | ||
7 | test_integration_disconnect_nat.py | ||
8 | test_integration_disconnect.py | ||
9 | test_integration_reconnect_nat.py | ||
10 | test_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 | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | if USE_COVERAGE | ||
5 | AM_CFLAGS = --coverage -O0 | ||
6 | XLIB = -lgcov | ||
7 | endif | ||
8 | |||
9 | noinst_SCRIPTS = \ | ||
10 | gnunet_testing.py \ | ||
11 | gnunet_pyexpect.py | ||
12 | |||
13 | if HAVE_PYTHON | ||
14 | check_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 | ||
21 | endif | ||
22 | |||
23 | |||
24 | if ENABLE_TEST_RUN | ||
25 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | ||
26 | TESTS = \ | ||
27 | $(check_SCRIPTS) | ||
28 | endif | ||
29 | |||
30 | SUFFIXES = .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 | |||
35 | gnunet_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 | |||
39 | gnunet_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 | |||
43 | test_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 | |||
47 | test_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 | |||
51 | test_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 | |||
55 | test_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 | |||
59 | test_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 | |||
63 | test_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 | |||
68 | EXTRA_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 | |||
87 | CLEANFILES = \ | ||
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] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/c_bootstrap_server/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = hostkeys/c_bootstrap_server | ||
8 | |||
9 | |||
10 | [transport] | ||
11 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-8 | ||
12 | PORT = 20011 | ||
13 | PLUGINS = tcp | ||
14 | |||
15 | [transport-tcp] | ||
16 | PORT = 20010 | ||
17 | ADVERTISED_PORT = 20010 | ||
18 | |||
19 | [hostlist] | ||
20 | OPTIONS = -p | ||
21 | SERVERs = | ||
22 | |||
23 | [nat] | ||
24 | BEHIND_NAT = NO | ||
25 | DISABLEV6 = NO | ||
26 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-4 | ||
27 | PORT = 20070 | ||
28 | |||
29 | [nat-auto] | ||
30 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-4 | ||
31 | PORT = 20076 | ||
32 | |||
33 | [arm] | ||
34 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-4 | ||
35 | PORT = 20004 | ||
36 | |||
37 | [dns] | ||
38 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-5 | ||
39 | |||
40 | [core] | ||
41 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-3 | ||
42 | PORT = 20003 | ||
43 | |||
44 | [ats] | ||
45 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-9 | ||
46 | PORT = 20012 | ||
47 | |||
48 | [cadet] | ||
49 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-13 | ||
50 | PORT = 20016 | ||
51 | |||
52 | [datastore] | ||
53 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-11 | ||
54 | PORT = 20014 | ||
55 | |||
56 | [resolver] | ||
57 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-14 | ||
58 | PORT = 20017 | ||
59 | |||
60 | [dht] | ||
61 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-1 | ||
62 | PORT = 20000 | ||
63 | |||
64 | [nat] | ||
65 | BEHIND_NAT = NO | ||
66 | |||
67 | [fs] | ||
68 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-6 | ||
69 | PORT = 20005 | ||
70 | |||
71 | [gns] | ||
72 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-15 | ||
73 | PORT = 20018 | ||
74 | |||
75 | [dv] | ||
76 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-16 | ||
77 | PORT = 20019 | ||
78 | |||
79 | [vpn] | ||
80 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-15 | ||
81 | |||
82 | [peerinfo] | ||
83 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-10 | ||
84 | PORT = 20013 | ||
85 | |||
86 | [statistics] | ||
87 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-2 | ||
88 | PORT = 20001 | ||
89 | |||
90 | [nse] | ||
91 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-12 | ||
92 | PORT = 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] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/c_nat_client/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = hostkeys/c_nat_client | ||
8 | |||
9 | |||
10 | [transport] | ||
11 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-50 | ||
12 | PORT = 20065 | ||
13 | PLUGINS = tcp | ||
14 | |||
15 | [transport-tcp] | ||
16 | PORT = 0 | ||
17 | ADVERTISED_PORT = 20064 | ||
18 | |||
19 | [transport-udp] | ||
20 | PORT = 0 | ||
21 | |||
22 | [hostlist] | ||
23 | SERVERS = http://localhost:8080/ | ||
24 | |||
25 | [nat] | ||
26 | BEHIND_NAT = YES | ||
27 | DISABLEV6 = NO | ||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-46 | ||
29 | PORT = 20071 | ||
30 | |||
31 | [nat-auto] | ||
32 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-46 | ||
33 | PORT = 20077 | ||
34 | |||
35 | [arm] | ||
36 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-46 | ||
37 | PORT = 20058 | ||
38 | |||
39 | [core] | ||
40 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-45 | ||
41 | PORT = 20057 | ||
42 | |||
43 | [ats] | ||
44 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-51 | ||
45 | PORT = 20066 | ||
46 | |||
47 | [datastore] | ||
48 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-53 | ||
49 | PORT = 20068 | ||
50 | |||
51 | [resolver] | ||
52 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-56 | ||
53 | PORT = 20071 | ||
54 | |||
55 | [dht] | ||
56 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-43 | ||
57 | PORT = 20054 | ||
58 | |||
59 | [fs] | ||
60 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-48 | ||
61 | PORT = 20059 | ||
62 | |||
63 | [dv] | ||
64 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_nat_c-1 | ||
65 | |||
66 | [peerinfo] | ||
67 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-52 | ||
68 | PORT = 20067 | ||
69 | |||
70 | [nse] | ||
71 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-54 | ||
72 | PORT = 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] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/c_no_nat_client/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = hostkeys/c_no_nat_client | ||
8 | |||
9 | [transport] | ||
10 | PLUGINS = tcp | ||
11 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-22 | ||
12 | PORT = 20029 | ||
13 | |||
14 | [transport-tcp] | ||
15 | PORT = 20028 | ||
16 | ADVERTISED_PORT = 20028 | ||
17 | |||
18 | [hostlist] | ||
19 | SERVERS = http://localhost:8080/ | ||
20 | |||
21 | [nat] | ||
22 | BEHIND_NAT = NO | ||
23 | DISABLEV6 = NO | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-18 | ||
25 | PORT = 20072 | ||
26 | |||
27 | [nat-auto] | ||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-18 | ||
29 | PORT = 20074 | ||
30 | |||
31 | [arm] | ||
32 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-18 | ||
33 | PORT = 20022 | ||
34 | |||
35 | [namestore] | ||
36 | START_ON_DEMAND = YES | ||
37 | |||
38 | [dns] | ||
39 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-19 | ||
40 | |||
41 | [consensus] | ||
42 | START_ON_DEMAND = YES | ||
43 | |||
44 | [core] | ||
45 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-17 | ||
46 | PORT = 20021 | ||
47 | |||
48 | [ats] | ||
49 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-23 | ||
50 | WAN_QUOTA_IN = 64 KiB | ||
51 | WAN_QUOTA_OUT = 64 KiB | ||
52 | PORT = 20030 | ||
53 | |||
54 | [cadet] | ||
55 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-27 | ||
56 | PORT = 20034 | ||
57 | |||
58 | [datastore] | ||
59 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-25 | ||
60 | PORT = 20032 | ||
61 | |||
62 | [resolver] | ||
63 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-28 | ||
64 | PORT = 20035 | ||
65 | |||
66 | [dht] | ||
67 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-15 | ||
68 | PORT = 20018 | ||
69 | |||
70 | [dhtcache] | ||
71 | DATABASE = heap | ||
72 | QUOTA = 50 MB | ||
73 | |||
74 | [gnunet-nat-server] | ||
75 | PORT = 20020 | ||
76 | |||
77 | [fs] | ||
78 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-20 | ||
79 | PORT = 20023 | ||
80 | |||
81 | [vpn] | ||
82 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-29 | ||
83 | |||
84 | [dv] | ||
85 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_no_nat_c-1 | ||
86 | |||
87 | [peerinfo] | ||
88 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-24 | ||
89 | PORT = 20031 | ||
90 | |||
91 | [statistics] | ||
92 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-16 | ||
93 | PORT = 20019 | ||
94 | |||
95 | [nse] | ||
96 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-26 | ||
97 | PORT = 20033 | ||
98 | |||
99 | [gns] | ||
100 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-35 | ||
101 | PORT = 20038 | ||
102 | |||
103 | [dv] | ||
104 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-36 | ||
105 | PORT = 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] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/c_no_nat_client_2/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = hostkeys/c_no_nat_client_2 | ||
8 | |||
9 | |||
10 | [transport] | ||
11 | PLUGINS = tcp | ||
12 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-transport-22 | ||
13 | PORT = 20039 | ||
14 | |||
15 | [transport-tcp] | ||
16 | PORT = 20038 | ||
17 | ADVERTISED_PORT = 20038 | ||
18 | |||
19 | [transport-udp] | ||
20 | PORT = 20027 | ||
21 | BROADCAST_INTERVAL = 30 s | ||
22 | |||
23 | [hostlist] | ||
24 | SERVERS = http://localhost:8080/ | ||
25 | |||
26 | [nat] | ||
27 | BEHIND_NAT = NO | ||
28 | DISABLEV6 = NO | ||
29 | PORT = 20073 | ||
30 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nat-18 | ||
31 | |||
32 | [nat-auto] | ||
33 | PORT = 20075 | ||
34 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-natauto-18 | ||
35 | |||
36 | |||
37 | [arm] | ||
38 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-arm-18 | ||
39 | PORT = 20022 | ||
40 | |||
41 | [namestore] | ||
42 | START_ON_DEMAND = YES | ||
43 | |||
44 | [dns] | ||
45 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-19 | ||
46 | |||
47 | [consensus] | ||
48 | START_ON_DEMAND = YES | ||
49 | |||
50 | [lockmanager] | ||
51 | START_ON_DEMAND = YES | ||
52 | |||
53 | [core] | ||
54 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-core-17 | ||
55 | PORT = 20021 | ||
56 | |||
57 | [ats] | ||
58 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-ats-23 | ||
59 | WAN_QUOTA_IN = 64 KiB | ||
60 | WAN_QUOTA_OUT = 64 KiB | ||
61 | PORT = 20030 | ||
62 | |||
63 | [cadet] | ||
64 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-cadet-27 | ||
65 | PORT = 20034 | ||
66 | |||
67 | [datastore] | ||
68 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-datastore-25 | ||
69 | PORT = 20032 | ||
70 | |||
71 | [resolver] | ||
72 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-resolver-28 | ||
73 | PORT = 20035 | ||
74 | |||
75 | [dht] | ||
76 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dht-15 | ||
77 | PORT = 20018 | ||
78 | |||
79 | [dhtcache] | ||
80 | DATABASE = heap | ||
81 | QUOTA = 50 MB | ||
82 | |||
83 | [gnunet-nat-server] | ||
84 | PORT = 20020 | ||
85 | |||
86 | [fs] | ||
87 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-fs-20 | ||
88 | PORT = 20023 | ||
89 | |||
90 | [vpn] | ||
91 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-vpn-29 | ||
92 | |||
93 | [dv] | ||
94 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-b_no_nat_c-1 | ||
95 | |||
96 | [peerinfo] | ||
97 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-peerinfo-24 | ||
98 | USE_INCLUDED_HELLOS = YES | ||
99 | PORT = 20031 | ||
100 | |||
101 | [statistics] | ||
102 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-statistics-16 | ||
103 | PORT = 20019 | ||
104 | |||
105 | [template] | ||
106 | PORT = 20024 | ||
107 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-template-21 | ||
108 | |||
109 | [nse] | ||
110 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-nse-26 | ||
111 | PORT = 20033 | ||
112 | |||
113 | [gns] | ||
114 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-gns-35 | ||
115 | PORT = 20038 | ||
116 | |||
117 | [dv] | ||
118 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dv-36 | ||
119 | PORT = 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] | ||
5 | IMMEDIATE_START = YES | ||
6 | |||
7 | [datastore] | ||
8 | START_ON_DEMAND = YES | ||
9 | |||
10 | [dht] | ||
11 | START_ON_DEMAND = YES | ||
12 | |||
13 | [nse] | ||
14 | START_ON_DEMAND = YES | ||
15 | |||
16 | [cadet] | ||
17 | START_ON_DEMAND = YES | ||
18 | |||
19 | [hostlist] | ||
20 | IMMEDIATE_START = YES | ||
21 | |||
22 | [topology] | ||
23 | IMMEDIATE_START = YES | ||
24 | |||
25 | [peerinfo] | ||
26 | USE_INCLUDED_HELLOS = NO | ||
27 | |||
28 | [transport-tcp] | ||
29 | USE_LOCALADDR = YES | ||
30 | |||
31 | [transport-udp] | ||
32 | BROADCAST = NO | ||
33 | BROADCAST_RECEIVE = no | ||
34 | USE_LOCALADDR = YES | ||
35 | |||
36 | [nat] | ||
37 | BEHIND_NAT = NO | ||
38 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
39 | INTERNAL_ADDRESS = 127.0.0.1 | ||
40 | BINDTO = 127.0.0.1 | ||
41 | RETURN_LOCAL_ADDRESSES = YES | ||
42 | |||
43 | [hostlist] | ||
44 | SERVERS = | ||
45 | |||
46 | [dns] | ||
47 | UNIXPATH = $GNUNET_RUNTIME_DIR/test-service-dns-47 | ||
48 | ACCEPT_FROM = 127.0.0.1; | ||
49 | ACCEPT_FROM6 = ::1; | ||
50 | PROVIDE_EXIT = NO | ||
51 | |||
52 | [ats] | ||
53 | WAN_QUOTA_IN = unlimited | ||
54 | WAN_QUOTA_OUT = unlimited | ||
55 | ATS_MIN_INTERVAL = 15000 | ||
56 | ATS_EXEC_INTERVAL = 30000 | ||
57 | |||
58 | [datastore] | ||
59 | UNIX_MATCH_UID = YES | ||
60 | QUOTA = 100 MB | ||
61 | BLOOMFILTER = $GNUNET_TEST_HOME/fs/bloomfilter | ||
62 | |||
63 | [dhtcache] | ||
64 | DATABASE = sqlite | ||
65 | QUOTA = 1 MB | ||
66 | |||
67 | [fs] | ||
68 | INDEXDB = $GNUNET_TEST_HOME/idxinfo.lst | ||
69 | IDENTITY_DIR = $GNUNET_TEST_HOME/identities/ | ||
70 | STATE_DIR = $GNUNET_TEST_HOME/persistence/ | ||
71 | UPDATE_DIR = $GNUNET_TEST_HOME/updates/ | ||
72 | TRUST = $GNUNET_TEST_HOME/data/credit/ | ||
73 | |||
74 | [datacache-mysql] | ||
75 | DATABASE = gnunet | ||
76 | CONFIG = ~/.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 | |||
22 | import os | ||
23 | import re | ||
24 | import subprocess | ||
25 | import sys | ||
26 | import shutil | ||
27 | import time | ||
28 | |||
29 | |||
30 | class 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 | |||
22 | import os | ||
23 | import subprocess | ||
24 | import sys | ||
25 | import shutil | ||
26 | import time | ||
27 | from gnunet_pyexpect import pexpect | ||
28 | import logging | ||
29 | |||
30 | logger = logging.getLogger() | ||
31 | handler = logging.StreamHandler() | ||
32 | formatter = logging.Formatter( | ||
33 | '%(asctime)s %(name)-12s %(levelname)-8s %(message)s' | ||
34 | ) | ||
35 | handler.setFormatter(formatter) | ||
36 | logger.addHandler(handler) | ||
37 | logger.setLevel(logging.DEBUG) | ||
38 | |||
39 | |||
40 | class 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 | |||
108 | class 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 | |||
132 | class 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 | |||
163 | class 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 | ||
205 | class 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 | |||
246 | class 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 | |||
278 | class 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 | |||
22 | import signal | ||
23 | import sys | ||
24 | import os | ||
25 | import subprocess | ||
26 | import re | ||
27 | import shutil | ||
28 | import time | ||
29 | from gnunet_testing import Peer | ||
30 | from gnunet_testing import Test | ||
31 | from gnunet_testing import Check | ||
32 | from gnunet_testing import Condition | ||
33 | from 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 | |||
51 | testname = "test_integration_bootstrap_and_connect" | ||
52 | verbose = False | ||
53 | check_timeout = 180 | ||
54 | |||
55 | if os.name == "nt": | ||
56 | tmp = os.getenv("TEMP") | ||
57 | signals = [signal.SIGTERM, signal.SIGINT] | ||
58 | else: | ||
59 | tmp = "/tmp" | ||
60 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
61 | |||
62 | |||
63 | def 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 | |||
75 | def 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 | |||
97 | def success_cont(check): | ||
98 | global success | ||
99 | success = True | ||
100 | print('Peers connected successfully') | ||
101 | |||
102 | |||
103 | def fail_cont(check): | ||
104 | global success | ||
105 | success = False | ||
106 | print('Peers did not connect') | ||
107 | check.evaluate(True) | ||
108 | |||
109 | |||
110 | def 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 | |||
132 | def 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 | |||
146 | def 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 | |||
202 | try: | ||
203 | run() | ||
204 | except (KeyboardInterrupt, SystemExit): | ||
205 | print('Test interrupted') | ||
206 | server.stop() | ||
207 | client.stop() | ||
208 | cleanup() | ||
209 | if (success == False): | ||
210 | sys.exit(1) | ||
211 | else: | ||
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 | |||
28 | import sys | ||
29 | import signal | ||
30 | import os | ||
31 | import subprocess | ||
32 | import re | ||
33 | import shutil | ||
34 | import time | ||
35 | from gnunet_testing import Peer | ||
36 | from gnunet_testing import Test | ||
37 | from gnunet_testing import Check | ||
38 | from gnunet_testing import Condition | ||
39 | from gnunet_testing import * | ||
40 | |||
41 | if os.name == "nt": | ||
42 | tmp = os.getenv("TEMP") | ||
43 | else: | ||
44 | tmp = "/tmp" | ||
45 | |||
46 | # definitions | ||
47 | |||
48 | testname = "test_integration_clique" | ||
49 | verbose = True | ||
50 | check_timeout = 180 | ||
51 | |||
52 | |||
53 | def 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 | |||
65 | def 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 | |||
95 | def success_cont(check): | ||
96 | global success | ||
97 | success = True | ||
98 | print('Connected clique successfully') | ||
99 | |||
100 | |||
101 | def fail_cont(check): | ||
102 | global success | ||
103 | success = False | ||
104 | check.evaluate(True) | ||
105 | print('Failed to connect clique') | ||
106 | |||
107 | |||
108 | def 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 | |||
140 | def 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 | |||
157 | def 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 | |||
225 | try: | ||
226 | run() | ||
227 | except (KeyboardInterrupt, SystemExit): | ||
228 | print('Test interrupted') | ||
229 | server.stop() | ||
230 | client.stop() | ||
231 | client_nat.stop() | ||
232 | cleanup() | ||
233 | if (success == False): | ||
234 | sys.exit(1) | ||
235 | else: | ||
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 | |||
22 | import sys | ||
23 | import signal | ||
24 | import os | ||
25 | import subprocess | ||
26 | import re | ||
27 | import shutil | ||
28 | import time | ||
29 | from gnunet_testing import Peer | ||
30 | from gnunet_testing import Test | ||
31 | from gnunet_testing import Check | ||
32 | from gnunet_testing import Condition | ||
33 | from 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 | |||
45 | testname = "test_integration_disconnect" | ||
46 | verbose = True | ||
47 | check_timeout = 180 | ||
48 | |||
49 | if os.name == "nt": | ||
50 | tmp = os.getenv("TEMP") | ||
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
52 | else: | ||
53 | tmp = "/tmp" | ||
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | |||
57 | def 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 | |||
69 | def 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 | |||
76 | def success_disconnect_cont(check): | ||
77 | print('Peers disconnected successfully') | ||
78 | global success | ||
79 | success = True | ||
80 | |||
81 | |||
82 | def fail_disconnect_cont(check): | ||
83 | global success | ||
84 | success = False | ||
85 | print('Peers failed to disconnect') | ||
86 | check.evaluate(True) | ||
87 | |||
88 | |||
89 | def 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 | |||
103 | def success_connect_cont(check): | ||
104 | print('Peers connected successfully') | ||
105 | check_disconnect() | ||
106 | |||
107 | |||
108 | def fail_connect_cont(check): | ||
109 | global success | ||
110 | success = False | ||
111 | print('Peers failed to connected!') | ||
112 | check.evaluate(True) | ||
113 | |||
114 | |||
115 | def 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 | |||
137 | def 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 | |||
151 | def 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 | |||
205 | try: | ||
206 | run() | ||
207 | except (KeyboardInterrupt, SystemExit): | ||
208 | print('Test interrupted') | ||
209 | server.stop() | ||
210 | client.stop() | ||
211 | cleanup() | ||
212 | if (success == False): | ||
213 | sys.exit(1) | ||
214 | else: | ||
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 | |||
22 | import sys | ||
23 | import signal | ||
24 | import os | ||
25 | import subprocess | ||
26 | import re | ||
27 | import shutil | ||
28 | import time | ||
29 | from gnunet_testing import Peer | ||
30 | from gnunet_testing import Test | ||
31 | from gnunet_testing import Check | ||
32 | from gnunet_testing import Condition | ||
33 | from 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 | |||
45 | testname = "test_integration_disconnect" | ||
46 | verbose = True | ||
47 | check_timeout = 180 | ||
48 | |||
49 | if os.name == "nt": | ||
50 | tmp = os.getenv("TEMP") | ||
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
52 | else: | ||
53 | tmp = "/tmp" | ||
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | |||
57 | def 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 | |||
69 | def 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 | |||
76 | def success_disconnect_cont(check): | ||
77 | print('Peers disconnected successfully') | ||
78 | global success | ||
79 | success = True | ||
80 | |||
81 | |||
82 | def fail_disconnect_cont(check): | ||
83 | global success | ||
84 | success = False | ||
85 | print('Peers failed to disconnect') | ||
86 | check.evaluate(True) | ||
87 | |||
88 | |||
89 | def 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 | |||
105 | def success_connect_cont(check): | ||
106 | print('Peers connected successfully') | ||
107 | check_disconnect() | ||
108 | |||
109 | |||
110 | def fail_connect_cont(check): | ||
111 | global success | ||
112 | success = False | ||
113 | print('Peers failed to connected!') | ||
114 | check.evaluate(True) | ||
115 | |||
116 | |||
117 | def 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 | |||
145 | def 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 | |||
159 | def 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 | |||
213 | try: | ||
214 | run() | ||
215 | except (KeyboardInterrupt, SystemExit): | ||
216 | print('Test interrupted') | ||
217 | server.stop() | ||
218 | nat_client.stop() | ||
219 | cleanup() | ||
220 | if (success == False): | ||
221 | sys.exit(1) | ||
222 | else: | ||
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 | |||
22 | import sys | ||
23 | import os | ||
24 | import subprocess | ||
25 | import re | ||
26 | import shutil | ||
27 | import time | ||
28 | import signal | ||
29 | from gnunet_testing import Peer | ||
30 | from gnunet_testing import Test | ||
31 | from gnunet_testing import Check | ||
32 | from gnunet_testing import Condition | ||
33 | from 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 | |||
45 | testname = "test_integration_restart" | ||
46 | verbose = True | ||
47 | check_timeout = 180 | ||
48 | |||
49 | if os.name == "nt": | ||
50 | tmp = os.getenv("TEMP") | ||
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
52 | else: | ||
53 | tmp = "/tmp" | ||
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | |||
57 | def 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 | |||
69 | def 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 | |||
91 | def 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 | |||
99 | def fail_restart_cont(check): | ||
100 | global success | ||
101 | success = False | ||
102 | print('Peers failed to connect after restart') | ||
103 | check.evaluate(True) | ||
104 | |||
105 | |||
106 | def 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 | |||
131 | def fail_connect_cont(check): | ||
132 | global success | ||
133 | success = False | ||
134 | print('Peers failed to connect') | ||
135 | check.evaluate(True) | ||
136 | |||
137 | |||
138 | def 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 | |||
158 | def 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 | |||
172 | def 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 | |||
227 | try: | ||
228 | run() | ||
229 | except (KeyboardInterrupt, SystemExit): | ||
230 | print('Test interrupted') | ||
231 | server.stop() | ||
232 | client.stop() | ||
233 | cleanup() | ||
234 | if (success == False): | ||
235 | sys.exit(1) | ||
236 | else: | ||
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 | |||
22 | import sys | ||
23 | import os | ||
24 | import subprocess | ||
25 | import re | ||
26 | import shutil | ||
27 | import time | ||
28 | import signal | ||
29 | from gnunet_testing import Peer | ||
30 | from gnunet_testing import Test | ||
31 | from gnunet_testing import Check | ||
32 | from gnunet_testing import Condition | ||
33 | from 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 | |||
45 | testname = "test_integration_restart" | ||
46 | verbose = True | ||
47 | check_timeout = 180 | ||
48 | |||
49 | if os.name == "nt": | ||
50 | tmp = os.getenv("TEMP") | ||
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
52 | else: | ||
53 | tmp = "/tmp" | ||
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | |||
57 | def 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 | |||
69 | def 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 | |||
91 | def 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 | |||
99 | def fail_restart_cont(check): | ||
100 | global success | ||
101 | success = False | ||
102 | print('Peers failed to connect after restart') | ||
103 | check.evaluate(True) | ||
104 | |||
105 | |||
106 | def 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 | |||
131 | def fail_connect_cont(check): | ||
132 | global success | ||
133 | success = False | ||
134 | print('Peers failed to connect') | ||
135 | check.evaluate(True) | ||
136 | |||
137 | |||
138 | def 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 | |||
158 | def 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 | |||
172 | def 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 | |||
227 | try: | ||
228 | run() | ||
229 | except (KeyboardInterrupt, SystemExit): | ||
230 | print('Test interrupted') | ||
231 | server.stop() | ||
232 | client.stop() | ||
233 | cleanup() | ||
234 | if (success == False): | ||
235 | sys.exit(1) | ||
236 | else: | ||
237 | sys.exit(0) | ||