Beispiel #1
0
    def test_end_to_end(self):
        tc = {0: ts.TaskClient(self.dbi, 'localhost')}
        s = ts.Scheduler(tc, actions_per_still=1)
        thd = threading.Thread(target=s.start,
                               args=(self.dbi, ),
                               kwargs={
                                   'ActionClass': ts.Action,
                                   'action_args': (tc, ),
                                   'sleeptime': 0
                               })
        thd.start()
        try:

            def all_done():
                for f in self.dbi.files:
                    if self.dbi.get_obs_status(f) != 'COMPLETE':
                        return False
                return True

            while not all_done():
                time.sleep(.1)
        finally:
            s.quit()
            thd.join()
        for i in self.dbi.files:
            self.assertEqual(self.dbi.get_obs_status(i), 'COMPLETE')
Beispiel #2
0
 def test_gen_args(self):
     # tc = ts.TaskClient(self.dbi, 'localhost')
     tc = ts.TaskClient(self.dbi, 'localhost', self.wf, port=TEST_PORT)
     for task in FILE_PROCESSING_STAGES[2:-1]:  # Jon : FIXME : HARDWF
         args = tc.gen_args(task, 2)
         if task in ['UVCRE', 'UVCRRE']:  # Jon : HARDWF
             self.assertEqual(len(args), 3)
         elif task in [
                 'UVC',
                 'CLEAN_UV',
                 'CLEAN_UVC',
                 'NPZ',
                 'UVCRR',  # Jon : HARDWF
                 'CLEAN_UVCRE',
                 'CLEAN_UVCRR',
                 'CLEAN_NPZ',
                 'CLEAN_UVCR',  # Jon : HARDWF
                 'CLEAN_UVCRRE'
         ]:  # Jon : HARDWF
             self.assertEqual(len(args), 1)
         elif task in ['ACQUIRE_NEIGHBORS',
                       'CLEAN_NEIGHBORS']:  # Jon : HARDWF
             self.assertEqual(len(args), 0)
         elif task in ['UV', 'NPZ_POT', 'UVCRRE_POT']:  # Jon : HARDWF
             self.assertEqual(len(args), 2)
Beispiel #3
0
    def test_many_stills(self):
        dbi = FakeDataBaseInterface()
        try:
            os.mkdir('still0')
            os.mkdir('still1')
        except (OSError):
            pass
        ts0 = ts.TaskServer(dbi, data_dir='still0', port=4441)
        ts1 = ts.TaskServer(dbi, data_dir='still1', port=4442)
        ts0_thd = threading.Thread(target=ts0.start)
        ts1_thd = threading.Thread(target=ts1.start)
        tc = {
            0: ts.TaskClient(dbi, 'localhost', port=4441),
            1: ts.TaskClient(dbi, 'localhost', port=4442)
        }
        s = ts.Scheduler(tc, actions_per_still=2, blocksize=2)
        s_thd = threading.Thread(target=s.start,
                                 args=(dbi, ),
                                 kwargs={
                                     'ActionClass': ts.Action,
                                     'action_args': (tc, 30),
                                     'sleeptime': 0
                                 })
        ts0_thd.start()
        ts1_thd.start()
        s_thd.start()
        try:

            def all_done():
                for f in dbi.files:
                    if dbi.get_obs_status(f) != 'COMPLETE':
                        return False
                return True

            while not all_done():
                time.sleep(.1)
        finally:
            s.quit()
            ts0.shutdown()
            ts1.shutdown()
            s_thd.join()
            ts0_thd.join()
            ts1_thd.join()
        for i in dbi.files:
            self.assertEqual(dbi.get_obs_status(i), 'COMPLETE')
Beispiel #4
0
    def test__tx(self):
        self.pkt = ''

        class SleepHandler(ts.TaskHandler):
            def handle(me):
                self.pkt = me.get_pkt()

        s = ts.TaskServer(self.dbi, handler=SleepHandler, port=TEST_PORT)
        thd = threading.Thread(target=s.start)
        thd.start()
        try:
            tc = ts.TaskClient(self.dbi, 'localhost', self.wf, port=TEST_PORT)
            tc._tx('UV', 1, ['a', 'b', 'c'])  # Jon : HARDWF
        finally:
            s.shutdown()
            thd.join()
        self.assertEqual(
            self.pkt, ('UV', 1, 'localhost', ['a', 'b', 'c']))  # Jon : HARDWF
Beispiel #5
0
 def test_attributes(self):
     # tc = ts.TaskClient(self.dbi, 'localhost', port=TEST_PORT)
     tc = ts.TaskClient(self.dbi, 'localhost', self.wf, port=TEST_PORT)
     self.assertEqual(tc.host_port, ('localhost', TEST_PORT))