mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
simplecache: don't use memcache in tests
Summary: The simplecache test attempts to connect to a memcache instance on localhost. This means the test fails if a memcache instance is not available. Remove the use of memcache in the test. We still test local files, and assume that memcache itself works. Also corrupt the correct key when testing corruption handling, and document the config options. Reviewed By: quark-zju Differential Revision: D13818471 fbshipit-source-id: 6ca7f575aa813f95773144be5337796f029ffd90
This commit is contained in:
parent
ae0a81f2c2
commit
b44e2103d7
@ -14,10 +14,23 @@ Currently we cache the full results of these functions:
|
||||
copies.pathcopies (a dictionary)
|
||||
context.basectx._buildstatus (a scmutil.status object -- a tuple of lists)
|
||||
|
||||
You can disable its debug statements (defaults to 'on' except in tests)::
|
||||
Config::
|
||||
|
||||
[simplecache]
|
||||
# enable debug statements (defaults to 'on' except during tests)
|
||||
showdebug = False
|
||||
|
||||
# list of caches to enable ('local' or 'memcache')
|
||||
caches = local
|
||||
|
||||
# path for local cache files
|
||||
cachedir = ~/.hgsimplecache
|
||||
|
||||
# memcache host
|
||||
host = localhost
|
||||
|
||||
# memcache port
|
||||
port = 11101
|
||||
"""
|
||||
|
||||
import json
|
||||
|
@ -149,8 +149,6 @@ New errors are not allowed. Warnings are strongly discouraged.
|
||||
undocumented: remotenames.transitionmessage (str)
|
||||
undocumented: remotenames.upstream (list)
|
||||
undocumented: server.requireexplicitfullclone (bool)
|
||||
undocumented: simplecache.cachedir (str)
|
||||
undocumented: simplecache.caches (list) [["local"]]
|
||||
undocumented: smartlog.ignorebookmarks (str) ["!"]
|
||||
undocumented: ssl.timeout (int) [5]
|
||||
undocumented: treemanifest.verifyautocreate (bool)
|
||||
|
@ -8,8 +8,6 @@ Setup the extension
|
||||
> [simplecache]
|
||||
> showdebug=true
|
||||
> cachedir=$TESTTMP/hgsimplecache
|
||||
> caches=memcache
|
||||
> local
|
||||
> EOF
|
||||
|
||||
Initialize the repo
|
||||
@ -30,8 +28,6 @@ Initialize the repo
|
||||
$ hg book foo
|
||||
|
||||
Test that output remains the same with multiple invocations.
|
||||
$ printf "delete cca.hg.buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1\r\n" | nc localhost 11101
|
||||
* (glob)
|
||||
$ hg --debug export
|
||||
exporting patch:
|
||||
# HG changeset patch
|
||||
@ -42,10 +38,8 @@ Test that output remains the same with multiple invocations.
|
||||
# Parent b292c1e3311fd0f13ae83b409caae4a6d1fb348c
|
||||
xx
|
||||
|
||||
no value found for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
no value found for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
falling back for value buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1
|
||||
set value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 to memcache
|
||||
set value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 to local
|
||||
diff -r b292c1e3311fd0f13ae83b409caae4a6d1fb348c -r a5d935fe38ada2b984c29e4e02bffd7f19bf818d x
|
||||
--- a/x Thu Jan 01 00:00:00 1970 +0000
|
||||
@ -68,7 +62,7 @@ Test that output remains the same with multiple invocations.
|
||||
# Parent b292c1e3311fd0f13ae83b409caae4a6d1fb348c
|
||||
xx
|
||||
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
diff -r b292c1e3311fd0f13ae83b409caae4a6d1fb348c -r a5d935fe38ada2b984c29e4e02bffd7f19bf818d x
|
||||
--- a/x Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
@ -81,8 +75,8 @@ Test that output remains the same with multiple invocations.
|
||||
+x
|
||||
+x
|
||||
$ hg --debug log -vpC -r .
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
changeset: 1:a5d935fe38ada2b984c29e4e02bffd7f19bf818d
|
||||
bookmark: foo
|
||||
tag: tip
|
||||
@ -136,30 +130,6 @@ Test that output remains the same with multiple invocations.
|
||||
+x
|
||||
|
||||
|
||||
Test that localcache gets hit if memcache is off
|
||||
$ hg --debug --config simplecache.caches=local export
|
||||
exporting patch:
|
||||
# HG changeset patch
|
||||
# User test
|
||||
# Date 0 0
|
||||
# Thu Jan 01 00:00:00 1970 +0000
|
||||
# Node ID a5d935fe38ada2b984c29e4e02bffd7f19bf818d
|
||||
# Parent b292c1e3311fd0f13ae83b409caae4a6d1fb348c
|
||||
xx
|
||||
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
diff -r b292c1e3311fd0f13ae83b409caae4a6d1fb348c -r a5d935fe38ada2b984c29e4e02bffd7f19bf818d x
|
||||
--- a/x Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
@@ -1,1 +0,0 @@
|
||||
-x
|
||||
diff -r b292c1e3311fd0f13ae83b409caae4a6d1fb348c -r a5d935fe38ada2b984c29e4e02bffd7f19bf818d y
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/y Thu Jan 01 00:00:00 1970 +0000
|
||||
@@ -0,0 +1,2 @@
|
||||
+x
|
||||
+x
|
||||
|
||||
Test that disabling the cache entirely doesn't break things
|
||||
$ hg --debug --config simplecache.caches= export
|
||||
exporting patch:
|
||||
@ -185,11 +155,14 @@ Test that disabling the cache entirely doesn't break things
|
||||
+x
|
||||
|
||||
Test that corrupt caches are gracefully ignored, and updated
|
||||
$ printf "set cca.hg.buildstatus:0632994590a85631ac9ce1a256862a1683a3ce56:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 0 0 5\r\nhello\r\n" | nc localhost 11101
|
||||
STORED\r (esc)
|
||||
$ printf "hello" > "$TESTTMP/hgsimplecache/buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1"
|
||||
$ hg --debug log -vpC -r .
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from memcache
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
error getting or deserializing key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1: No JSON object could be decoded
|
||||
no value found for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
falling back for value buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1
|
||||
set value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 to local
|
||||
got value for key buildstatus:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:b292c1e3311fd0f13ae83b409caae4a6d1fb348c:v1 from local
|
||||
changeset: 1:a5d935fe38ada2b984c29e4e02bffd7f19bf818d
|
||||
bookmark: foo
|
||||
tag: tip
|
||||
@ -236,10 +209,8 @@ Test strange (unicode) filenames
|
||||
# Parent a5d935fe38ada2b984c29e4e02bffd7f19bf818d
|
||||
unicode test
|
||||
|
||||
no value found for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from memcache
|
||||
no value found for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from local
|
||||
falling back for value buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1
|
||||
set value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 to memcache
|
||||
set value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 to local
|
||||
diff -r a5d935fe38ada2b984c29e4e02bffd7f19bf818d -r f3a143469693894d291b7388ea8392a07492751f \xc3\x85 (esc)
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
@ -247,8 +218,8 @@ Test strange (unicode) filenames
|
||||
@@ -0,0 +1,1 @@
|
||||
+x
|
||||
$ hg --debug log -vpC -r .
|
||||
got value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from memcache
|
||||
got value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from memcache
|
||||
got value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from local
|
||||
got value for key buildstatus:f3a143469693894d291b7388ea8392a07492751f:a5d935fe38ada2b984c29e4e02bffd7f19bf818d:v1 from local
|
||||
changeset: 2:f3a143469693894d291b7388ea8392a07492751f
|
||||
bookmark: foo
|
||||
tag: tip
|
||||
@ -271,11 +242,6 @@ Test strange (unicode) filenames
|
||||
+x
|
||||
|
||||
Test local cache eviction
|
||||
$ cat >> $HGRCPATH <<EOF
|
||||
> [simplecache]
|
||||
> showdebug=true
|
||||
> caches=local
|
||||
> EOF
|
||||
$ echo 'x' >> y && hg commit -qm "1" && hg export --debug > /dev/null
|
||||
$ echo 'x' >> y && hg commit -qm "2" && hg export --debug > /dev/null
|
||||
$ echo 'x' >> y && hg commit -qm "3" && hg export --debug > /dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user