MCPcopy
hub / github.com/alibaba/MongoShake / generate_conf

Function generate_conf

scripts/run_sys_test.py:38–76  ·  view source on GitHub ↗
(tp, all, id, src_url, dst_url, dir_name, ckpt_time)

Source from the content-addressed store, hash-verified

36
37# write conf file
38def generate_conf(tp, all, id, src_url, dst_url, dir_name, ckpt_time):
39 content = {
40 "conf.version": "7",
41 "id": id,
42 "log.dir": test_dir,
43 "log.file": id + ".log",
44 "log.flush": "true",
45 "sync_mode": "all" if all else "incr", # we only test sync_mode=all
46 "tunnel": "direct",
47 "tunnel.address": dst_url,
48 "filter.namespace.white": '%s.%s' % (test_db, test_coll),
49 "mongo_connect_mode": "secondaryPreferred",
50 "checkpoint.storage.db": test_checkpoint_db,
51 "checkpoint.start_position": "1970-01-01T00:00:00Z" if all else ckpt_time,
52 "incr_sync.mongo_fetch_method": tp,
53 }
54 if "#" in src_url:
55 # sharding
56 role_lists = src_url.split("#")
57 print(role_lists)
58 content["mongo_urls"] = role_lists[1]
59 content["mongo_cs_url"] = role_lists[2]
60 content["mongo_s_url"] = role_lists[0]
61 elif "^" in src_url:
62 content["special.source.db.flag"] = "aliyun_serverless"
63 addr = src_url.split("^")
64 print(addr)
65 content["mongo_urls"] = addr[1]
66 else:
67 content["mongo_urls"] = src_url
68
69 file_name = os.path.join(dir_name, id + ".conf")
70 f = open(file_name, "w")
71 for key, val in content.items():
72 f.write(' = '.join([key, val]) + '\n')
73 f.close()
74
75 print('generate conf: %r with details:\n%r' % (file_name, content))
76 return file_name
77
78
79def _get_mongodb_addr(src_url):

Callers 2

test_full_syncFunction · 0.85
test_incr_syncFunction · 0.85

Calls 2

splitMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected