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
Lisa Casino
slapos
Commits
75af5cd3
Commit
75af5cd3
authored
May 14, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm, jupyter: fix proxy.db queries in instantiation tests
parent
392b9e8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
39 deletions
+31
-39
software/jupyter/test/test.py
software/jupyter/test/test.py
+17
-23
software/kvm/test/test.py
software/kvm/test/test.py
+14
-16
No files found.
software/jupyter/test/test.py
View file @
75af5cd3
...
...
@@ -32,7 +32,7 @@ import os
import
requests
import
sqlite3
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
setUpModule
,
InstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
...
...
@@ -169,27 +169,21 @@ class SelectMixin(object):
)
return
sqlite3
.
connect
(
sqlitedb_file
)
def
select
(
self
,
fields
,
table
,
where
=
{}):
connection
=
self
.
sqlite3_connect
()
def
dict_factory
(
cursor
,
row
):
d
=
{}
for
idx
,
col
in
enumerate
(
cursor
.
description
):
d
[
col
[
0
]]
=
row
[
idx
]
return
d
connection
.
row_factory
=
dict_factory
cursor
=
connection
.
cursor
()
condition
=
" AND "
.
join
(
"%s='%s'"
%
(
k
,
v
)
for
k
,
v
in
where
.
items
())
cursor
.
execute
(
"SELECT %s FROM %s%s"
%
(
def
select
(
self
,
table
,
fields
=
(
'*'
,),
**
where
):
db
=
self
.
sqlite3_connect
()
try
:
db
.
row_factory
=
lambda
cursor
,
row
:
{
col
[
0
]:
row
[
idx
]
for
idx
,
col
in
enumerate
(
cursor
.
description
)
}
return
db
.
execute
(
"SELECT %s FROM %s%s%s"
%
(
", "
.
join
(
fields
),
table
,
" WHERE %s"
%
condition
if
where
else
""
,
)
)
return
cursor
.
fetchall
()
table
,
DB_VERSION
,
" WHERE "
+
" AND "
.
join
(
"%s='%s'"
%
x
for
x
in
where
.
items
())
if
where
else
""
,
)).
fetchall
()
finally
:
db
.
close
()
class
TestJupyterCustomFrontend
(
SelectMixin
,
InstanceTestCase
):
...
...
@@ -226,7 +220,7 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase):
except
Exception
:
pass
selection
=
self
.
select
(
fields
=
[
"*"
],
table
=
"slave14"
,
where
=
{
"hosted_by"
:
r
.
_partition_id
}
)
selection
=
self
.
select
(
"slave"
,
hosted_by
=
r
.
_partition_id
)
self
.
assertEqual
(
len
(
selection
),
1
)
...
...
@@ -268,7 +262,7 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase):
except
Exception
:
pass
selection
=
self
.
select
(
fields
=
[
"*"
],
table
=
"slave14"
,
where
=
{
"hosted_by"
:
r
.
_partition_id
}
)
selection
=
self
.
select
(
"slave"
,
hosted_by
=
r
.
_partition_id
)
self
.
assertEqual
(
len
(
selection
),
1
)
...
...
software/kvm/test/test.py
View file @
75af5cd3
...
...
@@ -46,6 +46,7 @@ import time
import
shutil
import
sys
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.slap.standalone
import
SlapOSNodeCommandError
...
...
@@ -214,22 +215,19 @@ class MonitorAccessMixin(object):
return
sqlite3
.
connect
(
sqlitedb_file
)
def
get_all_instantiated_partition_list
(
self
):
connection
=
self
.
sqlite3_connect
()
def
dict_factory
(
cursor
,
row
):
d
=
{}
for
idx
,
col
in
enumerate
(
cursor
.
description
):
d
[
col
[
0
]]
=
row
[
idx
]
return
d
connection
.
row_factory
=
dict_factory
cursor
=
connection
.
cursor
()
cursor
.
execute
(
"SELECT reference, xml, connection_xml, partition_reference, "
"software_release, requested_state, software_type "
"FROM partition14 "
"WHERE slap_state='busy'"
)
return
cursor
.
fetchall
()
db
=
self
.
sqlite3_connect
()
try
:
db
.
row_factory
=
lambda
cursor
,
row
:
{
col
[
0
]:
row
[
idx
]
for
idx
,
col
in
enumerate
(
cursor
.
description
)
}
return
db
.
execute
(
"SELECT reference, xml, connection_xml, partition_reference,"
" software_release, requested_state, software_type"
" FROM partition%s"
" WHERE slap_state='busy'"
%
DB_VERSION
).
fetchall
()
finally
:
db
.
close
()
def
test_access_monitor
(
self
):
connection_parameter_dict
=
self
.
computer_partition
\
...
...
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