~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/tests/unit/mongo/sync/sync_cmd_kill_cursors.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "test.h"
 
2
#include "mongo.h"
 
3
 
 
4
#include <sys/socket.h>
 
5
#include "libmongo-private.h"
 
6
 
 
7
void
 
8
test_mongo_sync_cmd_kill_cursors_net_secondary (void)
 
9
{
 
10
  mongo_packet *p;
 
11
  mongo_sync_connection *conn;
 
12
  bson *b;
 
13
 
 
14
  mongo_reply_packet_header rh;
 
15
  gint64 cid;
 
16
 
 
17
  skip (!config.secondary_host, 1,
 
18
        "Secondary server not configured");
 
19
 
 
20
  conn = mongo_sync_connect (config.secondary_host, config.secondary_port,
 
21
                             TRUE);
 
22
  b = bson_new ();
 
23
  bson_append_string (b, "test-name", __FILE__, -1);
 
24
  bson_finish (b);
 
25
 
 
26
  p = mongo_sync_cmd_query (conn, config.ns,
 
27
                            MONGO_WIRE_FLAG_QUERY_NO_CURSOR_TIMEOUT,
 
28
                            0, 2, b, NULL);
 
29
  bson_free (b);
 
30
  mongo_wire_reply_packet_get_header (p, &rh);
 
31
  cid = rh.cursor_id;
 
32
  mongo_wire_packet_free (p);
 
33
 
 
34
  ok (mongo_sync_cmd_kill_cursors (conn, 1, cid) == TRUE,
 
35
      "mongo_sync_cmd_kill_cursors() works on secondary too");
 
36
 
 
37
  mongo_sync_disconnect (conn);
 
38
 
 
39
  endskip;
 
40
}
 
41
 
 
42
void
 
43
test_mongo_sync_cmd_kill_cursors_net (void)
 
44
{
 
45
  mongo_packet *p;
 
46
  mongo_sync_connection *conn;
 
47
  bson *b;
 
48
  gint i;
 
49
  mongo_reply_packet_header rh;
 
50
  gint64 cid;
 
51
 
 
52
  begin_network_tests (3);
 
53
 
 
54
  conn = mongo_sync_connect (config.primary_host, config.primary_port, TRUE);
 
55
  mongo_sync_conn_set_auto_reconnect (conn, TRUE);
 
56
 
 
57
  b = bson_new ();
 
58
  for (i = 0; i < 40; i++)
 
59
    {
 
60
      bson_reset (b);
 
61
      bson_append_string (b, "test-name", __FILE__, -1);
 
62
      bson_append_int32 (b, "seq", i);
 
63
      bson_finish (b);
 
64
 
 
65
      mongo_sync_cmd_insert (conn, config.ns, b, NULL);
 
66
    }
 
67
  bson_free (b);
 
68
 
 
69
  b = bson_new ();
 
70
  bson_append_string (b, "test-name", __FILE__, -1);
 
71
  bson_finish (b);
 
72
 
 
73
  p = mongo_sync_cmd_query (conn, config.ns,
 
74
                            MONGO_WIRE_FLAG_QUERY_NO_CURSOR_TIMEOUT,
 
75
                            0, 2, b, NULL);
 
76
  mongo_wire_reply_packet_get_header (p, &rh);
 
77
  cid = rh.cursor_id;
 
78
  mongo_wire_packet_free (p);
 
79
 
 
80
  ok (mongo_sync_cmd_kill_cursors (conn, 1, cid) == TRUE,
 
81
      "mongo_sync_kill_cursors() works");
 
82
 
 
83
  p = mongo_sync_cmd_query (conn, config.ns,
 
84
                            MONGO_WIRE_FLAG_QUERY_NO_CURSOR_TIMEOUT,
 
85
                            0, 2, b, NULL);
 
86
  bson_free (b);
 
87
  mongo_wire_reply_packet_get_header (p, &rh);
 
88
  cid = rh.cursor_id;
 
89
  mongo_wire_packet_free (p);
 
90
  shutdown (conn->super.fd, SHUT_RDWR);
 
91
  sleep (3);
 
92
 
 
93
  ok (mongo_sync_cmd_kill_cursors (conn, 1, cid) == TRUE,
 
94
      "mongo_sync_cmd_kill_cursors() automatically reconnects");
 
95
 
 
96
  mongo_sync_disconnect (conn);
 
97
 
 
98
  test_mongo_sync_cmd_kill_cursors_net_secondary ();
 
99
 
 
100
  end_network_tests ();
 
101
}
 
102
 
 
103
void
 
104
test_mongo_sync_cmd_kill_cursors (void)
 
105
{
 
106
  mongo_sync_connection *c;
 
107
 
 
108
  c = test_make_fake_sync_conn (-1, FALSE);
 
109
 
 
110
  ok (mongo_sync_cmd_kill_cursors (NULL, 1, (gint64)1234) == FALSE,
 
111
      "mongo_sync_cmd_kill_cursors() fails with a NULL connection");
 
112
  ok (mongo_sync_cmd_kill_cursors (c, 0, (gint64)1234) == FALSE,
 
113
      "mongo_sync_cmd_kill_cursors() fails with a negative number of cursors");
 
114
 
 
115
  ok (mongo_sync_cmd_kill_cursors (c, 1, (gint64)1234) == FALSE,
 
116
      "mongo_sync_cmd_kill_cursors() fails with a bogus FD");
 
117
 
 
118
  mongo_sync_disconnect (c);
 
119
 
 
120
  test_mongo_sync_cmd_kill_cursors_net ();
 
121
}
 
122
 
 
123
RUN_TEST (6, mongo_sync_cmd_kill_cursors);