|
|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
#include "etcp_connections.h" |
|
|
|
|
#include "test_utils.h" |
|
|
|
|
#include "test_clock.h" |
|
|
|
|
#include "test_net.h" |
|
|
|
|
#include <sqlite3.h> |
|
|
|
|
#include <openssl/evp.h> |
|
|
|
|
|
|
|
|
|
@ -591,13 +592,10 @@ static void _intg_setup_contexts(void) {
|
|
|
|
|
done_sync = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int _intg_create_cfgs(int* port_a, int* port_b, int* port_c, |
|
|
|
|
char* cfg_a, char* cfg_b, char* cfg_c, size_t sz) { |
|
|
|
|
static int _intg_create_cfgs(char* cfg_a, char* cfg_b, char* cfg_c, size_t sz) { |
|
|
|
|
/* reset template (mkdtemp modifies it) */ |
|
|
|
|
strcpy(intg_temp_dir, "/tmp/utun_msync_XXXXXX"); |
|
|
|
|
if (test_mkdtemp(intg_temp_dir) != 0) { printf(" mkdtemp failed\n"); return -1; } |
|
|
|
|
int base = 43000 + (getpid() % 15000); |
|
|
|
|
*port_a = base; *port_b = base + 1; *port_c = base + 2; |
|
|
|
|
snprintf(cfg_a, sz, "%s/a.conf", intg_temp_dir); |
|
|
|
|
snprintf(cfg_b, sz, "%s/b.conf", intg_temp_dir); |
|
|
|
|
snprintf(cfg_c, sz, "%s/c.conf", intg_temp_dir); |
|
|
|
|
@ -609,25 +607,25 @@ static int _intg_create_cfgs(int* port_a, int* port_b, int* port_c,
|
|
|
|
|
_write_cfg(cfg_a, |
|
|
|
|
"[global]\nmy_node_id=0xAAAAAAAAAAAAAAAA\ntun_ip=10.220.0.1/24\n" |
|
|
|
|
"tun_ifname=tun220\nkeepalive_adaptive=0\ndb_path=%s/db_a\n\n" |
|
|
|
|
"[server: srv_a]\naddr=127.0.0.1:%d\ntype=public\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir, *port_a); |
|
|
|
|
"[server: srv_a]\naddr=127.0.0.1:0\ntype=public\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir); |
|
|
|
|
config_ensure_keys_and_node_id(cfg_a); |
|
|
|
|
char* pub_a = _get_pubkey(cfg_a); if (!pub_a) return -1; |
|
|
|
|
|
|
|
|
|
_write_cfg(cfg_b, |
|
|
|
|
"[global]\nmy_node_id=0xBBBBBBBBBBBBBBBB\ntun_ip=10.220.0.2/24\n" |
|
|
|
|
"tun_ifname=tun221\nkeepalive_adaptive=0\ndb_path=%s/db_b\n\n" |
|
|
|
|
"[server: srv_b]\naddr=127.0.0.1:%d\ntype=public\n\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=srv_b:127.0.0.1:%d\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir, *port_b, pub_a, *port_a); |
|
|
|
|
"[server: srv_b]\naddr=127.0.0.1:0\ntype=public\n\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=srv_b:127.0.0.1:0\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir, pub_a); |
|
|
|
|
config_ensure_keys_and_node_id(cfg_b); |
|
|
|
|
|
|
|
|
|
_write_cfg(cfg_c, |
|
|
|
|
"[global]\nmy_node_id=0xCCCCCCCCCCCCCCCC\ntun_ip=10.220.0.3/24\n" |
|
|
|
|
"tun_ifname=tun222\nkeepalive_adaptive=0\ndb_path=%s/db_c\n\n" |
|
|
|
|
"[server: srv_c]\naddr=127.0.0.1:%d\ntype=public\n\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=srv_c:127.0.0.1:%d\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir, *port_c, pub_a, *port_a); |
|
|
|
|
"[server: srv_c]\naddr=127.0.0.1:0\ntype=public\n\n" |
|
|
|
|
"[client: to_a]\nkeepalive=1\npeer_public_key=%s\nlink=srv_c:127.0.0.1:0\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", intg_temp_dir, pub_a); |
|
|
|
|
config_ensure_keys_and_node_id(cfg_c); |
|
|
|
|
|
|
|
|
|
u_free(pub_a); |
|
|
|
|
@ -655,13 +653,13 @@ static void _intg_cleanup(void) {
|
|
|
|
|
|
|
|
|
|
static int _intg_init_two(void) { |
|
|
|
|
i_phase = 0; i_timeout_id = NULL; i_a = i_b = i_c = NULL; |
|
|
|
|
int port_a, port_b, port_c; |
|
|
|
|
char cfg_a[256], cfg_b[256], cfg_c[256]; |
|
|
|
|
if (_intg_create_cfgs(&port_a, &port_b, &port_c, cfg_a, cfg_b, cfg_c, sizeof(cfg_a)) != 0) return -1; |
|
|
|
|
if (_intg_create_cfgs(cfg_a, cfg_b, cfg_c, sizeof(cfg_a)) != 0) return -1; |
|
|
|
|
utun_instance_set_tun_init_enabled(0); |
|
|
|
|
i_ua = uasync_create(); if (!i_ua) { _intg_cleanup(); return -1; } |
|
|
|
|
i_a = utun_instance_create(i_ua, cfg_a); |
|
|
|
|
i_b = utun_instance_create(i_ua, cfg_b); |
|
|
|
|
if (i_a && i_b) test_etcp_set_peer(i_b, "to_a", i_a, "srv_a"); |
|
|
|
|
if (!i_a || !i_b || utun_instance_init(i_a) != 0 || utun_instance_init(i_b) != 0) |
|
|
|
|
{ _intg_cleanup(); return -1; } |
|
|
|
|
i_timeout_id = uasync_set_timeout(i_ua, INTG_TIMEOUT_TB, NULL, _intg_timeout, "ms_intg_timeout"); |
|
|
|
|
@ -836,14 +834,17 @@ static void test_randomized_two(void) {
|
|
|
|
|
|
|
|
|
|
static int _intg_init_three(void) { |
|
|
|
|
i_phase = 0; i_timeout_id = NULL; i_a = i_b = i_c = NULL; |
|
|
|
|
int port_a, port_b, port_c; |
|
|
|
|
char cfg_a[256], cfg_b[256], cfg_c[256]; |
|
|
|
|
if (_intg_create_cfgs(&port_a, &port_b, &port_c, cfg_a, cfg_b, cfg_c, sizeof(cfg_a)) != 0) return -1; |
|
|
|
|
if (_intg_create_cfgs(cfg_a, cfg_b, cfg_c, sizeof(cfg_a)) != 0) return -1; |
|
|
|
|
utun_instance_set_tun_init_enabled(0); |
|
|
|
|
i_ua = uasync_create(); if (!i_ua) { _intg_cleanup(); return -1; } |
|
|
|
|
i_a = utun_instance_create(i_ua, cfg_a); |
|
|
|
|
i_b = utun_instance_create(i_ua, cfg_b); |
|
|
|
|
i_c = utun_instance_create(i_ua, cfg_c); |
|
|
|
|
if (i_a && i_b && i_c) { |
|
|
|
|
test_etcp_set_peer(i_b, "to_a", i_a, "srv_a"); |
|
|
|
|
test_etcp_set_peer(i_c, "to_a", i_a, "srv_a"); |
|
|
|
|
} |
|
|
|
|
if (!i_a || !i_b || !i_c || utun_instance_init(i_a) != 0 || utun_instance_init(i_b) != 0 || utun_instance_init(i_c) != 0) |
|
|
|
|
{ _intg_cleanup(); return -1; } |
|
|
|
|
i_timeout_id = uasync_set_timeout(i_ua, INTG_TIMEOUT_TB*5, NULL, _intg_timeout, "ms_intg_timeout"); |
|
|
|
|
@ -1089,9 +1090,7 @@ static int _str_init(void) {
|
|
|
|
|
if (test_mkdtemp(tmpld) != 0) { printf(" mkdtemp failed\n"); u_free(s); gs = NULL; return -1; } |
|
|
|
|
|
|
|
|
|
/* --- create configs --- */ |
|
|
|
|
int base_port = 44000 + (getpid() % 10000); |
|
|
|
|
char cfgs[STRESS_N][256]; int ports[STRESS_N]; |
|
|
|
|
for (int i = 0; i < STRESS_N; i++) ports[i] = base_port + i; |
|
|
|
|
char cfgs[STRESS_N][256]; |
|
|
|
|
|
|
|
|
|
utun_instance_set_tun_init_enabled(0); |
|
|
|
|
s->ua = uasync_create(); |
|
|
|
|
@ -1103,8 +1102,8 @@ static int _str_init(void) {
|
|
|
|
|
char dbp[256]; snprintf(dbp, sizeof(dbp), "%s/db_0", tmpld); utun_mkdir(dbp, 0755); |
|
|
|
|
_write_cfg(cfgs[0], |
|
|
|
|
"[global]\nmy_node_id=0xAAAAAAAAAAAAAAAA\ntun_ip=10.240.0.1/24\ntun_ifname=tun240\nkeepalive_adaptive=0\ndb_path=%s\n\n" |
|
|
|
|
"[server:s0]\naddr=127.0.0.1:%d\ntype=public\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", dbp, ports[0]); |
|
|
|
|
"[server:s0]\naddr=127.0.0.1:0\ntype=public\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", dbp); |
|
|
|
|
config_ensure_keys_and_node_id(cfgs[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1116,10 +1115,10 @@ static int _str_init(void) {
|
|
|
|
|
char nid[32]; snprintf(nid, sizeof(nid), "BBBBBBBBBBBB%02d00", i); |
|
|
|
|
_write_cfg(cfgs[i], |
|
|
|
|
"[global]\nmy_node_id=0x%s\ntun_ip=10.240.0.%d/24\ntun_ifname=tun240\nkeepalive_adaptive=0\ndb_path=%s\n\n" |
|
|
|
|
"[server:s%d]\naddr=127.0.0.1:%d\ntype=public\n\n" |
|
|
|
|
"[client:to_hub]\nkeepalive=1\npeer_public_key=%s\nlink=s%d:127.0.0.1:%d\n\n" |
|
|
|
|
"[server:s%d]\naddr=127.0.0.1:0\ntype=public\n\n" |
|
|
|
|
"[client:to_hub]\nkeepalive=1\npeer_public_key=%s\nlink=s%d:127.0.0.1:0\n\n" |
|
|
|
|
"[allowed_keys]\nallow_all=1\n", |
|
|
|
|
nid, i + 1, dbp, i, ports[i], hub_pub, i, ports[0]); |
|
|
|
|
nid, i + 1, dbp, i, hub_pub, i); |
|
|
|
|
config_ensure_keys_and_node_id(cfgs[i]); |
|
|
|
|
} |
|
|
|
|
u_free(hub_pub); |
|
|
|
|
@ -1127,6 +1126,7 @@ static int _str_init(void) {
|
|
|
|
|
/* --- create instances --- */ |
|
|
|
|
for (int i = 0; i < STRESS_N; i++) { |
|
|
|
|
s->inst[i] = utun_instance_create(s->ua, cfgs[i]); |
|
|
|
|
if (s->inst[i] && i) test_etcp_set_peer(s->inst[i], "to_hub", s->inst[STRESS_HUB], "s0"); |
|
|
|
|
if (!s->inst[i] || utun_instance_init(s->inst[i]) != 0) { |
|
|
|
|
printf(" FAIL: instance %d init\n", i); |
|
|
|
|
goto fail; |
|
|
|
|
|