Exemplo n.º 1
0
def message_handler(data, message):
    # Do something with the message data
    payload = data['payload']
    revision_id = payload['revision']
    tests_url = payload['testsurl']
    date = datetime.datetime.fromtimestamp(payload['builddate'])

    try:
        rev = CodeRevision.objects.get(id=revision_id)
        log.info("Revision {} already exists".format(revision_id))
    except mongoengine.DoesNotExist:
        rev = CodeRevision(id=revision_id, tests_url=tests_url, date=date)
        rev.save()
        log.info("Created a new revision: {}".format(revision_id))

    # Ack the message to tell pulse we processed it
    message.ack()
Exemplo n.º 2
0
def rev_stats():
    test_suites = CodeRevision.MANIFESTS_REL_PATHS
    revs = CodeRevision.objects(processed=True)
    data = dict()
    datasets = {test_suite: dict(label="Testsuite '{}'".format(test_suite),
                                 fillColor="rgba(220,220,220,0.2)",
                                 strokeColor="rgba(220,220,220,1)",
                                 pointColor="rgba(220,220,220,1)",
                                 pointStrokeColor="#fff",
                                 pointHighlightFill="#fff",
                                 pointHighlightStroke="rgba(220,220,220,1)",
                                 data=[]) for test_suite in test_suites}
    data['datasets'] = datasets
    data['labels'] = list()

    for rev in revs:
        timestamp = calendar.timegm(rev.date.utctimetuple())
        data['labels'].append(timestamp)
        for manifest_state in rev.manifest_states:
            skipped_tests = len(manifest_state.skipped_tests)
            datasets[manifest_state.test_suite]['data'].append(skipped_tests)

    return json.dumps(data)
Exemplo n.º 3
0
import logging
import sys
import time

import mongoengine

import config
from models import CodeRevision

# Setting up logging
log = logging.getLogger('manifestmonitor')
log.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
log.addHandler(handler)

if __name__ == '__main__':
    mongoengine.connect(config.db_name)
    while True:
        revisions = CodeRevision.objects(processed=False)
        for rev in revisions:
            log.info("Processing revision: {}".format(rev.id))
            tests_path = rev.download_tests()
            log.info("Downloaded to tests path: {}".format(tests_path))
            rev.parse_manifests(tests_path)

        time.sleep(1)