Project

General

Profile

« Previous | Next » 

Revision 4906

Added by daigle over 15 years ago

Update load test code

View differences:

squery-load-test.py
11 11
interval = int(sys.argv[3])
12 12
host = sys.argv[4]
13 13

  
14
# set debug=0 for no debugging.  Set it to 0 - 3 for increasing amounts of debug.
15
debug=0
14
# set debug_level=0 for no debugging.  Set it to 0 - 3 for increasing amounts of debug.
15
debug_level=2
16 16

  
17
output_file = "./squery-" + letter + ".out"
18
output_file = open(output_file, 'w')
17
output_file_name = "./squery-" + letter + ".out"
18
output_file = open(output_file_name, 'w')
19
output_file.close()
19 20

  
20 21
def debug (message):
22
	output_file = open(output_file_name, 'a')
21 23
	output_file.write(message + '\n')
24
	output_file.close()
22 25
	
23 26
def debug1 (message):
24
	if debug > 0:
27
	if debug_level > 0:
28
		output_file = open(output_file_name, 'a')
25 29
		output_file.write(message + '\n')
30
		output_file.close()
26 31

  
27 32
def debug2 (message):
28
	if debug > 1:
33
	if debug_level > 1:
34
		output_file = open(output_file_name, 'a')
29 35
		output_file.write(message + '\n')
36
		output_file.close()
30 37

  
31 38
def debug3 (message):
32
	if debug > 2:
39
	if debug_level > 2:
40
		output_file = open(output_file_name, 'a')
33 41
		output_file.write(message + '\n')
42
		output_file.close()
34 43

  
35
dictionary_file = open('./dictionary.txt', 'r')
44
dictionary_file_name = './dictionary-' + letter + '.txt'
45
dictionary_file = open(dictionary_file_name, 'r')
36 46

  
37 47
iter_count = 0
38 48

  
......
41 51
debug("       letter: $letter ") 
42 52
debug("       iterations: $iterations ")
43 53
debug("       interval: $interval ")
54
debug("       host: $host ")
44 55
debug("************************************************** ")
45 56

  
46 57
mc = metacat.MetacatClient(host,'/knb/metacat')
......
50 61
query_template_file.close
51 62

  
52 63
for line in dictionary_file:
53
	if line.lower().startswith(letter.lower()):
54
		word = line.strip()
55
		debug("[%s] -- Processing Search" % (word))
56
		query = query_template.replace("@!search-word!@", word)
57
		t1 = time()
58
		response = mc.squery(query)
59
		t2 = time()
64
	word = line.strip()
65
	debug("[%s] -- Processing Search" % (word))
66
	query = query_template.replace("@!search-word!@", word)
67
	t1 = time()
68
	response = mc.squery(query)
69
	t2 = time()
60 70

  
61
		if response.find("<resultset>") != -1:
62
			debug("[%s] -- SUCCESS: elapsed time: %.5f seconds" % (word, t2-t1))
63
		else:
64
			debug("[%s] -- ERROR: " % (word), response)
71
	if response.find("<resultset>") != -1:
72
		debug("[%s] -- SUCCESS: elapsed time: %.5f seconds" % (word, t2-t1))
73
	else:
74
		debug("[%s] -- ERROR: " % (word), response)
65 75
			
66
		iter_count = iter_count + 1
67
		debug3("iter_count: %d, iterations: %d" % (iter_count, iterations))
68
		if iter_count >= iterations:		
69
			sys.exit()
76
	iter_count = iter_count + 1
77
	debug2("iter_count: %d, iterations: %d" % (iter_count, iterations))
78
	if iter_count >= iterations:		
79
		sys.exit()
70 80
			
71
		sleep(interval)
81
	sleep(interval)
72 82
	
73 83
dictionary_file.close()
74 84
output_file.close()

Also available in: Unified diff