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

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/tests/func/mongo/sync/f_sync_safe_mode.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 <errno.h>
 
5
#include <string.h>
 
6
 
 
7
#include "libmongo-private.h"
 
8
 
 
9
void
 
10
test_func_mongo_sync_safe_mode (void)
 
11
{
 
12
  mongo_sync_connection *conn;
 
13
  const bson *docs[10];
 
14
  bson *b1, *b2, *b3, *b4, *cmd;
 
15
  mongo_packet *p;
 
16
  gchar *error;
 
17
 
 
18
  mongo_util_oid_init (0);
 
19
 
 
20
  b1 = bson_new ();
 
21
  bson_append_string (b1, "func_mongo_sync_safe_mode", "works", -1);
 
22
  bson_finish (b1);
 
23
 
 
24
  b2 = bson_new ();
 
25
  bson_append_int32 (b2, "int32", 1984);
 
26
  bson_finish (b2);
 
27
 
 
28
  b3 = test_bson_generate_full ();
 
29
  b4 = test_bson_generate_full ();
 
30
 
 
31
  docs[0] = b1;
 
32
  docs[1] = b2;
 
33
  docs[2] = b3;
 
34
  docs[3] = b4;
 
35
 
 
36
  conn = mongo_sync_connect (config.primary_host, config.primary_port,
 
37
                             FALSE);
 
38
 
 
39
  /* Test inserts */
 
40
  mongo_sync_conn_set_safe_mode (conn, FALSE);
 
41
  ok (mongo_sync_cmd_insert_n (conn, config.ns, 4, docs) == TRUE,
 
42
      "mongo_sync_cmd_insert_n() should not fail with safe mode off");
 
43
 
 
44
  mongo_sync_conn_set_safe_mode (conn, TRUE);
 
45
  ok (mongo_sync_cmd_insert_n (conn, config.ns, 4, docs) == FALSE,
 
46
      "mongo_sync_cmd_insert_n() should fail with safe mode on");
 
47
 
 
48
  /* Test a custom command */
 
49
  cmd = bson_new ();
 
50
  bson_append_int32 (cmd, "bogusCommand", 1);
 
51
  bson_finish (cmd);
 
52
 
 
53
  mongo_sync_cmd_reset_error (conn, config.db);
 
54
  mongo_sync_conn_set_safe_mode (conn, FALSE);
 
55
  p = mongo_sync_cmd_custom (conn, config.db, cmd);
 
56
  mongo_sync_cmd_get_last_error (conn, config.db, &error);
 
57
  ok (p == NULL && strcmp (error, "no such cmd: bogusCommand") == 0,
 
58
      "mongo_sync_cmd_custom() with a bogus command fails with safe-mode off");
 
59
  bson_free (cmd);
 
60
 
 
61
  cmd = bson_new ();
 
62
  bson_append_int32 (cmd, "bogusCommand2", 1);
 
63
  bson_finish (cmd);
 
64
  mongo_sync_cmd_reset_error (conn, config.db);
 
65
  mongo_sync_conn_set_safe_mode (conn, TRUE);
 
66
  p = mongo_sync_cmd_custom (conn, config.db, cmd);
 
67
  mongo_sync_cmd_get_last_error (conn, config.db, &error);
 
68
  ok (p == NULL && strcmp (error, "no such cmd: bogusCommand2") == 0,
 
69
      "mongo_sync_cmd_custom() with a bogus command fails with safe-mode on");
 
70
  bson_free (cmd);
 
71
 
 
72
  mongo_sync_disconnect (conn);
 
73
  bson_free (b1);
 
74
  bson_free (b2);
 
75
  bson_free (b3);
 
76
  bson_free (b4);
 
77
}
 
78
 
 
79
RUN_NET_TEST (4, func_mongo_sync_safe_mode);