Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70c66a65
authored
Apr 04, 2015
by
Csók Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrected and tweaked few things
parent
b089b223
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
24 deletions
+56
-24
circle/dashboard/tests/selenium/basic_tests.py
+5
-4
circle/dashboard/tests/selenium/util.py
+51
-20
No files found.
circle/dashboard/tests/selenium/basic_tests.py
View file @
70c66a65
...
@@ -46,11 +46,12 @@ logger.addHandler(fileHandler)
...
@@ -46,11 +46,12 @@ logger.addHandler(fileHandler)
class
BasicSeleniumTests
(
SeleniumTestCase
,
CircleSeleniumMixin
):
class
BasicSeleniumTests
(
SeleniumTestCase
,
CircleSeleniumMixin
):
template_ids
=
[]
vm_ids
=
[]
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
self
.
__class__
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
self
.
__class__
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
conf
=
conf
self
.
conf
=
conf
self
.
template_ids
=
[]
self
.
vm_ids
=
[]
@classmethod
@classmethod
def
setup_class
(
cls
):
def
setup_class
(
cls
):
...
@@ -208,8 +209,8 @@ class BasicSeleniumTests(SeleniumTestCase, CircleSeleniumMixin):
...
@@ -208,8 +209,8 @@ class BasicSeleniumTests(SeleniumTestCase, 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'
)
logger
.
warning
(
"Selenium found
%(vm_number)
s virtual machine
template
"
logger
.
warning
(
"Selenium found
%(vm_number)
s virtual machine"
" possibilities"
%
{
"
template
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
...
...
circle/dashboard/tests/selenium/util.py
View file @
70c66a65
...
@@ -216,6 +216,13 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -216,6 +216,13 @@ class CircleSeleniumMixin(SeleniumMixin):
logger
.
exception
(
"Selenium cannot find the form controls"
)
logger
.
exception
(
"Selenium cannot find the form controls"
)
raise
Exception
(
'Cannot find the form controls'
)
raise
Exception
(
'Cannot find the form controls'
)
def
fallback
(
self
,
fallback_url
,
fallback_function
):
logger
.
warning
(
"However error was anticipated falling back to
%(url)
s"
%
{
'url'
:
fallback_url
})
self
.
driver
.
get
(
fallback_url
)
return
fallback_function
()
def
wait_and_accept_operation
(
self
,
argument
=
None
,
try_wait
=
None
,
def
wait_and_accept_operation
(
self
,
argument
=
None
,
try_wait
=
None
,
fallback_url
=
None
):
fallback_url
=
None
):
"""
"""
...
@@ -242,16 +249,20 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -242,16 +249,20 @@ class CircleSeleniumMixin(SeleniumMixin):
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
visibility_of_element_located
((
ec
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
try_wait
)))
By
.
CSS_SELECTOR
,
try_wait
)))
except
TimeoutException
:
logger
.
exception
(
"Selenium cannot accept the"
" operation confirmation"
)
if
fallback_url
is
not
None
:
self
.
fallback
(
fallback_url
,
lambda
:
self
.
wait_and_accept_operation
(
argument
))
except
:
except
:
logger
.
exception
(
"Selenium cannot accept the"
logger
.
exception
(
"Selenium cannot accept the"
" operation confirmation"
)
" operation confirmation"
)
if
fallback_url
is
not
None
:
if
fallback_url
is
not
None
:
logger
.
warning
(
self
.
fallback
(
"However error was anticipated falling back to
%(url)
s"
%
{
fallback_url
,
'url'
:
fallback_url
})
lambda
:
self
.
wait_and_accept_operation
(
argument
,
try_wait
))
self
.
driver
.
get
(
fallback_url
)
self
.
wait_and_accept_operation
(
argument
,
try_wait
)
else
:
else
:
self
.
driver
.
save_screenshot
(
'error_at_try_wait.png'
)
self
.
driver
.
save_screenshot
(
'error_at_try_wait.png'
)
raise
Exception
(
raise
Exception
(
...
@@ -269,7 +280,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -269,7 +280,7 @@ class CircleSeleniumMixin(SeleniumMixin):
self
.
wait_and_accept_operation
(
self
.
wait_and_accept_operation
(
try_wait
=
"a[href$='/op/shut_off/']"
,
fallback_url
=
fallback_url
)
try_wait
=
"a[href$='/op/shut_off/']"
,
fallback_url
=
fallback_url
)
recent_deploy
=
self
.
recently
(
self
.
get_timeline_elements
(
recent_deploy
=
self
.
recently
(
self
.
get_timeline_elements
(
"vm.Instance.deploy"
))
"vm.Instance.deploy"
,
url_save
))
if
not
self
.
check_operation_result
(
if
not
self
.
check_operation_result
(
recent_deploy
,
"a[href*='#activity']"
):
recent_deploy
,
"a[href*='#activity']"
):
logger
.
warning
(
"Selenium cannot deploy the "
logger
.
warning
(
"Selenium cannot deploy the "
...
@@ -284,7 +295,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -284,7 +295,7 @@ class CircleSeleniumMixin(SeleniumMixin):
self
.
wait_and_accept_operation
(
self
.
wait_and_accept_operation
(
try_wait
=
"a[href$='/op/deploy/']"
,
fallback_url
=
fallback_url
)
try_wait
=
"a[href$='/op/deploy/']"
,
fallback_url
=
fallback_url
)
recent_shut_off
=
self
.
recently
(
self
.
get_timeline_elements
(
recent_shut_off
=
self
.
recently
(
self
.
get_timeline_elements
(
"vm.Instance.shut_off"
))
"vm.Instance.shut_off"
,
url_save
))
if
not
self
.
check_operation_result
(
if
not
self
.
check_operation_result
(
recent_shut_off
,
"a[href*='#activity']"
):
recent_shut_off
,
"a[href*='#activity']"
):
logger
.
warning
(
"Selenium cannot shut off the "
logger
.
warning
(
"Selenium cannot shut off the "
...
@@ -295,7 +306,17 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -295,7 +306,17 @@ class CircleSeleniumMixin(SeleniumMixin):
ec
.
element_to_be_clickable
((
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
"a[href$='/op/save_as_template/']"
))))
"a[href$='/op/save_as_template/']"
))))
self
.
wait_and_accept_operation
(
name
)
fallback_url
=
"
%
sop/save_as_template/"
%
url_save
self
.
wait_and_accept_operation
(
argument
=
name
,
fallback_url
=
fallback_url
)
recent_save_template
=
self
.
recently
(
self
.
get_timeline_elements
(
"vm.Instance.save_as_template"
,
url_save
))
if
not
self
.
check_operation_result
(
recent_save_template
,
"a[href*='#activity']"
):
logger
.
warning
(
"Selenium cannot save the "
"chosen virtual machine as a template"
)
raise
Exception
(
'Cannot save the virtual machine as a template'
)
logger
.
warning
(
"Selenium created
%(name)
s template"
%
{
logger
.
warning
(
"Selenium created
%(name)
s template"
%
{
'name'
:
name
})
'name'
:
name
})
return
name
return
name
...
@@ -492,7 +513,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -492,7 +513,7 @@ class CircleSeleniumMixin(SeleniumMixin):
raise
Exception
(
raise
Exception
(
'Cannot filter timeline activities to find most recent'
)
'Cannot filter timeline activities to find most recent'
)
def
get_timeline_elements
(
self
,
code
=
None
,
time_out_handle
=
Tru
e
):
def
get_timeline_elements
(
self
,
code
=
None
,
fallback_url
=
Non
e
):
try
:
try
:
if
code
is
None
:
if
code
is
None
:
css_activity_selector
=
"div[data-activity-code]"
css_activity_selector
=
"div[data-activity-code]"
...
@@ -508,7 +529,6 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -508,7 +529,6 @@ class CircleSeleniumMixin(SeleniumMixin):
ec
.
element_to_be_clickable
((
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
"a[href*='#activity']"
))))
By
.
CSS_SELECTOR
,
"a[href*='#activity']"
))))
activity_dict
=
{}
activity_dict
=
{}
self
.
driver
.
save_screenshot
(
'activity.png'
)
timeline
=
WebDriverWait
(
timeline
=
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
visibility_of_element_located
((
ec
.
visibility_of_element_located
((
...
@@ -526,14 +546,15 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -526,14 +546,15 @@ class CircleSeleniumMixin(SeleniumMixin):
activity_dict
[
key
]
=
activity_id
activity_dict
[
key
]
=
activity_id
except
StaleElementReferenceException
:
except
StaleElementReferenceException
:
logger
.
warning
(
'Timeline changed while processing it'
)
logger
.
warning
(
'Timeline changed while processing it'
)
return
self
.
get_timeline_elements
(
code
)
return
self
.
get_timeline_elements
(
code
,
fallback_url
)
except
TimeoutException
:
except
TimeoutException
:
logger
.
warning
(
'Can not found timeline in the page'
)
logger
.
warning
(
'Can not found timeline in the page'
)
if
time_out_handl
e
:
if
fallback_url
is
not
Non
e
:
self
.
driver
.
save_screenshot
(
'lost-timeline.png'
)
return
self
.
fallback
(
self
.
driver
.
get
(
self
.
get_url
(
fragment
=
'activity'
))
fallback_url
,
return
self
.
get_timeline_elements
(
code
,
False
)
lambda
:
self
.
get_timeline_elements
(
code
)
)
else
:
else
:
self
.
driver
.
save_screenshot
(
'lost-timeline.png'
)
raise
Exception
(
'Selenium could not locate the timeline'
)
raise
Exception
(
'Selenium could not locate the timeline'
)
except
:
except
:
logger
.
exception
(
'Selenium cannot get timeline elemets'
)
logger
.
exception
(
'Selenium cannot get timeline elemets'
)
...
@@ -562,6 +583,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -562,6 +583,7 @@ class CircleSeleniumMixin(SeleniumMixin):
self
.
driver
.
find_element_by_id
(
self
.
driver
.
find_element_by_id
(
"template-choose-next-button"
)
.
click
()
"template-choose-next-button"
)
.
click
()
if
delete_disk
:
if
delete_disk
:
url_save
=
self
.
get_url
(
fragment
=
'activity'
)
self
.
click_on_link
(
self
.
click_on_link
(
self
.
get_link_by_href
(
"#resources"
))
self
.
get_link_by_href
(
"#resources"
))
disks
=
WebDriverWait
(
disks
=
WebDriverWait
(
...
@@ -577,7 +599,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -577,7 +599,7 @@ class CircleSeleniumMixin(SeleniumMixin):
try_wait
=
"a[href*='#activity']"
)
try_wait
=
"a[href*='#activity']"
)
recent_remove_disk
=
self
.
recently
(
recent_remove_disk
=
self
.
recently
(
self
.
get_timeline_elements
(
self
.
get_timeline_elements
(
"vm.Instance.remove_disk"
))
"vm.Instance.remove_disk"
,
url_save
))
if
not
self
.
check_operation_result
(
recent_remove_disk
):
if
not
self
.
check_operation_result
(
recent_remove_disk
):
logger
.
warning
(
"Selenium cannot delete disk "
logger
.
warning
(
"Selenium cannot delete disk "
"of the chosen template"
)
"of the chosen template"
)
...
@@ -593,11 +615,13 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -593,11 +615,13 @@ class CircleSeleniumMixin(SeleniumMixin):
try
:
try
:
self
.
driver
.
get
(
self
.
driver
.
get
(
'
%
s/dashboard/template/
%
s/'
%
(
self
.
conf
.
host
,
template_id
))
'
%
s/dashboard/template/
%
s/'
%
(
self
.
conf
.
host
,
template_id
))
url
=
urlparse
.
urlparse
(
self
.
driver
.
current_url
)
url_save
=
"
%(host)
s/dashboard/template/delete/
%(pk)
s/"
%
{
'host'
:
self
.
conf
.
host
,
'pk'
:
template_id
}
self
.
click_on_link
(
self
.
click_on_link
(
self
.
get_link_by_href
(
self
.
get_link_by_href
(
"/dashboard/template/delete/
%
s/"
%
template_id
))
"/dashboard/template/delete/
%
s/"
%
template_id
))
self
.
wait_and_accept_operation
()
self
.
wait_and_accept_operation
(
fallback_url
=
url_save
)
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
visibility_of_element_located
((
ec
.
visibility_of_element_located
((
By
.
CLASS_NAME
,
'alert-success'
)))
By
.
CLASS_NAME
,
'alert-success'
)))
...
@@ -606,6 +630,8 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -606,6 +630,8 @@ class CircleSeleniumMixin(SeleniumMixin):
logger
.
warning
(
'CIRCLE does not redirect to /template/list/'
)
logger
.
warning
(
'CIRCLE does not redirect to /template/list/'
)
raise
Exception
(
raise
Exception
(
'System does not redirect to template listing'
)
'System does not redirect to template listing'
)
logger
.
warning
(
'Successfully deleted template: id -
%(pk)
s'
%
{
'pk'
:
template_id
})
except
:
except
:
logger
.
exception
(
"Selenium cannot delete the desired template"
)
logger
.
exception
(
"Selenium cannot delete the desired template"
)
raise
Exception
(
'Cannot delete the desired template'
)
raise
Exception
(
'Cannot delete the desired template'
)
...
@@ -680,8 +706,10 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -680,8 +706,10 @@ class CircleSeleniumMixin(SeleniumMixin):
By
.
CLASS_NAME
,
'fa-trash-o'
)))
By
.
CLASS_NAME
,
'fa-trash-o'
)))
except
:
except
:
# Selenium can time-out by not realising the JS refresh
# Selenium can time-out by not realising the JS refresh
url_save
=
self
.
get_url
(
fragment
=
'activity'
)
recent_destroy_vm
=
self
.
recently
(
recent_destroy_vm
=
self
.
recently
(
self
.
get_timeline_elements
(
"vm.Instance.destroy"
))
self
.
get_timeline_elements
(
"vm.Instance.destroy"
,
url_save
))
if
not
self
.
check_operation_result
(
recent_destroy_vm
):
if
not
self
.
check_operation_result
(
recent_destroy_vm
):
logger
.
warning
(
"Selenium cannot destroy "
logger
.
warning
(
"Selenium cannot destroy "
"the chosen
%(id)
s vm"
%
{
"the chosen
%(id)
s vm"
%
{
...
@@ -693,6 +721,9 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -693,6 +721,9 @@ class CircleSeleniumMixin(SeleniumMixin):
ec
.
visibility_of_element_located
((
ec
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
"span[data-status*='DESTROYED']"
)))
"span[data-status*='DESTROYED']"
)))
logger
.
warning
(
'Successfully deleted virtual machine: id -
%(pk)
s'
%
{
'pk'
:
pk
})
return
True
return
True
except
:
except
:
return
False
return
False
...
...
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