Details
-
Sub-task
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
None
Description
add description
Error Message
TypeError: unsupported operand type(s) for +: 'MemoryPointer' and 'str'
Stacktrace
params_from_base_test_setup =
{'base_url': 'http://10.100.172.58:8080', 'cbl_ce': False, 'cbl_db': 'cbl-test1598723891.150649', 'cbl_log_decoder_build': None, ...}replicator_type = 'pull'
@pytest.mark.listener
@pytest.mark.custom_conflict
@pytest.mark.replication
@pytest.mark.parametrize("replicator_type", [
"pull",
"push_pull"
])
def test_non_blocking_custom_conflicts_resolution(params_from_base_test_setup, replicator_type):
"""
@summary:
1. create a doc on cbl then push the doc to sgw
2. modify the doc on sgw and cbl separately in offline mode in order to generate conflicts, doc is not null on
either sgw or cbl
3. get the doc respectively from sgw and cbl, remember the rev id of the sgw doc and the sequence number of the
cbl doc
4. initialize a replicator, register a custom conflict resolver which intentionally takes longer period of time
to complete
5. stop replicator before conflict resolver finishes, verify replicator will wait for conflict resolver to complete
then stop
6. verify the cbl doc is successfully resolved
7. replicate with sgw, verify sgw successfully synced with the cbl doc
"""
sg_db = "db"
sg_url = params_from_base_test_setup["sg_url"]
sg_admin_url = params_from_base_test_setup["sg_admin_url"]
sg_config = params_from_base_test_setup["sg_config"]
cluster_config = params_from_base_test_setup["cluster_config"]
sg_blip_url = params_from_base_test_setup["target_url"]
liteserv_version = params_from_base_test_setup["liteserv_version"]
base_url = params_from_base_test_setup["base_url"]
num_of_docs = 10
channels = ["ABC"]
db = params_from_base_test_setup["db"]
cbl_db = params_from_base_test_setup["source_db"]
if liteserv_version < "2.6.0":
pytest.skip('test does not work with liteserv_version < 2.6.0 , so skipping the test')
- Reset cluster to ensure no data in system
c = Cluster(config=cluster_config)
c.reset(sg_config_path=sg_config)
- Create bulk doc json
db.create_bulk_docs(num_of_docs, "delayed_local_conflicts", db=cbl_db, channels=channels)
sg_client = MobileRestClient()
log_info("Using SG url: {}".format(sg_admin_url))
sg_client.create_user(sg_admin_url, sg_db, "autotest", password="password", channels=channels)
cookie, session_id = sg_client.create_session(sg_admin_url, sg_db, "autotest")
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=False, channels=channels,
replicator_authenticator=replicator_authenticator,
replication_type="push_pull")
repl = replicator.create(repl_config)
replicator.start(repl)
replicator.wait_until_replicator_idle(repl)
total = replicator.getTotal(repl)
completed = replicator.getCompleted(repl)
replicator.stop(repl)
assert total == completed, "total is not equal to completed"
sg_docs = sg_client.get_all_docs(url=sg_url, db=sg_db, auth=session)["rows"]
- creating conflict for docs on SG
sg_client.update_docs(url=sg_url, db=sg_db, docs=sg_docs, number_updates=2,
property_updater=property_updater, auth=session)
- creating conflict for docs on CBL
doc_ids = db.getDocIds(cbl_db)
cbl_docs = db.getDocuments(cbl_db, doc_ids)
for doc_id in cbl_docs:
for _ in range(2):
log_info("Updating CBL Doc - {}".format(doc_id))
data = cbl_docs[doc_id]
data = property_updater(data)
data["cbl_random"] = random_string(length=10, printable=True)
db.updateDocument(cbl_db, doc_id=doc_id, data=data)
repl_config = replicator.configure(cbl_db, sg_blip_url, continuous=True, channels=channels,
replicator_authenticator=replicator_authenticator,
replication_type=replicator_type,
conflict_resolver="delayed_local_win")
repl = replicator.create(repl_config)
replicator.start(repl)
- updating doc at CBL couple of times
new_docs_body = {}
log_info("Updating CBL docs during conflict resolution")
for doc_id in cbl_docs:
for _ in range(2):
log_info("Updating CBL Doc - {}".format(doc_id))
data = cbl_docs[doc_id]
new_docs_body[doc_id] = [data]
data = property_updater(data)
random_value = random_string(length=10, printable=True)
data["update_during_CCR"] = random_value
db.updateDocument(cbl_db, doc_id=doc_id, data=data)
- Saving the history of update to CBL doc
new_docs_body[doc_id].append(data)
replicator.wait_until_replicator_idle(repl, sleep_time=12) # Added sleep time because CCR sleeps for 10 secs
- Double checking that the complete replication is done as delayed CCR might give false idle for replication
sleep(2)
replicator.wait_until_replicator_idle(repl, sleep_time=12)
total = replicator.getTotal(repl)
completed = replicator.getCompleted(repl)
replicator.stop(repl)
assert total == completed, "total is not equal to completed"
sg_docs_content = sg_client.get_bulk_docs(sg_url, sg_db, doc_ids, session)[0]
cbl_docs = db.getDocuments(cbl_db, doc_ids)
if replicator_type == "pull":
for sg_doc in sg_docs_content:
doc_id = sg_doc["_id"]
cbl_doc = cbl_docs[doc_id]
assert sg_doc["sg_new_update1"] != cbl_doc["sg_new_update1"], "CCR failed to resolve conflict " \
"with delayed local win"
assert sg_doc["sg_new_update2"] != cbl_doc["sg_new_update2"], "CCR failed to resolve conflict " \
"with delayed local win"
assert sg_doc["sg_new_update3"] != cbl_doc["sg_new_update3"], "CCR failed to resolve conflict " \
"with delayed local win"
assert "random" not in cbl_doc, "CCR failed to resolve conflict with delayed local win"
assert "cbl_random" not in sg_doc, "CCR failed to resolve conflict with delayed local win"
log_info(
> cbl_doc["update_during_CCR"] + "resolve conflict with delayed local win" + new_docs_body[doc_id][1][
"update_during_CCR"])
E TypeError: unsupported operand type(s) for +: 'MemoryPointer' and 'str'
testsuites/CBLTester/CBL_Functional_tests/TestSetup_FunctionalTests/test_custom_conflicts.py:699: TypeError
Attachments
Issue Links
- is cloned by
-
CM-507 IOS and Dot all platforms 100% pass rates
- Done