sapling/eden/mononoke/tests/integration/test-scs.t
Kostia Balytskyi fc61c74f23 live_commit_sync_config: make scs xrepo-lookup watch live changes
Summary:
When we change `CommitSyncConfig`, we want to not have to restart `scs` servers, and instead have them pick up the new config by using `LiveCommitSyncConfig`.

This diff turned out larger than I expected, mainly due to the need to introduce various things around `TestLiveCommitSyncConfig`:
- `TestLiveCommitSyncConfig`: the trait implementer to use in `mononoke_api::Repo`
- `TestLiveCommitSyncConfigSource`: the helper struct to keep around for new values injection (very similar to how our `ConfigStore` has an inner `ConfigSource`, which can also be `TestSource`, but here injected values can be `CommitSyncConfig` instead of JSON).
- all the places in integration tests, where `setup_configerator_configs` is now needed (I plan to start setting up configerator configs always in a separate diff, as it is cheap)

Here are the explanations for a few things I think may be not immediately obvious:
- I removed the `Clone` bound from `LiveCommitSyncConfig` trait, as `Clone` traits [cannot be made into trait objects](https://doc.rust-lang.org/book/ch17-02-trait-objects.html#object-safety-is-required-for-trait-objects)
- `TestLiveCommitSyncConfigSource` vs `TestLiveCommitSyncConfigSourceInner` discrepancy is to ensure nobody should instantiate `TestLiveCommitSyncConfigSourceInner` outside of `live_commit_sync_config/src`
- I am aware of the ugly discrepancy between the main `--mononoke-config-path`, which is used to load initial configuration and can be both a file-based and a configerator-based config; and `--local-configerator-path`, used to override config sources for `Tunables` and `LiveCommitSyncConfig`. Ideally these two should just be unified somehow, but that is a little out of scope of this diff (I've already added it to the dirt doc though).
- in `mononoke_api::Repo` there are methods `new_test_xrepo` and `new_test_common`, which changed from maybe accepting just a `CommitSyncConfig` to now maybe accepting both `CommitSyncConfig` and `LiveCommitSyncConfig`. It can be made a bit cleaner: I can just query `CommitSyncConfig` from `LiveCommitSyncConfig` in `new_test_common` and avoid having two args. I was too lazy to do this, lmk if you feel strongly about it.

Reviewed By: StanislavGlebik

Differential Revision: D22443623

fbshipit-source-id: 0d6bbda2223e77b89cc59863b703db5081bcd601
2020-07-21 09:09:23 -07:00

279 lines
7.4 KiB
Perl

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License found in the LICENSE file in the root
# directory of this source tree.
$ . "${TEST_FIXTURES}/library.sh"
Setup config repo:
$ POPULATE_GIT_MAPPING=1 setup_common_config
$ setup_configerator_configs
$ cd "$TESTTMP"
Setup testing repo for mononoke:
$ hg init repo-hg
$ cd repo-hg
$ setup_hg_server
Helper for making commit:
$ function commit() { # the arg is used both for commit message and variable name
> hg commit -Am $1 # create commit
> export COMMIT_$1="$(hg --debug id -i)" # save hash to variable
> }
First two simple commits and bookmark:
$ echo -e "a\nb\nc\nd\ne" > a
$ commit A
adding a
$ echo -e "a\nb\nd\ne\nf" > b
$ commit B
adding b
$ hg bookmark -i BOOKMARK_B
A commit with a file change and binary file
$ echo -e "b\nc\nd\ne\nf" > b
$ echo -e "\0 10" > binary
$ commit C
adding binary
Commit with globalrev:
$ touch c
$ hg add
adding c
$ hg commit -Am "commit with globalrev" --extra global_rev=9999999999
$ hg bookmark -i BOOKMARK_C
Commit git SHA:
$ touch d
$ hg add
adding d
$ hg commit -Am "commit with git sha" --extra convert_revision=37b0a167e07f2b84149c918cec818ffeb183dddd --extra hg-git-rename-source=git
import testing repo to mononoke
$ cd ..
$ blobimport repo-hg/.hg repo --has-globalrev
try talking to the server before it is up
$ SCS_PORT=$(get_free_socket) scsc lookup --repo repo -B BOOKMARK_B
error: apache::thrift::transport::TTransportException: AsyncSocketException: connect failed, type = Socket not open, errno = 111 (Connection refused): Connection refused
[1]
start SCS server
$ start_and_wait_for_scs_server --scuba-log-file "$TESTTMP/scuba.json"
make some simple requests that we can use to check scuba logging
repos
$ scsc repos
repo
lookup using bookmark
$ scsc lookup --repo repo -B BOOKMARK_C -S bonsai
006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b
diff paths only
$ scsc diff --repo repo --paths-only -B BOOKMARK_B --bonsai-id "006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b"
M b
A binary
A c
check the scuba methods and perf counters logs
$ summarize_scuba_json "Request.*" < "$TESTTMP/scuba.json" \
> .normal.log_tag .normal.msg .normal.method \
> .normal.commit .normal.other_commit .normal.path \
> .normal.bookmark_name .normvector.identity_schemes \
> .normal.status .normal.error \
> .int.BlobGets
{
"log_tag": "Request start",
"method": "list_repos"
}
{
"BlobGets": 0,
"log_tag": "Request complete",
"method": "list_repos",
"status": "SUCCESS"
}
{
"bookmark_name": "BOOKMARK_C",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request start",
"method": "repo_resolve_bookmark"
}
{
"BlobGets": 0,
"bookmark_name": "BOOKMARK_C",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request complete",
"method": "repo_resolve_bookmark",
"status": "SUCCESS"
}
{
"commit": "006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request start",
"method": "commit_lookup"
}
{
"BlobGets": 0,
"commit": "006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request complete",
"method": "commit_lookup",
"status": "SUCCESS"
}
{
"bookmark_name": "BOOKMARK_B",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request start",
"method": "repo_resolve_bookmark"
}
{
"BlobGets": 0,
"bookmark_name": "BOOKMARK_B",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request complete",
"method": "repo_resolve_bookmark",
"status": "SUCCESS"
}
{
"commit": "006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request start",
"method": "commit_compare",
"other_commit": "c63b71178d240f05632379cf7345e139fe5d4eb1deca50b3e23c26115493bbbb"
}
{
"BlobGets": 0,
"commit": "006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b",
"identity_schemes": [
"BONSAI"
],
"log_tag": "Request complete",
"method": "commit_compare",
"other_commit": "c63b71178d240f05632379cf7345e139fe5d4eb1deca50b3e23c26115493bbbb",
"status": "SUCCESS"
}
commands after this point may run requests in parallel, which can change the ordering
of the scuba samples.
cat a file
$ scsc cat --repo repo -B BOOKMARK_B -p a
a
b
c
d
e
show commit info
$ scsc info --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402
Commit: ee87eb8cfeb218e7352a94689b241ea973b80402
Parent: c29e0e474e30ae40ed639fa6292797a7502bc590
Date: 1970-01-01 00:00:00 +00:00
Author: test
Generation: 4
Extra:
global_rev=9999999999
commit with globalrev
$ scsc info --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402 -S bonsai,hg,globalrev
Commit:
bonsai=006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b
globalrev=9999999999
hg=ee87eb8cfeb218e7352a94689b241ea973b80402
Parent:
bonsai=d5ded5e738f4fc36b03c3e09db9cdd9259d167352a03fb6130f5ee138b52972f
hg=c29e0e474e30ae40ed639fa6292797a7502bc590
Date: 1970-01-01 00:00:00 +00:00
Author: test
Generation: 4
Extra:
global_rev=9999999999
commit with globalrev
show commit info for git commit
$ scsc info --repo repo -i 37b0a167e07f2b84149c918cec818ffeb183dddd -S bonsai,hg,globalrev,git
Commit:
bonsai=227d4402516061c45a7ba66cf4561bdadaf3ac96eb12c6e75aa9c72dbabd42b6
git=37b0a167e07f2b84149c918cec818ffeb183dddd
hg=6e602c2eaa591b482602f5f3389de6c2749516d5
Parent:
bonsai=006c988c4a9f60080a6bc2a2fff47565fafea2ca5b16c4d994aecdef0c89973b
globalrev=9999999999
hg=ee87eb8cfeb218e7352a94689b241ea973b80402
Date: 1970-01-01 00:00:00 +00:00
Author: test
Generation: 5
Extra:
convert_revision=37b0a167e07f2b84149c918cec818ffeb183dddd
hg-git-rename-source=git
commit with git sha
show tree info
$ scsc info --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402 -p ""
Path:
Type: tree
Id: 7403a559399d2aeb6b0e58f62131ac121a3347ec6342201895d34036d87c726e
Simple-Format-SHA1: 7c6d1b3745da28107356823689cb2b83c4132f7c
Simple-Format-SHA256: 57abececda70ab40c538a02743987a7e5f829581986c582fc11e7fe9d37b7bac
Children: 4 files (25 bytes), 0 dirs
Descendants: 4 files (25 bytes)
show file info
$ scsc info --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402 -p a
Path: a
Type: file
Id: af1950dbdacd7eee24e4dbb7de9bcbf1f6b05c4a24b066deab407e9143715702
Content-SHA1: 6249443f65b64a5ac07802a3582fd5c1f5f2ebd8
Content-SHA256: 86dc03602dcf385217216784784a8ecf20e6400decc3208170b12fcb0afb6698
Size: 10 bytes
list directory
$ scsc ls --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402
a
b
binary
c
$ scsc ls --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402 -l
file 10 a
file 10 b
file 5 binary
file 0 c
export
$ scsc export --repo repo -i ee87eb8cfeb218e7352a94689b241ea973b80402 -p "" -o exported
$ find exported | sort
exported
exported/a
exported/b
exported/binary
exported/c
$ cat exported/a
a
b
c
d
e