def setup_class(cls): try: conn = Connection() conn.open('127.0.0.1', 9671, 3000) auth_result = conn.authenticate('root', 'nebula') session_id = auth_result.get_session_id() assert session_id != 0 cls.execute_with_retry(conn, session_id, 'CREATE SPACE IF NOT EXISTS test_graph_storage_client(' 'PARTITION_NUM=10,' 'REPLICA_FACTOR=1,' 'vid_type=FIXED_STRING(20));' 'USE test_graph_storage_client;' 'CREATE TAG IF NOT EXISTS person(name string, age int);' 'CREATE EDGE IF NOT EXISTS friend(start int, end int);') time.sleep(5) for id in range(1000): vid = 'person' + str(id) cmd = 'INSERT VERTEX person(name, age) ' \ 'VALUES \"{}\":(\"{}\", {})'.format(vid, vid, id) cls.execute_with_retry(conn, session_id, cmd) for id in range(1000): src_id = 'person' + str(id) dst_id = 'person' + str(1000 - id) start = random.randint(2000, 2010) end = random.randint(2010, 2020) cmd = 'INSERT EDGE friend(start, end) ' \ 'VALUES \"{}\"->\"{}\":({}, {})'.format(src_id, dst_id, start, end) cls.execute_with_retry(conn, session_id, cmd) conn.close() meta_cache = MetaCache([('172.28.1.1', 9559), ('172.28.1.2', 9559), ('172.28.1.3', 9559)], 50000) cls.graph_storage_client = GraphStorageClient(meta_cache) except Exception: import traceback print(traceback.format_exc()) assert False
(person12)-[:friend@0{'start': 2007, 'end': 2010}]->(person8) (person17)-[:friend@0{'start': 2008, 'end': 2013}]->(person3) (person5)-[:friend@0{'start': 2005, 'end': 2015}]->(person15) (person8)-[:friend@0{'start': 2000, 'end': 2019}]->(person12) """ if __name__ == '__main__': meta_cache = None graph_storage_client = None try: # the metad servers's address meta_cache = MetaCache([('172.28.1.1', 45500), ('172.28.1.2', 45500), ('172.28.1.3', 45500)], 50000) graph_storage_client = GraphStorageClient(meta_cache) prepare_data() scan_person_vertex(graph_storage_client) scan_person_edge(graph_storage_client) except Exception as x: import traceback print(traceback.format_exc()) if graph_storage_client is not None: graph_storage_client.close() exit(1) finally: if graph_storage_client is not None: graph_storage_client.close() if meta_cache is not None: meta_cache.close()