Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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.core
Commits
198c2d6a
Commit
198c2d6a
authored
Sep 06, 2024
by
Carlos Ramos Carreño
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept `pathlib.Path` objects as a software URL.
parent
f4ceaaa3
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
271 additions
and
193 deletions
+271
-193
slapos/testing/check_software.py
slapos/testing/check_software.py
+239
-171
slapos/testing/testcase.py
slapos/testing/testcase.py
+32
-22
No files found.
slapos/testing/check_software.py
View file @
198c2d6a
This diff is collapsed.
Click to expand it.
slapos/testing/testcase.py
View file @
198c2d6a
...
...
@@ -37,8 +37,6 @@ import sqlite3
import
unittest
import
warnings
from
six.moves.urllib.parse
import
urlparse
from
netaddr
import
valid_ipv6
from
.utils
import
getPortFromPath
...
...
@@ -54,6 +52,7 @@ from .check_software import checkSoftware
from
..proxy.db_version
import
DB_VERSION
from
os
import
fspath
,
PathLike
from
typing
import
(
Callable
,
ClassVar
,
...
...
@@ -67,6 +66,8 @@ from typing import (
Type
,
TypeVar
,
)
from
urllib.parse
import
urlparse
ManagedResourceType
=
TypeVar
(
"ManagedResourceType"
,
bound
=
ManagedResource
)
IPV4_ADDRESS_DEFAULT
:
str
=
os
.
environ
[
'SLAPOS_TEST_IPV4'
]
...
...
@@ -95,7 +96,7 @@ SNAPSHOT_DIRECTORY_DEFAULT: str | None = os.environ.get(
)
def
makeModuleSetUpAndTestCaseClass
(
software_url
:
str
,
software_url
:
str
|
PathLike
[
str
]
,
*
,
base_directory
:
str
|
None
=
None
,
ipv4_address
:
str
=
IPV4_ADDRESS_DEFAULT
,
...
...
@@ -125,7 +126,7 @@ def makeModuleSetUpAndTestCaseClass(
See https://lab.nexedi.com/kirr/slapns for a solution to this problem.
Args:
software_url: The URL of the software to test.
software_url: The URL o
r path o
f the software to test.
base_directory: The base directory used for SlapOS.
By default, it will use the value in the environment variable
``SLAPOS_TEST_WORKING_DIR``.
...
...
@@ -189,7 +190,7 @@ def makeModuleSetUpAndTestCaseClass(
)
if
not
software_id
:
software_id
=
urlparse
(
software_url
).
path
.
split
(
'/'
)[
-
2
]
software_id
=
urlparse
(
fspath
(
software_url
)
).
path
.
split
(
'/'
)[
-
2
]
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
...
...
@@ -253,31 +254,40 @@ def makeModuleSetUpAndTestCaseClass(
return
setUpModule
,
SlapOSInstanceTestCase_
def
installSoftwareUrlList
(
cls
,
software_url_list
,
max_retry
=
10
,
debug
=
False
):
# type: (Type[SlapOSInstanceTestCase], Iterable[str], int, bool) -> None
"""Install softwares on the current testing slapos, for use in `setUpModule`.
def
installSoftwareUrlList
(
cls
:
Type
[
SlapOSInstanceTestCase
],
software_url_list
:
Sequence
[
str
|
PathLike
[
str
]],
max_retry
:
int
=
10
,
debug
:
bool
=
False
,
)
->
None
:
"""
Install softwares on the current testing slapos, for use in `setUpModule`.
This also check softwares with `checkSoftware`.
Args:
cls: The test case class used for the installation.
software_url_list: List of URLs or paths to install.
max_retry: Number of times that the installation will be retried if there
is an error.
debug: If set to ``True`` the software will not be automatically removed
if there is an error during the installation process, in order to
facilitate inspection during debug.
This also check softwares with `checkSoftware`
"""
def
_storeSoftwareSnapshot
(
name
)
:
def
_storeSoftwareSnapshot
(
name
:
str
)
->
None
:
for
path
in
glob
.
glob
(
os
.
path
.
join
(
cls
.
_base_directory
,
'var'
,
'log'
,
'*'
,
"var/log/*"
,
))
+
glob
.
glob
(
os
.
path
.
join
(
cls
.
slap
.
software_directory
,
'*'
,
'*.cfg'
,
"*/*.cfg"
,
))
+
glob
.
glob
(
os
.
path
.
join
(
cls
.
slap
.
software_directory
,
'*'
,
'.installed.cfg'
,
"*/.installed.cfg"
,
))
+
glob
.
glob
(
os
.
path
.
join
(
cls
.
slap
.
shared_directory
,
'*'
,
'*'
,
'.slapos.recipe.cmmi.signature'
,
"*/*/.slapos.recipe.cmmi.signature"
,
)):
cls
.
_copySnapshot
(
path
,
name
)
...
...
@@ -286,7 +296,7 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False):
cls
.
slap
.
start
()
for
software_url
in
software_url_list
:
cls
.
logger
.
debug
(
"Supplying %s"
,
software_url
)
cls
.
slap
.
supply
(
software_url
)
cls
.
slap
.
supply
(
fspath
(
software_url
)
)
cls
.
logger
.
debug
(
"Waiting for slapos node software to build"
)
cls
.
slap
.
waitForSoftware
(
max_retry
=
max_retry
,
debug
=
debug
,
install_all
=
not
cls
.
_skip_software_rebuild
)
_storeSoftwareSnapshot
(
'setupModule'
)
...
...
@@ -305,7 +315,7 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False):
try
:
for
software_url
in
software_url_list
:
cls
.
logger
.
debug
(
"Removing %s"
,
software_url
)
cls
.
slap
.
supply
(
software_url
,
state
=
"destroyed"
)
cls
.
slap
.
supply
(
fspath
(
software_url
)
,
state
=
"destroyed"
)
cls
.
logger
.
debug
(
"Waiting for slapos node software to remove"
)
cls
.
slap
.
waitForSoftware
(
max_retry
=
max_retry
,
debug
=
debug
)
except
BaseException
:
...
...
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