2
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
7
"""execution_management.py
8
code for dealing with test execution.
9
The actual nuts and bolts of executing a test lies with the
10
mode-specific test-executor
12
The code here is for managing the executors and such.
20
class executionManager:
21
""" Manages the mode-specific test-executors
22
and serves as an intermediary between the executors
23
and the other management code (system, server, test)
27
def __init__(self, server_manager, system_manager, test_manager
28
, executor_type, variables):
30
self.server_manager = server_manager
31
self.system_manager = system_manager
32
self.logging = system_manager.logging
33
self.test_manager = test_manager
34
if variables['verbose']:
35
self.logging.info("Initializing test execution manager...")
36
self.skip_keys = [ 'server_manager'
40
, 'executor_start_count'
41
, 'executor_current_count'
44
self.debug = variables['debug']
45
self.verbose = variables['verbose']
46
self.force = variables['force']
47
self.record_flag = variables['record']
49
self.executor_name_base = 'testbot'
50
self.executor_start_count = 0
51
self.executor_current_count = 0
52
# We will eventually allow this to be set
53
# by the user, but we are hard-coded at 1
54
# for the moment (will = --parallel)
55
self.executor_count = 1
56
self.executor_type = executor_type
59
self.logging.debug_class(self)
62
def execute_tests(self):
63
""" Execute the testCases stored in the testManager
64
via spawning executor_count of the mode-specific
67
Currently only supporting single executor, but trying
72
# create our testExecutors to execute the tests
73
self.create_test_executors()
75
# fire up the testExecutors and let them rip it up
76
for executor_name, executor in self.executors.items():
78
self.logging.verbose("Starting executor: %s" %(executor_name))
79
# thread.start_new(executor.execute,()) # sigh...one day...damned drizzletest!
82
while self.has_running_executors():
84
self.test_manager.statistical_report()
85
self.logging.info("Test execution complete")
87
def has_running_executors(self):
88
""" We see if our executors are still running """
89
for executor in self.executors.values():
90
if executor.status == 1:
94
def create_test_executors(self):
95
""" create however many test executors of executor_type
96
that we need (only supporting 1 for now)
100
self.logging.info("Creating %d %s(s)" %(self.executor_count
101
, self.executor_name_base))
102
for i in range(self.executor_start_count,self.executor_count,1):
103
executor_name = "%s%d" %(self.executor_name_base,i)
104
new_executor = self.create_test_executor(executor_name)
107
def create_test_executor(self, executor_name):
108
""" Create a single testExecutor """
111
self.logging.verbose("Creating %s" %(executor_name))
112
new_executor = self.executor_type( self, executor_name
113
, self.verbose, self.debug)
114
self.log_executor(executor_name, new_executor)
116
def log_executor(self, executor_name, new_executor):
117
""" Bookkeeping function to track created executors """
118
self.executors[executor_name] = new_executor
119
self.executor_current_count += 1