-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhanastress.py
executable file
·69 lines (52 loc) · 2.85 KB
/
hanastress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/opt/hanastress/hanapython
import util.printUtil
import generators.generator
import destroyers.schemaDestroyer
from optparse import OptionParser
import sys
class HanaStress:
def __init__(self):
self.getCommand()
def setCommands(self, parser):
parser.add_option("-v", "--verbose", help="Give detailed messages", action="store_true")
parser.add_option("-l", "--host", help="The hostname of the DB instance")
parser.add_option("-i", "--instance", help="The DB instance to connect to")
parser.add_option("-u", "--user", help="The user to use for the DB connection")
parser.add_option("-p", "--password", help="The password to use for the DB connection")
parser.add_option("-g", "--generate", help="Generate a schema. Usage: --create {SCHEMA_TYPE}. Can be: ")
parser.add_option("-t", "--tables", help="Used with '--generate'. The amount of tables to create. Default: 50", default=50)
parser.add_option("-s", "--rowstorage", help="Used with '--generate', Will set table type to Row Store instead of Column Store", action="store_true")
parser.add_option("-r", "--rows", help="Used with '--generate', set the amount of rows for each table. Default: 100", default=100)
parser.add_option("-k", "--threads", help="The amount of threads to use", default=10)
parser.add_option("--destroy", help="This will DESTROY all the schemas owned by the given user (expect their default schema). BE CAREFUL!", action="store_true")
def getCommand(self):
# create an option parser
parser = OptionParser()
# Set out commands
self.setCommands(parser)
# Get the options passed in by the user
options, args = parser.parse_args()
# Should be output verbose messages
self.printUtil = util.printUtil.PrintUtil(options.verbose)
# Convert the username to upper case
if options.user:
options.user = options.user.upper()
if options.threads:
options.threads = int(options.threads)
# Make sure we never run as system
if options.user == "SYSTEM":
self.printUtil.err("INVALID", "CAN NOT RUN AS 'SYSTEM' USER, THIS PROGRAM CAN BE VERY DESTRUCTIVE FOR THE USER GIVEN. CREATE A NEW USER FOR THIS TO RUN AS.")
sys.exit(1)
self.runCommands(options)
def runCommands(self, options):
if options.generate:
store_type = "row"
if not options.rowstorage:
store_type = "column"
self.generator = generators.generator.Generator(options, int(options.tables), store_type, int(options.rows))
self.generator.generate()
elif options.destroy:
self.destroyer = destroyers.schemaDestroyer.SchemaDestroyer(options)
self.destroyer.destroy()
# Run our main class
hanastress = HanaStress()