Details
-
Task
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Description
The failure:
Error MessageException: ('Error while replicating', 'CouchbaseLiteException{CouchbaseLite, 5022: java.net.ConnectException: Failed to connect to /10.100.150.54:4984')Stacktraceparams_from_base_test_setup = {'base_url': 'http://10.100.150.56:8080', 'cbl_ce': False, 'cbl_db': 'cbl-test1707503018.849599', 'cbl_log_decoder_build': None, ...} |
sg_conf_name = 'sync_gateway_revs_conflict_configurable', num_of_docs = 100 |
revs_limit = 35 |
|
@pytest.mark.listener |
@pytest.mark.conflicts |
@pytest.mark.noconflicts |
@pytest.mark.replication |
@pytest.mark.parametrize("sg_conf_name, num_of_docs, revs_limit", [ |
('sync_gateway_revs_conflict_configurable', 10, 25), |
('sync_gateway_revs_conflict_configurable', 100, 35), |
('sync_gateway_revs_conflict_configurable', 100, 50) |
])
|
def test_no_conflicts_update_with_revs_limit(params_from_base_test_setup, sg_conf_name, num_of_docs, revs_limit):
|
""" |
@summary: |
1. Have sg config with allow conflicts with some revs_limit |
2. Create docs in CBL |
3. Start a continous Replicator to have SG load all the docs. Verify if the no. of docs are same in both SG and CBL. |
4. Update docs in CBL and also update docs through SG with number of times more than revs_limit. check the docs after replication become idle |
5. Change the revs_limit less than actual revs limit |
6. Restart sg |
7. update doc 1 more time and let replication become idle |
8. Verify revs limit is maintained with new modified revs_limit |
|
""" |
sg_db = "db" |
sg_url = params_from_base_test_setup["sg_url"] |
sg_admin_url = params_from_base_test_setup["sg_admin_url"] |
mode = params_from_base_test_setup["mode"] |
cluster_config = params_from_base_test_setup["cluster_config"] |
sg_blip_url = params_from_base_test_setup["target_url"] |
no_conflicts_enabled = params_from_base_test_setup["no_conflicts_enabled"] |
sync_gateway_version = params_from_base_test_setup["sync_gateway_version"] |
base_url = params_from_base_test_setup["base_url"] |
db = params_from_base_test_setup["db"] |
cbl_db = params_from_base_test_setup["source_db"] |
need_sgw_admin_auth = params_from_base_test_setup["need_sgw_admin_auth"] |
|
channels = ["no-conflicts-cbl"] |
reduced_revs_limit = revs_limit - 3 |
|
if sync_gateway_version < "2.0": |
pytest.skip('--no-conflicts is enabled and does not work with sg < 2.0 , so skipping the test') |
|
# Reset cluster to ensure no data in system
|
sg_config = sync_gateway_config_path_for_mode(sg_conf_name, mode)
|
c = cluster.Cluster(config=cluster_config)
|
c.reset(sg_config_path=sg_config)
|
|
# Modify the revs_limit
|
temp_cluster_config = copy_to_temp_conf(cluster_config, mode)
|
persist_cluster_config_environment_prop(temp_cluster_config, 'revs_limit', revs_limit, property_name_check=False) |
status = c.sync_gateways[0].restart(config=sg_config, cluster_config=temp_cluster_config) |
assert status == 0, "Syncgateway did not start after adding revs_limit with no conflicts mode " |
|
# Create bulk doc json and update docs in CBL
|
db.create_bulk_docs(num_of_docs, "no-conflicts", db=cbl_db, channels=channels) |
db.update_bulk_docs(cbl_db, number_of_updates=4) |
|
sg_client = MobileRestClient()
|
auth = need_sgw_admin_auth and (RBAC_FULL_ADMIN['user'], RBAC_FULL_ADMIN['pwd']) or None |
sg_client.create_user(sg_admin_url, sg_db, "autotest", password="password", channels=channels, auth=auth) |
cookie, session_id = sg_client.create_session(sg_admin_url, sg_db, "autotest", auth=auth) |
session = cookie, session_id
|
|
# Start and stop continuous replication
|
replicator = Replication(base_url)
|
authenticator = Authenticator(base_url)
|
replicator_authenticator = authenticator.authentication(session_id, cookie, authentication_type="session") |
repl_config = replicator.configure(cbl_db, sg_blip_url, continuous=True, channels=channels, replication_type="push", replicator_authenticator=replicator_authenticator) |
repl = replicator.create(repl_config)
|
replicator.start(repl)
|
log_info("replicator status is {} ".format(replicator.status(repl))) |
replicator.wait_until_replicator_idle(repl)
|
time.sleep(2) # Give some time to get update to sync-gateway |
sg_docs = sg_client.get_all_docs(url=sg_url, db=sg_db, auth=session)
|
sg_docs = sg_docs["rows"] |
|
assert len(sg_docs) == num_of_docs, "SG docs docs count is not same as CBL docs count " |
|
for doc in sg_docs: |
if no_conflicts_enabled: |
with pytest.raises(HTTPError) as he:
|
sg_client.add_conflict(url=sg_url, db=sg_db, doc_id=doc["id"], parent_revisions=doc["value"]["rev"], new_revision="2-2B", |
auth=session)
|
assert str(he.value).startswith('409 Client Error: Conflict for url:') |
|
time.sleep(1) |
else: |
conflicted_rev = sg_client.add_conflict(url=sg_url, db=sg_db, doc_id=doc["id"], parent_revisions=doc["value"]["rev"], new_revision="2-2B", |
auth=session)
|
assert conflicted_rev["rev"] == "2-2B" |
|
replicator.wait_until_replicator_idle(repl)
|
# Update the docs few times
|
for i in range(revs_limit + 5): |
db.update_bulk_docs(cbl_db)
|
time.sleep(1) |
|
replicator.wait_until_replicator_idle(repl)
|
# Get number of revisions and verify length is equal to revs_limit set to
|
for doc in sg_docs: |
num_of_revs = sg_client.get_revs_num_in_history(url=sg_url, db=sg_db, doc_id=doc["id"], auth=session) |
assert len(num_of_revs) == revs_limit, "Number of revisions in history does not match the revs_limit set in sg config" |
|
# Modify the revs_limit less than actual revs_limit
|
temp_cluster_config = copy_to_temp_conf(cluster_config, mode)
|
persist_cluster_config_environment_prop(temp_cluster_config, 'revs_limit', reduced_revs_limit, property_name_check=False) |
status = c.sync_gateways[0].restart(config=sg_config, cluster_config=temp_cluster_config) |
assert status == 0, "Syncgateway did not start after having revs_limit 2 with no conflicts mode" |
time.sleep(9) |
|
# Update the docs 1 more time |
sg_client.update_docs(url=sg_url, db=sg_db, docs=sg_docs, number_updates=1, delay=None, auth=session, channels=channels) |
time.sleep(5) |
> replicator.wait_until_replicator_idle(repl)
|