示例#1
0
    def setup(self):
        os.chdir('functests')
        self.igsession = None
        self.infile = "test/cpingest.in"
        if os.path.exists(self.infile):
            os.remove(self.infile)
        os.environ["ICE_CONFIG"] = "ice.cfg"
        os.environ["PYTHON_LOG_FILE"] = "cpmanager.log"
        self.igsession = IceSession('applications.txt', cleanup=True)
        try:
            self.igsession.start()
            time.sleep(5)

            self.dataservice = get_service(
                "SchedulingBlockService@DataServiceAdapter",
                ISchedulingBlockServicePrx, self.igsession.communicator)

            self.cpservice = get_service(
                "CentralProcessorService@IngestManagerAdapter",
                ICPObsServicePrx, self.igsession.communicator)

            self.monitoringservice = get_service(
                "MonitoringService@IngestManagerMonitoringAdapter",
                MonitoringProviderPrx, self.igsession.communicator)

        except Exception as ex:
            os.chdir('..')
            self.igsession.terminate()
            raise
示例#2
0
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     os.chdir('functests')
     self.isession = IceSession('applications.txt', cleanup=True)
     try:
         self.isession.start()
     except Exception as ex:
         self.teardown()
         raise
示例#3
0
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     self.isession = IceSession()  #cleanup=True)
     try:
         self.isession.add_app("icebox")
         self.isession.start()
         time.sleep(2)
         self.subscriber = LogSubscriber(self.isession.communicator)
         time.sleep(2)
     except Exception as ex:
         self.isession.terminate()
         raise
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     os.chdir('functests')
     self.igsession = IceSession('applications2.txt', cleanup=True)
     try:
         self.igsession.start()
         self.service = get_service_object(
             self.igsession.communicator,
             "MonProviderService@MonProviderAdapter",
             askap.interfaces.monitoring.MonitoringProviderPrx)
     except Exception as ex:
         self.teardown()
         raise
示例#5
0
class TestPubSub(object):
    def __init__(self):
        self.logger = None
        self.topic = "testtopic"
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.isession = IceSession('applications.txt', cleanup=True)
        try:
            self.isession.start()
        except Exception as ex:
            self.teardown()
            raise

    def teardown(self):
        os.chdir('..')
        self.isession.terminate()

    def test_typedvalue_publish(self):
        block = threading.Event()
        self.publisher = TypedValuePublisher(
            topic=self.topic,
            communicator=self.isession.communicator
            )
        self.subscriber = TypedValueSubscriber(
            topic=self.topic, communicator=self.isession.communicator,
            impl_cls=SubscriberImpl, impl_kwargs={'event': block}
            )
        self.publisher.publish({'test': True})
        nottimedout = block.wait(3.0)
        #python2.6
        nottimedout = block.is_set()
        assert_equals(nottimedout, True)

    def test_timetaggedtypedvalue_publish(self):
        block = threading.Event()
        self.publisher = TimeTaggedTypedValuePublisher(
            topic=self.topic,
            communicator=self.isession.communicator
            )
        self.subscriber = TypedValueSubscriber(
            topic=self.topic, communicator=self.isession.communicator,
            impl_cls=TTSubscriberImpl, impl_kwargs={'event': block}
            )
        self.publisher.publish({'test': True}, 12345L)
        nottimedout = block.wait(3.0)
        nottimedout = block.is_set()
        assert_equals(nottimedout, True)
示例#6
0
class TestIceLogger(object):
    def __init__(self):
        self.subscriber = None
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        self.isession = IceSession()  #cleanup=True)
        try:
            self.isession.add_app("icebox")
            self.isession.start()
            time.sleep(2)
            self.subscriber = LogSubscriber(self.isession.communicator)
            time.sleep(2)
        except Exception as ex:
            self.isession.terminate()
            raise

    def teardown(self):
        self.isession.terminate()

    def test_info(self):
        time.sleep(2)
        # this sends a log message over icestorm to the logger topic
        #        with open('out.log', 'w') as outf:
        subprocess.check_call(['./tIceAppender'],
                              stderr=sys.stderr,
                              shell=True)
        received = LOGEVENT.wait(10)
        if received is None:
            received = LOGEVENT.is_set()
        assert (received)
        assert_equals(last_event[0], log_origin)
        assert_equals(last_event[-3], log_msg)
        assert_equals(last_event[-1], socket.gethostname())
示例#7
0
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     os.chdir('functests')
     self.isession = IceSession(cleanup=True)
     try:
         self.isession.add_app("icebox")
         self.isession.start()
         self.subscriber = LogSubscriber(self.isession.communicator)
         askap.logging.config.fileConfig("test.log_cfg")
         self.logger = askap.logging.getLogger(__name__)
     except Exception as ex:
         os.chdir("..")
         self.isession.terminate()
         raise
示例#8
0
class TestIceLogger(object):
    def __init__(self):
        self.subscriber = None
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        self.isession = IceSession()#cleanup=True)
        try:
            self.isession.add_app("icebox")
            self.isession.start()
            time.sleep(2)
            self.subscriber = LogSubscriber(self.isession.communicator)
            time.sleep(2)
        except Exception as ex:
            self.isession.terminate()
            raise

    def teardown(self):
        self.isession.terminate()

    def test_info(self):
        time.sleep(2)
        # this sends a log message over icestorm to the logger topic
#        with open('out.log', 'w') as outf:
        subprocess.check_call(['./tIceAppender'], stderr=sys.stderr,
                              shell=True)
        received = LOGEVENT.wait(10)
        if received is None:
            received = LOGEVENT.is_set()
        assert(received)
        assert_equals(last_event[0], log_origin)
        assert_equals(last_event[-3], log_msg)
        assert_equals(last_event[-1], socket.gethostname())
示例#9
0
class TestPubSub(object):
    def __init__(self):
        self.logger = None
        self.topic = "testtopic"
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.isession = IceSession('applications.txt', cleanup=True)
        try:
            self.isession.start()
        except Exception as ex:
            self.teardown()
            raise

    def teardown(self):
        os.chdir('..')
        self.isession.terminate()

    def test_typedvalue_publish(self):
        block = threading.Event()
        self.publisher = TypedValuePublisher(
            topic=self.topic, communicator=self.isession.communicator)
        self.subscriber = TypedValueSubscriber(
            topic=self.topic,
            communicator=self.isession.communicator,
            impl_cls=SubscriberImpl,
            impl_kwargs={'event': block})
        self.publisher.publish({'test': True})
        nottimedout = block.wait(3.0)
        #python2.6
        nottimedout = block.is_set()
        assert_equals(nottimedout, True)

    def test_timetaggedtypedvalue_publish(self):
        block = threading.Event()
        self.publisher = TimeTaggedTypedValuePublisher(
            topic=self.topic, communicator=self.isession.communicator)
        self.subscriber = TypedValueSubscriber(
            topic=self.topic,
            communicator=self.isession.communicator,
            impl_cls=TTSubscriberImpl,
            impl_kwargs={'event': block})
        self.publisher.publish({'test': True}, 12345L)
        nottimedout = block.wait(3.0)
        nottimedout = block.is_set()
        assert_equals(nottimedout, True)
示例#10
0
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     os.chdir('functests')
     self.isession = IceSession('applications.txt', cleanup=True)
     try:
         self.isession.start()
     except Exception as ex:
         self.teardown()
         raise
示例#11
0
class TestMonProvider(object):
    def __init__(self):
        self.logger = None
        self.igsession = None
        self.service = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.igsession = IceSession('applications2.txt', cleanup=True)
        try:
            self.igsession.start()
            self.service = get_service_object(
                self.igsession.communicator,
                "MonProviderService@MonProviderAdapter",
                askap.interfaces.monitoring.MonitoringProviderPrx)
        except Exception as ex:
            self.teardown()
            raise

    def teardown(self):
        os.chdir('..')
        self.igsession.terminate()

    def test_get(self):
        block = threading.Event()

        first = self.service.get(['a'])
        assert_equals(first[0].name, 'a')
        block.wait(0.1)
        second = self.service.get(['a'])
        assert_equals(second[0].name, 'a')
        assert_greater(second[0].value.value, first[0].value.value)
        both = self.service.get(['a', 'b'])
        assert_equals(len(both), 2)
        assert_equals(len(self.service.get(['c'])), 0)

        foo = self.service.get(['foo1'])
        assert_equals(foo[0].name, 'foo1')
        assert_equals(foo[0].unit, 'MHz')
        assert_equals(foo[0].status,
                      askap.interfaces.monitoring.PointStatus.OK)
        assert_equals(foo[0].value.value, 1)
示例#12
0
 def setup(self):
     os.environ["ICE_CONFIG"] = 'ice.cfg'
     self.isession = IceSession()#cleanup=True)
     try:
         self.isession.add_app("icebox")
         self.isession.start()
         time.sleep(2)
         self.subscriber = LogSubscriber(self.isession.communicator)
         time.sleep(2)
     except Exception as ex:
         self.isession.terminate()
         raise
