~launchpad-pqm/python-oops-tools/trunk

« back to all changes in this revision

Viewing changes to src/oopstools/oops/test/db-summary.txt

  • Committer: Robert Collins
  • Date: 2011-10-13 20:18:51 UTC
  • Revision ID: robertc@robertcollins.net-20111013201851-ym8jmdhoeol3p83s
Export of cruft-deleted tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
= Daily summary generated from the OOPS database =
 
2
 
 
3
The analyse script accepts a parameter to generate OOPS summaries directly
 
4
from the database.
 
5
 
 
6
    >>> from oopstools.oops.helpers import generate_summary, load_database
 
7
    >>> prefixes = ["S", "X"]
 
8
    >>> from datetime import date
 
9
    >>> start_date = date(2007, 02, 22)
 
10
    >>> end_date = date(2010, 01, 8)
 
11
 
 
12
Before generating the summary, let's load the sample data into the database.
 
13
 
 
14
    >>> load_database(start_date, end_date)
 
15
    'Oopses loaded into the database.'
 
16
 
 
17
And add a bug to the oops database so we can test that a linked bug is
 
18
correctly displayed in the summary.
 
19
 
 
20
    >>> from oopstools.oops.models import Oops
 
21
    >>> oops = Oops.objects.get(oopsid__exact='OOPS-689S4')
 
22
    >>> oops.oopsinfestation.bug = 2112
 
23
    >>> oops.oopsinfestation.save()
 
24
 
 
25
Now let's generate the summary.
 
26
 
 
27
    >>> webapp_summary = generate_summary(
 
28
    ...     prefixes, from_date=start_date, to_date=end_date)
 
29
 
 
30
    >>> from oopstools.oops.helpers import get_section_contents
 
31
    >>> print get_section_contents("Statistics", webapp_summary)
 
32
     * Log starts: ...
 
33
     * Analyzed period: ...
 
34
     * Total OOPSes: 2
 
35
     * Average OOPSes per day: ...
 
36
    <BLANKLINE>
 
37
     * 0 Exceptions
 
38
     * 0 Time Outs
 
39
     * 2 Soft Time Outs
 
40
     * 0 Informational Only Errors
 
41
     * 0 User Generated Errors
 
42
     * 0 Unauthorized Errors
 
43
     * 0 Pages Not Found
 
44
 
 
45
    >>> print get_section_contents("Top 10 Durations", webapp_summary)
 
46
    26.46s  OOPS-689S4      FooBar:+questions
 
47
    20.67s  OOPS-689S6      FooBar:+bug-text
 
48
    0.28s  OOPS-1308X1     https://launchpad.dev/foobar
 
49
 
 
50
    >>> print get_section_contents("Top 10 Statement Counts", webapp_summary)
 
51
    14  OOPS-1308X1     https://launchpad.dev/foobar
 
52
    4 OOPS-689S6        FooBar:+bug-text
 
53
    3  OOPS-689S4       FooBar:+questions
 
54
 
 
55
     4203  OOPS-969XMLP1805  MailingListApplication:MailingListAPIView
 
56
      260  OOPS-894EB74    Archive:+index
 
57
      111  OOPS-1311EC295  Product:+code-index
 
58
      107  OOPS-689S6      FooBar:+bug-text
 
59
       72  OOPS-689S80     FooBarPackage:+translate
 
60
    ...
 
61
 
 
62
    >>> print get_section_contents("Time Out Counts by Page ID", webapp_summary)
 
63
    Hard / Soft  Page ID
 
64
 
 
65
    >>> print get_section_contents("All Exceptions", webapp_summary)
 
66
 
 
67
    >>> print get_section_contents("All Time Outs", webapp_summary)
 
68
 
 
69
    >>> print get_section_contents("All Soft Time Outs", webapp_summary)
 
70
       1 SELECT ...
 
71
        Other: 1  Robots: 1  Local: 1
 
72
           1 https://answers.../questions/+index (FooBar:+questions)
 
73
            OOPS-689S4
 
74
 
 
75
    >>> print get_section_contents(
 
76
    ...     "All Informational Only Errors", webapp_summary)
 
77
 
 
78
    >>> print get_section_contents("All User Generated Errors", webapp_summary)
 
79
 
 
80
    >>> print get_section_contents("All Unauthorized Errors", webapp_summary)
 
81
    <BLANKLINE>
 
82
 
 
83
    >>> print get_section_contents("All Pages Not Found", webapp_summary)
 
84
    <BLANKLINE>
 
85
 
 
86
 
 
87
Let's remove the bug from the database, so it won't change the behaviour of
 
88
other tests.
 
89
 
 
90
    >>> oops.oopsinfestation.delete()
 
91
 
 
92
And reset the database.
 
93
 
 
94
    >>> from oopstools.oops.helpers import reset_database
 
95
    >>> reset_database()
 
96
    'Oops, DBOopsRootDirectory and Infestation deleted.'
 
97