Project

General

Profile

« Previous | Next » 

Revision 4906

Added by daigle over 15 years ago

Update load test code

View differences:

insert-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 17
run_time = str(time()).replace('.','')
18 18

  
19
output_file = "./insert-" + letter + ".out"
20
output_file = open(output_file, 'w')
19
output_file_name = "./insert-" + letter + ".out"
20
output_file = open(output_file_name, 'w')
21
output_file.close()
21 22

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

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

  
33 40
def debug3 (message):
34
	if debug > 2:
41
	if debug_level > 2:
42
		output_file = open(output_file_name, 'a')
35 43
		output_file.write(message + '\n')
44
		output_file.close()
36 45

  
37
dictionary_file = open('./dictionary.txt', 'r')
46
dictionary_file_name = './dictionary-' + letter + '.txt'
47
dictionary_file = open(dictionary_file_name, 'r')
38 48

  
39 49
iter_count = 0
40 50

  
41 51
debug("************************************************** ")
42
debug("Starting squery-load-test for ") 
52
debug("Starting insert-load-test for ") 
43 53
debug("       letter: $letter ") 
44 54
debug("       iterations: $iterations ")
45 55
debug("       interval: $interval ")
56
debug("       host: $host ")
46 57
debug("************************************************** ")
47 58

  
48 59
# Initialize a metacat client connection and log in as test user
......
62 73
insert_template_file.close
63 74

  
64 75
for line in dictionary_file:
65
	if line.lower().startswith(letter.lower()):
66
		word = line.strip()
76
	word = line.strip()
67 77
		
68
		debug3("word: " + word)
69
		debug3("run time: " + run_time)
70
		debug3("iter count: " + str(iter_count))
71
		docid = word + run_time + '.' + str(iter_count) + '.1'
72
		doc = insert_template.replace("@!docid!@", docid)
73
		t1 = time()
78
	debug3("word: " + word)
79
	debug3("run time: " + run_time)
80
	debug3("iter count: " + str(iter_count))
81
	docid = word + run_time + '.' + str(iter_count) + '.1'
82
	doc = insert_template.replace("@!docid!@", docid)
83
	t1 = time()
74 84

  
75
		debug("[%s] -- Processing Insert" % (docid))
76
		response = mc.insert(docid, doc)
77
		t2 = time()
85
	debug("[%s] -- Processing Insert" % (docid))
86
	response = mc.insert(docid, doc)
87
	t2 = time()
78 88

  
79
		if (response.lower().find('<error>') == -1):
80
			debug("[%s] -- SUCCESS: elapsed time: %.5f seconds" % (docid, t2-t1))
81
		else:
82
			debug("[%s] -- ERROR: %s" % (docid, response))
89
	if (response.lower().find('<error>') == -1):
90
		debug("[%s] -- SUCCESS: elapsed time: %.5f seconds" % (docid, t2-t1))
91
	else:
92
		debug("[%s] -- ERROR: %s" % (docid, response))
83 93
		
84
		iter_count = iter_count + 1
85
		debug3("iter_count: %d, iterations: %d" % (iter_count, iterations))
86
		if iter_count >= iterations:		
87
			sys.exit()
94
	iter_count = iter_count + 1
95
	debug2("iter_count: %d, iterations: %d" % (iter_count, iterations))
96
	if iter_count >= iterations:		
97
		sys.exit()
88 98
			
89
		sleep(interval)
99
	sleep(interval)
90 100
	
91 101
dictionary_file.close()
92 102
output_file.close()

Also available in: Unified diff