def test_sg_replicate_basic_test_channels(params_from_base_test_setup): cluster_config = params_from_base_test_setup["cluster_config"] mode = params_from_base_test_setup["mode"] log_info("Running 'test_sg_replicate_basic_test_channels'") log_info("Using cluster_config: {}".format(cluster_config)) config = sync_gateway_config_path_for_mode("sync_gateway_sg_replicate", mode) sg1, sg2 = create_sync_gateways( cluster_config=cluster_config, sg_config_path=config ) admin = Admin(sg1) admin.admin_url = sg1.url sg1a_user, sg1b_user, sg2_user = create_sg_users_channels(sg1, sg2, DB1, DB2) # Add docs to sg1 in channel A and channel B doc_id_sg1a = sg1a_user.add_doc() doc_id_sg1b = sg1b_user.add_doc() # Wait until docs show up in changes feed wait_until_doc_in_changes_feed(sg1, DB1, doc_id_sg1a) wait_until_doc_in_changes_feed(sg1, DB1, doc_id_sg1b) # Make sure it doesn't appear on the target DB # even without starting a replication (which will # happen if the SG's are sharing a CB bucket) time.sleep(5) assert_does_not_have_doc(sg2_user, doc_id_sg1a) assert_does_not_have_doc(sg2_user, doc_id_sg1b) # Start a push replication sg1 -> sg2 chans = sg1a_user.channels sg1.start_push_replication( sg2.admin.admin_url, DB1, DB2, continuous=False, use_remote_source=True, channels=chans, use_admin_url=True ) # Verify that the doc added to sg1 made it to sg2 assert_has_doc(sg2_user, doc_id_sg1a)
def test_sg_replicate_basic_test(params_from_base_test_setup): cluster_config = params_from_base_test_setup["cluster_config"] mode = params_from_base_test_setup["mode"] log_info("Running 'test_sg_replicate_basic_test'") log_info("Using cluster_config: {}".format(cluster_config)) config = sync_gateway_config_path_for_mode("sync_gateway_sg_replicate", mode) sg1, sg2 = create_sync_gateways( cluster_config=cluster_config, sg_config_path=config ) admin = Admin(sg1) admin.admin_url = sg1.url sg1_user, sg2_user = create_sg_users(sg1, sg2, DB1, DB2) # Add docs to sg1 and sg2 doc_id_sg1 = sg1_user.add_doc() doc_id_sg2 = sg2_user.add_doc() # Wait until docs show up in changes feed wait_until_doc_in_changes_feed(sg1, DB1, doc_id_sg1) wait_until_doc_in_changes_feed(sg2, DB2, doc_id_sg2) # Make sure it doesn't appear on the target DB # even without starting a replication (which will # happen if the SG's are sharing a CB bucket) time.sleep(5) assert_does_not_have_doc(sg2_user, doc_id_sg1) assert_does_not_have_doc(sg1_user, doc_id_sg2) # Start a push replication sg1 -> sg2 # Should block until replication # Result should contain the stats of the completed replication replication_result = sg1.start_push_replication( sg2.admin.admin_url, DB1, DB2, continuous=False, use_remote_source=True, use_admin_url=True ) logging.debug("replication_result 1: {}".format(replication_result)) assert replication_result["continuous"] is False, 'replication_result["continuous"] != False' assert replication_result["docs_written"] == 1, 'replication_result["docs_written"] != 1' assert replication_result["docs_read"] == 1, 'replication_result["docs_read"] != 1' assert replication_result["doc_write_failures"] == 0, 'replication_result["doc_write_failures"] != 0' # Start a pull replication sg1 <- sg2 replication_result = sg1.start_pull_replication( sg2.admin.admin_url, DB2, DB1, continuous=False, use_remote_target=True, use_admin_url=True ) logging.debug("replication_result 2: {}".format(replication_result)) assert replication_result["continuous"] is False, 'replication_result["continuous"] != False' assert replication_result["docs_written"] == 1, 'replication_result["docs_written"] != 1' assert replication_result["docs_read"] == 1, 'replication_result["docs_read"] != 1' assert replication_result["doc_write_failures"] == 0, 'replication_result["doc_write_failures"] != 0' # Verify that the doc added to sg1 made it to sg2 assert_has_doc(sg2_user, doc_id_sg1) # Verify that the doc added to sg2 made it to sg1 assert_has_doc(sg1_user, doc_id_sg2)