mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 10:56:49 +00:00
Run integration tests both with and without HTTP storage protocol.
This commit is contained in:
parent
bb053c714a
commit
add510701c
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -229,7 +229,11 @@ jobs:
|
||||
# aren't too long. On Windows tox won't pass it through so it has no
|
||||
# effect. On Linux it doesn't make a difference one way or another.
|
||||
TMPDIR: "/tmp"
|
||||
run: tox -e integration
|
||||
run: |
|
||||
# Run with Foolscap forced:
|
||||
__TAHOE_INTEGRATION_FORCE_FOOLSCAP=1 tox -e integration
|
||||
# Run with Foolscap not forced, which should result in HTTP being used.
|
||||
__TAHOE_INTEGRATION_FORCE_FOOLSCAP=0 tox -e integration
|
||||
|
||||
- name: Upload eliot.log in case of failure
|
||||
uses: actions/upload-artifact@v1
|
||||
|
@ -1,14 +1,6 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
import sys
|
||||
import time
|
||||
@ -38,6 +30,7 @@ from allmydata.util.configutil import (
|
||||
write_config,
|
||||
)
|
||||
from allmydata import client
|
||||
from allmydata.testing import foolscap_only_for_integration_testing
|
||||
|
||||
import pytest_twisted
|
||||
|
||||
@ -300,6 +293,14 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
||||
u'log_gatherer.furl',
|
||||
flog_gatherer,
|
||||
)
|
||||
force_foolscap = foolscap_only_for_integration_testing()
|
||||
if force_foolscap is not None:
|
||||
set_config(
|
||||
config,
|
||||
'storage',
|
||||
'force_foolscap',
|
||||
str(force_foolscap),
|
||||
)
|
||||
write_config(FilePath(config_path), config)
|
||||
created_d.addCallback(created)
|
||||
|
||||
|
0
newsfragments/3937.minor
Normal file
0
newsfragments/3937.minor
Normal file
@ -30,6 +30,7 @@ from foolscap.api import Tub
|
||||
|
||||
from .storage.http_server import HTTPServer, build_nurl
|
||||
from .storage.server import StorageServer
|
||||
from .testing import foolscap_only_for_integration_testing
|
||||
|
||||
|
||||
class _PretendToBeNegotiation(type):
|
||||
@ -170,6 +171,21 @@ class _FoolscapOrHttps(Protocol, metaclass=_PretendToBeNegotiation):
|
||||
# and later data, otherwise assume HTTPS.
|
||||
self._timeout.cancel()
|
||||
if self._buffer.startswith(b"GET /id/"):
|
||||
if foolscap_only_for_integration_testing() == False:
|
||||
# Tahoe will prefer HTTP storage protocol over Foolscap when possible.
|
||||
#
|
||||
# If this is branch is taken, we are running a test that should
|
||||
# be using HTTP for the storage protocol. As such, we
|
||||
# aggressively disable Foolscap to ensure that HTTP is in fact
|
||||
# going to be used. If we hit this branch that means our
|
||||
# expectation that HTTP will be used was wrong, suggesting a
|
||||
# bug in either the code of the integration testing setup.
|
||||
#
|
||||
# This branch should never be hit in production!
|
||||
self.transport.loseConnection()
|
||||
print("FOOLSCAP IS DISABLED, I PITY THE FOOLS WHO SEE THIS MESSAGE")
|
||||
return
|
||||
|
||||
# We're a Foolscap Negotiation server protocol instance:
|
||||
transport = self.transport
|
||||
buf = self._buffer
|
||||
|
@ -0,0 +1,18 @@
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def foolscap_only_for_integration_testing() -> Optional[bool]:
|
||||
"""
|
||||
Return whether HTTP storage protocol has been disabled / Foolscap
|
||||
forced, for purposes of integration testing.
|
||||
|
||||
This is determined by the __TAHOE_INTEGRATION_FORCE_FOOLSCAP environment
|
||||
variable, which can be 1, 0, or not set, corresponding to results of
|
||||
``True``, ``False`` and ``None`` (i.e. default).
|
||||
"""
|
||||
force_foolscap = os.environ.get("__TAHOE_INTEGRATION_FORCE_FOOLSCAP")
|
||||
if force_foolscap is None:
|
||||
return None
|
||||
|
||||
return bool(int(force_foolscap))
|
Loading…
x
Reference in New Issue
Block a user