]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add test for test_all_runs
authorZack Cerza <zack@cerza.org>
Thu, 3 Oct 2013 20:51:11 +0000 (15:51 -0500)
committerZack Cerza <zack@cerza.org>
Thu, 3 Oct 2013 21:08:12 +0000 (16:08 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/test/fake_archive.py
teuthology/test/test_report.py [new file with mode: 0644]

index b27a1a7877011527f0b58093c3673ea72df3e621..ce804e8b5e6c8f38d3ff00a7b2362e449c3102d4 100644 (file)
@@ -79,3 +79,21 @@ class FakeArchive(object):
                 with file(summary_path, 'w') as yfile:
                     yaml.safe_dump(job['summary'], yfile)
 
+    def create_fake_run(self, run_name, job_count, yaml_path):
+        """
+        Creates a fake run using run_name. Uses the YAML specified for each
+        job's config.yaml
+        """
+        assert os.path.exists(yaml_path)
+        assert job_count > 0
+        jobs = []
+        for i in range(job_count):
+            jobs.append(self.get_random_metadata(run_name))
+            #job_config = yaml.safe_load(yaml_path)
+        self.populate_archive(run_name, jobs)
+        for job in jobs:
+            job_id = job['job_id']
+            job_yaml_path = os.path.join(self.archive_base, run_name,
+                                         str(job_id), 'config.yaml')
+            shutil.copyfile(yaml_path, job_yaml_path)
+
diff --git a/teuthology/test/test_report.py b/teuthology/test/test_report.py
new file mode 100644 (file)
index 0000000..6b943ce
--- /dev/null
@@ -0,0 +1,22 @@
+import fake_archive
+from .. import report
+
+
+class TestReport(object):
+    def setup(self):
+        self.archive = fake_archive.FakeArchive()
+        self.archive.setup()
+        self.archive_base = self.archive.archive_base
+        self.reporter = report.ResultsReporter(archive_base=self.archive_base)
+
+    def teardown(self):
+        self.archive.teardown()
+
+    def test_all_runs(self):
+        run_name = "test_all_runs"
+        yaml_path = "examples/3node_ceph.yaml"
+        job_count = 3
+        self.archive.create_fake_run(run_name, job_count, yaml_path)
+        assert [run_name] == self.reporter.serializer.all_runs
+
+