aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/graphs_test.go
blob: 3a87da7bfc322b94d4880678965fc8ba836285d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package main

import (
	"testing"
	"time"

	"github.com/google/syzkaller/dashboard/dashapi"
)

func TestManagersGraphs(t *testing.T) {
	c := NewCtx(t)
	defer c.Close()

	build1 := testBuild(1)
	c.client2.UploadBuild(build1)
	build2 := testBuild(2)
	c.client2.UploadBuild(build2)

	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build1.Manager,
		Corpus: 100,
		PCs:    1000,
		Cover:  2000,
	}))
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build2.Manager,
		Corpus: 200,
		PCs:    2000,
		Cover:  4000,
	}))
	c.advanceTime(25 * time.Hour)
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build1.Manager,
		Corpus: 110,
		PCs:    1100,
		Cover:  2200,
	}))
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build2.Manager,
		Corpus: 220,
		PCs:    2200,
		Cover:  4400,
	}))
	c.advanceTime(25 * time.Hour)
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build1.Manager,
		Corpus: 150,
		PCs:    1500,
		Cover:  2900,
	}))
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build2.Manager,
		Corpus: 270,
		PCs:    2700,
		Cover:  5400,
	}))
	c.advanceTime(25 * time.Hour)
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build1.Manager,
		Corpus: 50,
		PCs:    500,
		Cover:  900,
	}))
	c.expectOK(c.client2.UploadManagerStats(&dashapi.ManagerStatsReq{
		Name:   build2.Manager,
		Corpus: 70,
		PCs:    700,
		Cover:  400,
	}))

	for i := 0; i < 3; i++ {
		c.advanceTime(7 * 25 * time.Hour)
		for j := 0; j <= i; j++ {
			crash := testCrash(build1, i*i+j)
			c.client2.ReportCrash(crash)
		}
	}

	for {
		c.advanceTime(7 * 25 * time.Hour)
		_, err := c.GET("/email_poll")
		c.expectOK(err)
		if len(c.emailSink) == 0 {
			break
		}
		for len(c.emailSink) != 0 {
			<-c.emailSink
		}
	}

	reply, err := c.AuthGET(AccessAdmin, "/test2/graph/bugs")
	c.expectOK(err)
	// TODO: check reply
	_ = reply

	reply, err = c.AuthGET(AccessAdmin, "/test2/graph/lifetimes")
	c.expectOK(err)
	// TODO: check reply
	_ = reply

	reply, err = c.AuthGET(AccessAdmin, "/test2/graph/fuzzing")
	c.expectOK(err)
	// TODO: check reply
	_ = reply

	reply, err = c.AuthGET(AccessAdmin, "/test2/graph/crashes")
	c.expectOK(err)
	// TODO: check reply
	_ = reply
}