Beispiel #1
0
def histo(request):
    client = CbClient()

    test_id = request.POST.get('id', uuid4().hex)
    description = request.POST.get('description', uuid4().hex)
    attachment = request.POST.get('attachment', '')
    attachment = json.loads(str(attachment))

    histograms = client.find(test_id).get('histograms', {})
    histograms.update({description: attachment})

    doc = {'histograms': histograms}

    client.update(test_id, doc)

    return Response(test_id)
Beispiel #2
0
def report(request):
    client = CbClient()

    test_id = request.POST.get('test_id', uuid4().hex)
    description = request.POST.get('description', uuid4().hex)
    url = request.POST.get('url', '')

    reports = client.find(test_id).get('reports', {})
    reports.update({description: url})

    doc = {'reports': reports}

    client.update(test_id, doc)

    if request.POST.get('submit'):
        location = '/details?id={0}'.format(test_id)
        return HTTPFound(location)
    else:
        return Response(test_id)
Beispiel #3
0
def home(request):
    # Couchbase client
    client = CbClient()

    # Output dictionary
    data = list()

    for row in client.query(ddoc='karma', view='uid')['rows']:
        test = client.find(str(row['id']))

        latest_timestamp = max(test['events'].keys())
        status = "{0}: {1}".format(test['events'][latest_timestamp]['phase'],
                                   test['events'][latest_timestamp]['status'])

        data.append({'test_id': row['id'],
                     'build': test['build'],
                     'spec': test['spec'],
                     'description': test['description'],
                     'status': status,
                     'timestamp': latest_timestamp
        })

    return {'data': data}
Beispiel #4
0
def update(request):
    client = CbClient()

    test_id = request.POST.get('id', uuid4().hex)

    build = request.POST.get('build', '')
    spec = request.POST.get('spec', '')
    description = request.POST.get('description', '')
    timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    phase = request.POST.get('phase', '')
    status = request.POST.get('status', '')

    events = client.find(test_id).get('events', {})
    events.update({timestamp: {'phase': phase, 'status': status}})

    doc = {'build': build,
           'spec': spec,
           'description': description,
           'events': events,
           'type': 'update'}

    client.update(test_id, doc)

    return Response(test_id)
Beispiel #5
0
def details(request):
    # Couchbase client
    client = CbClient()

    # Phases
    test_id = request.GET['id']

    events = client.find(test_id)['events']

    phases = []
    for event in sorted(events):
        phases.append("{0} phase {1} at {2}".format(events[event]['phase'],
                                                    events[event]['status'],
                                                    event))

    histograms = client.find(test_id).get('histograms', {})
    histograms = dict((d, LatencyDict(a)) for d, a in histograms.iteritems())

    reports = client.find(test_id).get('reports', {})

    return {'phases': phases, 'histograms': histograms, 'reports': reports,
            'build': client.find(test_id)['build'],
            'spec': client.find(test_id)['spec'],
            'test_id': test_id}