db_updater: Put parentheses back
[merlin.git] / test-csync.c
blob738c4d989b8cd984617e7aafd065bbf15a633053
1 #include "daemon.c"
2 #include "shared.h"
3 #include "mrln_logging.h"
4 #include "test_utils.h"
6 int main(int argc, char **argv)
8 merlin_node node;
10 t_set_colors(0);
11 t_verbose = 1;
13 memset(&node, 0, sizeof(node));
14 ipc.info.last_cfg_change = 10;
15 node.info.last_cfg_change = 5;
16 node.type = MODE_POLLER;
17 node.name = "testelitest";
19 log_grok_var("log_level", "debug");
21 /* remove this line to see what's going on */
22 log_grok_var("log_file", "/dev/null");
25 csync.push.cmd = ":";
26 csync.fetch.cmd = ":";
28 printf("node.csync_last_attemp: %lu\n", node.csync_last_attempt);
29 t_start("csync tests");
31 /* test that we avoid pushing when "connect = no" */
32 node.flags = MERLIN_NODE_DEFAULT_POLLER_FLAGS & ~MERLIN_NODE_CONNECT;
33 csync_node_active(&node);
34 ok_int(node.csync_last_attempt, 0, "Should avoid config pushing when 'connect = no'");
37 * make sure we push when "connect = no" but pushing is
38 * explicitly configured for this node
40 node.csync_num_attempts = 0;
41 node.csync.push.cmd = ":";
42 csync_node_active(&node);
43 ok_int(node.csync_num_attempts, 1, "Should push config when 'connect = no' and node has local push config");
44 node.csync.push.pid = 0;
45 csync_node_active(&node);
47 /* test that we avoid pushing when max attempts is reached */
48 node.flags = MERLIN_NODE_DEFAULT_POLLER_FLAGS;
49 node.csync_num_attempts = node.csync_max_attempts = 3;
50 csync_node_active(&node);
51 ok_int(node.csync_last_attempt > 0, 1, "Should keep pushing config when max attempts reached");
53 return t_end();