From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: mhagger@alum.mit.edu, jrnieder@gmail.com, gitster@pobox.com,
ronniesahlberg@gmail.com, Stefan Beller <sbeller@google.com>
Subject: [PATCH 5/5] t5543-atomic-push.sh: add basic tests for atomic pushes
Date: Mon, 15 Dec 2014 11:56:08 -0800 [thread overview]
Message-ID: <1418673368-20785-6-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1418673368-20785-1-git-send-email-sbeller@google.com>
This adds tests for the atomic push option.
The first four tests check if the atomic option works in
good conditions and the last three patches check if the atomic
option prevents any change to be pushed if just one ref cannot
be updated.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Notes:
Originally Ronnie had a similar patch prepared. But as I added
more tests and cleaned up the existing tests (e.g. use test_commit
instead of "echo one >file && gitadd file && git commit -a -m 'one'",
removal of dead code), the file has changed so much that I'd rather
take ownership.
t/t5543-atomic-push.sh | 185 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 185 insertions(+)
create mode 100755 t/t5543-atomic-push.sh
diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh
new file mode 100755
index 0000000..6cbedc5
--- /dev/null
+++ b/t/t5543-atomic-push.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+
+test_description='pushing to a repository using the atomic push option'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+mk_repo_pair () {
+ rm -rf workbench upstream thirdparty &&
+ mkdir upstream &&
+ (
+ cd upstream &&
+ git init --bare #&&
+ #git config receive.denyCurrentBranch warn
+ ) &&
+ mkdir workbench &&
+ (
+ cd workbench &&
+ git init &&
+ git remote add up ../upstream
+ )
+}
+
+test_push_failed () {
+ workbench_master=$(cd workbench && git show-ref -s --verify refs/heads/master) &&
+ upstream_master=$(cd upstream && git show-ref -s --verify refs/heads/master) &&
+ test "$workbench_master" != "$upstream_master" &&
+
+ workbench_second=$(cd workbench && git show-ref -s --verify refs/heads/second) &&
+ upstream_second=$(cd upstream && git show-ref -s --verify refs/heads/second) &&
+ test "$workbench_second" != "$upstream_second"
+}
+
+test_push_succeeded () {
+ workbench_master=$(cd workbench && git show-ref -s --verify refs/heads/master) &&
+ upstream_master=$(cd upstream && git show-ref -s --verify refs/heads/master) &&
+ test "$workbench_master" = "$upstream_master"
+
+ workbench_second=$(cd workbench && git show-ref -s --verify refs/heads/second) &&
+ upstream_second=$(cd upstream && git show-ref -s --verify refs/heads/second) &&
+ test "$workbench_second" = "$upstream_second"
+}
+
+test_expect_success 'atomic push works for a single branch' '
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git push --mirror up &&
+ test_commit two &&
+ git push --atomic-push --mirror up
+ ) &&
+ workbench_master=$(cd workbench && git show-ref -s --verify refs/heads/master) &&
+ upstream_master=$(cd upstream && git show-ref -s --verify refs/heads/master) &&
+ test "$workbench_master" = "$upstream_master"
+'
+
+test_expect_success 'atomic push works for two branches' '
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git branch second &&
+ git push --mirror up &&
+ test_commit two &&
+ git checkout second &&
+ test_commit three &&
+ git push --atomic-push --mirror up
+ ) &&
+ test_push_succeeded
+'
+
+test_expect_success 'atomic push works in combination with --mirror' '
+ mk_repo_pair &&
+ ls workbench &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git checkout -b second &&
+ test_commit two &&
+ git push --atomic-push --mirror up
+ ) &&
+ test_push_succeeded
+'
+
+test_expect_success 'atomic push works in combination with --force' '
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git checkout -b second &&
+ test_commit two &&
+ test_commit three &&
+ test_commit four &&
+ git push --mirror up &&
+ git reset --hard HEAD^ &&
+ git push --force --atomic-push up master second
+ ) &&
+ test_push_succeeded
+'
+
+# set up two branches where master can be pushed but second can not
+# (non-fast-forward). Since second can not be pushed the whole operation
+# will fail and leave master untouched.
+test_expect_success 'atomic push fails if one branch fails locally' '
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git checkout -b second master &&
+ test_commit two &&
+ test_commit three &&
+ test_commit four &&
+ git push --mirror up
+ git reset --hard HEAD~2 &&
+ git checkout master &&
+ test_commit five &&
+ ! git push --atomic-push --all up
+ ) &&
+ test_push_failed
+'
+
+test_expect_success 'atomic push fails if one branch fails remotely' '
+ # prepare the repo
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git checkout -b second master &&
+ test_commit two &&
+ git push --mirror up
+ ) &&
+ # a third party modifies the server side:
+ (
+ git clone upstream thirdparty &&
+ cd thirdparty
+ git checkout second
+ test_commit unrelated_changes &&
+ git push origin second
+ ) &&
+ # see if we can now push both branches.
+ (
+ cd workbench &&
+ git checkout master &&
+ test_commit three &&
+ git checkout second &&
+ test_commit four &&
+ ! git push --atomic-push up master second
+ ) &&
+ test_push_failed
+'
+
+test_expect_success 'atomic push fails if one tag fails remotely' '
+ # prepare the repo
+ mk_repo_pair &&
+ (
+ cd workbench &&
+ test_commit one &&
+ git checkout -b second master &&
+ test_commit two &&
+ git push --mirror up
+ ) &&
+ # a third party modifies the server side:
+ (
+ git clone upstream thirdparty &&
+ cd thirdparty
+ git checkout second
+ git tag test_tag &&
+ git push --tags origin second
+ ) &&
+ # see if we can now push both branches.
+ (
+ cd workbench &&
+ git checkout master &&
+ test_commit three &&
+ git checkout second &&
+ test_commit four &&
+ git tag test_tag &&
+ ! git push --tags --atomic-push up master second
+ ) &&
+ test_push_failed
+'
+
+test_done
--
2.2.0.33.gc2219e3.dirty
next prev parent reply other threads:[~2014-12-15 19:56 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-15 19:56 [PATCH 0/5] Add a flag to push atomically Stefan Beller
2014-12-15 19:56 ` [PATCH 1/5] receive-pack.c: add protocol support to negotiate atomic-push Stefan Beller
2014-12-15 20:53 ` Junio C Hamano
2014-12-15 22:30 ` Stefan Beller
2014-12-15 19:56 ` [PATCH 2/5] send-pack.c: add an --atomic-push command line argument Stefan Beller
2014-12-15 21:01 ` Junio C Hamano
2014-12-15 19:56 ` [PATCH 3/5] receive-pack.c: use a single ref_transaction for atomic pushes Stefan Beller
2014-12-15 21:37 ` Junio C Hamano
2014-12-15 19:56 ` [PATCH 4/5] push.c: add an --atomic-push argument Stefan Beller
2014-12-15 21:50 ` Junio C Hamano
2014-12-15 19:56 ` Stefan Beller [this message]
2014-12-15 22:29 ` [PATCH 5/5] t5543-atomic-push.sh: add basic tests for atomic pushes Junio C Hamano
2014-12-15 22:33 ` [PATCH 0/5] Add a flag to push atomically Junio C Hamano
2014-12-16 18:49 ` [PATCHv2 1/6] receive-pack.c: add protocol support to negotiate atomic-push Stefan Beller
2014-12-16 18:49 ` [PATCHv2 2/6] send-pack: Invert the return value of ref_update_to_be_sent Stefan Beller
2014-12-16 19:14 ` Junio C Hamano
2014-12-16 18:49 ` [PATCHv2 3/6] send-pack.c: add --atomic command line argument Stefan Beller
2014-12-16 19:31 ` Junio C Hamano
2014-12-16 18:49 ` [PATCHv2 4/6] receive-pack.c: use a single ref_transaction for atomic pushes Stefan Beller
2014-12-16 19:29 ` Eric Sunshine
2014-12-16 20:30 ` Eric Sunshine
2014-12-16 19:35 ` Junio C Hamano
2014-12-16 18:49 ` [PATCHv2 5/6] push.c: add an --atomic-push argument Stefan Beller
2014-12-16 19:33 ` Eric Sunshine
2014-12-16 20:43 ` Junio C Hamano
2014-12-16 19:36 ` Junio C Hamano
2014-12-16 18:49 ` [PATCHv2 6/6] t5543-atomic-push.sh: add basic tests for atomic pushes Stefan Beller
2014-12-16 19:14 ` [PATCH] receive-pack: refuse all commands if one fails in atomic mode Stefan Beller
2014-12-16 20:32 ` Junio C Hamano
2014-12-16 19:37 ` [PATCHv2 6/6] t5543-atomic-push.sh: add basic tests for atomic pushes Eric Sunshine
2014-12-16 19:46 ` Junio C Hamano
2014-12-16 19:57 ` Stefan Beller
2014-12-16 20:46 ` Junio C Hamano
2014-12-16 20:51 ` Stefan Beller
2014-12-16 20:30 ` Junio C Hamano
2014-12-16 20:36 ` Stefan Beller
2014-12-16 19:05 ` [PATCHv2 1/6] receive-pack.c: add protocol support to negotiate atomic-push Junio C Hamano
2014-12-17 18:32 ` [PATCHv3 0/6] atomic pushes Stefan Beller
2014-12-17 18:32 ` [PATCHv3 1/6] receive-pack.c: add protocol support to negotiate atomic Stefan Beller
2014-12-19 1:05 ` Eric Sunshine
2014-12-17 18:32 ` [PATCHv3 2/6] send-pack: Rename ref_update_to_be_sent to check_to_send_update Stefan Beller
2014-12-17 22:53 ` Junio C Hamano
2014-12-17 18:32 ` [PATCHv3 3/6] send-pack.c: add --atomic command line argument Stefan Beller
2014-12-17 23:14 ` Junio C Hamano
2014-12-19 1:22 ` Eric Sunshine
2014-12-17 18:32 ` [PATCHv3 4/6] receive-pack.c: use a single ref_transaction for atomic pushes Stefan Beller
2014-12-17 23:26 ` Junio C Hamano
2014-12-17 23:58 ` Stefan Beller
2014-12-18 17:02 ` Junio C Hamano
2014-12-18 17:45 ` [PATCHv4 " Stefan Beller
2014-12-18 22:26 ` Eric Sunshine
2014-12-19 0:22 ` [PATCHv5 " Stefan Beller
2014-12-19 10:14 ` Eric Sunshine
2014-12-17 18:32 ` [PATCHv3 5/6] push.c: add an --atomic argument Stefan Beller
2014-12-19 1:29 ` Eric Sunshine
2014-12-17 18:32 ` [PATCHv3 6/6] t5543-atomic-push.sh: add basic tests for atomic pushes Stefan Beller
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=1418673368-20785-6-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=mhagger@alum.mit.edu \
--cc=ronniesahlberg@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).