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
Carlos Ramos Carreño
slapos
Commits
7e7e7703
Commit
7e7e7703
authored
Mar 15, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/theia: Improve tests
parent
c8f8159e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
52 deletions
+23
-52
software/theia/test/test.py
software/theia/test/test.py
+23
-52
No files found.
software/theia/test/test.py
View file @
7e7e7703
...
@@ -50,8 +50,17 @@ setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
...
@@ -50,8 +50,17 @@ setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
class
TestTheia
(
SlapOSInstanceTestCase
):
class
TheiaTestCase
(
SlapOSInstanceTestCase
):
__partition_reference__
=
'T'
# for sockets in included slapos
__partition_reference__
=
'T'
# for supervisord sockets in included slapos
@
classmethod
def
_getSlapos
(
cls
):
partition_root
=
cls
.
computer_partition_root_path
slapos
=
os
.
path
.
join
(
partition_root
,
'srv'
,
'runner'
,
'bin'
,
'slapos'
)
return
slapos
class
TestTheia
(
TheiaTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
connection_parameters
=
self
.
computer_partition
.
getConnectionParameterDict
()
self
.
connection_parameters
=
self
.
computer_partition
.
getConnectionParameterDict
()
...
@@ -178,9 +187,7 @@ class TestTheia(SlapOSInstanceTestCase):
...
@@ -178,9 +187,7 @@ class TestTheia(SlapOSInstanceTestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
script_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
script_path
))
class
TestTheiaEmbeddedSlapOSShutdown
(
SlapOSInstanceTestCase
):
class
TestTheiaEmbeddedSlapOSShutdown
(
TheiaTestCase
):
__partition_reference__
=
'T'
# for sockets in included slapos
def
test_stopping_instance_stops_embedded_slapos
(
self
):
def
test_stopping_instance_stops_embedded_slapos
(
self
):
embedded_slapos_supervisord_socket
=
_getSupervisordSocketPath
(
embedded_slapos_supervisord_socket
=
_getSupervisordSocketPath
(
os
.
path
.
join
(
os
.
path
.
join
(
...
@@ -212,57 +219,21 @@ class TestTheiaEmbeddedSlapOSShutdown(SlapOSInstanceTestCase):
...
@@ -212,57 +219,21 @@ class TestTheiaEmbeddedSlapOSShutdown(SlapOSInstanceTestCase):
self
.
assertFalse
(
embedded_slapos_process
.
is_running
())
self
.
assertFalse
(
embedded_slapos_process
.
is_running
())
class
SQLiteDB
(
object
):
class
TestTheiaWithSR
(
TheiaTestCase
):
def
__init__
(
self
,
sqlitedb_file
):
sr_url
=
'bogus/software.cfg'
self
.
sqlitedb_file
=
sqlitedb_file
sr_type
=
'bogus_type'
def
select
(
self
,
fields
,
table
,
where
=
{}):
connection
=
sqlite3
.
connect
(
self
.
sqlitedb_file
)
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"
%
(
", "
.
join
(
fields
),
table
,
" WHERE %s"
%
condition
if
where
else
""
,
)
)
return
cursor
.
fetchall
()
class
TestTheiaWithSR
(
SlapOSInstanceTestCase
):
__partition_reference__
=
'T'
# for sockets in included slapos
srurl
=
'bogus/software.cfg'
srtype
=
'bogus'
@
classmethod
@
classmethod
def
getInstanceParameterDict
(
cls
):
def
getInstanceParameterDict
(
cls
):
return
{
return
{
'embedded-sr'
:
cls
.
srurl
,
'embedded-sr'
:
cls
.
sr
_
url
,
'embedded-sr-type'
:
cls
.
srtype
,
'embedded-sr-type'
:
cls
.
sr
_
type
,
}
}
def
test
(
self
):
def
test
(
self
):
db
=
SQLiteDB
(
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'srv'
,
'runner'
,
'var'
,
'proxy.db'
))
slapos
=
self
.
_getSlapos
()
supplied
=
db
.
select
(
info
=
subprocess
.
check_output
((
slapos
,
'proxy'
,
'show'
))
fields
=
[
"*"
],
instance_name
=
"Embedded Instance"
table
=
"software14"
,
where
=
{
'url'
:
self
.
srurl
}
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+sl
aprunner\
s+
available"
%
(
self
.
sr_url
,),
info
),
info
)
)
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+%s
\s+%s"
%
(
self
.
sr_url
,
self
.
sr_type
,
instance_name
),
info
),
info
)
self
.
assertEqual
(
len
(
supplied
),
1
)
requested
=
db
.
select
(
fields
=
[
"*"
],
table
=
"partition14"
,
where
=
{
'software_release'
:
self
.
srurl
,
'software_type'
:
self
.
srtype
}
)
self
.
assertEqual
(
len
(
requested
),
1
)
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