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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
slapos
Commits
893a5bd2
Commit
893a5bd2
authored
Apr 12, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: fix python3 support in test
parent
748db419
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
software/kvm/test/test.py
software/kvm/test/test.py
+10
-9
No files found.
software/kvm/test/test.py
View file @
893a5bd2
...
@@ -38,8 +38,8 @@ from six.moves.urllib.parse import parse_qs, urlparse
...
@@ -38,8 +38,8 @@ from six.moves.urllib.parse import parse_qs, urlparse
import
unittest
import
unittest
import
subprocess
import
subprocess
import
tempfile
import
tempfile
import
SocketServer
import
six.moves.socketserver
as
SocketServer
import
SimpleHTTPServer
from
six.moves
import
SimpleHTTPServer
import
multiprocessing
import
multiprocessing
import
time
import
time
import
shutil
import
shutil
...
@@ -604,13 +604,13 @@ class FakeImageServerMixin(object):
...
@@ -604,13 +604,13 @@ class FakeImageServerMixin(object):
(
self
.
_ipv4_address
,
findFreeTCPPort
(
self
.
_ipv4_address
)),
(
self
.
_ipv4_address
,
findFreeTCPPort
(
self
.
_ipv4_address
)),
FakeImageHandler
)
FakeImageHandler
)
fake_image_content
=
'fake_image_content'
fake_image_content
=
b
'fake_image_content'
self
.
fake_image_md5sum
=
hashlib
.
md5
(
fake_image_content
).
hexdigest
()
self
.
fake_image_md5sum
=
hashlib
.
md5
(
fake_image_content
).
hexdigest
()
with
open
(
os
.
path
.
join
(
with
open
(
os
.
path
.
join
(
self
.
image_source_directory
,
self
.
fake_image_md5sum
),
'wb'
)
as
fh
:
self
.
image_source_directory
,
self
.
fake_image_md5sum
),
'wb'
)
as
fh
:
fh
.
write
(
fake_image_content
)
fh
.
write
(
fake_image_content
)
fake_image2_content
=
'fake_image2_content'
fake_image2_content
=
b
'fake_image2_content'
self
.
fake_image2_md5sum
=
hashlib
.
md5
(
fake_image2_content
).
hexdigest
()
self
.
fake_image2_md5sum
=
hashlib
.
md5
(
fake_image2_content
).
hexdigest
()
with
open
(
os
.
path
.
join
(
with
open
(
os
.
path
.
join
(
self
.
image_source_directory
,
self
.
fake_image2_md5sum
),
'wb'
)
as
fh
:
self
.
image_source_directory
,
self
.
fake_image2_md5sum
),
'wb'
)
as
fh
:
...
@@ -1187,17 +1187,16 @@ class TestWhitelistFirewall(InstanceTestCase):
...
@@ -1187,17 +1187,16 @@ class TestWhitelistFirewall(InstanceTestCase):
'.slapos-whitelist-firewall'
)
'.slapos-whitelist-firewall'
)
self
.
assertTrue
(
os
.
path
.
exists
(
slapos_whitelist_firewall
))
self
.
assertTrue
(
os
.
path
.
exists
(
slapos_whitelist_firewall
))
with
open
(
slapos_whitelist_firewall
,
'rb'
)
as
fh
:
with
open
(
slapos_whitelist_firewall
,
'rb'
)
as
fh
:
content
=
fh
.
read
()
.
encode
(
'utf-8'
)
content
=
fh
.
read
()
try
:
try
:
self
.
content_json
=
json
.
loads
(
content
)
self
.
content_json
=
json
.
loads
(
content
)
except
ValueError
:
except
ValueError
:
self
.
fail
(
'Failed to parse json of %
s
'
%
(
content
,))
self
.
fail
(
'Failed to parse json of %
r
'
%
(
content
,))
self
.
assertTrue
(
isinstance
(
self
.
content_json
,
list
))
self
.
assertTrue
(
isinstance
(
self
.
content_json
,
list
))
# check /etc/resolv.conf
# check /etc/resolv.conf
with
open
(
'/etc/resolv.conf'
,
'r
b'
)
as
fh
:
with
open
(
'/etc/resolv.conf'
,
'r
'
)
as
f
:
resolv_conf_ip_list
=
[]
resolv_conf_ip_list
=
[]
for
line
in
fh
.
readlines
():
for
line
in
f
.
readlines
():
line
=
line
.
encode
(
'utf-8'
)
if
line
.
startswith
(
'nameserver'
):
if
line
.
startswith
(
'nameserver'
):
resolv_conf_ip_list
.
append
(
line
.
split
()[
1
])
resolv_conf_ip_list
.
append
(
line
.
split
()[
1
])
resolv_conf_ip_list
=
list
(
set
(
resolv_conf_ip_list
))
resolv_conf_ip_list
=
list
(
set
(
resolv_conf_ip_list
))
...
@@ -1223,6 +1222,7 @@ class TestWhitelistFirewallRequest(TestWhitelistFirewall):
...
@@ -1223,6 +1222,7 @@ class TestWhitelistFirewallRequest(TestWhitelistFirewall):
self
.
assertIn
(
'4.4.4.4'
,
self
.
content_json
)
self
.
assertIn
(
'4.4.4.4'
,
self
.
content_json
)
@
skipIfPython3
@
skipUnlessKvm
@
skipUnlessKvm
class
TestWhitelistFirewallResilient
(
TestWhitelistFirewall
):
class
TestWhitelistFirewallResilient
(
TestWhitelistFirewall
):
kvm_instance_partition_reference
=
'wf2'
kvm_instance_partition_reference
=
'wf2'
...
@@ -1232,6 +1232,7 @@ class TestWhitelistFirewallResilient(TestWhitelistFirewall):
...
@@ -1232,6 +1232,7 @@ class TestWhitelistFirewallResilient(TestWhitelistFirewall):
return
'kvm-resilient'
return
'kvm-resilient'
@
skipIfPython3
@
skipUnlessKvm
@
skipUnlessKvm
class
TestWhitelistFirewallRequestResilient
(
TestWhitelistFirewallRequest
):
class
TestWhitelistFirewallRequestResilient
(
TestWhitelistFirewallRequest
):
kvm_instance_partition_reference
=
'wf2'
kvm_instance_partition_reference
=
'wf2'
...
...
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