Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89292b7d
authored
Mar 13, 2015
by
Csók Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
selenium: logging revisited, errors corrected
parent
8ff74260
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
20 deletions
+33
-20
circle/dashboard/tests/selenium/basic_tests.py
+23
-20
circle/dashboard/tests/selenium/config.py
+10
-0
circle/dashboard/tests/selenium/util.py
+0
-0
No files found.
circle/dashboard/tests/selenium/basic_tests.py
View file @
89292b7d
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
logging
from
sys
import
stdout
import
random
import
random
import
re
import
re
import
urlparse
import
urlparse
...
@@ -34,10 +33,14 @@ from vm.models import Instance
...
@@ -34,10 +33,14 @@ from vm.models import Instance
from
.config
import
SeleniumConfig
from
.config
import
SeleniumConfig
from
.util
import
CircleSeleniumMixin
,
SeleniumMixin
from
.util
import
CircleSeleniumMixin
,
SeleniumMixin
logger
=
logging
.
getLogger
(
__name__
)
consoleHandler
=
logging
.
StreamHandler
(
stdout
)
logger
.
addHandler
(
consoleHandler
)
conf
=
SeleniumConfig
()
conf
=
SeleniumConfig
()
log_formatter
=
logging
.
Formatter
(
conf
.
log_format
)
logger
=
logging
.
getLogger
(
conf
.
logger_name
)
fileHandler
=
logging
.
handlers
.
RotatingFileHandler
(
conf
.
log_file
,
maxBytes
=
conf
.
log_size
,
backupCount
=
conf
.
log_backup
)
fileHandler
.
setFormatter
(
log_formatter
)
fileHandler
.
setLevel
(
logging
.
WARNING
)
logger
.
addHandler
(
fileHandler
)
class
BasicSeleniumTests
(
SeleniumTestCase
,
SeleniumMixin
,
CircleSeleniumMixin
):
class
BasicSeleniumTests
(
SeleniumTestCase
,
SeleniumMixin
,
CircleSeleniumMixin
):
...
@@ -82,9 +85,9 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -82,9 +85,9 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
elif
len
(
template_pool
)
==
1
:
elif
len
(
template_pool
)
==
1
:
chosen
=
template_pool
[
0
]
chosen
=
template_pool
[
0
]
else
:
else
:
logg
ing
.
warning
(
"Selenium did not found any templates"
)
logg
er
.
exception
(
"Selenium did not found any templates"
)
logging
.
e
xception
(
raise
E
xception
(
"S
ystem did not meet required conditions to continue
"
)
"S
elenium did not found any templates
"
)
self
.
driver
.
get
(
'
%
s/dashboard/template/
%
s/'
%
(
conf
.
host
,
chosen
))
self
.
driver
.
get
(
'
%
s/dashboard/template/
%
s/'
%
(
conf
.
host
,
chosen
))
acces_form
=
self
.
driver
.
find_element_by_css_selector
(
acces_form
=
self
.
driver
.
find_element_by_css_selector
(
"form[action*='/dashboard/template/
%(template_id)
s/acl/']"
"form[action*='/dashboard/template/
%(template_id)
s/acl/']"
...
@@ -106,10 +109,10 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -106,10 +109,10 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
user_text
=
re
.
split
(
r':[ ]?'
,
user
.
text
)
user_text
=
re
.
split
(
r':[ ]?'
,
user
.
text
)
if
len
(
user_text
)
==
2
:
if
len
(
user_text
)
==
2
:
found_name
=
re
.
search
(
r'[\w\W]+(?=\))'
,
user_text
[
1
])
.
group
()
found_name
=
re
.
search
(
r'[\w\W]+(?=\))'
,
user_text
[
1
])
.
group
()
logg
ing
.
info
(
"'
%(user)
s' found in ACL "
logg
er
.
warning
(
"'
%(user)
s' found in ACL "
"list for template
%(id)
s"
%
{
"list for template
%(id)
s"
%
{
'user'
:
found_name
,
'user'
:
found_name
,
'id'
:
chosen
})
'id'
:
chosen
})
found_users
.
append
(
found_name
)
found_users
.
append
(
found_name
)
self
.
assertIn
(
conf
.
client_name
,
found_users
,
self
.
assertIn
(
conf
.
client_name
,
found_users
,
"Could not add user to template's ACL"
)
"Could not add user to template's ACL"
)
...
@@ -124,7 +127,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -124,7 +127,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
By
.
ID
,
'confirmation-modal'
)))
By
.
ID
,
'confirmation-modal'
)))
template_list
=
self
.
driver
.
find_elements_by_class_name
(
template_list
=
self
.
driver
.
find_elements_by_class_name
(
'template-choose-list-element'
)
'template-choose-list-element'
)
logg
ing
.
info
(
'Selenium found
%(count)
s template possibilities'
%
{
logg
er
.
warning
(
'Selenium found
%(count)
s template possibilities'
%
{
'count'
:
len
(
template_list
)})
'count'
:
len
(
template_list
)})
(
self
.
assertIsNotNone
(
(
self
.
assertIsNotNone
(
template_list
,
"Selenium can not find the create template list"
)
or
template_list
,
"Selenium can not find the create template list"
)
or
...
@@ -157,7 +160,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -157,7 +160,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
success
=
False
success
=
False
self
.
login
()
self
.
login
()
for
template_id
in
self
.
template_ids
:
for
template_id
in
self
.
template_ids
:
logg
ing
.
info
(
"Deleting template
%
s"
%
template_id
)
logg
er
.
warning
(
"Deleting template
%
s"
%
template_id
)
self
.
delete_template
(
template_id
)
self
.
delete_template
(
template_id
)
existing_templates
=
self
.
get_template_id
()
existing_templates
=
self
.
get_template_id
()
if
len
(
existing_templates
)
==
0
:
if
len
(
existing_templates
)
==
0
:
...
@@ -181,9 +184,9 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -181,9 +184,9 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
By
.
ID
,
'confirmation-modal'
)))
By
.
ID
,
'confirmation-modal'
)))
vm_list
=
self
.
driver
.
find_elements_by_class_name
(
vm_list
=
self
.
driver
.
find_elements_by_class_name
(
'vm-create-template-summary'
)
'vm-create-template-summary'
)
logg
ing
.
info
(
"Selenium found
%(vm_number)
s virtual machine template "
logg
er
.
warning
(
"Selenium found
%(vm_number)
s virtual machine template "
" possibilities"
%
{
" possibilities"
%
{
'vm_number'
:
len
(
vm_list
)})
'vm_number'
:
len
(
vm_list
)})
(
self
.
assertIsNotNone
(
(
self
.
assertIsNotNone
(
vm_list
,
"Selenium can not find the VM list"
)
or
vm_list
,
"Selenium can not find the VM list"
)
or
self
.
assertGreater
(
len
(
vm_list
),
0
,
"The create VM list is empty"
))
self
.
assertGreater
(
len
(
vm_list
),
0
,
"The create VM list is empty"
))
...
@@ -200,8 +203,8 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -200,8 +203,8 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"none"
,
""
,
"none"
,
""
,
"block"
,
"none"
]
"block"
,
"none"
]
states
=
self
.
view_change
(
"vm"
)
states
=
self
.
view_change
(
"vm"
)
logg
ing
.
info
(
'states: [
%
s]'
%
', '
.
join
(
map
(
str
,
states
)))
logg
er
.
warning
(
'states: [
%
s]'
%
', '
.
join
(
map
(
str
,
states
)))
logg
ing
.
info
(
'expected: [
%
s]'
%
', '
.
join
(
map
(
str
,
expected_states
)))
logg
er
.
warning
(
'expected: [
%
s]'
%
', '
.
join
(
map
(
str
,
expected_states
)))
self
.
assertListEqual
(
states
,
expected_states
,
self
.
assertListEqual
(
states
,
expected_states
,
"The view mode does not change for VM listing"
)
"The view mode does not change for VM listing"
)
...
@@ -211,8 +214,8 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -211,8 +214,8 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"none"
,
""
,
"none"
,
""
,
"block"
,
"none"
]
"block"
,
"none"
]
states
=
self
.
view_change
(
"node"
)
states
=
self
.
view_change
(
"node"
)
logg
ing
.
info
(
'states: [
%
s]'
%
', '
.
join
(
map
(
str
,
states
)))
logg
er
.
warning
(
'states: [
%
s]'
%
', '
.
join
(
map
(
str
,
states
)))
logg
ing
.
info
(
'expected: [
%
s]'
%
', '
.
join
(
map
(
str
,
expected_states
)))
logg
er
.
warning
(
'expected: [
%
s]'
%
', '
.
join
(
map
(
str
,
expected_states
)))
self
.
assertListEqual
(
states
,
expected_states
,
self
.
assertListEqual
(
states
,
expected_states
,
"The view mode does not change for NODE listing"
)
"The view mode does not change for NODE listing"
)
...
...
circle/dashboard/tests/selenium/config.py
View file @
89292b7d
...
@@ -24,6 +24,16 @@ class SeleniumConfig:
...
@@ -24,6 +24,16 @@ class SeleniumConfig:
wait_max_sec
=
10
wait_max_sec
=
10
# How much sec can pass before the activity is no longer happened recently
# How much sec can pass before the activity is no longer happened recently
recently_sec
=
90
recently_sec
=
90
# Name of the logger (necessary to override test logger)
logger_name
=
"selenium"
# File where the log should be stored
log_file
=
"selenium.log"
# Log file max size in Bytes
log_size
=
1024
*
100
# Format of the log file
log_format
=
"
%(asctime)
s:
%(name)
s:
%(levelname)
s:
%(message)
s"
# Backup count of the logfiles
log_backup
=
5
# Accented letters from which selenium can choose to name stuff
# Accented letters from which selenium can choose to name stuff
accents
=
u"áéíöóúűÁÉÍÖÓÜÚŰ"
accents
=
u"áéíöóúűÁÉÍÖÓÜÚŰ"
...
...
circle/dashboard/tests/selenium/util.py
View file @
89292b7d
This diff is collapsed.
Click to expand it.
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