~james-page/ubuntu/natty/cobbler/fix-764391

« back to all changes in this revision

Viewing changes to tests/performance.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short, Chuck Short, Andres Rodriguez
  • Date: 2011-03-11 07:59:55 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110311075955-9z16j4suh6xwcwh8
Tags: 2.1.0~bzr2005-0ubuntu1
[Chuck Short]
* New upstream release 

[Andres Rodriguez]
* Add python-koan package (LP: #731616):
  - debian/control: Add python-koan binary package; fix typo
  - debian/python-cobbler.install: Do not install koan python modules.
  - debian/python-koan.install: Add. Install koan python modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# test script to evaluate Cobbler API performance
 
2
#
 
3
# Michael DeHaan <mdehaan@redhat.com>
 
4
 
 
5
import os
 
6
import cobbler.api as capi
 
7
import time
 
8
import sys
 
9
import random
 
10
 
 
11
N = 500
 
12
print "sample size is %s" % N
 
13
 
 
14
api = capi.BootAPI()
 
15
 
 
16
# part one ... create our test systems for benchmarking purposes if
 
17
# they do not seem to exist.
 
18
 
 
19
#if not api.find_profile("foo"):
 
20
#    print "CREATE A PROFILE NAMED 'foo' to be able to run this test"
 
21
#    sys.exit(0)
 
22
 
 
23
def random_mac():
 
24
    mac = [ 0x00, 0x16, 0x3e,
 
25
      random.randint(0x00, 0x7f),
 
26
      random.randint(0x00, 0xff),
 
27
      random.randint(0x00, 0xff) ]
 
28
    return ':'.join(map(lambda x: "%02x" % x, mac))
 
29
 
 
30
print "Deleting autotest entries from a previous run"
 
31
time1 = time.time()
 
32
for x in xrange(0,N):
 
33
   try:
 
34
       sys = api.remove_system("autotest-%s" % x,with_delete=True)
 
35
   except:
 
36
       pass
 
37
time2 = time.time()
 
38
print "ELAPSED: %s seconds" % (time2 - time1)
 
39
 
 
40
print "Creating test systems from scratch"
 
41
time1 = time.time()
 
42
for x in xrange(0,N):
 
43
   sys = api.new_system()
 
44
   sys.set_name("autotest-%s" % x)
 
45
   sys.set_mac_address(random_mac(), "eth0")
 
46
   sys.set_profile("foo") # assumes there is already a foo
 
47
   # print "... adding: %s" % sys.name
 
48
   api.add_system(sys)
 
49
time2 = time.time()
 
50
print "ELAPSED %s seconds" % (time2 - time1)
 
51
 
 
52
#for mode2 in [ "fast", "normal", "full" ]:
 
53
for mode in [ "on", "off" ]:
 
54
 
 
55
   print "Running netboot edit benchmarks (turn %s)" % (mode)
 
56
   time1 = time.time()
 
57
   for x in xrange(0,N):
 
58
       sys = api.systems().find("autotest-%s" % x)
 
59
       if mode == "off":
 
60
           sys.set_netboot_enabled(0)
 
61
       else:
 
62
           sys.set_netboot_enabled(1)
 
63
           # print "... editing: %s" % sys.name
 
64
       api.add_system(sys)
 
65
 
 
66
   time2 = time.time()
 
67
   print "ELAPSED: %s seconds" % (time2 - time1)
 
68
 
 
69
 
 
70