Patchwork [2,of,2,RFC] test-lfs-test-server: add a testcase for `hg serve`

login
register
mail settings
Submitter Matt Harbison
Date Feb. 18, 2018, 7:15 a.m.
Message ID <253cb78bcfe06c3cefc7.1518938132@Envy>
Download mbox | patch
Permalink /patch/28060/
State New
Headers show

Comments

Matt Harbison - Feb. 18, 2018, 7:15 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1518937262 18000
#      Sun Feb 18 02:01:02 2018 -0500
# Node ID 253cb78bcfe06c3cefc7a675e08024e970e501d1
# Parent  ba2e8627d87cfaca00931fe2dcee738c3c9a4f9d
test-lfs-test-server: add a testcase for `hg serve`

The output for the corruption variance previously mentioned around line 157 has
been conditionalized, so this should run cleanly.

Patch

diff --git a/tests/test-lfs-test-server.t b/tests/test-lfs-test-server.t
--- a/tests/test-lfs-test-server.t
+++ b/tests/test-lfs-test-server.t
@@ -1,13 +1,27 @@ 
+#testcases git-server hg-server
+
+#if git-server
 #require lfs-test-server
+#else
+#require serve
+#endif
 
+#if git-server
   $ LFS_LISTEN="tcp://:$HGPORT"
   $ LFS_HOST="localhost:$HGPORT"
   $ LFS_PUBLIC=1
   $ export LFS_LISTEN LFS_HOST LFS_PUBLIC
-#if no-windows
+#else
+  $ LFS_HOST="localhost:$HGPORT/.git/info/lfs"
+#endif
+
+#if no-windows git-server
   $ lfs-test-server &> lfs-server.log &
   $ echo $! >> $DAEMON_PIDS
-#else
+#endif
+
+#if windows git-server
+.#else
   $ cat >> $TESTTMP/spawn.py <<EOF
   > import os
   > import subprocess
@@ -29,10 +43,20 @@ 
   > [extensions]
   > lfs=
   > [lfs]
-  > url=http://foo:bar@$LFS_HOST/
+  > url=http://foo:bar@$LFS_HOST
   > track=all()
   > EOF
 
+Use a separate usercache, otherwise the server sees what the client commits, and
+never requests a transfer.
+
+#if hg-server
+  $ hg init server
+  $ hg --config "lfs.usercache=$TESTTMP/servercache" -R server serve -d \
+  >    -p $HGPORT --pid-file=hg.pid -A $TESTTMP/access.log -E $TESTTMP/errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+#endif
+
   $ hg init repo1
   $ cd repo1
   $ echo THIS-IS-LFS > a
@@ -117,15 +141,21 @@ 
 Test a corrupt file download, but clear the cache first to force a download.
 
   $ rm -rf `hg config lfs.usercache`
+#if git-server
   $ cp $TESTTMP/lfs-content/d1/1e/1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 blob
   $ echo 'damage' > $TESTTMP/lfs-content/d1/1e/1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+#else
+  $ cp $TESTTMP/server/.hg/store/lfs/objects/d1/1e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 blob
+  $ echo 'damage' > $TESTTMP/server/.hg/store/lfs/objects/d1/1e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+#endif
   $ rm ../repo1/.hg/store/lfs/objects/d1/1e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
   $ rm ../repo1/*
 
   $ hg --repo ../repo1 update -C tip -v
   resolving manifests
   lfs: downloading d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes)
-  abort: corrupt remote lfs object: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+  abort: corrupt remote lfs object: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (git-server !)
+  abort: HTTP error: HTTP Error 500: Internal Server Error (oid=d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998, action=download)! (hg-server !)
   [255]
 
 The corrupted blob is not added to the usercache or local store
@@ -134,7 +164,11 @@ 
   [1]
   $ test -f `hg config lfs.usercache`/d1/1e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
   [1]
+#if git-server
   $ cp blob $TESTTMP/lfs-content/d1/1e/1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+#else
+  $ cp blob $TESTTMP/server/.hg/store/lfs/objects/d1/1e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+#endif
 
 Test a corrupted file upload
 
@@ -254,16 +288,30 @@ 
 (Restart the server in a different location so it no longer has the content)
 
   $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
+
+#if hg-server
+.  $ cat $TESTTMP/access.log $TESTTMP/errors.log
+#endif
+
   $ rm $DAEMON_PIDS
   $ mkdir $TESTTMP/lfs-server2
   $ cd $TESTTMP/lfs-server2
-#if no-windows
+#if no-windows git-server
   $ lfs-test-server &> lfs-server.log &
   $ echo $! >> $DAEMON_PIDS
-#else
+#endif
+
+#if windows git-server
   $ $PYTHON $TESTTMP/spawn.py >> $DAEMON_PIDS
 #endif
 
+#if hg-server
+  $ hg init server2
+  $ hg --config "lfs.usercache=$TESTTMP/servercache2" -R server2 serve -d \
+  >    -p $HGPORT --pid-file=hg.pid -A $TESTTMP/access.log -E $TESTTMP/errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+#endif
+
   $ cd $TESTTMP
   $ hg clone test test2
   updating to branch default