Exemplo n.º 1
0
    def report(self, test, host=None, wait_on_client=True):
        assert self.current_test == test
        self.current_test = None

        # signal to all the clients that they should report
        if wait_on_client:
            for host, (at, autodir) in self._get_hosts(host).iteritems():
                try:
                    self._signal_client(host, autodir, "report")
                except:
                    self._get_failure_logs(autodir, test, host)
                    raise

        # pull back all the results
        for host, (at, autodir) in self._get_hosts(host).iteritems():
            if wait_on_client:
                self._wait_on_client(host, autodir, "finished")
            results_dir = get_profiler_results_dir(autodir)
            local_dir = os.path.join(test.profdir, host.hostname)
            if not os.path.exists(local_dir):
                os.makedirs(local_dir)

            self.job.remove_client_log(host.hostname, results_dir, local_dir)
            tempdir = tempfile.mkdtemp(dir=self.job.tmpdir)
            try:
                host.get_file(results_dir + "/", tempdir)
            except error.AutoservRunError:
                pass # no files to pull back, nothing we can do
            utils.merge_trees(tempdir, local_dir)
            shutil.rmtree(tempdir, ignore_errors=True)
Exemplo n.º 2
0
 def test_directory_with_subdirectories(self):
     os.mkdir(self.src("src_subdir"))
     print >>open(self.src("src_subdir", "subfile"), "w"), "subdir line"
     os.mkdir(self.src("both_subdir"))
     os.mkdir(self.dest("both_subdir"))
     print >>open(self.src("both_subdir", "subfile"), "w"), "src line"
     print >>open(self.dest("both_subdir", "subfile"), "w"), "dest line"
     utils.merge_trees(*self.paths())
     self.assertFileContents("subdir line\n", "src_subdir", "subfile")
     self.assertFileContents("dest line\nsrc line\n", "both_subdir", "subfile")
 def test_directory_with_subdirectories(self):
     os.mkdir(self.src("src_subdir"))
     print >> open(self.src("src_subdir", "subfile"), "w"), "subdir line"
     os.mkdir(self.src("both_subdir"))
     os.mkdir(self.dest("both_subdir"))
     print >> open(self.src("both_subdir", "subfile"), "w"), "src line"
     print >> open(self.dest("both_subdir", "subfile"), "w"), "dest line"
     utils.merge_trees(*self.paths())
     self.assertFileContents("subdir line\n", "src_subdir", "subfile")
     self.assertFileContents("dest line\nsrc line\n", "both_subdir",
                             "subfile")
Exemplo n.º 4
0
    def _get_profiler_logs(self, autodir, test, host):
        results_dir = get_profiler_results_dir(autodir)
        local_dir = self._get_local_profilers_dir(test, host.hostname)

        self.job.remove_client_log(host.hostname, results_dir, local_dir)

        tempdir = tempfile.mkdtemp(dir=self.job.tmpdir)
        try:
            host.get_file(results_dir + '/', tempdir)
        except error.AutoservRunError:
            pass  # no files to pull back, nothing we can do
        utils.merge_trees(tempdir, local_dir)
        shutil.rmtree(tempdir, ignore_errors=True)
Exemplo n.º 5
0
    def _get_profiler_logs(self, autodir, test, host):
        results_dir = get_profiler_results_dir(autodir)
        local_dir = self._get_local_profilers_dir(test, host.hostname)

        self.job.remove_client_log(host.hostname, results_dir, local_dir)

        tempdir = tempfile.mkdtemp(dir=self.job.tmpdir)
        try:
            host.get_file(results_dir + '/', tempdir)
        except error.AutoservRunError:
            pass # no files to pull back, nothing we can do
        utils.merge_trees(tempdir, local_dir)
        shutil.rmtree(tempdir, ignore_errors=True)
Exemplo n.º 6
0
 def test_file_at_both(self):
     print >> open(self.dest("in_both"), "w"), "line 1"
     print >> open(self.src("in_both"), "w"), "line 2"
     utils.merge_trees(*self.paths("in_both"))
     self.assertFileContents("line 1\nline 2\n", "in_both")
Exemplo n.º 7
0
 def test_file_only_at_dest(self):
     print >> open(self.dest("dest_only"), "w"), "line 1"
     utils.merge_trees(*self.paths("dest_only"))
     self.assertEqual(False, os.path.exists(self.src("dest_only")))
     self.assertFileContents("line 1\n", "dest_only")
Exemplo n.º 8
0
 def test_file_only_at_src(self):
     print >> open(self.src("src_only"), "w"), "line 1"
     utils.merge_trees(*self.paths("src_only"))
     self.assertFileEqual("src_only")
Exemplo n.º 9
0
 def test_both_dont_exist(self):
     utils.merge_trees(*self.paths("empty"))
 def test_directory_with_files_in_both(self):
     print >> open(self.dest("in_both"), "w"), "line 1"
     print >> open(self.src("in_both"), "w"), "line 3"
     utils.merge_trees(*self.paths())
     self.assertFileContents("line 1\nline 3\n", "in_both")
 def test_file_at_both(self):
     print >> open(self.dest("in_both"), "w"), "line 1"
     print >> open(self.src("in_both"), "w"), "line 2"
     utils.merge_trees(*self.paths("in_both"))
     self.assertFileContents("line 1\nline 2\n", "in_both")
 def test_file_only_at_dest(self):
     print >> open(self.dest("dest_only"), "w"), "line 1"
     utils.merge_trees(*self.paths("dest_only"))
     self.assertEqual(False, os.path.exists(self.src("dest_only")))
     self.assertFileContents("line 1\n", "dest_only")
 def test_file_only_at_src(self):
     print >> open(self.src("src_only"), "w"), "line 1"
     utils.merge_trees(*self.paths("src_only"))
     self.assertFileEqual("src_only")
 def test_both_dont_exist(self):
     utils.merge_trees(*self.paths("empty"))
Exemplo n.º 15
0
 def test_directory_with_files_in_both(self):
     print >> open(self.dest("in_both"), "w"), "line 1"
     print >> open(self.src("in_both"), "w"), "line 3"
     utils.merge_trees(*self.paths())
     self.assertFileContents("line 1\nline 3\n", "in_both")
Exemplo n.º 16
0
 def test_directory_with_mix_of_files(self):
     print >> open(self.dest("in_dest"), "w"), "dest line"
     print >> open(self.src("in_src"), "w"), "src line"
     utils.merge_trees(*self.paths())
     self.assertFileContents("dest line\n", "in_dest")
     self.assertFileContents("src line\n", "in_src")
 def test_directory_with_mix_of_files(self):
     print >> open(self.dest("in_dest"), "w"), "dest line"
     print >> open(self.src("in_src"), "w"), "src line"
     utils.merge_trees(*self.paths())
     self.assertFileContents("dest line\n", "in_dest")
     self.assertFileContents("src line\n", "in_src")