-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce first test for browser-side behavior. #798
Conversation
3c5aee1
to
9218c12
Compare
Codecov Report
@@ Coverage Diff @@
## main #798 +/- ##
=======================================
Coverage 66.99% 66.99%
=======================================
Files 45 45
Lines 9861 9861
=======================================
Hits 6606 6606
Misses 2795 2795
Partials 460 460 |
aadbe0d
to
6d2f13e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing with integration style tests is how flaky they are, but I guess it's hard to know as we don't have bazel-style --runs_per_test
flag to use.
.github/workflows/ci.yaml
Outdated
@@ -92,10 +92,11 @@ jobs: | |||
./test.sh | |||
|
|||
- name: Check to make sure that tests also work in GOPATH mode | |||
if: matrix.go != 'tip' # Is GO111MODULE support going away in go1.21? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 1.22, not 1.21 (1.21 is out already). Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
.github/workflows/ci.yaml
Outdated
@@ -137,6 +138,14 @@ jobs: | |||
with: | |||
path: ${{ env.WORKING_DIR }} | |||
|
|||
# Limit to just Linux for now since this is expensive and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
if err != nil { | ||
return fmt.Errorf("text %s: %v", query, err) | ||
} | ||
t.Logf("text %s:\n%s", query, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this for debugging or intended to stay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like leaving things like this in because if the test breaks, it is something useful for the fixer to look at -- they will see the extracted HTML.
A plain "go test" shows t.Logf() output only for failing runs. We should consider dropping the "-v" argument from the "go test" call in test.sh to reduce the clutter from our workflow runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, including removing "-v". I think having the verbose output was helpful a couple of times, but I agree in most cases it's more likely to get in the way rather than be useful (often takes a lot of scrolling to see the error message).
if err != nil { | ||
return fmt.Errorf("text %s: %v", query, err) | ||
} | ||
t.Logf("text %s:\n%s", query, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto: debugging leftover?
internal/driver/webui_test.go
Outdated
@@ -43,6 +43,7 @@ func makeTestServer(t testing.TB, prof *profile.Profile) *httptest.Server { | |||
creator := func(a *plugin.HTTPServerArgs) error { | |||
server = httptest.NewServer(http.HandlerFunc( | |||
func(w http.ResponseWriter, r *http.Request) { | |||
t.Logf("serving URL %q", r.URL.Path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: serving -> Serving
https://google.github.io/styleguide/go/decisions#error-strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this one since I had added this just for temporary debugging.
0b24ea8
to
ca21896
Compare
Will merge once tests complete. |
b7b1e34
to
719f4ce
Compare
Added a test that uses chromedp to drive web page interactions and check the resulting display. Disable "GOPATH" mode tests since "go get" support for that was deleted from Go on Aug 16 by golang/go@de4d503 Drop the "-v" from "go test" since it clutters logs. We will still get verbose info for failing tests, so diagnosing failures should not get any harder. Caveat: just adding a single test initially (it checks sorting of the "Top" view table). Other tests will be added later. Caveat: coverage of browser Javascript is not gathered, so we won't be able to rely on coverage to measure quality/changes in Javascript testing.
I sync-ed with other changes, dropped the unnecessary action to setup chrome (it is already available by default in github runners), and dropped the "-v" from the "go test" invocation. This should now be fine to merge. |
if _, err := exec.LookPath("chrome"); err == nil { | ||
return | ||
} | ||
t.Skip("chrome not available") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I paused here for a second wondering if this should fail instead of skip so that we know early if the CI gets misconfigured somehow and starts silently skipping the test. But you added a chrome check in the CI configuration so probably we are good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we indeed will need to skip here instead of failing the test, because otherwise the test will always fail in environments that do not have chrome, e.g. windows, mac (where we currently skip this test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an earlier check that Skips unless we are on Linux+amd64. So we could easily change this one to Fail() which will reduce the long distance coupling to the workflow definition.
Marking #791 as fixed |
Added a test that uses chromedp to drive web page interactions and check the resulting display. Disable "GOPATH" mode tests since "go get" support for that was deleted from Go on Aug 16 by golang/go@de4d503 Drop the "-v" from "go test" since it clutters logs. We will still get verbose info for failing tests, so diagnosing failures should not get any harder. Caveat: just adding a single test initially (it checks sorting of the "Top" view table). Other tests will be added later. Caveat: coverage of browser Javascript is not gathered, so we won't be able to rely on coverage to measure quality/changes in Javascript testing.
github.com/gobwas/pool v0.2.1 // indirect | ||
github.com/gobwas/ws v1.2.1 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github.com/mailru/easyjson
is considered unmaintained in Kubernetes. Updating pprof to the latest version in Kubernetes triggers a check about this new dependency:
024/05/22 09:09:54 Unwanted module "github.com/mailru/easyjson" marked in /home/prow/go/src/k8s.io/kubernetes/hack/unwanted-dependencies.json is referenced by new dependants:
2024/05/22 09:09:54 github.com/google/pprof
2024/05/22 09:09:54 !!! Avoid updating referencing modules to versions that reintroduce use of unwanted dependencies
As this is presumable now a dependency only because of some integration test, do you see a chance to move this dependency into a separate package inside this repo?
github.com/chromedp/chromedp
seems like pretty heavy dependency for a simple package like pprof
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps worth filing a separate issue for this so that we discuss it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #862
Added a test that uses chromedp to drive web page interactions and check the resulting display.
Caveat: just adding a single test initially (it checks sorting of the "Top" view table). Other tests will be added later.
Caveat: coverage of browser Javascript is not gathered, so we won't be able to rely on coverage to measure quality/changes in Javascript testing.