Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
107
Merge Requests
107
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
af9ab301
Commit
af9ab301
authored
Jun 01, 2021
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend: Provide assertLastLogLineRegexp method
parent
cf89ce81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+27
-31
No files found.
software/caddy-frontend/test/test.py
View file @
af9ab301
...
@@ -1201,6 +1201,16 @@ class SlaveHttpFrontendTestCase(HttpFrontendTestCase):
...
@@ -1201,6 +1201,16 @@ class SlaveHttpFrontendTestCase(HttpFrontendTestCase):
return
parameter_dict
return
parameter_dict
def
assertLastLogLineRegexp
(
self
,
log_name
,
log_regexp
):
log_file
=
glob
.
glob
(
os
.
path
.
join
(
self
.
instance_path
,
'*'
,
'var'
,
'log'
,
'httpd'
,
log_name
))[
0
]
self
.
assertRegexpMatches
(
open
(
log_file
,
'r'
).
readlines
()[
-
1
],
log_regexp
)
class
TestMasterRequestDomain
(
HttpFrontendTestCase
,
TestDataMixin
):
class
TestMasterRequestDomain
(
HttpFrontendTestCase
,
TestDataMixin
):
@
classmethod
@
classmethod
...
@@ -1891,38 +1901,24 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
...
@@ -1891,38 +1901,24 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
result
.
headers
[
'Set-Cookie'
]
result
.
headers
[
'Set-Cookie'
]
)
)
# check access log
self
.
assertLastLogLineRegexp
(
log_file
=
glob
.
glob
(
'_Url_access_log'
,
os
.
path
.
join
(
r'^\
d{
1,3}\
.
\d{1,3}\
.
\d{1,3}\
.
\d{1,3} - - '
self
.
instance_path
,
'*'
,
'var'
,
'log'
,
'httpd'
,
'_Url_access_log'
r'\
[
\d{2}\
/.{
3}\
/
\d{4}\
:
\d{2}\
:
\d{2}\
:
\d{2} \
+
\d{4}\
]
'
))[
0
]
r'"GET
\
/
t
est-path
\
/deep
\
/..
\
/.
\
/deeper HTTP
\
/
1
.1"
\
d
{
3
}
'
r'
\
d
+
"-"
"TEST USER AGENT"
\
d
+
'
log_regexp
=
r'^\
d{
1,3}\
.
\d{1,3}\
.
\d{1,3}\
.
\d{1,3} - - '
\
)
r'\
[
\d{2}\
/.{
3}\
/
\d{4}\
:
\d{2}\
:
\d{2}\
:
\d{2} \
+
\d{4}\
]
' \
r'"GET
\
/
t
est-path
\
/deep
\
/..
\
/.
\
/deeper HTTP
\
/
1
.1"
\
d
{
3
}
'
\
r'
\
d
+
"-"
"TEST USER AGENT"
\
d
+
'
self.assertRegexpMatches(
open(log_file, 'r').readlines()[-1],
log_regexp)
# check backend log
log_file = glob.glob(
os.path.join(
self.instance_path, '
*
', '
var
', '
log
', '
httpd
', '
_Url_backend_log
'
))[0]
log_regexp = r'
^
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}:
\
d
+
'
\
r'
\
[
\
d
{
2
}
\
/
.{
3
}
\
/
\
d
{
4
}
\
:
\
d
{
2
}
\
:
\
d
{
2
}
\
:
\
d
{
2
}.
\
d
{
3
}
\
]
'
\
r'
http
-
backend
_Url
-
http
\
/
_Url
-
backend
'
\
r'
\
d
+/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
'
\
r'
200
\
d
+
-
-
----
'
\
r'
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
d
+
\
/
\
d
+
'
\
r'"GET /test-path/deeper HTTP/1.1"'
self.assertRegexpMatches(
self.assertLastLogLineRegexp(
open(log_file, 'r').readlines()[-1],
'
_Url_backend_log
',
log_regexp)
r'
^
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}
\
.
\
d
{
1
,
3
}:
\
d
+
'
r'
\
[
\
d
{
2
}
\
/
.{
3
}
\
/
\
d
{
4
}
\
:
\
d
{
2
}
\
:
\
d
{
2
}
\
:
\
d
{
2
}.
\
d
{
3
}
\
]
'
r'
http
-
backend
_Url
-
http
\
/
_Url
-
backend
'
r'
\
d
+/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
'
r'
200
\
d
+
-
-
----
'
r'
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
/
\
d
+
\
d
+
\
/
\
d
+
'
r'"GET /test-path/deeper HTTP/1.1"'
)
result_http = fakeHTTPResult(
result_http = fakeHTTPResult(
parameter_dict['
domain
'],
parameter_dict['
domain
'],
...
...
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