Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
moodle_rebase10.1.2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Blinov
moodle_rebase10.1.2
Commits
4da444c5
Commit
4da444c5
authored
May 15, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/caddy-frontend-config-corner-cases'
parents
621165c7
94442881
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
311 additions
and
308 deletions
+311
-308
software/caddy-frontend/buildout.hash.cfg
software/caddy-frontend/buildout.hash.cfg
+2
-2
software/caddy-frontend/templates/Caddyfile.in
software/caddy-frontend/templates/Caddyfile.in
+6
-2
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
.../caddy-frontend/templates/apache-custom-slave-list.cfg.in
+4
-0
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+299
-296
software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt
..._data/test.TestMasterRequest.test_file_list_log-CADDY.txt
+0
-4
software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt
...test.TestMasterRequestDomain.test_file_list_log-CADDY.txt
+0
-4
No files found.
software/caddy-frontend/buildout.hash.cfg
View file @
4da444c5
...
...
@@ -30,7 +30,7 @@ md5sum = 087bd9404cd120bd7602a9fbfcddc064
[template-slave-list]
filename = templates/apache-custom-slave-list.cfg.in
md5sum =
29a61267959cc9ba7cdcd96fef41641a
md5sum =
d96fea7dd4d7f0a157c86d25a263d8e1
[template-slave-configuration]
filename = templates/custom-virtualhost.conf.in
...
...
@@ -42,7 +42,7 @@ md5sum = 7e3ee70c447f8203273d78f66ab519c3
[template-caddy-frontend-configuration]
filename = templates/Caddyfile.in
md5sum =
908b859ff76469381024947f5c98c891
md5sum =
f0faf6d2e6c187df7e25bf717676f9df
[caddy-backend-url-validator]
filename = templates/caddy-backend-url-validator.in
...
...
software/caddy-frontend/templates/Caddyfile.in
View file @
4da444c5
...
...
@@ -4,7 +4,8 @@ import {{frontend_configuration.get('log-access-configuration')}}
import {{ slave_configuration_directory }}/*.conf
import {{ slave_with_cache_configuration_directory }}/*.conf
:{{ https_port }} {
{% for port in [https_port] %}
:{{ port }} {
tls {{ master_certificate }} {{ master_certificate }}
bind {{ local_ipv4 }}
status 404 /
...
...
@@ -16,8 +17,10 @@ import {{ slave_with_cache_configuration_directory }}/*.conf
* {{ not_found_file }}
}
}
{%- endfor %}
:{{ http_port }} {
{% for port in [http_port, cached_port, ssl_cached_port] %}
:{{ port }} {
bind {{ local_ipv4 }}
status 404 /
log / {{ access_log }} "{remote} - {>REMOTE_USER} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\" {latency_ms}" {
...
...
@@ -28,6 +31,7 @@ import {{ slave_with_cache_configuration_directory }}/*.conf
* {{ not_found_file }}
}
}
{%- endfor %}
# Access to server-status Caddy-style
https://[{{ global_ipv6 }}]:{{ https_port }}/server-status, https://{{ local_ipv4 }}:{{ https_port }}/server-status {
...
...
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
View file @
4da444c5
...
...
@@ -42,6 +42,10 @@ create = true
{% set slave_kedifa_information = {} %}
{% endif %}
# empty sections if no slaves are available
[slave-log-directory-dict]
[slave-password]
# empty section if no cached slaves are available
[slave-log-cache-direct-directory-dict]
...
...
software/caddy-frontend/test/test.py
View file @
4da444c5
...
...
@@ -500,193 +500,19 @@ class TestHandler(BaseHTTPRequestHandler):
self
.
wfile
.
write
(
response
)
class
Slave
HttpFrontendTestCase
(
SlapOSInstanceTestCase
):
class
HttpFrontendTestCase
(
SlapOSInstanceTestCase
):
# show full diffs, as it is required for proper analysis of problems
maxDiff
=
None
# minimise partition path
__partition_reference__
=
'T-'
@
classmethod
def
callSupervisorMethod
(
cls
,
method
,
*
args
,
**
kwargs
):
with
cls
.
slap
.
instance_supervisor_rpc
as
instance_supervisor
:
return
getattr
(
instance_supervisor
,
method
)(
*
args
,
**
kwargs
)
@
classmethod
def
requestSlaves
(
cls
):
software_url
=
cls
.
getSoftwareURL
()
for
slave_reference
,
partition_parameter_kw
in
cls
\
.
getSlaveParameterDictDict
().
items
():
cls
.
logger
.
debug
(
'requesting slave "%s" software:%s parameters:%s'
,
slave_reference
,
software_url
,
partition_parameter_kw
)
cls
.
slap
.
request
(
software_release
=
software_url
,
partition_reference
=
slave_reference
,
partition_parameter_kw
=
partition_parameter_kw
,
shared
=
True
)
@
classmethod
def
getInstanceSoftwareType
(
cls
):
# Because of unknown problem yet, the root instance software type changes
# from RootSoftwareInstance to '', so always request it with given type
return
"RootSoftwareInstance"
@
classmethod
def
requestDefaultInstance
(
cls
,
state
=
'started'
):
default_instance
=
super
(
SlaveHttpFrontendTestCase
,
cls
).
requestDefaultInstance
(
state
=
state
)
if
state
!=
'destroyed'
:
cls
.
requestSlaves
()
return
default_instance
@
classmethod
def
setUpClass
(
cls
):
try
:
cls
.
createWildcardExampleComCertificate
()
cls
.
startServerProcess
()
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
cls
.
_cleanup
(
"{}.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
))
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
super
(
SlaveHttpFrontendTestCase
,
cls
).
setUpClass
()
try
:
# expose instance directory
cls
.
instance_path
=
cls
.
slap
.
instance_directory
# expose software directory, extract from found computer partition
cls
.
software_path
=
os
.
path
.
realpath
(
os
.
path
.
join
(
cls
.
computer_partition_root_path
,
'software_release'
))
# do working directory
cls
.
working_directory
=
os
.
path
.
join
(
os
.
path
.
realpath
(
os
.
environ
.
get
(
'SLAPOS_TEST_WORKING_DIR'
,
os
.
path
.
join
(
os
.
getcwd
(),
'.slapos'
))),
'caddy-frontend-test'
)
if
not
os
.
path
.
isdir
(
cls
.
working_directory
):
os
.
mkdir
(
cls
.
working_directory
)
cls
.
setUpMaster
()
cls
.
setUpSlaves
()
cls
.
waitForCaddy
()
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
# "{}.{}.setUpClass".format(cls.__module__, cls.__name__) is already used
# by SlapOSInstanceTestCase.setUpClass so we use another name for
# snapshot, to make sure we don't store another snapshot in same
# directory.
cls
.
_cleanup
(
"{}.SlaveHttpFrontendTestCase.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
))
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
def
assertLogAccessUrlWithPop
(
self
,
parameter_dict
):
log_access_url
=
parameter_dict
.
pop
(
'log-access-url'
)
self
.
assertTrue
(
len
(
log_access_url
)
>=
1
)
# check only the first one, as second frontend will be stopped
log_access
=
log_access_url
[
0
]
entry
=
log_access
.
split
(
': '
)
if
len
(
entry
)
!=
2
:
self
.
fail
(
'Cannot parse %r'
%
(
log_access
,))
frontend
,
url
=
entry
result
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
httplib
.
OK
,
result
.
status_code
,
'While accessing %r of %r the status code was %r'
%
(
url
,
frontend
,
result
.
status_code
))
def
assertKedifaKeysWithPop
(
self
,
parameter_dict
,
prefix
=
''
):
generate_auth_url
=
parameter_dict
.
pop
(
'%skey-generate-auth-url'
%
(
prefix
,))
upload_url
=
parameter_dict
.
pop
(
'%skey-upload-url'
%
(
prefix
,))
kedifa_ipv6_base
=
'https://[%s]:%s'
%
(
self
.
_ipv6_address
,
KEDIFA_PORT
)
base
=
'^'
+
kedifa_ipv6_base
.
replace
(
'['
,
r'\
[
').replace('
]
', r'
\
]
') + '
/
.{
32
}
'
self.assertRegexpMatches(
generate_auth_url,
base + r'
\
/
generateauth
$
'
)
self.assertRegexpMatches(
upload_url,
base + r'
\
?
auth
=
$
'
)
kedifa_caucase_url = parameter_dict.pop('
kedifa
-
caucase
-
url
')
self.assertEqual(
kedifa_caucase_url,
'
http
:
//
[
%
s
]:
%
s
' % (self._ipv6_address, CAUCASE_PORT),
)
return generate_auth_url, upload_url
def assertKeyWithPop(self, key, d):
self.assertTrue(key in d, '
Key
%
r
is
missing
in
%
r' % (key, d))
d.pop(key)
def assertEqualResultJson(self, result, key, value):
try:
j = result.json()
except Exception:
raise ValueError('
JSON
decode
problem
in
:
\
n
%
s
' % (result.text,))
self.assertTrue(key in j, '
No
key
%
r
in
%
s
' % (key, j))
self.assertEqual(value, j[key])
def parseParameterDict(self, parameter_dict):
parsed_parameter_dict = {}
for key, value in parameter_dict.items():
if key in [
'
rejected
-
slave
-
dict
',
'
warning
-
slave
-
dict
',
'
warning
-
list
',
'
request
-
error
-
list
',
'
log
-
access
-
url
']:
value = json.loads(value)
parsed_parameter_dict[key] = value
return parsed_parameter_dict
def parseConnectionParameterDict(self):
return self.parseParameterDict(
self.requestDefaultInstance().getConnectionParameterDict()
)
@classmethod
def runComputerPartitionUntil(cls, until):
max_try = 10
try_num = 1
while True:
if until():
break
if try_num > max_try:
raise ValueError('
Failed
to
run
computer
partition
with
%
r' % (until,))
try:
cls.slap.waitForInstance()
except Exception:
cls.logger.exception("Error during until run")
try_num += 1
@classmethod
def untilNotReadyYetNotInMasterKeyGenerateAuthUrl(cls):
parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict()
key = '
master
-
key
-
generate
-
auth
-
url
'
if key not in parameter_dict:
return False
if '
NotReadyYet
' in parameter_dict[key]:
return False
return True
@classmethod
def getSlaveParameterDictDict(cls):
return {
'
waitforcaddyslave
': {
'
url
': cls.backend_url,
'
enable_cache
': True,
}
}
@
classmethod
def
startServerProcess
(
cls
):
server
=
HTTPServer
(
...
...
@@ -789,50 +615,6 @@ class SlaveHttpFrontendTestCase(SlapOSInstanceTestCase):
# block until caddy is refreshed
time
.
sleep
(
2
)
@classmethod
def untilSlavePartitionReady(cls):
# all on-watch services shall not be exited
for process in cls.callSupervisorMethod('
getAllProcessInfo
'):
if process['
name
'].endswith('
-
on
-
watch
') and
\
process['
statename
'] == '
EXITED
':
if process['
name
'].startswith('
monitor
-
http
'):
continue
return False
for slave_reference, partition_parameter_kw in cls
\
.getSlaveParameterDictDict().items():
parameter_dict = cls.slap.request(
software_release=cls.getSoftwareURL(),
partition_reference=slave_reference,
partition_parameter_kw=partition_parameter_kw,
shared=True
).getConnectionParameterDict()
log_access_ready = '
log
-
access
-
url
' in parameter_dict
key = '
key
-
generate
-
auth
-
url
'
key_generate_auth_ready = key in parameter_dict
\
and '
NotReadyYet
' not in parameter_dict[key]
if log_access_ready and key_generate_auth_ready:
return True
return False
@classmethod
def setUpSlaves(cls):
cls.slave_connection_parameter_dict_dict = {}
# run partition for slaves to be setup
cls.runComputerPartitionUntil(
cls.untilSlavePartitionReady)
request = cls.slap.request
for slave_reference, partition_parameter_kw in cls
\
.getSlaveParameterDictDict().items():
slave_instance = request(
software_release=cls.getSoftwareURL(),
partition_reference=slave_reference,
partition_parameter_kw=partition_parameter_kw,
shared=True
)
cls.slave_connection_parameter_dict_dict[slave_reference] =
\
slave_instance.getConnectionParameterDict()
@
classmethod
def
createWildcardExampleComCertificate
(
cls
):
_
,
cls
.
key_pem
,
_
,
cls
.
certificate_pem
=
createSelfSignedCertificate
(
...
...
@@ -842,39 +624,88 @@ class SlaveHttpFrontendTestCase(SlapOSInstanceTestCase):
'*.alias1.example.com'
,
])
check_slave_id = '
waitforcaddyslave
'
@
classmethod
def waitForCaddy(cls):
# awaits until caddy is ready to serve slaves
parameter_dict = cls.slave_connection_parameter_dict_dict[
cls.check_slave_id
]
wait_time = 600
begin = time.time()
try_num = 0
cls.logger.debug('
waitForCaddy
for
%
is
' % (wait_time,))
def
runComputerPartitionUntil
(
cls
,
until
):
max_try
=
10
try_num
=
1
while
True
:
if
until
():
break
if
try_num
>
max_try
:
raise
ValueError
(
'Failed to run computer partition with %r'
%
(
until
,))
try
:
try_num += 1
fakeHTTPSResult(
parameter_dict['
domain
'], parameter_dict['
public
-
ipv4
'],
'
/
',
)
cls
.
slap
.
waitForInstance
()
except
Exception
:
if time.time() - begin > wait_time:
cls.logger.exception(
"Error during waitForCaddy after %.2fs" % ((time.time() - begin),))
raise
else:
time.sleep(0.5)
else:
cls.logger.info("waitForCaddy took %.2fs" % ((time.time() - begin),))
break
cls
.
logger
.
exception
(
"Error during until run"
)
try_num
+=
1
@
classmethod
def _cleanup(cls, snapshot_name):
cls.stopServerProcess()
super(SlaveHttpFrontendTestCase, cls)._cleanup(snapshot_name)
def
untilNotReadyYetNotInMasterKeyGenerateAuthUrl
(
cls
):
parameter_dict
=
cls
.
requestDefaultInstance
().
getConnectionParameterDict
()
key
=
'master-key-generate-auth-url'
if
key
not
in
parameter_dict
:
return
False
if
'NotReadyYet'
in
parameter_dict
[
key
]:
return
False
return
True
@
classmethod
def
callSupervisorMethod
(
cls
,
method
,
*
args
,
**
kwargs
):
with
cls
.
slap
.
instance_supervisor_rpc
as
instance_supervisor
:
return
getattr
(
instance_supervisor
,
method
)(
*
args
,
**
kwargs
)
def
assertLogAccessUrlWithPop
(
self
,
parameter_dict
):
log_access_url
=
parameter_dict
.
pop
(
'log-access-url'
)
self
.
assertTrue
(
len
(
log_access_url
)
>=
1
)
# check only the first one, as second frontend will be stopped
log_access
=
log_access_url
[
0
]
entry
=
log_access
.
split
(
': '
)
if
len
(
entry
)
!=
2
:
self
.
fail
(
'Cannot parse %r'
%
(
log_access
,))
frontend
,
url
=
entry
result
=
requests
.
get
(
url
,
verify
=
False
)
self
.
assertEqual
(
httplib
.
OK
,
result
.
status_code
,
'While accessing %r of %r the status code was %r'
%
(
url
,
frontend
,
result
.
status_code
))
def
assertKedifaKeysWithPop
(
self
,
parameter_dict
,
prefix
=
''
):
generate_auth_url
=
parameter_dict
.
pop
(
'%skey-generate-auth-url'
%
(
prefix
,))
upload_url
=
parameter_dict
.
pop
(
'%skey-upload-url'
%
(
prefix
,))
kedifa_ipv6_base
=
'https://[%s]:%s'
%
(
self
.
_ipv6_address
,
KEDIFA_PORT
)
base
=
'^'
+
kedifa_ipv6_base
.
replace
(
'['
,
r'\
[
').replace('
]
', r'
\
]
') + '
/
.{
32
}
'
self.assertRegexpMatches(
generate_auth_url,
base + r'
\
/
generateauth
$
'
)
self.assertRegexpMatches(
upload_url,
base + r'
\
?
auth
=
$
'
)
kedifa_caucase_url = parameter_dict.pop('
kedifa
-
caucase
-
url
')
self.assertEqual(
kedifa_caucase_url,
'
http
:
//
[
%
s
]:
%
s
' % (self._ipv6_address, CAUCASE_PORT),
)
return generate_auth_url, upload_url
def assertKeyWithPop(self, key, d):
self.assertTrue(key in d, '
Key
%
r
is
missing
in
%
r' % (key, d))
d.pop(key)
def assertEqualResultJson(self, result, key, value):
try:
j = result.json()
except Exception:
raise ValueError('
JSON
decode
problem
in
:
\
n
%
s
' % (result.text,))
self.assertTrue(key in j, '
No
key
%
r
in
%
s
' % (key, j))
self.assertEqual(value, j[key])
def patchRequests(self):
HTTPResponse = requests.packages.urllib3.response.HTTPResponse
...
...
@@ -917,7 +748,216 @@ class SlaveHttpFrontendTestCase(SlapOSInstanceTestCase):
def tearDown(self):
self.unpatchRequests()
super(SlaveHttpFrontendTestCase, self).tearDown()
super(HttpFrontendTestCase, self).tearDown()
def parseParameterDict(self, parameter_dict):
parsed_parameter_dict = {}
for key, value in parameter_dict.items():
if key in [
'
rejected
-
slave
-
dict
',
'
warning
-
slave
-
dict
',
'
warning
-
list
',
'
request
-
error
-
list
',
'
log
-
access
-
url
']:
value = json.loads(value)
parsed_parameter_dict[key] = value
return parsed_parameter_dict
def getMasterPartitionPath(self):
return '
/
' + os.path.join(
*glob.glob(
os.path.join(
self.instance_path, '
*
', '
etc
', '
Caddyfile
-
rejected
-
slave
'
)
)[0].split('
/
')[:-2])
def parseConnectionParameterDict(self):
return self.parseParameterDict(
self.requestDefaultInstance().getConnectionParameterDict()
)
@classmethod
def waitForMethod(cls, name, method):
wait_time = 600
begin = time.time()
try_num = 0
cls.logger.debug('
%
s
for
%
is
' % (name, wait_time,))
while True:
try:
try_num += 1
method()
except Exception:
if time.time() - begin > wait_time:
cls.logger.exception(
"Error during %s after %.2fs" % (name, (time.time() - begin),))
raise
else:
time.sleep(0.5)
else:
cls.logger.info("%s took %.2fs" % (name, (time.time() - begin),))
break
@classmethod
def waitForCaddy(cls):
def method():
fakeHTTPSResult(
cls._ipv4_address, cls._ipv4_address,
'
/
',
)
cls.waitForMethod('
waitForCaddy
', method)
@classmethod
def _cleanup(cls, snapshot_name):
cls.stopServerProcess()
super(HttpFrontendTestCase, cls)._cleanup(snapshot_name)
@classmethod
def setUpClass(cls):
try:
cls.createWildcardExampleComCertificate()
cls.startServerProcess()
except BaseException:
cls.logger.exception("Error during setUpClass")
cls._cleanup("{}.{}.setUpClass".format(cls.__module__, cls.__name__))
cls.setUp = lambda self: self.fail('
Setup
Class
failed
.
')
raise
super(HttpFrontendTestCase, cls).setUpClass()
try:
# expose instance directory
cls.instance_path = cls.slap.instance_directory
# expose software directory, extract from found computer partition
cls.software_path = os.path.realpath(os.path.join(
cls.computer_partition_root_path, '
software_release
'))
# do working directory
cls.working_directory = os.path.join(os.path.realpath(
os.environ.get(
'
SLAPOS_TEST_WORKING_DIR
',
os.path.join(os.getcwd(), '
.
slapos
'))),
'
caddy
-
frontend
-
test
')
if not os.path.isdir(cls.working_directory):
os.mkdir(cls.working_directory)
cls.setUpMaster()
cls.waitForCaddy()
except BaseException:
cls.logger.exception("Error during setUpClass")
# "{}.{}.setUpClass".format(cls.__module__, cls.__name__) is already used
# by SlapOSInstanceTestCase.setUpClass so we use another name for
# snapshot, to make sure we don'
t
store
another
snapshot
in
same
# directory.
cls
.
_cleanup
(
"{}.SlaveHttpFrontendTestCase.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
))
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
class
SlaveHttpFrontendTestCase
(
HttpFrontendTestCase
):
@
classmethod
def
requestDefaultInstance
(
cls
,
state
=
'started'
):
default_instance
=
super
(
SlaveHttpFrontendTestCase
,
cls
).
requestDefaultInstance
(
state
=
state
)
if
state
!=
'destroyed'
:
cls
.
requestSlaves
()
return
default_instance
@
classmethod
def
requestSlaves
(
cls
):
software_url
=
cls
.
getSoftwareURL
()
for
slave_reference
,
partition_parameter_kw
in
cls
\
.
getSlaveParameterDictDict
().
items
():
cls
.
logger
.
debug
(
'requesting slave "%s" software:%s parameters:%s'
,
slave_reference
,
software_url
,
partition_parameter_kw
)
cls
.
slap
.
request
(
software_release
=
software_url
,
partition_reference
=
slave_reference
,
partition_parameter_kw
=
partition_parameter_kw
,
shared
=
True
)
@
classmethod
def
setUpClass
(
cls
):
super
(
SlaveHttpFrontendTestCase
,
cls
).
setUpClass
()
try
:
cls
.
setUpSlaves
()
cls
.
waitForSlave
()
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
# "{}.{}.setUpClass".format(cls.__module__, cls.__name__) is already used
# by SlapOSInstanceTestCase.setUpClass so we use another name for
# snapshot, to make sure we don't store another snapshot in same
# directory.
cls
.
_cleanup
(
"{}.SlaveHttpFrontendTestCase.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
))
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
@
classmethod
def
waitForSlave
(
cls
):
def
method
():
for
parameter_dict
in
cls
.
getSlaveConnectionParameterDictList
():
if
'domain'
in
parameter_dict
and
'public-ipv4'
in
parameter_dict
:
try
:
fakeHTTPSResult
(
parameter_dict
[
'domain'
],
parameter_dict
[
'public-ipv4'
],
'/'
)
except
requests
.
exceptions
.
InvalidURL
:
# ignore slaves to which connection is impossible by default
continue
cls
.
waitForMethod
(
'waitForSlave'
,
method
)
@
classmethod
def
getSlaveConnectionParameterDictList
(
cls
):
parameter_dict_list
=
[]
for
slave_reference
,
partition_parameter_kw
in
cls
\
.
getSlaveParameterDictDict
().
items
():
parameter_dict_list
.
append
(
cls
.
slap
.
request
(
software_release
=
cls
.
getSoftwareURL
(),
partition_reference
=
slave_reference
,
partition_parameter_kw
=
partition_parameter_kw
,
shared
=
True
).
getConnectionParameterDict
())
return
parameter_dict_list
@
classmethod
def
untilSlavePartitionReady
(
cls
):
# all on-watch services shall not be exited
for
process
in
cls
.
callSupervisorMethod
(
'getAllProcessInfo'
):
if
process
[
'name'
].
endswith
(
'-on-watch'
)
and
\
process
[
'statename'
]
==
'EXITED'
:
if
process
[
'name'
].
startswith
(
'monitor-http'
):
continue
return
False
for
parameter_dict
in
cls
.
getSlaveConnectionParameterDictList
():
log_access_ready
=
'log-access-url'
in
parameter_dict
key
=
'key-generate-auth-url'
key_generate_auth_ready
=
key
in
parameter_dict
\
and
'NotReadyYet'
not
in
parameter_dict
[
key
]
if
not
(
log_access_ready
and
key_generate_auth_ready
):
return
False
return
True
@
classmethod
def
setUpSlaves
(
cls
):
cls
.
slave_connection_parameter_dict_dict
=
{}
# run partition for slaves to be setup
cls
.
runComputerPartitionUntil
(
cls
.
untilSlavePartitionReady
)
request
=
cls
.
slap
.
request
for
slave_reference
,
partition_parameter_kw
in
cls
\
.
getSlaveParameterDictDict
().
items
():
slave_instance
=
request
(
software_release
=
cls
.
getSoftwareURL
(),
partition_reference
=
slave_reference
,
partition_parameter_kw
=
partition_parameter_kw
,
shared
=
True
)
cls
.
slave_connection_parameter_dict_dict
[
slave_reference
]
=
\
slave_instance
.
getConnectionParameterDict
()
def
parseSlaveParameterDict
(
self
,
key
):
return
self
.
parseParameterDict
(
...
...
@@ -945,16 +985,8 @@ class SlaveHttpFrontendTestCase(SlapOSInstanceTestCase):
return
parameter_dict
def getMasterPartitionPath(self):
return '
/
' + os.path.join(
*glob.glob(
os.path.join(
self.instance_path, '
*
', '
etc
', '
Caddyfile
-
rejected
-
slave
'
)
)[0].split('
/
')[:-2])
class TestMasterRequestDomain(
Slave
HttpFrontendTestCase, TestDataMixin):
class
TestMasterRequestDomain
(
HttpFrontendTestCase
,
TestDataMixin
):
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
...
...
@@ -965,14 +997,7 @@ class TestMasterRequestDomain(SlaveHttpFrontendTestCase, TestDataMixin):
'caucase_port'
:
CAUCASE_PORT
,
}
@classmethod
def waitForCaddy(cls):
pass
def
test
(
self
):
# run partition until AIKC finishes
self.runComputerPartitionUntil(
self.untilNotReadyYetNotInMasterKeyGenerateAuthUrl)
parameter_dict
=
self
.
parseConnectionParameterDict
()
self
.
assertKeyWithPop
(
'monitor-setup-url'
,
parameter_dict
)
self
.
assertKedifaKeysWithPop
(
parameter_dict
,
'master-'
)
...
...
@@ -982,16 +1007,16 @@ class TestMasterRequestDomain(SlaveHttpFrontendTestCase, TestDataMixin):
{
'monitor-base-url'
:
'https://[%s]:8401'
%
self
.
_ipv6_address
,
'domain'
:
'example.com'
,
'
accepted
-
slave
-
amount
': '
1
',
'accepted-slave-amount'
:
'
0
'
,
'rejected-slave-amount'
:
'0'
,
'
slave
-
amount
': '
1
',
'slave-amount'
:
'
0
'
,
'rejected-slave-dict'
:
{}
},
parameter_dict
)
class TestMasterRequest(
Slave
HttpFrontendTestCase, TestDataMixin):
class
TestMasterRequest
(
HttpFrontendTestCase
,
TestDataMixin
):
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
...
...
@@ -1001,14 +1026,7 @@ class TestMasterRequest(SlaveHttpFrontendTestCase, TestDataMixin):
'caucase_port'
:
CAUCASE_PORT
,
}
@classmethod
def waitForCaddy(cls):
pass
def
test
(
self
):
# run partition until AIKC finishes
self.runComputerPartitionUntil(
self.untilNotReadyYetNotInMasterKeyGenerateAuthUrl)
parameter_dict
=
self
.
parseConnectionParameterDict
()
self
.
assertKeyWithPop
(
'monitor-setup-url'
,
parameter_dict
)
self
.
assertKedifaKeysWithPop
(
parameter_dict
,
'master-'
)
...
...
@@ -1017,9 +1035,9 @@ class TestMasterRequest(SlaveHttpFrontendTestCase, TestDataMixin):
{
'monitor-base-url'
:
'https://[%s]:8401'
%
self
.
_ipv6_address
,
'domain'
:
'None'
,
'
accepted
-
slave
-
amount
': '
1
',
'accepted-slave-amount'
:
'
0
'
,
'rejected-slave-amount'
:
'0'
,
'
slave
-
amount
': '
1
',
'slave-amount'
:
'
0
'
,
'rejected-slave-dict'
:
{}},
parameter_dict
)
...
...
@@ -1101,8 +1119,6 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
'request-timeout'
:
'12'
,
}
check_slave_id = '
Url
'
@
classmethod
def
startServerProcess
(
cls
):
cls
.
ca
=
CertificateAuthority
(
'TestSlave'
)
...
...
@@ -1621,7 +1637,7 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
r'"python-requests.*"
\
d
+
'
self.assertRegexpMatches(
open(log_file, 'r').read
()
,
open(log_file, 'r').read
lines()[-1]
,
log_regexp)
result_http = fakeHTTPResult(
parameter_dict['
domain
'], parameter_dict['
public
-
ipv4
'], '
test
-
path
')
...
...
@@ -4270,7 +4286,6 @@ class TestReplicateSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'caucase_port': CAUCASE_PORT,
}
check_slave_id = 'replicate'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4338,7 +4353,6 @@ class TestReplicateSlaveOtherDestroyed(SlaveHttpFrontendTestCase):
'caucase_port': CAUCASE_PORT,
}
check_slave_id = 'empty'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4377,7 +4391,6 @@ class TestEnableHttp2ByDefaultFalseSlave(SlaveHttpFrontendTestCase,
'caucase_port': CAUCASE_PORT,
}
check_slave_id = 'dummy-cached'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4469,7 +4482,6 @@ class TestEnableHttp2ByDefaultDefaultSlave(SlaveHttpFrontendTestCase,
'caucase_port': CAUCASE_PORT,
}
check_slave_id = 'dummy-cached'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4559,10 +4571,6 @@ class TestRe6stVerificationUrlDefaultSlave(SlaveHttpFrontendTestCase,
'caucase_port': CAUCASE_PORT,
}
@classmethod
def waitForCaddy(cls):
pass
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4572,6 +4580,11 @@ class TestRe6stVerificationUrlDefaultSlave(SlaveHttpFrontendTestCase,
},
}
@classmethod
def waitForSlave(cls):
# no need to wait for slave availability here
return True
def test_default(self):
parameter_dict = self.parseSlaveParameterDict('default')
self.assertLogAccessUrlWithPop(parameter_dict)
...
...
@@ -4618,10 +4631,6 @@ class TestRe6stVerificationUrlSlave(SlaveHttpFrontendTestCase,
'caucase_port': CAUCASE_PORT,
}
@classmethod
def waitForCaddy(cls):
pass
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4777,7 +4786,6 @@ class TestDefaultMonitorHttpdPort(SlaveHttpFrontendTestCase, TestDataMixin):
def runKedifaUpdater(cls):
return
check_slave_id = 'test'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -4828,7 +4836,6 @@ class TestQuicEnabled(SlaveHttpFrontendTestCase, TestDataMixin):
'caucase_port': CAUCASE_PORT,
}
check_slave_id = 'url'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -5591,7 +5598,6 @@ class TestSlaveSlapOSMasterCertificateCompatibilityOverrideMaster(
'mpm-graceful-shutdown-timeout': 2,
}
check_slave_id = 'ssl_from_master_kedifa_overrides_master_certificate'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -5730,7 +5736,6 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
'mpm-graceful-shutdown-timeout': 2,
}
check_slave_id = 'ssl_from_master'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -6489,7 +6494,6 @@ class TestSlaveSlapOSMasterCertificateCompatibilityUpdate(
cls.instance_parameter_dict['public-ipv4'] = cls._ipv4_address
return cls.instance_parameter_dict
check_slave_id = 'ssl_from_master'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
@@ -6591,7 +6595,6 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin):
'ciphers': 'ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384'
}
check_slave_id = 'default_ciphers'
@classmethod
def getSlaveParameterDictDict(cls):
return {
...
...
software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt
View file @
4da444c5
...
...
@@ -7,11 +7,7 @@ T-1/var/log/monitor-httpd-access.log
T-1/var/log/monitor-httpd-error.log
T-2/var/log/frontend-access.log
T-2/var/log/frontend-error.log
T-2/var/log/httpd-cache-direct/_waitforcaddyslave_access_log
T-2/var/log/httpd-cache-direct/_waitforcaddyslave_error_log
T-2/var/log/httpd-csr_id/expose-csr_id.log
T-2/var/log/httpd/_waitforcaddyslave_access_log
T-2/var/log/httpd/_waitforcaddyslave_error_log
T-2/var/log/monitor-httpd-access.log
T-2/var/log/monitor-httpd-error.log
T-2/var/log/trafficserver/manager.log
...
...
software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt
View file @
4da444c5
...
...
@@ -7,11 +7,7 @@ T-1/var/log/monitor-httpd-access.log
T-1/var/log/monitor-httpd-error.log
T-2/var/log/frontend-access.log
T-2/var/log/frontend-error.log
T-2/var/log/httpd-cache-direct/_waitforcaddyslave_access_log
T-2/var/log/httpd-cache-direct/_waitforcaddyslave_error_log
T-2/var/log/httpd-csr_id/expose-csr_id.log
T-2/var/log/httpd/_waitforcaddyslave_access_log
T-2/var/log/httpd/_waitforcaddyslave_error_log
T-2/var/log/monitor-httpd-access.log
T-2/var/log/monitor-httpd-error.log
T-2/var/log/trafficserver/manager.log
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment