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