File: sync_connect_from_cache_enforce_primary.c

package info (click to toggle)
libmongo-client 0.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,384 kB
  • ctags: 770
  • sloc: ansic: 14,979; makefile: 322; perl: 137; sh: 48
file content (47 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (4)
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
#include "test.h"
#include "mongo.h"

#define NETWORK_TESTS_NUM 5

void
test_mongo_sync_connect_from_cache_enforce_primary (void)
{
  mongo_sync_conn_recovery_cache *cache;
  mongo_sync_connection *c;

  begin_network_tests (NETWORK_TESTS_NUM);

  cache = mongo_sync_conn_recovery_cache_new ();

  skip (!config.secondary_host,
        NETWORK_TESTS_NUM,
        "Secondary server not configured");

  ok (mongo_sync_conn_recovery_cache_seed_add (cache, config.secondary_host,
                                               config.secondary_port) == TRUE,
      "mongo_sync_conn_recovery_seed_add() works");

  ok ((c = mongo_sync_connect_recovery_cache (cache, TRUE)) != NULL,
      "mongo_sync_connect_recovery_cache() works");

  ok (mongo_sync_cmd_is_master(c) == FALSE,
      "Secondary server should not be The Master.");

  mongo_sync_disconnect (c);

  ok ((c = mongo_sync_connect_recovery_cache (cache, FALSE)) != NULL,
      "mongo_sync_connect_recovery_cache() works");

  ok (mongo_sync_cmd_is_master (c) == TRUE,\
      "Retrieved connection should be The Master when it is forced to be.");

  mongo_sync_disconnect (c);

  endskip;

  mongo_sync_conn_recovery_cache_free (cache);

  end_network_tests ();
}

RUN_TEST (NETWORK_TESTS_NUM, mongo_sync_connect_from_cache_enforce_primary);