sapling/tests/integration/test-sqlblob.t
Thomas Orozco 196a363236 mononoke: rebuild test framework
Summary:
Our test framework as it stands right now is a light passthrough to the hg `run-tests.py` test framework, which attempts to place all the files it needs to run (including tests) into a `python_binary`, then runs the hg test runner from that directory.

It heavily relies on how Buck works to offer functionality:

- It expects that all the sources it registers for its master binary will all be in the same directory when it builds
- It expects that the sources will be symlinks to the real files so that `--interactive` can work.

This has a few problems:

- It doesn't work in `mode/opt`. The archive that gets built in `mode/opt` doesn't actually have all the sources we registered, so it's impossible to run tests.
- To add a new test, you must rebuild everything. We don't do that very often, but it'd be nice if we didn't have to.
- Iterating on the runner itself is painful, because as far as Buck is concerned, it depends on the entire world. This means that every change to the runner has to scan a lot more stuff than necessary. There's some functionality I'd like to get into the runner (like reporting test timings) that hasn't been easy to add as a result.

This diff attempts to solve these problems by separating concerns a little more:

- The runner is now just a simple `python_binary`, so it's easier to make changes to it.
- The runner now provides the logic of working from local files when needed (this means you can add a new test and it'll work immediately),
- All the binaries we need are dependencies of the integration test target, not the runner's. However, to make it possible to run the runner incrementally while iterating on something, there's a manifest target that points at all the various paths the runner needs to work. This will also help integrate the test runner with other build frameworks if necessary (e.g. for open-sourcing).
- We have separate targets for various assets we need to run the tests (e.g. the hg test framework).
- The runner now controls whether to use the network blackhole. This was necessary because the network blackhole breaks PAR archives (because tmp is no longer owned by the right owner, because we use a user namespace). We should be able to bring this back at some point if we want to by using a proper chroot for opt tests.

I included a README to explain this new design as well.

There are some things that could yet stand to be improved here (notably, I think we should put assets and tests in different directories for the sake of clarity), but so far I've been aiming at providing a 1-1 translation of the old system into the new one. I am planning to make further improvements in followup diffs.

Reviewed By: farnz

Differential Revision: D15921732

fbshipit-source-id: 09052591c419acf97f7e360b1e88ef1f412da6e5
2019-06-25 08:41:31 -07:00

211 lines
4.5 KiB
Perl

$ . "${TEST_FIXTURES}/library.sh"
setup configuration
$ setup_mononoke_config "blob:sqlite"
$ cd $TESTTMP
setup common configuration
$ cat >> $HGRCPATH <<EOF
> [ui]
> ssh="$DUMMYSSH"
> EOF
setup repo
$ hg init repo-hg
Init treemanifest and remotefilelog
$ cd repo-hg
$ cat >> .hg/hgrc <<EOF
> [extensions]
> treemanifest=
> remotefilelog=
> [treemanifest]
> server=True
> [remotefilelog]
> server=True
> shallowtrees=True
> EOF
$ touch a
$ hg add a
$ hg ci -ma
$ hg log
changeset: 0:3903775176ed
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
(re)
$ cd $TESTTMP
setup repo2
$ cat >> $HGRCPATH <<EOF
> [extensions]
> remotefilelog=
> [remotefilelog]
> cachepath=$TESTTMP/cachepath
> EOF
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo2 --noupdate
$ cd repo2
$ hg pull
pulling from ssh://user@dummy/repo-hg
searching for changes
no changes found
$ cd $TESTTMP
$ cd repo-hg
$ touch b
$ hg add b
$ hg ci -mb
$ echo content > c
$ hg add c
$ hg ci -mc
$ mkdir dir
$ echo 1 > dir/1
$ mkdir dir2
$ echo 2 > dir/2
$ hg addremove
adding dir/1
adding dir/2
$ hg ci -m 'new directory'
$ echo cc > c
$ hg addremove
$ hg ci -m 'modify file'
$ hg mv dir/1 dir/rename
$ hg ci -m 'rename'
$ hg debugdrawdag <<'EOS'
> D # D/D=1\n2\n
> /| # B/D=1\n
> B C # C/D=2\n
> |/ # A/D=x\n
> A
> EOS
$ hg log --graph -T '{node|short} {desc}'
o e635b24c95f7 D
|\
| o d351044ef463 C
| |
o | 9a827afb7e25 B
|/
o af6aa0dfdf3d A
(re)
@ 28468743616e rename
|
o 329b10223740 modify file
|
o a42a44555d7c new directory
|
o 3e19bf519e9a c
|
o 0e067c57feba b
|
o 3903775176ed a
(re)
setup master bookmarks
$ hg bookmark master_bookmark -r e635b24c95f7
$ hg bookmark master_bookmark2 -r 28468743616e
blobimport
$ cd ..
$ blobimport repo-hg/.hg repo
start mononoke
$ mononoke
$ wait_for_mononoke $TESTTMP/repo
$ hgmn debugwireargs ssh://user@dummy/disabled_repo one two --three three
remote: * ERRO Requested repo "disabled_repo" does not exist or disabled (glob)
abort: no suitable response from remote hg!
[255]
$ hgmn debugwireargs ssh://user@dummy/repo one two --three three
one two three None None
$ cd repo2
$ hg up -q 0
Test a pull of one specific revision
$ hgmn pull -r 3e19bf519e9af6c66edf28380101a92122cbea50 -q
Pull the rest
$ hgmn pull -q
$ hg log -r '3903775176ed::329b10223740' --graph -T '{node|short} {desc}'
o 329b10223740 modify file
|
o a42a44555d7c new directory
|
o 3e19bf519e9a c
|
o 0e067c57feba b
|
@ 3903775176ed a
(re)
$ ls
a
$ hgmn up 28468743616e -q
$ ls
a
b
c
dir
$ cat c
cc
$ hgmn up 28468743616e -q
$ hg log c -T '{node|short} {desc}\n'
warning: file log can be slow on large repos - use -f to speed it up
329b10223740 modify file
3e19bf519e9a c
$ cat dir/rename
1
$ cat dir/2
2
$ hg log dir/rename -f -T '{node|short} {desc}\n'
28468743616e rename
a42a44555d7c new directory
$ hg st --change 28468743616e -C
A dir/rename
dir/1
R dir/1
$ hgmn up -q e635b24c95f7
Sort the output because it may be unpredictable because of the merge
$ hg log D --follow -T '{node|short} {desc}\n' | sort
9a827afb7e25 B
af6aa0dfdf3d A
d351044ef463 C
e635b24c95f7 D
Create a new bookmark and try and send it over the wire
Test commented while we have no bookmark support in blobimport or easy method
to create a fileblob bookmark
# $ cd ../repo
# $ hg bookmark test-bookmark
# $ hg bookmarks
# * test-bookmark 0:3903775176ed
# $ cd ../repo2
# $ hgmn pull ssh://user@dummy/repo
# pulling from ssh://user@dummy/repo
# searching for changes
# no changes found
# adding remote bookmark test-bookmark
# $ hg bookmarks
# test-bookmark 0:3903775176ed
Do a streaming clone of the repo
$ hgmn clone --stream ssh://user@dummy/repo repo-streamclone --config extensions.treemanifest= --config remotefilelog.reponame=master --shallow --config treemanifest.treeonly=true --config extensions.lz4revlog=
streaming all changes
2 files to transfer, * bytes of data (glob)
transferred * bytes in * seconds (* bytes/sec) (glob)
requesting all changes
adding changesets
adding manifests
adding file changes
added 10 changesets with 0 changes to 0 files (+1 heads)
new changesets * (glob)
updating to branch default
5 files updated, 0 files merged, 0 files removed, 0 files unresolved