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
Lu Xu
slapos.core
Commits
78be3e6e
Commit
78be3e6e
authored
Dec 11, 2023
by
Lu Xu
👀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
f173c1a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
slapos/testing/e2e.py
slapos/testing/e2e.py
+21
-7
No files found.
slapos/testing/e2e.py
View file @
78be3e6e
...
@@ -9,12 +9,26 @@ import requests
...
@@ -9,12 +9,26 @@ import requests
import
re
import
re
import
slapos.client
import
slapos.client
from
websocket
import
create_connection
from
websocket
import
create_connection
from
logging.handlers
import
RotatingFileHandler
class
EndToEndTestCase
(
unittest
.
TestCase
):
class
EndToEndTestCase
(
unittest
.
TestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
().
__init__
(
methodName
)
LOG_FILE
=
os
.
environ
[
'LOG_FILE'
]
self
.
logger
=
logging
.
getLogger
(
'logger'
)
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
handler
=
RotatingFileHandler
(
LOG_FILE
,
maxBytes
=
100000
,
backupCount
=
5
)
self
.
logger
.
addHandler
(
handler
)
formatter
=
logging
.
Formatter
(
"%(asctime)s [%(levelname)s] %(message)s"
)
handler
.
setFormatter
(
formatter
)
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
configp
=
configparser
.
ConfigParser
()
configp
=
configparser
.
ConfigParser
()
print
(
os
.
environ
)
config_path
=
os
.
environ
[
'SLAPOS_TEST_CLIENT_CFG'
]
config_path
=
os
.
environ
[
'SLAPOS_TEST_CLIENT_CFG'
]
configp
.
read
(
config_path
)
configp
.
read
(
config_path
)
args
=
type
(
"empty_args"
,
(),
{})()
args
=
type
(
"empty_args"
,
(),
{})()
...
@@ -101,7 +115,7 @@ class EndToEndTestCase(unittest.TestCase):
...
@@ -101,7 +115,7 @@ class EndToEndTestCase(unittest.TestCase):
t0
=
t0
or
time
.
time
()
t0
=
t0
or
time
.
time
()
while
(
status
:
=
cls
.
getInstanceStatus
(
instance_name
))
!=
'green'
:
while
(
status
:
=
cls
.
getInstanceStatus
(
instance_name
))
!=
'green'
:
msg
=
'Instance %s status is still %s'
%
(
instance_name
,
status
)
msg
=
'Instance %s status is still %s'
%
(
instance_name
,
status
)
print
(
msg
)
self
.
logger
.
info
(
msg
)
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
@
classmethod
@
classmethod
...
@@ -109,7 +123,7 @@ class EndToEndTestCase(unittest.TestCase):
...
@@ -109,7 +123,7 @@ class EndToEndTestCase(unittest.TestCase):
t0
=
t0
or
time
.
time
()
t0
=
t0
or
time
.
time
()
msg
=
'Instance %s still does not publish %s'
%
(
instance_name
,
key
)
msg
=
'Instance %s still does not publish %s'
%
(
instance_name
,
key
)
while
(
value
:
=
cls
.
getInstanceInfos
(
instance_name
).
connection_dict
.
get
(
key
))
==
None
:
while
(
value
:
=
cls
.
getInstanceInfos
(
instance_name
).
connection_dict
.
get
(
key
))
==
None
:
print
(
msg
)
self
.
logger
.
info
(
msg
)
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
return
value
return
value
...
@@ -186,7 +200,7 @@ class EndToEndTestCase(unittest.TestCase):
...
@@ -186,7 +200,7 @@ class EndToEndTestCase(unittest.TestCase):
result
=
"[OK]"
in
title
result
=
"[OK]"
in
title
name
=
title
.
replace
(
"[OK]"
,
""
).
replace
(
"[ERROR]"
,
""
).
strip
()
name
=
title
.
replace
(
"[OK]"
,
""
).
replace
(
"[ERROR]"
,
""
).
strip
()
status
[
name
]
=
result
status
[
name
]
=
result
print
(
f"Test alarm:
{
title
}
:
{
description
}
"
)
self
.
logger
.
info
(
f"Test alarm:
{
title
}
:
{
description
}
"
)
return
status
return
status
@
classmethod
@
classmethod
...
@@ -196,10 +210,10 @@ class EndToEndTestCase(unittest.TestCase):
...
@@ -196,10 +210,10 @@ class EndToEndTestCase(unittest.TestCase):
while
True
:
while
True
:
resp
,
url
=
cls
.
waitUntilMonitorURLReady
(
instance_name
,
code
=
200
,
timeout
=
timeout
,
t0
=
t0
)
resp
,
url
=
cls
.
waitUntilMonitorURLReady
(
instance_name
,
code
=
200
,
timeout
=
timeout
,
t0
=
t0
)
status
=
cls
.
getMonitorPromises
(
resp
.
content
)
status
=
cls
.
getMonitorPromises
(
resp
.
content
)
print
(
"Status:"
,
status
)
self
.
logger
.
info
(
"Status:"
,
status
)
print
(
"Promise Status:"
,
status
.
get
(
promise_name
,
"Promise not found"
))
self
.
logger
.
info
(
"Promise Status:"
,
status
.
get
(
promise_name
,
"Promise not found"
))
if
status
.
get
(
promise_name
)
==
expected
:
if
status
.
get
(
promise_name
)
==
expected
:
print
(
"%s is at expected status: %s"
%
(
promise_name
,
expected
))
self
.
logger
.
info
(
"%s is at expected status: %s"
%
(
promise_name
,
expected
))
break
break
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
cls
.
checkTimeoutAndSleep
(
t0
,
timeout
,
msg
)
resp
=
requests
.
get
(
url
)
resp
=
requests
.
get
(
url
)
...
...
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