-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from FACT-Finder/speedy-details
Speedup and add details page for test results
- Loading branch information
Showing
13 changed files
with
303 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
|
||
"github.com/FACT-Finder/noflake/database" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
func (a *api) GetTestResult(ctx echo.Context, testID, uploadID string) error { | ||
output, err := a.testResult(testID, uploadID) | ||
if err != nil { | ||
return err | ||
} | ||
return ctx.JSON(http.StatusOK, output) | ||
} | ||
|
||
func (a *api) testResult(testIDStr, uploadIDStr string) (TestResult, error) { | ||
testID, err := strconv.Atoi(testIDStr) | ||
if err != nil { | ||
return TestResult{}, err | ||
} | ||
|
||
uploadID, err := strconv.Atoi(uploadIDStr) | ||
if err != nil { | ||
return TestResult{}, err | ||
} | ||
|
||
testResult, err := database.GetTestResult(a.db, testID, uploadID) | ||
if err != nil { | ||
return TestResult{}, err | ||
} | ||
|
||
return TestResult{ | ||
TestId: testIDStr, | ||
UploadId: uploadIDStr, | ||
Name: testResult.Name, | ||
CommitSHA: testResult.CommitSHA, | ||
Url: testResult.URL, | ||
Success: testResult.Success, | ||
Output: testResult.Output, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{template "start" .}} | ||
<div> | ||
<a href="/ui/test/{{.Result.TestId}}/fails">Show all failures for this test</a> | ||
</div> | ||
<br /> | ||
<table> | ||
<tr><td>Name</td><td>{{.Result.Name}}</td></tr> | ||
<tr><td>Commit</td><td>{{.Result.CommitSHA}}</td></tr> | ||
<tr><td>Success</td><td>{{.Result.Success}}</td> | ||
<tr><td>Build</td><td><a href="{{.Result.Url}}">{{.Result.Url}}</a></td> | ||
</table> | ||
<br /> | ||
<div> | ||
<div><b>Output:</b></div> | ||
<pre> | ||
{{.Result.Output}} | ||
</pre> | ||
</div> | ||
{{template "end" .}} | ||
{{.Output}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DROP INDEX IF EXISTS tests_flaky; | ||
DROP INDEX IF EXISTS results_test_id; | ||
DROP INDEX IF EXISTS results_commit_id; | ||
ALTER TABLE tests DROP flaky; | ||
CREATE INDEX results_idx ON results(test_id, commit_id, success); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DROP INDEX IF EXISTS results_idx; | ||
|
||
ALTER TABLE tests ADD flaky INTEGER NOT NULL DEFAULT 0; | ||
|
||
UPDATE tests SET flaky = true | ||
WHERE tests.id in ( | ||
SELECT DISTINCT(tests.id) FROM results | ||
LEFT JOIN tests ON tests.id = results.test_id | ||
GROUP BY results.test_id, results.commit_id | ||
HAVING COUNT(DISTINCT results.success) > 1 | ||
); | ||
|
||
CREATE INDEX results_test_id ON results(test_id); | ||
CREATE INDEX results_commit_id ON results(commit_id); | ||
CREATE INDEX tests_flaky ON tests(flaky); |
Oops, something went wrong.