Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Iliya Manolov
slapos.toolbox
Commits
87771bf5
Commit
87771bf5
authored
Sep 26, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner resilience test: export methods for easy extension.
Also, some 80 columns.
parent
1694937b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
46 deletions
+87
-46
slapos/resiliencytest/suites/slaprunner.py
slapos/resiliencytest/suites/slaprunner.py
+87
-46
No files found.
slapos/resiliencytest/suites/slaprunner.py
View file @
87771bf5
...
@@ -50,7 +50,9 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
...
@@ -50,7 +50,9 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
# Setup urllib2 with cookie support
# Setup urllib2 with cookie support
cookie_jar
=
cookielib
.
CookieJar
()
cookie_jar
=
cookielib
.
CookieJar
()
self
.
_opener_director
=
urllib2
.
build_opener
(
urllib2
.
HTTPCookieProcessor
(
cookie_jar
))
self
.
_opener_director
=
urllib2
.
build_opener
(
urllib2
.
HTTPCookieProcessor
(
cookie_jar
)
)
ResiliencyTestSuite
.
__init__
(
ResiliencyTestSuite
.
__init__
(
self
,
self
,
...
@@ -60,12 +62,6 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
...
@@ -60,12 +62,6 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
slaprunner_rootinstance_name
slaprunner_rootinstance_name
)
)
def
generateData
(
self
):
self
.
slaprunner_password
=
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
ascii_lowercase
,
8
))
self
.
slaprunner_user
=
'slapos'
self
.
logger
.
info
(
'Generated slaprunner user is: %s'
%
self
.
slaprunner_user
)
self
.
logger
.
info
(
'Generated slaprunner password is: %s'
%
self
.
slaprunner_password
)
def
_connectToSlaprunner
(
self
,
resource
,
data
=
None
):
def
_connectToSlaprunner
(
self
,
resource
,
data
=
None
):
"""
"""
Utility.
Utility.
...
@@ -84,55 +80,37 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
...
@@ -84,55 +80,37 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
def
_login
(
self
):
def
_login
(
self
):
self
.
logger
.
debug
(
'Logging in...'
)
self
.
logger
.
debug
(
'Logging in...'
)
self
.
_connectToSlaprunner
(
'doLogin'
,
data
=
'clogin=%s&cpwd=%s'
%
(
self
.
slaprunner_user
,
self
.
slaprunner_password
))
self
.
_connectToSlaprunner
(
'doLogin'
,
data
=
'clogin=%s&cpwd=%s'
%
(
self
.
slaprunner_user
,
self
.
slaprunner_password
)
)
def
_retrieveInstanceLogFile
(
self
):
def
_retrieveInstanceLogFile
(
self
):
"""
"""
Store the logfile (=data) of the instance, check it is not empty nor it is html.
Store the logfile (=data) of the instance, check it is not empty nor it is
html.
"""
"""
data
=
self
.
_connectToSlaprunner
(
resource
=
'fileBrowser'
,
data
=
'opt=9&filename=log.log&dir=instance_root%252Fslappart0%252Fvar%252Flog%252F'
)
data
=
self
.
_connectToSlaprunner
(
resource
=
'fileBrowser'
,
data
=
'opt=9&filename=log.log&dir=instance_root%252Fslappart0%252Fvar%252Flog%252F'
)
self
.
logger
.
info
(
'Retrieved data are:
\
n
%s'
%
data
)
self
.
logger
.
info
(
'Retrieved data are:
\
n
%s'
%
data
)
if
data
.
find
(
'<'
)
is
not
-
1
:
if
data
.
find
(
'<'
)
is
not
-
1
:
raise
IOError
(
'Could not retrieve logfile content: retrieved content is html.'
)
raise
IOError
(
'Could not retrieve logfile content: retrieved content is html.'
)
if
data
.
find
(
'Could not load'
)
is
not
-
1
:
if
data
.
find
(
'Could not load'
)
is
not
-
1
:
raise
IOError
(
'Could not retrieve logfile content: server could not load the file.'
)
raise
IOError
(
'Could not retrieve logfile content: server could not load the file.'
)
if
data
.
find
(
'Hello'
)
is
-
1
:
if
data
.
find
(
'Hello'
)
is
-
1
:
raise
IOError
(
'Could not retrieve logfile content: retrieve content does not match "Hello".'
)
raise
IOError
(
'Could not retrieve logfile content: retrieve content does not match "Hello".'
)
return
data
return
data
def
pushDataOnMainInstance
(
self
):
def
_buildSoftwareRelease
(
self
):
"""
Create a dummy Software Release,
Build it,
Wait for build to be successful,
Deploy instance,
Wait for instance to be started.
Store the main IP of the slaprunner for future use.
"""
self
.
logger
.
debug
(
'Getting the backend URL and recovery code...'
)
parameter_dict
=
self
.
_getPartitionParameterDict
()
self
.
slaprunner_backend_url
=
parameter_dict
[
'backend_url'
]
self
.
logger
.
info
(
'backend_url is %s.'
%
self
.
slaprunner_backend_url
)
slaprunner_recovery_code
=
parameter_dict
[
'password_recovery_code'
]
self
.
logger
.
debug
(
'Creating the slaprunner account...'
)
self
.
_connectToSlaprunner
(
resource
=
'configAccount'
,
data
=
'name=slapos&username=%s&email=slapos@slapos.org&password=%s&rcode=%s'
%
(
self
.
slaprunner_user
,
self
.
slaprunner_password
,
slaprunner_recovery_code
))
self
.
_login
()
self
.
logger
.
debug
(
'Opening hello-world software release from git...'
)
try
:
self
.
_connectToSlaprunner
(
resource
=
'cloneRepository'
,
data
=
'repo=http://git.erp5.org/repos/slapos.git&name=workspace/slapos&email=slapos@slapos.org&user=slapos'
)
except
(
NotHttpOkException
,
urllib2
.
HTTPError
):
# cloning can be very long.
# XXX: quite dirty way to check.
while
self
.
_connectToSlaprunner
(
'getProjectStatus'
,
data
=
'project=workspace/slapos'
).
find
(
'On branch master'
)
is
-
1
:
self
.
logger
.
info
(
'git-cloning ongoing, sleeping...'
)
# XXX should be taken from parameter.
self
.
_connectToSlaprunner
(
resource
=
'setCurrentProject'
,
data
=
'path=workspace/slapos/software/helloworld/'
)
self
.
logger
.
info
(
'Building the Software Release...'
)
self
.
logger
.
info
(
'Building the Software Release...'
)
try
:
try
:
self
.
_connectToSlaprunner
(
resource
=
'runSoftwareProfile'
)
self
.
_connectToSlaprunner
(
resource
=
'runSoftwareProfile'
)
...
@@ -144,6 +122,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
...
@@ -144,6 +122,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
time
.
sleep
(
15
)
time
.
sleep
(
15
)
self
.
logger
.
info
(
'Software Release has been built.'
)
self
.
logger
.
info
(
'Software Release has been built.'
)
def
_deployInstance
(
self
):
self
.
logger
.
info
(
'Deploying instance...'
)
self
.
logger
.
info
(
'Deploying instance...'
)
try
:
try
:
self
.
_connectToSlaprunner
(
resource
=
'runInstanceProfile'
)
self
.
_connectToSlaprunner
(
resource
=
'runInstanceProfile'
)
...
@@ -155,8 +134,70 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
...
@@ -155,8 +134,70 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
time
.
sleep
(
15
)
time
.
sleep
(
15
)
self
.
logger
.
info
(
'Instance has been deployed.'
)
self
.
logger
.
info
(
'Instance has been deployed.'
)
self
.
data
=
self
.
_retrieveInstanceLogFile
()
def
_gitClone
(
self
):
self
.
logger
.
debug
(
'Doing git clone of git.erp5.org/repos/slapos.git...'
)
try
:
self
.
_connectToSlaprunner
(
resource
=
'cloneRepository'
,
data
=
'repo=http://git.erp5.org/repos/slapos.git&name=workspace/slapos&email=slapos@slapos.org&user=slapos'
)
except
(
NotHttpOkException
,
urllib2
.
HTTPError
):
# cloning can be very long.
# XXX: quite dirty way to check.
while
self
.
_connectToSlaprunner
(
'getProjectStatus'
,
data
=
'project=workspace/slapos'
).
find
(
'On branch master'
)
is
-
1
:
self
.
logger
.
info
(
'git-cloning ongoing, sleeping...'
)
def
_openSoftwareRelease
(
self
,
software_name
):
self
.
logger
.
debug
(
'Opening %s software release...'
%
software_name
)
self
.
_connectToSlaprunner
(
resource
=
'setCurrentProject'
,
data
=
'path=workspace/slapos/software/%s/'
%
software_name
)
def
generateData
(
self
):
self
.
slaprunner_password
=
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
ascii_lowercase
,
8
)
)
self
.
slaprunner_user
=
'slapos'
self
.
logger
.
info
(
'Generated slaprunner user is: %s'
%
self
.
slaprunner_user
)
self
.
logger
.
info
(
'Generated slaprunner password is: %s'
%
self
.
slaprunner_password
)
def
pushDataOnMainInstance
(
self
):
"""
Create a dummy Software Release,
Build it,
Wait for build to be successful,
Deploy instance,
Wait for instance to be started.
Store the main IP of the slaprunner for future use.
"""
self
.
logger
.
debug
(
'Getting the backend URL and recovery code...'
)
parameter_dict
=
self
.
_getPartitionParameterDict
()
self
.
slaprunner_backend_url
=
parameter_dict
[
'backend_url'
]
self
.
logger
.
info
(
'backend_url is %s.'
%
self
.
slaprunner_backend_url
)
slaprunner_recovery_code
=
parameter_dict
[
'password_recovery_code'
]
self
.
logger
.
debug
(
'Creating the slaprunner account...'
)
self
.
_connectToSlaprunner
(
resource
=
'configAccount'
,
data
=
'name=slapos&username=%s&email=slapos@slapos.org&password=%s&rcode=%s'
%
(
self
.
slaprunner_user
,
self
.
slaprunner_password
,
slaprunner_recovery_code
)
)
self
.
_login
()
self
.
_gitClone
()
# XXX should be taken from parameter.
self
.
_openSoftwareRelease
(
'helloworld'
)
self
.
_buildSoftwareRelease
()
self
.
_deployInstance
()
self
.
data
=
self
.
_retrieveInstanceLogFile
()
def
checkDataOnCloneInstance
(
self
):
def
checkDataOnCloneInstance
(
self
):
"""
"""
...
...
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