All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Hostetler <git@jeffhostetler.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, jonathantanmy@google.com,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH v6 14/14] t5616: end-to-end tests for partial clone
Date: Tue,  5 Dec 2017 17:02:54 +0000	[thread overview]
Message-ID: <20171205170254.65293-15-git@jeffhostetler.com> (raw)
In-Reply-To: <20171205170254.65293-1-git@jeffhostetler.com>

From: Jeff Hostetler <jeffhost@microsoft.com>

Additional end-to-end tests for partial clone.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 t/t5616-partial-clone.sh | 125 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)
 create mode 100755 t/t5616-partial-clone.sh

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
new file mode 100755
index 0000000..fa573f8
--- /dev/null
+++ b/t/t5616-partial-clone.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+test_description='git partial clone'
+
+. ./test-lib.sh
+
+# create a normal "src" repo where we can later create new commits.
+# expect_1.oids will contain a list of the OIDs of all blobs.
+test_expect_success 'setup normal src repo' '
+	echo "{print \$1}" >print_1.awk &&
+	echo "{print \$2}" >print_2.awk &&
+
+	git init src &&
+	for n in 1 2 3 4
+	do
+		echo "This is file: $n" > src/file.$n.txt
+		git -C src add file.$n.txt
+		git -C src commit -m "file $n"
+		git -C src ls-files -s file.$n.txt >>temp
+	done &&
+	awk -f print_2.awk <temp | sort >expect_1.oids &&
+	test "$(wc -l <expect_1.oids)" = "4"
+'
+
+# bare clone "src" giving "srv.bare" for use as our server.
+test_expect_success 'setup bare clone for server' '
+	git clone --bare "file://$(pwd)/src" srv.bare &&
+	git -C srv.bare config --local uploadpack.allowfilter 1 &&
+	git -C srv.bare config --local uploadpack.allowanysha1inwant 1
+'
+
+# do basic partial clone from "srv.bare"
+# confirm we are missing all of the known blobs.
+# confirm partial clone was registered in the local config.
+test_expect_success 'do partial clone 1' '
+	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
+		| awk -f print_1.awk \
+		| sed "s/?//" \
+		| sort >observed.oids &&
+	test_cmp expect_1.oids observed.oids &&
+	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
+	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
+	test "$(git -C pc1 config --local core.partialclonefilter)" = "blob:none"
+'
+
+# checkout master to force dynamic object fetch of blobs at HEAD.
+# confirm we now have the expected blobs in a new packfile.
+test_expect_success 'verify checkout with dynamic object fetch' '
+	git -C pc1 checkout master &&
+	(	cd pc1/.git/objects/pack;
+		git verify-pack -v *.pack
+	) >temp &&
+	grep blob <temp \
+		| awk -f print_1.awk \
+		| sort >observed.oids &&
+	test_cmp expect_1.oids observed.oids
+'
+
+# create new commits in "src" repo and push to "srv.bare".
+# repack srv.bare just to make it easy to count the blobs.
+# expect_2.oids will contain a list of the OIDs of all blobs.
+test_expect_success 'push new commits to server' '
+	git -C src remote add srv "file://$(pwd)/srv.bare" &&
+	for x in a b c d
+	do
+		echo "Mod $x" >>src/file.1.txt
+		git -C src add file.1.txt
+		git -C src commit -m "mod $x"
+	done &&
+	git -C src push -u srv master &&
+	git -C srv.bare repack &&
+	(	cd srv.bare/objects/pack;
+		git verify-pack -v *.pack
+	) >temp &&
+	grep blob <temp \
+		| awk -f print_1.awk \
+		| sort >expect_2.oids &&
+	test "$(wc -l <expect_2.oids)" = "8" &&
+	git -C src blame master -- file.1.txt >expect.blame
+'
+
+# fetch in the partial clone repo from the server (the promisor remote).
+# verify that fetch was a "partial fetch".
+# [] that it inherited the filter settings
+# [] that is DOES NOT have the new blobs.
+test_expect_success 'partial fetch inherits filter settings' '
+	git -C pc1 fetch origin &&
+	(	cd pc1/.git/objects/pack;
+		git verify-pack -v *.pack
+	) >temp &&
+	grep blob <temp \
+		| awk -f print_1.awk \
+		| sort >observed.oids &&
+	test_cmp expect_1.oids observed.oids
+'
+
+# force dynamic object fetch using diff.
+# we should only get 1 new blob (for the file in origin/master).
+# it should be in a new packfile (since the promisor boundary is
+# currently a packfile, it should not get unpacked upon receipt.)
+test_expect_success 'verify diff causes dynamic object fetch' '
+	test "$(wc -l <observed.oids)" = "4" &&
+		cat observed.oids &&
+	git -C pc1 diff master..origin/master -- file.1.txt &&
+	(	cd pc1/.git/objects/pack;
+		git verify-pack -v *.pack
+	) >temp &&
+	grep blob <temp \
+		| awk -f print_1.awk \
+		| sort >observed.oids &&
+		cat observed.oids &&
+	test "$(wc -l <observed.oids)" = "4"
+'
+
+# force dynamic object fetch using blame.
+# we should get the intermediate blobs for the file.
+# we may get multiple packfiles (one for each blob/commit) or
+# we may get a single new packfile, but we don't care.
+test_expect_success 'verify blame causes dynamic object fetch' '
+	git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
+	test_cmp expect.blame observed.blame
+'
+
+test_done
-- 
2.9.3


      parent reply	other threads:[~2017-12-05 17:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 17:02 [PATCH v6 00/14] Parial clone part 3: clone, fetch, fetch-pack, upload-pack, and tests Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 01/14] upload-pack: add object filtering for partial clone Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 02/14] fetch-pack, index-pack, transport: " Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 03/14] fetch-pack: add --no-filter Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 04/14] fetch-pack: test support excluding large blobs Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 05/14] fetch: refactor calculation of remote list Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 06/14] fetch: support filters Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 07/14] fixup: fetch: update error messages from --blob-max-bytes to --filter Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 08/14] fixup: fetch: update --blob-max-bytes to --fitler Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 09/14] fixup: connected: conditionally pass --exclude-promisor-objects to rev-list Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 10/14] partial-clone: define partial clone settings in config Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 11/14] clone: partial clone Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 12/14] unpack-trees: batch fetching of missing blobs Jeff Hostetler
2017-12-05 17:02 ` [PATCH v6 13/14] fetch-pack: restore save_commit_buffer after use Jeff Hostetler
2017-12-05 17:02 ` Jeff Hostetler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171205170254.65293-15-git@jeffhostetler.com \
    --to=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.