Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Mikolaï Krol
erp5
Commits
651a96b1
Commit
651a96b1
authored
Jul 21, 2017
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup in testing process.
parent
db793a34
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
erp5/util/testnode/SlapOSMasterCommunicator.py
erp5/util/testnode/SlapOSMasterCommunicator.py
+25
-6
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+2
-1
No files found.
erp5/util/testnode/SlapOSMasterCommunicator.py
View file @
651a96b1
...
...
@@ -34,16 +34,25 @@ class SlapOSMasterCommunicator(object):
self
.
certificate_path
=
certificate_path
self
.
key_path
=
key_path
self
.
url
=
url
self
.
log
(
"Getting connection to "
+
str
(
self
.
url
))
self
.
connection
=
self
.
_getConnection
(
self
.
certificate_path
,
self
.
key_path
,
self
.
url
)
self
.
log
(
"Connection done."
)
# Get master
master_link
=
{
'href'
:
api_path
,
'type'
:
"application/vnd.slapos.org.hal+json; class=slapos.org.master"
}
master
=
self
.
_curl
(
master_link
)
self
.
person_link
=
master
[
'_links'
][
'http://slapos.org/reg/me'
]
self
.
log
(
"Getting master with href: "
+
str
(
api_path
))
#master = self._curl(master_link)
#self.person_link = master['_links']['http://slapos.org/reg/me']
self
.
person_link
=
{
"href"
:
"urn:jio:get:person_module/20170705-995F2E"
}
self
.
log
(
"Getting person with curl to harcoded link."
)
# Get person related to specified key/certificate provided
person
=
self
.
_curl
(
self
.
person_link
)
self
.
log
(
"person: "
str
(
person
))
self
.
personnal_collection_link
=
person
[
'_links'
][
'http://slapos.org/reg/hosting_subscription'
]
self
.
log
(
"personal collection link : "
+
str
(
self
.
personnal_collection_link
))
# Get collection (of hosting subscriptions)
self
.
log
(
"Getting collection with curl"
)
collection
=
self
.
_curl
(
self
.
personnal_collection_link
)
self
.
log
(
"collection: "
+
str
(
collection
))
# XXX: This part may be extremly long (because here no hosting subscriptions
# has been visited)
self
.
hosting_subcriptions_dict
=
{}
...
...
@@ -54,7 +63,8 @@ class SlapOSMasterCommunicator(object):
def
_getConnection
(
self
,
certificate_path
,
key_path
,
url
):
api_scheme
,
api_netloc
,
api_path
,
api_query
,
api_fragment
=
urlparse
.
urlsplit
(
url
)
#self.log("HTTPS Connection with: %s, cert=%s, key=%s" %(api_netloc,key_path,certificate_path))
#self.log("HTTPS Connection with: api_scheme=%s, api_netloc=%s, api_path=%s, api_query=%s, api_fragment=%s" %(api_scheme, api_netloc, api_path, api_query, api_fragment))
self
.
log
(
"_getConnection method - api_netloc: "
+
str
(
api_netloc
))
return
httplib
.
HTTPSConnection
(
api_netloc
,
key_file
=
key_path
,
cert_file
=
certificate_path
,
timeout
=
TIMEOUT
)
def
_curl
(
self
,
link
):
...
...
@@ -69,21 +79,31 @@ class SlapOSMasterCommunicator(object):
max_retry
=
10
# Try to use existing conection
try
:
self
.
connection
.
request
(
method
=
'GET'
,
url
=
api_path
,
headers
=
{
'Accept'
:
link
[
'type'
]},
body
=
""
)
self
.
log
(
"Curl to link: "
+
str
(
link
))
self
.
log
(
"GET to api "
+
str
(
api_path
))
self
.
connection
.
request
(
method
=
'GET'
,
url
=
api_path
,
body
=
""
)
self
.
log
(
"Request done. Getting response..."
)
response
=
self
.
connection
.
getresponse
()
self
.
log
(
"REPONSE.read: "
+
str
(
response
.
read
()))
return
json
.
loads
(
response
.
read
())
# Create and use new connection
except
:
self
.
log
(
"Request or response fail! Entering the while-try"
)
retry
=
0
# (re)Try several time to use new connection
while
retry
<
max_retry
:
try
:
self
.
log
(
"Retry number: "
+
str
(
retry
))
self
.
log
(
"entering _getConnection() to "
+
str
(
self
.
url
))
self
.
connection
=
self
.
_getConnection
(
self
.
certificate_path
,
self
.
key_path
,
self
.
url
)
self
.
log
(
"_getConnection DONE. Getting response..."
)
self
.
connection
.
request
(
method
=
'GET'
,
url
=
api_path
,
headers
=
{
'Accept'
:
link
[
'type'
]},
body
=
""
)
response
=
self
.
connection
.
getresponse
()
self
.
log
(
"REPONSE.read: "
+
str
(
response
.
read
()))
return
json
.
loads
(
response
.
read
())
except
:
except
Exception
,
e
:
self
.
log
(
"SlapOSMasterCommunicator: Connection failed.."
)
self
.
log
(
"EXCEPTION MESSAGE: "
+
str
(
e
))
retry
+=
1
time
.
sleep
(
10
)
self
.
log
(
"SlapOSMasterCommunicator: All connection attempts failed after %d try.."
%
max_retry
)
...
...
@@ -203,4 +223,3 @@ class SlapOSMasterCommunicator(object):
}
else
:
return
None
\ No newline at end of file
erp5/util/testnode/testnode.py
View file @
651a96b1
...
...
@@ -375,7 +375,8 @@ shared = true
if
my_test_type
==
'UnitTest'
:
runner
=
UnitTestRunner
(
node_test_suite
)
elif
my_test_type
==
'ScalabilityTest'
:
runner
=
ScalabilityTestRunner
(
node_test_suite
)
log
(
"instantiating runner for test suite"
)
runner
=
ScalabilityTestRunner
(
self
)
else
:
log
(
"testnode, Runner type %s not implemented."
,
my_test_type
)
raise
NotImplementedError
...
...
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