Example #1
0
 def test_01_check_cache_for_egg(self):
     """
     Test _check_cache_for_egg  checks the cache for the egg,
     returns path if present locally, or None if not.
     """
     launcher = ZMQEggDriverProcess("DUMMY_VAL")
     self.assertEqual(launcher._check_cache_for_egg("NOT_FOUND_EGG"), None)
     self.assertEqual(launcher._check_cache_for_egg(EGG), None)
Example #2
0
    def test_03_check_cache_for_egg(self):
        """
        Test _check_cache_for_egg  checks the cache for the egg,
        returns path if present locally, or None if not.
        """
        # Cleanup on isle one!

        launcher = ZMQEggDriverProcess("DUMMY_VAL")
        self.assertEqual(launcher._get_remote_egg(EGG), "/tmp/%s" % EGG)
        self.assertEqual(launcher._check_cache_for_egg("NOT_FOUND_EGG"), None)
        self.assertEqual(launcher._check_cache_for_egg(EGG), "/tmp/%s" % EGG)
Example #3
0
    def test_04_get_egg(self):
        """
        Test _get_egg should return a path to a local egg for existing
        eggs, and exception for non-existing in the repo.
        """
        launcher = ZMQEggDriverProcess("DUMMY_VAL")

        got_exception = False
        try:
            self.assertEqual(launcher._get_egg("NOT_FOUND_EGG"), None)
        except DriverLaunchException:
            got_exception = True
        self.assertTrue(got_exception)
Example #4
0
    def test_02_get_remote_egg(self):
        """
        Test _get_remote_egg should return path for cached egg if present,
        path for cached egg if not present locally, but in repo, or exception if not present locally or in repo.
        """

        launcher = ZMQEggDriverProcess("DUMMY_VAL")
        got_exception = False
        try:
            self.assertEqual(launcher._get_remote_egg("NOT_FOUND_EGG"), None)
        except DriverLaunchException:
            got_exception = True
        self.assertTrue(got_exception)

        self.assertEqual(launcher._get_remote_egg(EGG), "/tmp/%s" % EGG)
Example #5
0
def load_egg(dvr_config=None):
    # Dynamically load the egg into the test path

    if dvr_config is None:
        dvr_config = make_config()
    dvr_egg = dvr_config['dvr_egg']
    #dvr_sha = CFG.device.sbe37.dvr_sha
    launcher = ZMQEggDriverProcess(dvr_config)

    egg = launcher._get_egg(dvr_egg)
    #from hashlib import sha1
    with open(egg, 'r') as f:
        doc = f.read()
        #This does not work uniformly
        #sha = sha1(doc).hexdigest()
        #if sha != dvr_sha:
        #    raise ImportError('Failed to load driver %s: incorrect checksum.  (%s!=%s)' % (dvr_egg, dvr_sha, sha))
        if not egg in sys.path: sys.path.insert(0, egg)
        dvr_config['process_type'] = (DriverProcessType.EGG, )

    return dvr_config
Example #6
0
# Driver config.
# DVR_CONFIG['comms_config']['port'] is set by the setup.
DVR_CONFIG = {
    'dvr_egg': DRV_URI,
    'dvr_mod': DRV_MOD,
    'dvr_cls': DRV_CLS,
    'workdir': WORK_DIR,
    'process_type': None
}

# Launch from egg or a local MI repo.
LAUNCH_FROM_EGG = True

if LAUNCH_FROM_EGG:
    # Dynamically load the egg into the test path
    launcher = ZMQEggDriverProcess(DVR_CONFIG)
    egg = launcher._get_egg(DRV_URI)
    from hashlib import sha1
    with open(egg, 'r') as f:
        doc = f.read()
        sha = sha1(doc).hexdigest()

    if not egg in sys.path: sys.path.insert(0, egg)
    DVR_CONFIG['process_type'] = (DriverProcessType.EGG, )

else:
    mi_repo = os.getcwd() + os.sep + 'extern' + os.sep + 'mi_repo'
    if not mi_repo in sys.path: sys.path.insert(0, mi_repo)
    DVR_CONFIG['process_type'] = (DriverProcessType.PYTHON_MODULE, )
    DVR_CONFIG['mi_repo'] = mi_repo