Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Xiaowu Zhang
slapos.toolbox
Commits
d4d00856
Commit
d4d00856
authored
Oct 04, 2021
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Plain Diff
Stabilizing fixup for SlapOS.Eggs.UnitTest
See merge request
!100
parents
ce634067
5d23278e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
slapos/test/test_networkbench.py
slapos/test/test_networkbench.py
+23
-10
No files found.
slapos/test/test_networkbench.py
View file @
d4d00856
...
...
@@ -30,8 +30,18 @@ import os.path
from
slapos.networkbench
import
dnsbench
from
slapos.networkbench.ping
import
ping
,
ping6
from
slapos.networkbench.http
import
request
import
dns
import
mock
class
MockIPAddress
:
def
__init__
(
self
,
ip_text
):
self
.
ip
=
ip_text
def
to_text
(
self
):
return
self
.
ip
MOCK_IP_ADDRESS_LIST
=
[
MockIPAddress
(
'161.97.166.226'
),
MockIPAddress
(
'176.31.129.213'
)]
DNS_EXPECTED_LIST
=
[
"161.97.166.226"
,
"176.31.129.213"
]
class
TestDNSBench
(
unittest
.
TestCase
):
...
...
@@ -40,17 +50,20 @@ class TestDNSBench(unittest.TestCase):
"""
Test dns resolution
"""
info
=
dnsbench
.
resolve
(
"eu.web.vifib.com"
,
DNS_EXPECTED_LIST
)
self
.
assertEqual
(
info
[
0
],
'DNS'
)
self
.
assertEqual
(
info
[
1
],
'eu.web.vifib.com'
)
self
.
assertEqual
(
info
[
2
],
200
)
with
mock
.
patch
.
object
(
dns
.
resolver
,
"query"
)
as
query
:
query
.
return_value
=
MOCK_IP_ADDRESS_LIST
self
.
assertLess
(
info
[
3
],
30
)
self
.
assertEqual
(
info
[
4
],
'OK'
,
"%s != OK, full info: %s"
%
(
info
[
4
],
info
)
)
self
.
assertEqual
(
set
(
info
[
5
]),
set
([
u'161.97.166.226'
,
u'176.31.129.213'
]),
info
=
dnsbench
.
resolve
(
"eu.web.vifib.com"
,
DNS_EXPECTED_LIST
)
self
.
assertEqual
(
info
[
0
],
'DNS'
)
self
.
assertEqual
(
info
[
1
],
'eu.web.vifib.com'
)
self
.
assertEqual
(
info
[
2
],
200
)
self
.
assertLess
(
info
[
3
],
30
)
self
.
assertEqual
(
info
[
4
],
'OK'
,
"%s != OK, full info: %s"
%
(
info
[
4
],
info
)
)
self
.
assertEqual
(
set
(
info
[
5
]),
set
([
u'161.97.166.226'
,
u'176.31.129.213'
]),
"%s != set([u'161.97.166.226', u'176.31.129.213']), full info: %s"
%
(
set
(
info
[
5
]),
info
))
def
test_dnsbench_fail
(
self
):
...
...
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