MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test07_current_queries

Method test07_current_queries

tests/flow/test_graph_info.py:324–435  ·  view source on GitHub ↗

test currently running queries

(self)

Source from the content-addressed store, hash-verified

322 t.join()
323
324 def test07_current_queries(self):
325 """test currently running queries"""
326
327 # flush DB
328 self.conn.flushall()
329
330 # shared variable, single consumer thread to exit
331 alive = True
332
333 # issue a number of threads all running the same query
334 def issue_query(g, q):
335 while alive:
336 g.query(q)
337
338 def issue_2_query(g, q1, q2):
339 while alive:
340 g.query(q1)
341 time.sleep(1)
342 g.query(q2)
343
344 num_threads = multiprocessing.cpu_count() * 2
345
346 # create multiple connections
347 connections = []
348 for i in range(num_threads+1):
349 connections.append(self.env.getConnection())
350
351 read_query = "MATCH (n) WHERE n.v > 100 RETURN count(1)"
352 write_query1 = "UNWIND range(1, 10000) AS x CREATE (v: x)"
353 write_query2 = "MATCH (n) DELETE n"
354 # create multiple threads
355 threads = []
356 for i in range(num_threads):
357 # read queries
358 t = threading.Thread(target=issue_query, args=(Graph(connections[i], GRAPH_ID), read_query))
359 threads.append(t)
360
361 # write query
362 t = threading.Thread(target=issue_2_query, args=(Graph(connections[-1], GRAPH_ID), write_query1, write_query2))
363 threads.append(t)
364
365 # issue threads
366 for t in threads:
367 t.start()
368
369 # wait for graph to be created
370 res = self.conn.type(GRAPH_ID)
371 while res != "graphdata":
372 res = self.conn.type(GRAPH_ID)
373
374 # get waiting and running queries
375
376 #-----------------------------------------------------------------------
377 # validate running queries
378 #-----------------------------------------------------------------------
379
380 res = self.conn.execute_command("GRAPH.INFO")
381 while True:

Callers

nothing calls this directly

Calls 3

GraphClass · 0.85
startMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected