Esempio n. 1
0
    def upload_artifact(self, context, artifact):
        artifact_path = os.path.join(context.output_directory, artifact.path)
        self.artifacts.append((artifact_path, artifact))
        if not os.path.exists(artifact_path):
            self.logger.debug('Artifact {} has not been generated'.format(artifact_path))
            return
        elif artifact.kind in ['raw', 'export']:
            self.logger.debug('Ignoring {} artifact {}'.format(artifact.kind, artifact_path))
            return
        else:
            self.logger.debug('Uploading artifact {}'.format(artifact_path))
            entry = artifact.to_dict()
            path = entry['path']
            del entry['path']
            del entry['name']
            del entry['level']
            del entry['mandatory']

            if context.workload is None:
                entry['filename'] = os.path.join(self.gridfs_dir, as_relative(path))
            else:
                entry['filename'] = os.path.join(self.gridfs_dir,
                                                 '{}-{}-{}'.format(context.spec.id,
                                                                   context.spec.label,
                                                                   context.current_iteration),
                                                 as_relative(path))
            with open(artifact_path, 'rb') as fh:
                fsid = self.fs.put(fh, **entry)
                entry['gridfs_id'] = fsid

            return entry
Esempio n. 2
0
    def setup(self, context):
        before_dirs = [
            _d(os.path.join(context.output_directory, 'before', self._local_dir(d)))
            for d in self.paths
        ]
        after_dirs = [
            _d(os.path.join(context.output_directory, 'after', self._local_dir(d)))
            for d in self.paths
        ]
        diff_dirs = [
            _d(os.path.join(context.output_directory, 'diff', self._local_dir(d)))
            for d in self.paths
        ]
        self.device_and_host_paths = zip(self.paths, before_dirs, after_dirs, diff_dirs)

        if self.use_tmpfs:
            for d in self.paths:
                before_dir = self.device.path.join(self.on_device_before,
                                                   self.device.path.dirname(as_relative(d)))
                after_dir = self.device.path.join(self.on_device_after,
                                                  self.device.path.dirname(as_relative(d)))
                if self.device.file_exists(before_dir):
                    self.device.execute('rm -rf  {}'.format(before_dir), as_root=True)
                self.device.execute('mkdir -p {}'.format(before_dir), as_root=True)
                if self.device.file_exists(after_dir):
                    self.device.execute('rm -rf  {}'.format(after_dir), as_root=True)
                self.device.execute('mkdir -p {}'.format(after_dir), as_root=True)
Esempio n. 3
0
    def upload_artifact(self, context, artifact):
        artifact_path = os.path.join(context.output_directory, artifact.path)
        self.artifacts.append((artifact_path, artifact))
        if not os.path.exists(artifact_path):
            self.logger.debug(
                'Artifact {} has not been generated'.format(artifact_path))
            return
        elif artifact.kind in ['raw', 'export']:
            self.logger.debug('Ignoring {} artifact {}'.format(
                artifact.kind, artifact_path))
            return
        else:
            self.logger.debug('Uploading artifact {}'.format(artifact_path))
            entry = artifact.to_dict()
            path = entry['path']
            del entry['path']
            del entry['name']
            del entry['level']
            del entry['mandatory']

            if context.workload is None:
                entry['filename'] = os.path.join(self.gridfs_dir,
                                                 as_relative(path))
            else:
                entry['filename'] = os.path.join(
                    self.gridfs_dir,
                    '{}-{}-{}'.format(context.spec.id, context.spec.label,
                                      context.current_iteration),
                    as_relative(path))
            with open(artifact_path, 'rb') as fh:
                fsid = self.fs.put(fh, **entry)
                entry['gridfs_id'] = fsid

            return entry
Esempio n. 4
0
 def slow_stop(self, context):
     if self.use_tmpfs:
         for d in self.paths:
             dest_dir = self.device.path.join(self.on_device_after, as_relative(d))
             if '*' in dest_dir:
                 dest_dir = self.device.path.dirname(dest_dir)
             self.device.execute('{} cp -Hr {} {}'.format(self.device.busybox, d, dest_dir),
                                 as_root=True, check_exit_code=False)
     else:  # not using tmpfs
         for dev_dir, _, after_dir, _ in self.device_and_host_paths:
             self.device.pull_file(dev_dir, after_dir)
Esempio n. 5
0
 def slow_start(self, context):
     if self.use_tmpfs:
         for d in self.paths:
             dest_dir = self.device.path.join(self.on_device_before, as_relative(d))
             if '*' in dest_dir:
                 dest_dir = self.device.path.dirname(dest_dir)
             self.device.execute('busybox cp -Hr {} {}'.format(d, dest_dir),
                                 as_root=True, check_exit_code=False)
     else:  # not rooted
         for dev_dir, before_dir in zip(self.paths, self.before_dirs):
             self.device.pull_file(dev_dir, before_dir)
Esempio n. 6
0
 def slow_start(self, context):
     if self.use_tmpfs:
         for d in self.paths:
             dest_dir = self.device.path.join(self.on_device_before, as_relative(d))
             if "*" in dest_dir:
                 dest_dir = self.device.path.dirname(dest_dir)
             self.device.execute(
                 "{} cp -Hr {} {}".format(self.device.busybox, d, dest_dir), as_root=True, check_exit_code=False
             )
     else:  # not rooted
         for dev_dir, before_dir, _, _ in self.device_and_host_paths:
             self.device.pull_file(dev_dir, before_dir)
Esempio n. 7
0
 def slow_stop(self, context):
     if self.use_tmpfs:
         for d in self.paths:
             dest_dir = self.device.path.join(self.on_device_after,
                                              as_relative(d))
             if '*' in dest_dir:
                 dest_dir = self.device.path.dirname(dest_dir)
             self.device.execute('{} cp -Hr {} {}'.format(
                 self.device.busybox, d, dest_dir),
                                 as_root=True,
                                 check_exit_code=False)
     else:  # not using tmpfs
         for dev_dir, _, after_dir, _ in self.device_and_host_paths:
             self.device.pull_file(dev_dir, after_dir)
Esempio n. 8
0
    def setup(self, context):
        before_dirs = [
            _d(
                os.path.join(context.output_directory, 'before',
                             self._local_dir(d))) for d in self.paths
        ]
        after_dirs = [
            _d(
                os.path.join(context.output_directory, 'after',
                             self._local_dir(d))) for d in self.paths
        ]
        diff_dirs = [
            _d(
                os.path.join(context.output_directory, 'diff',
                             self._local_dir(d))) for d in self.paths
        ]
        self.device_and_host_paths = zip(self.paths, before_dirs, after_dirs,
                                         diff_dirs)

        if self.use_tmpfs:
            for d in self.paths:
                before_dir = self.device.path.join(
                    self.on_device_before,
                    self.device.path.dirname(as_relative(d)))
                after_dir = self.device.path.join(
                    self.on_device_after,
                    self.device.path.dirname(as_relative(d)))
                if self.device.file_exists(before_dir):
                    self.device.execute('rm -rf  {}'.format(before_dir),
                                        as_root=True)
                self.device.execute('mkdir -p {}'.format(before_dir),
                                    as_root=True)
                if self.device.file_exists(after_dir):
                    self.device.execute('rm -rf  {}'.format(after_dir),
                                        as_root=True)
                self.device.execute('mkdir -p {}'.format(after_dir),
                                    as_root=True)
Esempio n. 9
0
 def _local_dir(self, directory):
     return os.path.dirname(
         as_relative(directory).replace(self.device.path.sep, os.sep))
Esempio n. 10
0
 def _local_dir(self, directory):
     return os.path.dirname(as_relative(directory).replace(self.device.path.sep, os.sep))