sapling/tests/test-clienttelemetry.t
Mark Thomas 6ea1e7437d clienttelemetry: correctly log full command line
Summary:
The full command line needs to come from the `dispatch.runcommand` function, as
`sys.argv` contains `serve ...` for chg invocations.

Also make sure the correlator remains the same for commands that make multiple
connections to the server.

Reviewed By: quark-zju

Differential Revision: D7443727

fbshipit-source-id: a785e372b7b67fbd0b4ab4d73e7ff914aa5db9c3
2018-04-13 21:51:45 -07:00

44 lines
1.1 KiB
Perl

$ cat >> $HGRCPATH << EOF
> [ui]
> ssh = $PYTHON "$TESTDIR/dummyssh"
> [extensions]
> clienttelemetry=
> EOF
set up the server repo
$ hg init server
$ cat >> server/.hg/hgrc << EOF
> [extensions]
> sampling=
> [sampling]
> filepath = $TESTTMP/sampling.txt
> key.clienttelemetry = client
> EOF
set up the local repo
$ hg clone 'ssh://user@dummy/server' local -q
$ cd local
$ hg pull
pulling from ssh://user@dummy/server
connected to * (glob)
no changes found
$ hg pull --config clienttelemetry.announceremotehostname=False
pulling from ssh://user@dummy/server
no changes found
check telemetry
>>> import json
>>> with open("$TESTTMP/sampling.txt") as f:
... data = f.read()
>>> for record in data.strip("\0").split("\0"):
... parsedrecord = json.loads(record)
... for key in "command", "fullcommand":
... print("%s: %s" % (key, parsedrecord["data"]["client_%s" % key]))
command: clone
fullcommand: clone 'ssh://user@dummy/server' local -q
command: pull
fullcommand: pull
command: pull
fullcommand: pull --config 'clienttelemetry.announceremotehostname=False'