dlz_bind9: torture tests exploring rndc reload behaviour
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Thu, 9 Aug 2018 05:09:01 +0000 (17:09 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 27 Sep 2018 02:47:16 +0000 (04:47 +0200)
These tests establish that the process triggered by the command 'rndc reload'
does not cause samba's bind9 dlz plugin to crash.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13214

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Sep 27 04:47:16 CEST 2018 on sn-devel-144

source4/torture/dns/dlz_bind9.c

index ef7220b6ef5254bf6b2210797b311b62a10ec417..a627e2351f7f912f40a45fb423166b1a7b5c16c9 100644 (file)
@@ -30,6 +30,9 @@
 #include "auth/credentials/credentials.h"
 #include "lib/cmdline/popt_common.h"
 
+/* Tests that configure multiple DLZs will use this. Increase to add stress. */
+#define NUM_DLZS_TO_CONFIGURE 4
+
 struct torture_context *tctx_static;
 
 static void dlz_bind9_log_wrapper(int level, const char *fmt, ...)
@@ -144,6 +147,74 @@ static bool test_dlz_bind9_configure(struct torture_context *tctx)
        return true;
 }
 
+static bool test_dlz_bind9_multiple_configure(struct torture_context *tctx)
+{
+       int i;
+       for(i = 0; i < NUM_DLZS_TO_CONFIGURE; i++){
+               test_dlz_bind9_configure(tctx);
+       }
+       return true;
+}
+
+static bool configure_multiple_dlzs(struct torture_context *tctx,
+                                   void **dbdata, int count)
+{
+       int i, res;
+       const char *argv[] = {
+               "samba_dlz",
+               "-H",
+               test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
+               NULL
+       };
+
+       tctx_static = tctx;
+       for(i = 0; i < count; i++){
+               res = dlz_create("samba_dlz", 3, argv, &(dbdata[i]),
+                                "log", dlz_bind9_log_wrapper,
+                                "writeable_zone",
+                                dlz_bind9_writeable_zone_hook, NULL);
+               torture_assert_int_equal(tctx, res, ISC_R_SUCCESS,
+                                        "Failed to create samba_dlz");
+
+               res = dlz_configure((void*)tctx, dbdata[i]);
+               torture_assert_int_equal(tctx, res, ISC_R_SUCCESS,
+                                        "Failed to configure samba_dlz");
+       }
+
+       return true;
+}
+
+static bool test_dlz_bind9_destroy_oldest_first(struct torture_context *tctx)
+{
+       void *dbdata[NUM_DLZS_TO_CONFIGURE];
+       int i;
+
+       configure_multiple_dlzs(tctx, dbdata, NUM_DLZS_TO_CONFIGURE);
+
+       /* Reload faults are reported to happen on the first destroy */
+       dlz_destroy(dbdata[0]);
+
+       for(i = 1; i < NUM_DLZS_TO_CONFIGURE; i++){
+               dlz_destroy(dbdata[i]);
+       }
+
+       return true;
+}
+
+static bool test_dlz_bind9_destroy_newest_first(struct torture_context *tctx)
+{
+       void *dbdata[NUM_DLZS_TO_CONFIGURE];
+       int i;
+
+       configure_multiple_dlzs(tctx, dbdata, NUM_DLZS_TO_CONFIGURE);
+
+       for(i = NUM_DLZS_TO_CONFIGURE - 1; i >= 0; i--) {
+               dlz_destroy(dbdata[i]);
+       }
+
+       return true;
+}
+
 /*
  * Test that a ticket obtained for the DNS service will be accepted on the Samba DLZ side
  *
@@ -1092,6 +1163,13 @@ static struct torture_suite *dlz_bind9_suite(TALLOC_CTX *ctx)
        torture_suite_add_simple_test(suite, "version", test_dlz_bind9_version);
        torture_suite_add_simple_test(suite, "create", test_dlz_bind9_create);
        torture_suite_add_simple_test(suite, "configure", test_dlz_bind9_configure);
+       torture_suite_add_simple_test(suite, "destroyoldestfirst",
+                                     test_dlz_bind9_destroy_oldest_first);
+       torture_suite_add_simple_test(suite, "destroynewestfirst",
+                                     test_dlz_bind9_destroy_newest_first);
+       torture_suite_add_simple_test(suite, "multipleconfigure",
+                                     test_dlz_bind9_multiple_configure);
+
        torture_suite_add_simple_test(suite, "gssapi", test_dlz_bind9_gssapi);
        torture_suite_add_simple_test(suite, "spnego", test_dlz_bind9_spnego);
        torture_suite_add_simple_test(suite, "lookup", test_dlz_bind9_lookup);