- def add_throughput_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Throughput " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "throughput"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_frameloss_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Frame Loss Rate " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "frameloss"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_latency_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Latency " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- unit = 'Average Latency'
- title = [unit + ' (uSec)']
- # chart_data = self._result.get_latency_chartdata(case)
- bar_data = self._result.get_latency_bardata(case)
- table_data = self._result.get_latency_tabledata(case)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = BarChartStory(story, data=bar_data)
-
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_systeminfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. System Information " % (chapterid)]
- story = PageBreakStory(story)
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_systeminfo_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=0)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_gitinfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- title = ["%d. Git Repository Information " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
-
- table_content = self._common.get_gitinfo_tabledata()
- if table_content:
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=5)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_testing_options(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. Testing Options" % (chapterid)]
-
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_testingoptions_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=1)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_profile_parameters(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = PageBreakStory(story)
- title = ["%d. " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_profileparameters_tabledData()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=2)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_appendix(self):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s: vSwitching Testing Methodology</b>" % (self._appendixid.get())]
- self._appendixid.next()
- story = TitleStory(story, data=title, style=1)
- filename = "res/Traffic-types.jpg"
- story = SpaceStory(story)
- story = ImageStory(story, data=[self._rootdir + filename])
- # story = SpaceStory(story)
-
- title = ["Traffic Patterns: "]
- story = TitleStory(story, data=title, style=6)
-
- body = [
- "<b>Ti</b> - South North Traffic",
- "<b>Tu</b> - East Eest Traffic",
- "<b>Tn</b> - Physical host or VM loop back",
- "<b>Tnv</b> - Virtual Machine loop back",
- ]
- story = ParagraphStory(story, data=body)
-
- title = ["<b>Performance Testing Coverage </b> (version 0.1):"]
- story = TitleStory(story, data=title, style=6)
-
- table_content = self._common.get_introduct_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=4)
- self._story += story.storylist
-
- def add_historys(self):
- case_list = self._result.get_caselist()
- for case in case_list:
- history = self._history.get_history_info(case)
- if history:
- self.add_history(case, history)
-
- def add_history(self, case, history):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s : %s History Records</b>" % (self._appendixid.get(), case)]
- story = TitleStory(story, data=title, style=1)
-
- for i in range(len(history)):
- title = ["%s.%s %s" % (self._appendixid.get(), i, history[i]["title"])]
- story = TitleStory(story, data=title, style=2)
-
- section = history[i]["data"]
- for unit in section:
- title = [unit['title']]
- story = TitleStory(story, data=title, style=6)
- content = unit['data']
- story = uTableStory(story, data=content)
-
- self._appendixid.next()
- self._story += story.storylist
+ def create(self, ofile):
+ self.create_pdf()
+ self.create_story()
+ self.save_pdf(ofile)
+
+ def add_context(self):
+ context = self._provider.get_context
+ self._story += self._raw_context(context)
+
+ def _raw_context(self, context, ci=0, si=0, ui=0, level=-1):
+ _story = []
+ for key, value in sorted(context.items()):
+ LOG.info(key)
+ LOG.info(value)
+ _sn, _node, _style = candy.text2tuple(key)
+ if _node in candy.dom:
+ if _node == candy.chapter:
+ ci = _style
+ elif _node == candy.section:
+ si = _style
+ else:
+ ui = _style
+ _story += self._raw_context(value, ci, si, ui, level + 1)
+
+ else:
+ story = Story()
+ LOG.info("node: %s %s" % (_node, candy.title))
+ if _node == candy.title:
+ assert value
+ if level in range(len(candy.dom)):
+ if level == 0:
+ value[0] = "Chapter %s %s" % (ci, value[0])
+ story = PageBreakStory(story)
+ elif level == 1:
+ value[0] = "%s.%s %s" % (ci, si, value[0])
+ else:
+ value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0])
+ LOG.info(value)
+ story = TitleStory(story, data=value, style=_style)
+ elif _node == candy.table:
+ story = TableStory(story, data=value, style=_style)
+ elif _node == candy.figure:
+ story = ImageStory(story, data=value, style=_style)
+ elif _node == candy.paragraph:
+ story = ParagraphStory(story, data=value, style=_style)
+ elif _node == candy.plot:
+ story = LinePlotStory(story, data=value, style=_style)
+ elif _node == candy.chart:
+ story = BarChartStory(story, data=value, style=_style)
+ elif _node == candy.space:
+ assert isinstance(value, int)
+ for i in range(value):
+ story = SpaceStory(story)
+ _story += story.storylist
+ return _story