Debian Codegraph @

test/lib/server.h

raw
1 /* Setup fully blown servers running in standalone threads. */
2
3 #ifndef TEST_SERVER_H
4 #define TEST_SERVER_H
5
6 #include <pthread.h>
7 #include <sys/un.h>
8
9 #include "../../src/client/protocol.h"
10
11 #include "../../include/cowsql.h"
12
13 #include "endpoint.h"
14 #include "munit.h"
15
16 #if defined(__arm__) || defined(__aarch64__) || defined(__s390x__) || \
17 defined(__hppa__) || defined(__mips64) || defined(__riscv)
18 #define FLAKY 1
19 #endif
20
21 #define SNAPSHOT_THRESHOLD_PARAM "snapshot-threshold"
22
23 struct test_server
24 {
25 unsigned id; /* Server ID. */
26 char address[8]; /* Server address. */
27 char *dir; /* Data directory. */
28 cowsql_node *cowsql; /* Cowsql instance. */
29 bool role_management;
30 struct client_proto client; /* Connected client. */
31 struct test_server *others[5]; /* Other servers, by ID-1. */
32 };
33
34 /* Initialize the test server. */
35 void test_server_setup(struct test_server *s,
36 unsigned id,
37 const MunitParameter params[]);
38
39 /* Cleanup the test server. */
40 void test_server_tear_down(struct test_server *s);
41
42 /* Start the test server. */
43 void test_server_start(struct test_server *s, const MunitParameter params[]);
44
45 /* Stop the test server. */
46 void test_server_stop(struct test_server *s);
47
48 /* Connect all the given the servers to each other. */
49 void test_server_network(struct test_server *servers, unsigned n_servers);
50
51 /* Return a client connected to the server. */
52 struct client_proto *test_server_client(struct test_server *s);
53
54 /* Closes and reopens a client connection to the server. */
55 void test_server_client_reconnect(struct test_server *s,
56 struct client_proto *c);
57
58 /* Opens a client connection to the server. */
59 void test_server_client_connect(struct test_server *s, struct client_proto *c);
60
61 /* Closes a client connection to ther server. */
62 void test_server_client_close(struct test_server *s, struct client_proto *c);
63
64 #endif /* TEST_SERVER_H */