NBT-WINSREPLICATION: be more robust to timing errors
[tprouty/samba.git] / source4 / torture / nbt / winsreplication.c
index 470eee831003d9c20e66070ab2e530882e5d1977..6b600bd7cd48ef847dcc3e7eacb77a6fdd1bbf71 100644 (file)
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
 
-       wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
-       wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        torture_comment(tctx, "Setup 2 wrepl connections\n");
        status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
 
        torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
 
        torture_comment(tctx, "Test one pull replication cycle\n");
 
-       wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        
        torture_comment(tctx, "Setup wrepl connections\n");
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        if (!ctx) return NULL;
 
        ctx->address    = address;
-       ctx->pull       = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->pull       = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->pull) return NULL;
 
        torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 
        talloc_free(pull_table.out.partners);
 
-       ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock) return NULL;
 
        load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
        if (!NT_STATUS_IS_OK(status)) return NULL;
 
-       ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
        if (!ctx->nbtsock_srv) return NULL;
 
        /* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
        }
 
        if (ctx->myaddr2 && ctx->nbtsock_srv) {
-               ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+               ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
                if (!ctx->nbtsock2) return NULL;
 
                status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
        uint32_t assoc_ctx;
        NTSTATUS status;
 
-       wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+       wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
 
        status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
@@ -6701,7 +6701,6 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx,
 /* 
  * unique vs. unique section
  */
-#if METZE_NEEDS_TO_LOOK_AT_THIS_ONE
        /*
         * unique,active vs. unique,active with same ip(s), unchecked
         */
@@ -6728,7 +6727,6 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx,
                        .apply_expected = true
                },
        },
-#endif
        /*
         * unique,active vs. unique,active with different ip(s), positive response
         */
@@ -8967,7 +8965,6 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx,
                        .sgroup_merge   = true
                },
        },
-#if 0
        /*
         * sgroup,active vs. sgroup,active with same ip(s)
         */
@@ -9157,7 +9154,6 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx,
                        .apply_expected = false
                },
        },
-#endif
        };
 
        if (!ctx->nbtsock_srv) {
@@ -9543,7 +9539,9 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_
        talloc_free(rep_packet);
 
        /* make sure we push the reply to the wire */
-       event_loop_once(nbtsock->event_ctx);
+       while (nbtsock->send_queue) {
+               event_loop_once(nbtsock->event_ctx);
+       }
        msleep(1000);
 
        rec->defend.timeout     = 0;
@@ -9598,7 +9596,9 @@ static void test_conflict_owned_active_vs_replica_handler_release(
        talloc_free(rep_packet);
 
        /* make sure we push the reply to the wire */
-       event_loop_once(nbtsock->event_ctx);
+       while (nbtsock->send_queue) {
+               event_loop_once(nbtsock->event_ctx);
+       }
        msleep(1000);
 
        rec->defend.timeout     = 0;