Skip to content
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

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

ghemawat
Copy link
Contributor

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.

@ghemawat ghemawat force-pushed the webtest branch 10 times, most recently from 3c5aee1 to 9218c12 Compare August 16, 2023 22:04
@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2023

Codecov Report

Merging #798 (2b14af0) into main (2861d24) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #798   +/-   ##
=======================================
  Coverage   66.99%   66.99%           
=======================================
  Files          45       45           
  Lines        9861     9861           
=======================================
  Hits         6606     6606           
  Misses       2795     2795           
  Partials      460      460           

aalexand
aalexand previously approved these changes Aug 16, 2023
Copy link
Collaborator

@aalexand aalexand left a 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.

@@ -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?
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -137,6 +138,14 @@ jobs:
with:
path: ${{ env.WORKING_DIR }}

# Limit to just Linux for now since this is expensive and the
Copy link
Collaborator

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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto: debugging leftover?

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

aalexand
aalexand previously approved these changes Aug 16, 2023
@aalexand
Copy link
Collaborator

Will merge once tests complete.

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.
@ghemawat
Copy link
Contributor Author

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")
Copy link
Collaborator

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.

Copy link
Collaborator

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).

Copy link
Contributor Author

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.

@aalexand aalexand merged commit 7a8ec2a into google:main Aug 17, 2023
49 checks passed
@Louis-Ye
Copy link
Collaborator

Marking #791 as fixed

cristaloleg pushed a commit to go-perf/pprof that referenced this pull request Sep 1, 2023
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
Copy link

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.

Copy link
Collaborator

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.

Copy link

Choose a reason for hiding this comment

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

See #862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants