Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: go/src/infra/appengine/test-results/model/end_to_end_test.go

Issue 2231393002: test-results: Add merge and trim methods (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: tests: remove unecessary Trim calls Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 package model
2
3 import (
4 "bytes"
5 "encoding/json"
6 "io/ioutil"
7 "path/filepath"
8 "testing"
9
10 . "github.com/smartystreets/goconvey/convey"
11 )
12
13 func TestEndToEnd(t *testing.T) {
14 t.Parallel()
15
16 Convey("End to end", t, func() {
17 // This test is a port of the test named "test_merge_full_result s_format"
18 // from "model/test/jsonresults_test.py" in the Python
19 // application.
20 Convey("FullResult: clean, unmarshal JSON, merge, trim", func() {
21 b, err := ioutil.ReadFile(filepath.Join("testdata", "ful l_results.jsonp"))
22 So(err, ShouldBeNil)
23 r, err := CleanJSON(bytes.NewReader(bytes.TrimSpace(b)))
24 So(err, ShouldBeNil)
25
26 expected := &AggregateResult{
27 Builder: "Webkit",
28 Version: ResultsVersion,
29 BuilderInfo: &BuilderInfo{
30 BuildNumbers: []Number{3},
31 ChromeRevs: []string{"5678"},
32 FailureMap: FailureLongNames,
33 FailuresByType: map[string][]int{
34 "AUDIO": {0},
35 "CRASH": {3},
36 "FAIL": {2},
37 "IMAGE": {1},
38 "IMAGE+TEXT": {0},
39 "MISSING": {0},
40 "PASS": {10},
41 "SKIP": {2},
42 "TEXT": {3},
43 "TIMEOUT": {16},
44 "LEAK": {1},
45 },
46 SecondsEpoch: []int64{1368146629},
47 Tests: AggregateTest{
48 "media": AggregateTest{
49 "W3C": AggregateTest{
50 "audio": Aggrega teTest{
51 "src": A ggregateTest{
52 "src_removal_does_not_trigger_loadstart.html": &AggregateTestLeaf{
53 Results: []ResultSummary{{1, "P"}},
54 Runtimes: []RuntimeSummary{{1, 4}},
55 },
56 },
57 },
58 // "video" is no t present because the
59 // expected fiel ds are "PASS" and "NOTRUN".
60 },
61 "encrypted-media": Aggre gateTest{
62 "random-test-1.h tml": &AggregateTestLeaf{
63 Bugs: []string{"crbug.com/1234"},
64 Results: []ResultSummary{{1, "T"}},
65 Runtimes : []RuntimeSummary{{1, 6}},
66 Expected : []string{"TIMEOUT"},
67 },
68 "random-test-2.h tml": &AggregateTestLeaf{
69 Expected : []string{"TIMEOUT"},
70 Results: []ResultSummary{{1, "T"}},
71 Runtimes : []RuntimeSummary{{1, 0}},
72 },
73 },
74 "media-document-audio-re paint.html": &AggregateTestLeaf{
75 Expected: []stri ng{"IMAGE"},
76 Results: []Resu ltSummary{{1, "I"}},
77 Runtimes: []Runt imeSummary{{1, 0}},
78 },
79 "progress-events-generat ed-correctly.html": &AggregateTestLeaf{
80 Expected: []stri ng{"PASS", "FAIL", "IMAGE", "TIMEOUT", "CRASH", "MISSING"},
81 Results: []Resu ltSummary{{1, "T"}},
82 Runtimes: []Runt imeSummary{{1, 6}},
83 },
84 "flaky-failed.html": &Ag gregateTestLeaf{
85 Expected: []stri ng{"PASS", "FAIL"},
86 Results: []Resu ltSummary{{1, "Q"}},
87 Runtimes: []Runt imeSummary{{1, 0}},
88 },
89 "unexpected-fail.html": &AggregateTestLeaf{
90 Results: []Resu ltSummary{{1, "Q"}},
91 Runtimes: []Runt imeSummary{{1, 0}},
92 },
93 "unexpected-leak.html": &AggregateTestLeaf{
94 Results: []Resu ltSummary{{1, "K"}},
95 Runtimes: []Runt imeSummary{{1, 0}},
96 },
97 "unexpected-flake.html": &AggregateTestLeaf{
98 Results: []Resu ltSummary{{1, "QP"}},
99 Runtimes: []Runt imeSummary{{1, 0}},
100 },
101 "unexpected-unexpected.h tml": &AggregateTestLeaf{
102 Results: []Resu ltSummary{{1, "U"}},
103 Runtimes: []Runt imeSummary{{1, 0}},
104 },
105 },
106 },
107 },
108 }
109
110 var aggr AggregateResult
111 aggr.Builder = "Webkit"
112 var result FullResult
113
114 So(json.NewDecoder(r).Decode(&result), ShouldBeNil)
115 convertedAggr, err := result.AggregateResult()
116 So(err, ShouldBeNil)
117 So(aggr.Merge(&convertedAggr), ShouldBeNil)
118 So(aggr.Trim(ResultsSize), ShouldBeNil)
119 So(&aggr, ShouldResemble, expected)
120 })
121 })
122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698