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
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
Łukasz Nowak
slapos
Commits
fa981453
Commit
fa981453
authored
Apr 22, 2024
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/kvm: Test nbd-host and nbd-port
Also nbd2-host and nbd2-port are asserted.
parent
93c50b62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
software/kvm/test/test.py
software/kvm/test/test.py
+84
-0
No files found.
software/kvm/test/test.py
View file @
fa981453
...
@@ -1244,6 +1244,90 @@ class TestVirtualHardDriveUrl(FakeImageServerMixin, KVMTestCase):
...
@@ -1244,6 +1244,90 @@ class TestVirtualHardDriveUrl(FakeImageServerMixin, KVMTestCase):
)
)
@
skipUnlessKvm
class
TestInstanceNbd
(
KVMTestCase
):
__partition_reference__
=
'in'
kvm_instance_partition_reference
=
'in0'
@
classmethod
def
startNbdServer
(
cls
):
cls
.
nbd_directory
=
tempfile
.
mkdtemp
()
img_1
=
os
.
path
.
join
(
cls
.
nbd_directory
,
'one.qcow'
)
img_2
=
os
.
path
.
join
(
cls
.
nbd_directory
,
'two.qcow'
)
subprocess
.
check_call
([
cls
.
qemu_img
,
"create"
,
"-f"
,
"qcow"
,
img_1
,
"1M"
])
subprocess
.
check_call
([
cls
.
qemu_img
,
"create"
,
"-f"
,
"qcow"
,
img_2
,
"1M"
])
nbd_list
=
[
cls
.
qemu_nbd
,
'-r'
,
'-t'
,
'-e'
,
'32767'
]
cls
.
nbd_1_port
=
findFreeTCPPort
(
cls
.
_ipv6_address
)
cls
.
nbd_1
=
subprocess
.
Popen
(
nbd_list
+
[
'-b'
,
cls
.
_ipv6_address
,
'-p'
,
str
(
cls
.
nbd_1_port
),
img_1
])
cls
.
nbd_1_uri
=
'[%s]:%s'
%
(
cls
.
_ipv6_address
,
cls
.
nbd_1_port
)
cls
.
nbd_2_port
=
findFreeTCPPort
(
cls
.
_ipv6_address
)
cls
.
nbd_2
=
subprocess
.
Popen
(
nbd_list
+
[
'-b'
,
cls
.
_ipv6_address
,
'-p'
,
str
(
cls
.
nbd_2_port
),
img_2
])
cls
.
nbd_2_uri
=
'[%s]:%s'
%
(
cls
.
_ipv6_address
,
cls
.
nbd_2_port
)
@
classmethod
def
stopNbdServer
(
cls
):
cls
.
nbd_1
.
terminate
()
cls
.
nbd_2
.
terminate
()
shutil
.
rmtree
(
cls
.
nbd_directory
)
@
classmethod
def
setUpClass
(
cls
):
# we need qemu-nbd binary location
# it's to hard to put qemu in software/slapos-sr-testing
# so let's find it here
# let's find our software .installed.cfg
cls
.
findQemuTools
()
cls
.
startNbdServer
()
super
().
setUpClass
()
@
classmethod
def
tearDownClass
(
cls
):
super
().
tearDownClass
()
cls
.
stopNbdServer
()
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
"nbd-host"
:
cls
.
_ipv6_address
,
"nbd-port"
:
cls
.
nbd_1_port
}
def
test
(
self
):
kvm_instance_partition
=
os
.
path
.
join
(
self
.
slap
.
instance_directory
,
self
.
kvm_instance_partition_reference
)
self
.
assertEqual
(
[
f'nbd:
{
self
.
nbd_1_uri
}
'
,
'${shared}/debian-${ver}-amd64-netinst.iso'
],
self
.
getRunningImageList
(
kvm_instance_partition
)
)
@
skipUnlessKvm
class
TestInstanceNbdBoth
(
TestInstanceNbd
):
__partition_reference__
=
'inb'
kvm_instance_partition_reference
=
'inb0'
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
"nbd-host"
:
cls
.
_ipv6_address
,
"nbd-port"
:
cls
.
nbd_1_port
,
"nbd2-host"
:
cls
.
_ipv6_address
,
"nbd2-port"
:
cls
.
nbd_2_port
}
def
test
(
self
):
kvm_instance_partition
=
os
.
path
.
join
(
self
.
slap
.
instance_directory
,
self
.
kvm_instance_partition_reference
)
self
.
assertEqual
(
[
f'nbd:
{
self
.
nbd_1_uri
}
'
,
f'nbd:
{
self
.
nbd_2_uri
}
'
,
'${shared}/debian-${ver}-amd64-netinst.iso'
],
self
.
getRunningImageList
(
kvm_instance_partition
)
)
@
skipUnlessKvm
@
skipUnlessKvm
class
TestVirtualHardDriveUrlGzipped
(
TestVirtualHardDriveUrl
):
class
TestVirtualHardDriveUrlGzipped
(
TestVirtualHardDriveUrl
):
__partition_reference__
=
'vhdug'
__partition_reference__
=
'vhdug'
...
...
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