~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/sys_mgmt/system_management.py

  • Committer: Lee Bieber
  • Date: 2011-02-10 18:34:13 UTC
  • mfrom: (2151.8.3 dbqp_fixes)
  • mto: This revision was merged to the branch mainline in revision 2155.
  • Revision ID: kalebral@gmail.com-20110210183413-bykzel58bzkzzekm
Merge Patrick - 715885: dbqp needs to return non-zero if tests fail

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import os
35
35
import sys
36
36
import copy
 
37
from uuid import uuid4
37
38
import shutil
38
39
import getpass
39
40
import commands
67
68
        self.shm_path = self.find_path(["/dev/shm", "/tmp"], required=0)
68
69
        self.cur_os = os.uname()[0]
69
70
        self.cur_user = getpass.getuser()
70
 
        self.symlink_name = 'dbqp_workdir_%s' %(self.cur_user)
71
71
        self.workdir = os.path.abspath(variables['workdir'])
 
72
        self.datadir = os.path.abspath(os.path.join(variables['testdir'],'dbqp_data'))
72
73
        self.top_srcdir = os.path.abspath(variables['topsrcdir'])
73
74
        self.top_builddir = os.path.abspath(variables['topbuilddir'])
74
75
        self.start_dirty = variables['startdirty']
80
81
        
81
82
        self.port_manager = portManager(self,variables['debug'])
82
83
        self.time_manager = timeManager(self)
83
 
       
84
 
            
 
84
                   
85
85
        # Make sure the tree we are testing looks good
86
86
        self.code_tree = self.get_code_tree(variables, tree_type)
87
87
 
115
115
        # self.process_environment_reqs(self.environment_reqs)
116
116
        self.update_environment_vars(self.environment_reqs)
117
117
 
 
118
        # We find or generate our id file
 
119
        # We use a uuid to identify the symlinked
 
120
        # workdirs.  That way, each installation
 
121
        # Will have a uuid/tmpfs workingdir
 
122
        # We store in a file so we know what
 
123
        # is ours
 
124
        self.uuid = self.get_uuid()
 
125
        self.symlink_name = 'dbqp_workdir_%s_%s' %(self.cur_user, self.uuid)
 
126
 
118
127
        # initialize our workdir
119
128
        self.process_workdir()
120
129
 
125
134
        if self.valgrind:
126
135
            self.handle_valgrind_reqs(variables['valgrindarglist'])
127
136
            
128
 
 
129
137
        if self.debug:
130
138
            self.logging.debug_class(self)
131
139
        
132
 
 
133
 
 
134
140
    def get_code_tree(self, variables, tree_type):
135
141
        """Find out the important files, directories, and env. vars
136
142
           for a particular type of tree.  We import a definition module
145
151
        test_tree = self.process_tree_type(tree_type, variables)
146
152
        return test_tree
147
153
 
148
 
    
149
 
 
150
154
    def process_tree_type(self, tree_type, variables):
151
155
        """Import the appropriate module depending on the type of tree
152
156
           we are testing. 
154
158
           Drizzle is the only supported type currently
155
159
 
156
160
        """
 
161
 
157
162
        if self.verbose:
158
163
            self.logging.verbose("Processing source tree under test...")
159
164
        if tree_type == 'drizzle':
165
170
            self.logging.error("Tree_type: %s not supported yet" %(tree_type))
166
171
            sys.exit(1)        
167
172
 
168
 
    def get_port_block(self, requester, base_port, block_size):
169
 
        """ Try to assign a block of ports for test execution
170
 
            purposes
171
 
 
172
 
        """
173
 
     
174
 
        return self.port_manager.get_port_block( requester
175
 
                                               , base_port, block_size)
176
 
 
 
173
    
177
174
    def create_dirset(self, rootdir, dirset):
178
175
        """ We produce the set of directories defined in dirset
179
176
            dirset is a set of dictionaries like
201
198
 
202
199
        return full_path    
203
200
 
 
201
    def get_uuid(self):
 
202
        """ We look to see if a uuid file exists
 
203
            If so, we use that to know where to work
 
204
            If not we produce one so future runs
 
205
            have a definitive id to use
 
206
 
 
207
        """
 
208
 
 
209
        uuid_file_name = os.path.join(self.datadir, 'uuid')
 
210
        if os.path.exists(uuid_file_name):
 
211
            uuid_file = open(uuid_file_name,'r')
 
212
            uuid = uuid_file.readline().strip()
 
213
            uuid_file.close()
 
214
        else:
 
215
            uuid = uuid4()
 
216
            print uuid
 
217
            print uuid4()
 
218
            uuid_file = open(uuid_file_name,'w')
 
219
            uuid_file.write(str(uuid))
 
220
            uuid_file.close()
 
221
        return uuid
 
222
 
204
223
    def process_workdir(self):
205
224
        """ We create our workdir, analyze relevant variables
206
225
            to see if we should/shouldn't symlink to shm