コード例 #1
0
def not_test_2(settings):
    """
    THIS WAS TESTING FOR A DECREASE IN THE MEAN, BUT THE CURRENT CODE IGNORES THOSE
    """
    test_data2 = struct.wrap({
        "header": ("timestamp", "mean", "std", "h0_rejected", "count"),
        "rows": [
            (1366388389, 295.36, 32.89741631, 0, 25),
            (1366387915, 307.92, 32.86198412, 0, 25),
            (1366390777, 309, 41.22802445, 0, 25),
            (1366398771, 309.24, 34.18488945, 0, 25),
            (1366401499, 308.2, 30.36170834, 0, 25),
            (1366412504, 192.8, 46.27634385, 1, 25), # Should be an alert
            (1366421699, 298.04, 29.09249617, 0, 25),
            (1366433920, 324.52, 28.13378752, 0, 25),
            (1366445744, 302.2, 28.19131072, 0, 25),
            (1366455408, 369.96, 31.25363979, 0, 25),
            (1366474119, 313.12, 33.66541252, 0, 25),
            (1366483789, 369.96, 30.81460693, 0, 25),
            (1366498412, 311.76, 36.02462121, 0, 25),
            (1366507773, 291.08, 27.86562996, 0, 25)
        ]
    })
    test_data2 = [
        struct.wrap({
            "timestamp": t.timestamp,
            "datetime": CNV.unix2datetime(t.timestamp),
            "count": t.count,
            "mean": t.mean,
            "variance": pow(t.std, 2),
            "reject": t.h0_rejected
        })
        for t in CNV.table2list(test_data2.header, test_data2.rows)
    ]

    with DB(settings.perftest) as db:
        tester = test_alert_exception(db)
        tester.test_alert_generated(test_data2)
コード例 #2
0
    def iterator():
        try:
            while True:
                try:
                    line = proc.stdout.readline()
                    if line == '':
                        proc.wait()
                        if proc.returncode:
                            Log.error("Unable to pull hg log: return code {{return_code}}", {
                                "return_code": proc.returncode
                            })
                        return
                except Exception, e:
                    Log.error("Problem getting another line", e)

                if line.strip() == "":
                    continue
                Log.note(line)


                # changeset = "{date|hgdate|urlescape}\t{node}\t{rev}\t{author|urlescape}\t{branches}\t\t\t\t{p1rev}\t{p1node}\t{parents}\t{children}\t{tags}\t{desc|urlescape}\n"
                # branch = "{branch}%0A"
                # parent = "{parent}%0A"
                # tag = "{tag}%0A"
                # child = "{child}%0A"
                (
                    date,
                    node,
                    rev,
                    author,
                    branches,
                    files,
                    file_adds,
                    file_dels,
                    p1rev,
                    p1node,
                    parents,
                    children,
                    tags,
                    desc
                ) = (CNV.latin12unicode(urllib.unquote(c)) for c in line.split("\t"))

                file_adds = set(file_adds.split("\n")) - {""}
                file_dels = set(file_dels.split("\n")) - {""}
                files = set(files.split("\n")) - set()
                doc = {
                    "repo": repo.name,
                    "date": CNV.unix2datetime(CNV.value2number(date.split(" ")[0])),
                    "node": node,
                    "revision": rev,
                    "author": author,
                    "branches": set(branches.split("\n")) - {""},
                    "file_changes": files - file_adds - file_dels - {""},
                    "file_adds": file_adds,
                    "file_dels": file_dels,
                    "parents": set(parents.split("\n")) - {""} | {p1rev+":"+p1node},
                    "children": set(children.split("\n")) - {""},
                    "tags": set(tags.split("\n")) - {""},
                    "description": desc
                }
                doc = ElasticSearch.scrub(doc)
                yield doc
        except Exception, e:
            if isinstance(e, ValueError) and e.message.startswith("need more than "):
                Log.error("Problem iterating through log ({{message}})", {
                    "message": line
                }, e)


            Log.error("Problem iterating through log", e)