File: f_sync_conn_seed_add.c

package info (click to toggle)
libmongo-client 0.1.8-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 1,440 kB
  • sloc: ansic: 14,980; makefile: 317; perl: 137; sh: 48
file content (58 lines) | stat: -rw-r--r-- 1,327 bytes parent folder | download | duplicates (6)
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
#include "test.h"
#include <mongo.h>

#include "libmongo-private.h"

void
test_func_mongo_sync_conn_seed_add (void)
{
  mongo_sync_connection *conn;
  GList *l;

  conn = mongo_sync_connect (config.primary_host, config.primary_port,
                             FALSE);
  close (conn->super.fd);

  l = conn->rs.hosts;
  while (l)
    {
      g_free (l->data);
      l = g_list_delete_link (l, l);
    }
  conn->rs.hosts = NULL;

  l = conn->rs.seeds;
  while (l)
    {
      g_free (l->data);
      l = g_list_delete_link (l, l);
    }
  conn->rs.seeds = NULL;

  conn = mongo_sync_reconnect (conn, TRUE);
  ok (conn == NULL,
      "mongo_sync_reconnect() fails without seeds or discovery");

  conn = mongo_sync_connect (config.primary_host, config.primary_port,
                             FALSE);
  close (conn->super.fd);
  l = conn->rs.hosts;
  while (l)
    {
      g_free (l->data);
      l = g_list_delete_link (l, l);
    }
  conn->rs.hosts = NULL;

  ok (mongo_sync_conn_seed_add (conn, config.primary_host,
                                config.primary_port),
      "mongo_sync_conn_seed_add() works");

  conn = mongo_sync_reconnect (conn, TRUE);
  ok (conn != NULL,
      "mongo_sync_reconnect() works when properly seeded");

  mongo_sync_disconnect (conn);
}

RUN_NET_TEST (3, func_mongo_sync_conn_seed_add);