コード例 #1
0
ファイル: zfs.py プロジェクト: snua12/zlomekfs
    def runZfs(self):
        """ Kill previously running zfsd instances and run our own zfsd. """

        self.killall()  # destroy previous zfsd instances
        if self.zfs:
            self.zfs.wait()

        self.makeDirs()
        self.unpackData()
        self.installModules()
        loglevel = pysyplog.LOG_LOOPS
        if self.logger:
            loglevel = pysyplog.get_log_level(self.logger)
        self.coreDumpSettings = allowCoreDumps()

        # NOTE: this could grow big, but current outputs are not big enough
        # to care about. Piping Popen outputs creates bigger problems than
        # few kilobytes on disk (there should be NO output at all)
        self.stdout = open(os.path.join(self.tempDir, "zfsd.stdout"), "wb+")
        self.stderr = open(os.path.join(self.tempDir, "zfsd.stderr"), "wb+")

        self.zfs = Popen(
            args=(
                "zfsd",
                "-d",
                "--" + str(pysyplog.PARAM_MEDIUM_TYPE_LONG) + "=" + str(pysyplog.FILE_MEDIUM_NAME),
                "--" + str(pysyplog.PARAM_MEDIUM_FMT_LONG) + "=" + str(pysyplog.USER_READABLE_FORMATTER_NAME),
                "--" + str(pysyplog.PARAM_MEDIUM_SIZE_LONG) + "=" + self.maxZfsLogSize,
                "--" + str(pysyplog.PARAM_MEDIUM_FN_LONG) + "=" + os.path.join(self.tempDir, ZfsProxy.logFileName),
                "-o",
                "loglevel=" + str(loglevel) + ",config=" + os.path.join(self.tempDir, self.config),
                self.zfsRoot,
            ),
            bufsize=0,
            cwd=self.tempDir,
            stdout=self.stdout,
            stderr=self.stderr,
            close_fds=True,
            universal_newlines=True,
        )

        for i in [0.2, 0.5, 1, 3, 5, 100]:
            time.sleep(i)
            if zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING:
                break
        if zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING:
            self.killall()  # be sure that we don't leave orphans
            if self.coreDumpSettings:
                setCoreDumpSettings(self.coreDumpSettings)
                self.coreDumpSettings = None
            raise ZfsRuntimeException("Zfsd doesn't start")
        self.running = True
        self.connectControl()
コード例 #2
0
 def runZfs(self):
     """ Kill previously running zfsd instances and run our own zfsd. """
     
     self.killall() #destroy previous zfsd instances
     if self.zfs:
         self.zfs.wait()
         
     self.makeDirs()
     self.unpackData()
     self.installModules()
     loglevel = pysyplog.LOG_LOOPS
     if self.logger:
         loglevel = pysyplog.get_log_level(self.logger)
     self.coreDumpSettings = allowCoreDumps()
     
     # NOTE: this could grow big, but current outputs are not big enough
     # to care about. Piping Popen outputs creates bigger problems than
     # few kilobytes on disk (there should be NO output at all)
     self.stdout = open(os.path.join(self.tempDir, 'zfsd.stdout'), 'wb+')
     self.stderr = open(os.path.join(self.tempDir, 'zfsd.stderr'), 'wb+')
     
     self.zfs = Popen(args=('zfsd',
         '-d',
         "--" + str(pysyplog.PARAM_MEDIUM_TYPE_LONG) + "=" + \
             str(pysyplog.FILE_MEDIUM_NAME),
         "--" + str(pysyplog.PARAM_MEDIUM_FMT_LONG) + "=" + \
             str(pysyplog.USER_READABLE_FORMATTER_NAME),
         "--" + str(pysyplog.PARAM_MEDIUM_SIZE_LONG) + "=" + \
             self.maxZfsLogSize,
         "--" + str(pysyplog.PARAM_MEDIUM_FN_LONG) + "=" + \
             os.path.join(self.tempDir, ZfsProxy.logFileName),
         '-o', 'loglevel=' + str(loglevel) +
         ',config=' + os.path.join(self.tempDir, self.config), 
         self.zfsRoot), bufsize=0,
         cwd = self.tempDir,
         stdout = self.stdout, stderr = self.stderr, close_fds = True, 
             universal_newlines=True)
     
     for i in [0.2, 0.5, 1, 3, 5, 100]:
         time.sleep(i)
         if zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING:
             break
     if zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING:
         self.killall() #be sure that we don't leave orphans
         if self.coreDumpSettings:
             setCoreDumpSettings(self.coreDumpSettings)
             self.coreDumpSettings = None
         raise ZfsRuntimeException("Zfsd doesn't start")
     self.running = True
     self.connectControl()
コード例 #3
0
ファイル: zenPlugin.py プロジェクト: snua12/zlomekfs
    def loadTestsFromFile(self, fileName):
        """ Try to load tests from binary.
            Since zen-unit doesn't provide test listing, we must run them now.
            
            .. See: nose plugin interface
        """
        if isSharedLibrary(fileName):
            (prefix, stripedFileName) = path.split(fileName)
            args = ('zenunit')
            env = {'LD_PRELOAD': stripedFileName}
            if prefix:
                env['LD_LIBRARY_PATH'] = prefix
        elif isExecutable(fileName):
            prefix = None
            args = (fileName)
            env = {'LD_PRELOAD': 'libzenunit.so'}
        else:
            return [None]

        #run tests
        coreSettings = allowCoreDumps()

        result = Popen(args=args, env=env, stdout=PIPE, stderr=PIPE)
        result.wait()

        setCoreDumpSettings(coreSettings)

        #find dump
        coreName = os.path.join('core.' + str(result.pid))
        if result.pid and os.path.isfile(coreName):

            return [
                ZenExceptionCase(errorCode=result.returncode,
                                 binary=args[0],
                                 library=env['LD_PRELOAD'],
                                 ldPath=prefix,
                                 core=coreName,
                                 stdout=result.stdout.readlines(),
                                 stderr=result.stderr.readlines())
            ]
        #create test report wrappers
        else:
            return self.parseZenOutputToTests(result.stdout.readlines(),
                                              result.stderr.readlines())
コード例 #4
0
ファイル: zenPlugin.py プロジェクト: snua12/zlomekfs
 def loadTestsFromFile(self, fileName):
     """ Try to load tests from binary.
         Since zen-unit doesn't provide test listing, we must run them now.
         
         .. See: nose plugin interface
     """
     if isSharedLibrary(fileName):
         (prefix, stripedFileName) = path.split(fileName)
         args = ('zenunit')
         env = {'LD_PRELOAD':stripedFileName}
         if prefix:
             env['LD_LIBRARY_PATH'] = prefix
     elif isExecutable(fileName):
         prefix = None
         args = (fileName)
         env = {'LD_PRELOAD':'libzenunit.so'}
     else:
         return [None]
         
     #run tests
     coreSettings = allowCoreDumps()
     
     result = Popen (args = args, env = env, stdout = PIPE, stderr = PIPE)
     result.wait()
     
     setCoreDumpSettings(coreSettings)
     
     #find dump
     coreName = os.path.join('core.' + str(result.pid))
     if result.pid and os.path.isfile(coreName):
         
         return [ZenExceptionCase(errorCode = result.returncode,
             binary = args[0], library = env['LD_PRELOAD'], ldPath = prefix,
             core = coreName, stdout = result.stdout.readlines(),
             stderr = result.stderr.readlines())]
     #create test report wrappers
     else:
         return self.parseZenOutputToTests(result.stdout.readlines(), 
             result.stderr.readlines())