Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Run diff prototype #228

Merged
merged 17 commits into from
Nov 24, 2017
Merged

Conversation

lukebjerring
Copy link
Collaborator

@lukebjerring lukebjerring commented Nov 10, 2017

See #301

Running at https://20171122t141813-dot-wptdashboard.appspot.com/

Example: Chrome 7a0cf8ade7 vs 6ed1ba18d0 (Nov 2nd vs Nov 4th)
https://20171122t141813-dot-wptdashboard.appspot.com/api/diff?before=chrome@7a0cf8ade7&after=chrome@6ed1ba18d0


This PR adds /api/diff?before=platform@sha&after=platform@sha endpoint, for (dangerously simplified) summaries of the diff counts between 2 runs.

Produces the same JSON format as /results?browser={platform}&sha={sha}, only instead of

{ "foo": [pass, total], "bar": ... }

it produces

{ "foo": [pass_delta, max(total_tests)], ... }

And omits anything with the same counts. This format can* then be piped into <wpt-results>

* Not yet prototyped

/cc @jeffcarp

@foolip
Copy link
Member

foolip commented Nov 22, 2017

I can't see "summary" in the diff, but this is based on the summary pass/fail numbers alone, right? Would anything much need to change in order to use the full pass/fail data once that's available in a more convenient format than tens of thousands of individual files?

@lukebjerring
Copy link
Collaborator Author

lukebjerring commented Nov 23, 2017 via email

return
}

diffJSON := diffResults(beforeJSON, afterJSON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first time reading go code. If I'm reading this right, almost everything up to this point is error handling :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, go's error handling is .. verbose.

run_diff.go Outdated
} else {
platformAtRevision.Revision = pieces[1]
}
if IsBrowserName(platformAtRevision.Platform) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about this? Seems curious to check if the platform is a browser.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform is actually browser[-version[-os[-version]]], in this case enforced as only the browser.

run_diff.go Outdated

var results []TestRun
query := baseQuery.
Filter("BrowserName =", revision.Platform)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks funny in the same way, so now I'm thinking we're just using browser and platform as synonyms in these parts. Is that the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO's added.

run_diff.go Outdated
return results[0], nil
}

func fetchRunResultsJSON(ctx context.Context, r *http.Request, run TestRun) (results map[string][]int, err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sprinkle some TODOs around here about not fetching lots of little files, and linking to the issue for that?

Copy link
Collaborator Author

@lukebjerring lukebjerring Nov 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should open the issue until this code lands (issues against branches feels dirty). However, I think this diff is valid once all data is in the one blob, so probably not a TODO for this code either.

reqURL.Path = url
}
var resp *http.Response
if resp, err = client.Get(url); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is where network errors end up, it seems somewhat likely that we'll see some. Will the client see a HTTP 500 then? If it's not very unlikely to happen, seems like some retry logic will be needed in the Travis integration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 500, idk about the likelyhood, not going to overengineer until we see an actual problem (travis makes a HUGE number of network fetches for pip etc anyway).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I suppose that this will only make a handful of requests, I was thinking about what @mdittmer told me about in code where he fetched 10k files or so. If we expected that kind of load some precautions might be in order.

run_diff.go Outdated
return results, nil
}

func diffResults(before map[string][]int, after map[string][]int) map[string][]int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdittmer, here are a bunch of loops over test results, this is the shape of things I was imagining would be involved in computing metrics. Just FYI, let's keep going in the design doc.

diff := make(map[string][]int)
for test, resultsBefore := range before {
if resultsAfter, ok := after[test]; !ok {
// Missing? Then N / N tests are 'different'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tests in the code base yet? This is a bit of code that would easier to review the tests for than convince oneself about correctness in edge cases by executing in head.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add some tests shortly and push them into this PR.

run_diff.go Outdated
}

func diffResults(before map[string][]int, after map[string][]int) map[string][]int {
diff := make(map[string][]int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about what the 2-tuple int represents here? I think "number of tests different" and "total number of tests known"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

util.go Outdated
}
for _, browser := range browsers {
if browser == name {
return true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no array.contains(thing) in Go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird :)

util.go Outdated
return false
}

func abs(x int) int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know go, but if https://golang.org/pkg/math/ is part of the standard library, is it most idiomatic to use that or roll your own?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math lib works with floats, not ints, arguing that ints are 'trivial to roll your own'.

(I don't like Go in that regard.)

run_diff_test.go Outdated
assertDelta(t, []int {0, 1}, []int {0, 2}, []int {1, 2})

// One new test, new test passing
assertDelta(t, []int {0, 1}, []int {1, 2}, []int {1, 2})
Copy link
Member

@foolip foolip Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this right, the numbers returned as the same when a new test is pass and when it's failing, is that right? That would make it impossible to notify about new failing tests but not new passing tests, which I think we should.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, currently the case. Removing the abs call would let you see negative values; however, this API will be extended to take a filters param, and you'd filter to only newly-failing in the fetch which is used for notifying.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan!

@lukebjerring lukebjerring removed the request for review from jeffcarp November 24, 2017 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants