Commit 47b8cf4f authored by Jérome Perrin's avatar Jérome Perrin

ERP5 wip

parent 0c9b98ea
......@@ -62,8 +62,8 @@ class CaucaseService(ManagedResource):
# type: () -> None
# start a caucased and server certificate.
software_release_root_path = os.path.join(
self._cls.slap._software_root,
hashlib.md5(self._cls.getSoftwareURL().encode()).hexdigest(),
self._cls.slap._software_root,
hashlib.md5(self._cls.getSoftwareURL().encode()).hexdigest(),
)
caucased_path = os.path.join(software_release_root_path, 'bin', 'caucased')
......@@ -76,15 +76,15 @@ class CaucaseService(ManagedResource):
backend_caucased_netloc = '%s:%s' % (self._cls._ipv4_address, findFreeTCPPort(self._cls._ipv4_address))
self.url = 'http://' + backend_caucased_netloc
self._caucased_process = subprocess.Popen(
[
caucased_path,
'--db', os.path.join(caucased_dir, 'caucase.sqlite'),
'--server-key', os.path.join(caucased_dir, 'server.key.pem'),
'--netloc', backend_caucased_netloc,
'--service-auto-approve-count', '1',
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
[
caucased_path,
'--db', os.path.join(caucased_dir, 'caucase.sqlite'),
'--server-key', os.path.join(caucased_dir, 'server.key.pem'),
'--netloc', backend_caucased_netloc,
'--service-auto-approve-count', '1',
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
for _ in range(10):
try:
......@@ -127,15 +127,15 @@ class BalancerTestCase(ERP5InstanceTestCase):
'apachedex-promise-threshold': 100,
'haproxy-server-check-path': '/',
'zope-family-dict': {
'default': ['dummy_http_server'], # TODO: dummy_http_server is bad name
'default': ['dummy_http_server'], # TODO: dummy_http_server is bad name
},
'dummy_http_server': [[cls.getManagedResource("backend_web_server", EchoHTTPServer).netloc, 1, False]],
'backend-path-dict': {
'default': '/',
'default': '/',
},
'ssl-authentication-dict': {},
'ssl': {
'caucase-url': cls.getManagedResource("caucase", CaucaseService).url,
'caucase-url': cls.getManagedResource("caucase", CaucaseService).url,
}
}
......@@ -170,7 +170,7 @@ class TestAccessLog(BalancerTestCase, CrontabMixin):
parameter_dict['dummy_http_server'] = [[cls.getManagedResource("slow_web_server", SlowHTTPServer).netloc, 1, False]]
return parameter_dict
def test_access_log(self):
def test_access_log_format(self):
# type: () -> None
balancer_url = json.loads(self.computer_partition.getConnectionParameterDict()['_'])['default']
requests.get(
......@@ -194,6 +194,9 @@ class TestAccessLog(BalancerTestCase, CrontabMixin):
self.assertLess(request_time, 4000000)
import pdb; pdb.set_trace()
# TODO: log rotation
# TODO: apachedex on logs
class CaucaseClientCertificate(ManagedResource):
ca_crt_file = None # type: str
......@@ -231,9 +234,9 @@ class CaucaseClientCertificate(ManagedResource):
]
key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
with open(self.key_file, 'wb') as f:
f.write(
......@@ -259,7 +262,7 @@ class CaucaseClientCertificate(ManagedResource):
csr_id = subprocess.check_output(
cas_args + [
'--send-csr', self.csr_file,
'--send-csr', self.csr_file,
],
).split()[0]
assert csr_id
......@@ -267,7 +270,7 @@ class CaucaseClientCertificate(ManagedResource):
for _ in range(10):
if not subprocess.call(
cas_args + [
'--get-crt', csr_id, self.cert_file,
'--get-crt', csr_id, self.cert_file,
],
) == 0:
break
......@@ -335,4 +338,24 @@ class TestFrontendXForwardedFor(BalancerTestCase):
verify=False,
)
del TestAccessLog
\ No newline at end of file
del TestAccessLog
'''before
----------------------------------------------------------------------
Ran 26 tests in 1195.545s
OK
________________________________________________________
Executed in 19.97 mins fish external
usr time 10.32 secs 1657.00 micros 10.31 secs
sys time 3.18 secs 235.00 micros 3.18 secs
/srv/slapgrid/slappart4/srv/slapos/soft/c63ba7265399450b28f9ea6d5667a5e7/eggs/slapos.cookbook-1.0.152-py2.7.egg
/srv/slapgrid/slappart4/srv/slapos/inst/slappart0/tmp/soft/c63ba7265399450b28f9ea6d5667a5e7/eggs/slapos.cookbook-1.0.152-py2.7.egg/slapos/recipe/switch_softwaretype.py
Ran 2 tests in 188.451s
Ran 2 tests in 161.661s
'''
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment