Commit Graph

11 Commits

Author SHA1 Message Date
Augie Fackler
e5d7bd82c5 cleanup: use $PYTHON to run python in many more tests
Spotted one of these, then wrote a check-code rule that caught them
all. It will be the next change.
2017-06-20 09:45:02 -04:00
Jun Wu
7bdcbacb01 tests: use LOCALIP
This patch replaces hardcoded 127.0.0.1 with $LOCALIP in all tests.

Till now, the IPv6 series should make tests pass on common IPv6 systems
where the local device has the address "::1" and the hostname "localhost"
resolves to "::1".
2017-02-16 09:38:52 -08:00
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
timeless
912b0a1260 py3: use absolute_import in test-hgweb-non-interactive.t 2016-04-10 21:32:05 +00:00
Gregory Szorc
4e3c6d9b7a hgweb: consume generator inside context manager (issue4756)
If code inside a context manager returns a generator, the context
manager exits before the generator is iterated.

hgweb was using a context manager to control thread safe access to a
localrepository instance. But it was returning a generator, so there was
a race condition between a previous request streaming a response to the
client and a new request obtaining the released but in use repository.
By iterating the generator inside the context manager, we ensure we
don't release the repo instance until after the response has finished.

With this change, hgweb finally appears to have full localrepository
isolation between threads. I can no longer reproduce the 2 exceptions
reported in issue4756.

test-hgweb-non-interactive.t has been modified to consume the output
of calling into a WSGI application. Without this, execution of the WSGI
application stalls because of the added yield statement.
2015-09-12 12:16:39 -07:00
Gregory Szorc
39247b40e9 hgweb: use separate repo instances per thread
Before this change, multiple threads/requests could share a
localrepository instance. This meant that all of localrepository needed
to be thread safe. Many bugs have been reported telling us that
localrepository isn't actually thread safe.

While making localrepository thread safe is a noble cause, it is a lot
of work. And there is little gain from doing so. Due to Python's GIL,
only 1 thread may be processing Python code at a time. The benefits
to multi-threaded servers are marginal.

Thread safety would be a lot of work for little gain. So, we're not
going to even attempt it.

This patch establishes a pool of repos in hgweb. When a request arrives,
we obtain the most recently used repository from the pool or create a
new one if none is available. When the request has finished, we put that
repo back in the pool.

We start with a pool size of 1. For servers using a single thread, the
pool will only ever be of size 1. For multi-threaded servers, the pool
size will grow to the max number of simultaneous requests the server
processes.

No logic for pruning the pool has been implemented. We assume server
operators either limit the number of threads to something they can
handle or restart the Mercurial process after a certain amount of
requests or time has passed.
2015-08-22 18:43:24 -07:00
Gregory Szorc
83818c1fca hg: establish a cache for localrepository instances
hgweb contained code for determining whether a cached localrepository
instance was up to date. This code was way too low-level to be in
hgweb.

This functionality has been moved to a new "cachedlocalrepo" class
in hg.py. The code has been changed slightly to facilitate use
inside a class. hgweb has been refactored to use the new API.

As part of this refactor, hgweb.repo no longer exists! We're very close
to using a distinct repo instance per thread.

The new cache records state when it is created. This intelligence
prevents an extra localrepository from being created on the first
hgweb request. This is why some redundant output from test-extension.t
has gone away.
2015-08-22 18:54:34 -07:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Martin Geisler
5a0135a6ca tests: remove redundant mkdir
There are still many tests that check that a bare 'hg init'
initializes the current directory.
2011-04-19 12:04:44 +02:00
Adrian Buehlmann
758fc721d8 check-code: add 'no tab indent' check for unified tests
and fix the offending tests accordingly
2010-10-16 18:09:01 +02:00
Matt Mackall
aa59a56f47 tests: unify test-hgweb-non-interactive 2010-09-26 13:41:32 -05:00