示例#13
0
class TestIceLogger(object):
    def __init__(self):
        self.logger = None
        self.subscriber = None
        self.isession = None
        self.topic = None
        self.adapter = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.isession = IceSession(cleanup=True)
        try:
            self.isession.add_app("icebox")
            self.isession.start()
            self.subscriber = LogSubscriber(self.isession.communicator)
            askap.logging.config.fileConfig("test.log_cfg")
            self.logger = askap.logging.getLogger(__name__)
        except Exception as ex:
            os.chdir("..")
            self.isession.terminate()
            raise

    def test_info(self):
        self.logger.setLevel(askap.logging.INFO)
        msg = "Log Test"
        tag = "gotcha"
        self.logger.info(msg, extra={"tag": tag})
        EVENT.wait(5)
        # make sure it gets delivered
        assert_true(len(last_event) > 0, "No log event received")
        #        assert_true(check_received()
        assert_equals(last_event[0], __name__)
        assert_equals(last_event[-3], msg)
        assert_equals(last_event[-2], tag)
        assert_equals(last_event[-1], socket.gethostname())

    def teardown(self):
        self.isession.terminate()
        os.chdir("..")
示例#14
0
class TestCPIngest(object):
    def __init__(self):
        self.logger = None
        self.igsession = None
        self.cpservice = None

    def setup(self):
        os.chdir('functests')
        self.igsession = None
        self.infile = "test/cpingest.in"
        if os.path.exists(self.infile):
            os.remove(self.infile)
        os.environ["ICE_CONFIG"] = "ice.cfg"
        os.environ["PYTHON_LOG_FILE"] = "cpmanager.log"
        self.igsession = IceSession('applications.txt', cleanup=True)
        try:
            self.igsession.start()
            time.sleep(5)

            self.dataservice = get_service(
                "SchedulingBlockService@DataServiceAdapter",
                ISchedulingBlockServicePrx, self.igsession.communicator)

            self.cpservice = get_service(
                "CentralProcessorService@IngestManagerAdapter",
                ICPObsServicePrx, self.igsession.communicator)

            self.monitoringservice = get_service(
                "MonitoringService@IngestManagerMonitoringAdapter",
                MonitoringProviderPrx, self.igsession.communicator)

        except Exception as ex:
            os.chdir('..')
            self.igsession.terminate()
            raise

    def teardown(self):
        self.igsession.terminate()
        os.chdir('..')
        self.igsession = None
        self.cpservice = None

    def test_obs(self):
        self.cpservice.startObs(5)
        is_complete = self.cpservice.waitObs(2000)
        assert_equals(is_complete, False)
        self.cpservice.abortObs()
        is_complete = self.cpservice.waitObs(2000)
        assert_equals(is_complete, True)
        is_complete = self.cpservice.waitObs(200)
        assert_equals(is_complete, True)

    def test_dataservice(self):
        self.cpservice.startObs(5)
        time.sleep(5)
        # sch block should have obs var updated
        obs_vars = self.dataservice.getObsVariables(5, '')
        obs_info = obs_vars.get('obs.info')

        # obs_info should be a json string, convert it back to
        # json object and check values
        obs_info_obj = json.loads(obs_info)

        startFreq = 1376.5
        chanWidth = 18.518518
        nChan = 2592
        #        bandWidth = chanWidth * nChan
        #        centreFreq = startFreq + bandWidth / 2

        temp = obs_info_obj["nChan"]["value"]

        assert_almost_equals(obs_info_obj["nChan"]["value"], nChan, places=1)
        assert_equals(obs_info_obj["ChanWidth"]["value"], chanWidth)
        assert_equals(obs_info_obj["StartFreq"]["value"], startFreq)
        #       assert_equals(obs_info_obj["CentreFreq"]["value"], centreFreq)
        #       assert_equals(obs_info_obj["BandWidth"]["value"], bandWidth)

        self.cpservice.abortObs()
        is_complete = self.cpservice.waitObs(2000)
        assert_equals(is_complete, True)

    def test_monitoring(self):
        # monitoring points should not be there
        point_names = [
            'ingest.running', 'ingest0.cp.ingest.obs.StartFreq',
            'ingest0.cp.ingest.obs.nChan', 'ingest0.cp.ingest.obs.ChanWidth',
            'ingest36.cp.ingest.obs.FieldName', 'ingest36.cp.ingest.obs.ScanId'
        ]

        points = self.monitoringservice.get(point_names)
        assert_equals(len(points), 1)
        assert_equals(points[0].value.value, False)

        self.cpservice.startObs(5)
        time.sleep(5)
        # monitoring points should be there
        points = self.monitoringservice.get(point_names)
        assert_equals(len(points), 6)
        assert_equals(points[0].value.value, True)
        assert_equals(points[1].value.value, 1376.5)
        assert_equals(points[2].value.value, 864)

        chanWidth = 18.518518
        value = points[3].value.value
        assert_almost_equals(value, chanWidth, places=6)

        assert_equals(points[4].value.value, 'Virgo')
        assert_equals(points[5].value.value, 73)

        self.cpservice.abortObs()
        time.sleep(5)
        # monitoring points should be gone
        points = self.monitoringservice.get(point_names)
        assert_equals(len(points), 1)
        assert_equals(points[0].value.value, False)
示例#15
0
class TestMonitors:
    def __init__(self):
        self.logger = None
        self.topic = "testtopic"
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.isession = IceSession('applications.txt', cleanup=True)
        try:
            self.isession.start()
        except Exception as ex:
            self.teardown()
            raise

    def teardown(self):
        os.chdir('..')
        self.isession.terminate()

    def test_monitor_send(self):
        data = []
        block = threading.Event()
        with Monitoring(topic=self.topic,
                        communicator=self.isession.communicator) as mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic,
                communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl,
                impl_kwargs={
                    'event': block,
                    'data': data,
                    'length': 10
                })
            outd = []
            for i in range(10):
                mon.add_points({'foo': i})
            nottimedout = block.wait(5.0)
            assert_equals(nottimedout, True)

    def test_monitor_send(self):
        data = []
        block = threading.Event()
        with Monitoring(topic=self.topic,
                        communicator=self.isession.communicator) as mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic,
                communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl,
                impl_kwargs={
                    'event': block,
                    'data': data,
                    'length': 10
                })
            outd = []
            for i in range(10):
                mon.add_points({'foo{}'.format(i): i})
            nottimedout = block.wait(5.0)
            assert_equals(nottimedout, True)

    def test_monitor_data(self):
        data = []
        block = threading.Event()
        mon = get_monitor(self.topic, self.isession.communicator)
        with mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic,
                communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl,
                impl_kwargs={
                    'event': block,
                    'data': data,
                    'length': 10
                })
            outd = []
            for i in range(10):
                md = MonitorData()
                md['foo{}'.format(i)] = i
                outd.append({'foo{}'.format(i): i})
                md.publish()
            nottimedout = block.wait(5.0)
        assert_equals(nottimedout, True)
        for i in range(10):
            assert_equals(data[i], outd[i])
示例#16
0
class TestMonitors:
    def __init__(self):
        self.logger = None
        self.topic = "testtopic"
        self.isession = None

    def setup(self):
        os.environ["ICE_CONFIG"] = 'ice.cfg'
        os.chdir('functests')
        self.isession = IceSession('applications.txt', cleanup=True)
        try:
            self.isession.start()
        except Exception as ex:
            self.teardown()
            raise

    def teardown(self):
        os.chdir('..')
        self.isession.terminate()

    def test_monitor_send(self):
        data = []
        block = threading.Event()
        with Monitoring(topic=self.topic, 
                           communicator=self.isession.communicator) as mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic, communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl, impl_kwargs={'event': block,
                                                        'data': data,
                                                        'length': 10}
                )
            outd = []
            for i in range(10):
                mon.add_points({'foo': i})
            nottimedout = block.wait(5.0)
            assert_equals(nottimedout, True)

    def test_monitor_send(self):
        data = []
        block = threading.Event()
        with Monitoring(topic=self.topic, 
                           communicator=self.isession.communicator) as mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic, communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl, impl_kwargs={'event': block,
                                                        'data': data,
                                                        'length': 10}
                )
            outd = []
            for i in range(10):
                mon.add_points({'foo{}'.format(i) : i})
            nottimedout = block.wait(5.0)
            assert_equals(nottimedout, True)

    def test_monitor_data(self):
        data = []
        block = threading.Event()
        mon = get_monitor(self.topic, self.isession.communicator)
        with mon:
            subscriber = TypedValueSubscriber(
                topic=self.topic, communicator=self.isession.communicator,
                impl_cls=TTSubscriberImpl, impl_kwargs={'event': block,
                                                        'data': data,
                                                        'length': 10}
                )
            outd = []
            for i in range(10):
                md = MonitorData()
                md['foo{}'.format(i)] = i
                outd.append({'foo{}'.format(i): i})
                md.publish()
            nottimedout = block.wait(5.0)
        assert_equals(nottimedout, True)
        for i in range(10):            
            assert_equals(data[i], outd[i]) 
示例#17
0
# [email protected]
#
# This file is part of the ASKAP software distribution.
#
# The ASKAP software distribution is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
#
import sys
from askap.iceutils import IceSession

file_name = None
if len(sys.argv) > 1:
    file_name = sys.argv[1]

if __name__ == "__main__":
    with IceSession(file_name) as ice:
        ice.start()
        ice.wait()