Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos-mynij-dev
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
Mynij
slapos-mynij-dev
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
Hide 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
...
@@ -32,7 +32,7 @@ import os
import
requests
import
requests
import
sqlite3
import
sqlite3
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
setUpModule
,
InstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
setUpModule
,
InstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
...
@@ -169,27 +169,21 @@ class SelectMixin(object):
...
@@ -169,27 +169,21 @@ class SelectMixin(object):
)
)
return
sqlite3
.
connect
(
sqlitedb_file
)
return
sqlite3
.
connect
(
sqlitedb_file
)
def
select
(
self
,
fields
,
table
,
where
=
{}):
def
select
(
self
,
table
,
fields
=
(
'*'
,),
**
where
):
connection
=
self
.
sqlite3_connect
()
db
=
self
.
sqlite3_connect
()
try
:
def
dict_factory
(
cursor
,
row
):
db
.
row_factory
=
lambda
cursor
,
row
:
{
d
=
{}
col
[
0
]:
row
[
idx
]
for
idx
,
col
in
enumerate
(
cursor
.
description
):
for
idx
,
col
in
enumerate
(
cursor
.
description
)
d
[
col
[
0
]]
=
row
[
idx
]
}
return
d
return
db
.
execute
(
"SELECT %s FROM %s%s%s"
%
(
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"
%
(
", "
.
join
(
fields
),
", "
.
join
(
fields
),
table
,
table
,
DB_VERSION
,
" WHERE %s"
%
condition
if
where
else
""
,
" WHERE "
+
" AND "
.
join
(
"%s='%s'"
%
x
for
x
in
where
.
items
())
)
if
where
else
""
,
)
)).
fetchall
()
return
cursor
.
fetchall
()
finally
:
db
.
close
()
class
TestJupyterCustomFrontend
(
SelectMixin
,
InstanceTestCase
):
class
TestJupyterCustomFrontend
(
SelectMixin
,
InstanceTestCase
):
...
@@ -226,7 +220,7 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase):
...
@@ -226,7 +220,7 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase):
except
Exception
:
except
Exception
:
pass
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
)
self
.
assertEqual
(
len
(
selection
),
1
)
...
@@ -268,7 +262,7 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase):
...
@@ -268,7 +262,7 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase):
except
Exception
:
except
Exception
:
pass
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
)
self
.
assertEqual
(
len
(
selection
),
1
)
...
...
software/kvm/test/test.py
View file @
75af5cd3
...
@@ -46,6 +46,7 @@ import time
...
@@ -46,6 +46,7 @@ import time
import
shutil
import
shutil
import
sys
import
sys
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.slap.standalone
import
SlapOSNodeCommandError
from
slapos.slap.standalone
import
SlapOSNodeCommandError
...
@@ -214,22 +215,19 @@ class MonitorAccessMixin(object):
...
@@ -214,22 +215,19 @@ class MonitorAccessMixin(object):
return
sqlite3
.
connect
(
sqlitedb_file
)
return
sqlite3
.
connect
(
sqlitedb_file
)
def
get_all_instantiated_partition_list
(
self
):
def
get_all_instantiated_partition_list
(
self
):
connection
=
self
.
sqlite3_connect
()
db
=
self
.
sqlite3_connect
()
try
:
def
dict_factory
(
cursor
,
row
):
db
.
row_factory
=
lambda
cursor
,
row
:
{
d
=
{}
col
[
0
]:
row
[
idx
]
for
idx
,
col
in
enumerate
(
cursor
.
description
):
for
idx
,
col
in
enumerate
(
cursor
.
description
)
d
[
col
[
0
]]
=
row
[
idx
]
}
return
d
return
db
.
execute
(
connection
.
row_factory
=
dict_factory
"SELECT reference, xml, connection_xml, partition_reference,"
cursor
=
connection
.
cursor
()
" software_release, requested_state, software_type"
" FROM partition%s"
cursor
.
execute
(
" WHERE slap_state='busy'"
%
DB_VERSION
).
fetchall
()
"SELECT reference, xml, connection_xml, partition_reference, "
finally
:
"software_release, requested_state, software_type "
db
.
close
()
"FROM partition14 "
"WHERE slap_state='busy'"
)
return
cursor
.
fetchall
()
def
test_access_monitor
(
self
):
def
test_access_monitor
(
self
):
connection_parameter_dict
=
self
.
computer_partition
\
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