示例#1
0
 def setUp(self):
   self.rootDir = '/tmp/hod-%s' % getpass.getuser()
   self.cfg = setupConf() # creat a conf
   # Modify hod.user_state
   self.cfg['hod']['user_state'] = tempfile.mkdtemp(dir=self.rootDir,
                             prefix='HodTestSuite.test_InvalidHodStateFiles_')
   self.log = MockLogger() # mock logger
   self.cluster = MockHadoopCluster() # mock hadoop cluster
   self.client = hodRunner(self.cfg, log=self.log, cluster=self.cluster)
   self.state = hodState(self.cfg['hod']['user_state'])
   self.statePath = os.path.join(self.cfg['hod']['user_state'], '%s.state' % \
                                 TEST_CLUSTER_DATA_FILE)
   self.clusterDir = tempfile.mkdtemp(dir=self.rootDir,
                             prefix='HodTestSuite.test_InvalidHodStateFiles_')
示例#2
0
  def setUp(self):

    self.cfg = setupConf()
    # initialize the mock objects
    self.log = MockLogger()
    self.cluster = MockHadoopCluster()

    # Use the test logger. This will be used for test verification.
    self.client = hodRunner(self.cfg, log=self.log, cluster=self.cluster)
    # Create the hodState object to set the test state you want.
    self.state = hodState(self.cfg['hod']['user_state'])
    if not os.path.exists(self.cfg['hod']['user_state']):
      os.path.mkdir(self.cfg['hod']['user_state'])
    p = os.path.join(self.cfg['hod']['user_state'], '%s.state' % TEST_CLUSTER_DATA_FILE)
    # ensure cluster data file exists, so write works in the tests.
    f = open(p, 'w')
    f.close()