Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b805a147
authored
Feb 23, 2015
by
Csók Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrected template create and delete tests
parent
1426611d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
35 deletions
+71
-35
circle/dashboard/tests/selenium/test_vm_controlls.py
+71
-35
No files found.
circle/dashboard/tests/selenium/test_vm_controlls.py
View file @
b805a147
...
@@ -162,7 +162,7 @@ class UtilityMixin(object):
...
@@ -162,7 +162,7 @@ class UtilityMixin(object):
'Selenium cannot inject javascript to the page'
)
'Selenium cannot inject javascript to the page'
)
def
wait_and_accept_operation
(
self
,
argument
=
None
):
def
wait_and_accept_operation
(
self
,
argument
=
None
):
try
:
#
try:
accept
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
accept
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
element_to_be_clickable
((
EC
.
element_to_be_clickable
((
By
.
ID
,
"op-form-send"
)))
By
.
ID
,
"op-form-send"
)))
...
@@ -178,9 +178,9 @@ class UtilityMixin(object):
...
@@ -178,9 +178,9 @@ class UtilityMixin(object):
form
.
clear
()
form
.
clear
()
form
.
send_keys
(
argument
)
form
.
send_keys
(
argument
)
accept
.
click
()
accept
.
click
()
except
:
#
except:
raise
Exception
(
"Selenium cannot accept the"
#
raise Exception("Selenium cannot accept the"
" operation confirmation"
)
#
" operation confirmation")
def
create_base_template
(
self
,
name
=
None
,
architecture
=
"x86-64"
,
def
create_base_template
(
self
,
name
=
None
,
architecture
=
"x86-64"
,
method
=
None
,
op_system
=
None
,
lease
=
None
,
method
=
None
,
op_system
=
None
,
lease
=
None
,
...
@@ -232,6 +232,27 @@ class UtilityMixin(object):
...
@@ -232,6 +232,27 @@ class UtilityMixin(object):
raise
Exception
(
raise
Exception
(
'Selenium cannot create a base template virtual machine'
)
'Selenium cannot create a base template virtual machine'
)
def
get_template_id
(
self
,
name
=
None
):
try
:
self
.
driver
.
get
(
'
%
s/dashboard/template/list/'
%
host
)
templates
=
self
.
driver
.
find_elements_by_css_selector
(
"td.name"
)
found_template_ids
=
[]
for
template
in
templates
:
if
name
in
template
.
text
or
name
is
None
:
template_link
=
template
.
find_element_by_css_selector
(
"a[data-original-title]"
)
found_template_ids
.
append
(
re
.
search
(
r'\d+'
,
template_link
.
get_attribute
(
'innerHTML'
))
.
group
())
if
not
found_template_ids
and
name
is
not
None
:
print
(
"Selenium could not find the specified "
"
%(name)
s template in the list"
%
{
'name'
:
name
})
return
found_template_ids
except
:
raise
Exception
(
'Selenium cannot found the template
\'
s id'
)
def
check_operation_result
(
self
,
operation_id
):
def
check_operation_result
(
self
,
operation_id
):
try
:
try
:
url_save
=
self
.
driver
.
current_url
url_save
=
self
.
driver
.
current_url
...
@@ -287,7 +308,7 @@ class UtilityMixin(object):
...
@@ -287,7 +308,7 @@ class UtilityMixin(object):
raise
Exception
(
'Selenium cannot find the searched activity'
)
raise
Exception
(
'Selenium cannot find the searched activity'
)
def
create_template_from_base
(
self
,
delete_disk
=
True
,
name
=
None
):
def
create_template_from_base
(
self
,
delete_disk
=
True
,
name
=
None
):
#
try:
try
:
if
name
is
None
:
if
name
is
None
:
name
=
"template_from_base_
%
s"
%
random_accents
name
=
"template_from_base_
%
s"
%
random_accents
self
.
driver
.
get
(
'
%
s/dashboard/template/choose/'
%
host
)
self
.
driver
.
get
(
'
%
s/dashboard/template/choose/'
%
host
)
...
@@ -302,14 +323,16 @@ class UtilityMixin(object):
...
@@ -302,14 +323,16 @@ class UtilityMixin(object):
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
:
self
.
get_link_by_href
(
"#resources"
)
.
click
()
self
.
click_on_link
(
self
.
get_link_by_href
(
"#resources"
))
disks
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
disks
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
visibility_of_element_located
((
EC
.
visibility_of_element_located
((
By
.
ID
,
'vm-details-resources-disk'
)))
By
.
ID
,
'vm-details-resources-disk'
)))
disk_list
=
disks
.
find_elements_by_css_selector
(
disk_list
=
disks
.
find_elements_by_css_selector
(
"h4[class*='list-group-item-heading']"
)
"h4[class*='list-group-item-heading']"
)
if
len
(
disk_list
)
>
0
:
if
len
(
disk_list
)
>
0
:
self
.
get_link_by_href
(
"/op/remove_disk/"
)
.
click
()
self
.
click_on_link
(
self
.
get_link_by_href
(
"/op/remove_disk/"
))
self
.
wait_and_accept_operation
()
self
.
wait_and_accept_operation
()
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
visibility_of_element_located
((
EC
.
visibility_of_element_located
((
...
@@ -325,7 +348,7 @@ class UtilityMixin(object):
...
@@ -325,7 +348,7 @@ class UtilityMixin(object):
EC
.
element_to_be_clickable
((
EC
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
"a[href$='/op/deploy/']"
)))
"a[href$='/op/deploy/']"
)))
self
.
get_link_by_href
(
"/op/deploy/"
)
.
click
(
)
self
.
click_on_link
(
self
.
get_link_by_href
(
"/op/deploy/"
)
)
self
.
wait_and_accept_operation
()
self
.
wait_and_accept_operation
()
time
.
sleep
(
5
)
time
.
sleep
(
5
)
recent_deploy
=
self
.
recently
(
self
.
get_timeline_elements
(
recent_deploy
=
self
.
recently
(
self
.
get_timeline_elements
(
...
@@ -334,10 +357,10 @@ class UtilityMixin(object):
...
@@ -334,10 +357,10 @@ class UtilityMixin(object):
print
(
"Selenium cannot deploy the "
print
(
"Selenium cannot deploy the "
"chosen template virtual machine"
)
"chosen template virtual machine"
)
raise
Exception
(
'Cannot deploy the virtual machine'
)
raise
Exception
(
'Cannot deploy the virtual machine'
)
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
self
.
click_on_link
(
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
element_to_be_clickable
((
EC
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
"a[href$='/op/shut_off/']"
)))
.
click
(
)
"a[href$='/op/shut_off/']"
))))
self
.
wait_and_accept_operation
()
self
.
wait_and_accept_operation
()
time
.
sleep
(
2
)
time
.
sleep
(
2
)
recent_shut_off
=
self
.
recently
(
self
.
get_timeline_elements
(
recent_shut_off
=
self
.
recently
(
self
.
get_timeline_elements
(
...
@@ -346,14 +369,30 @@ class UtilityMixin(object):
...
@@ -346,14 +369,30 @@ class UtilityMixin(object):
print
(
"Selenium cannot shut off the "
print
(
"Selenium cannot shut off the "
"chosen template virtual machine"
)
"chosen template virtual machine"
)
raise
Exception
(
'Cannot shut off the virtual machine'
)
raise
Exception
(
'Cannot shut off the virtual machine'
)
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
self
.
click_on_link
(
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
element_to_be_clickable
((
EC
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
"a[href$='/op/save_as_template/']"
)))
.
click
(
)
"a[href$='/op/save_as_template/']"
))))
self
.
wait_and_accept_operation
(
name
)
self
.
wait_and_accept_operation
(
name
)
return
name
return
name
#except:
except
:
# raise Exception('Selenium cannot start a template from a base one')
raise
Exception
(
'Selenium cannot start a template from a base one'
)
def
delete_template
(
self
,
template_id
):
try
:
self
.
driver
.
get
(
'
%
s/dashboard/template/
%
s/'
%
(
host
,
template_id
))
self
.
click_on_link
(
self
.
get_link_by_href
(
"/dashboard/template/delete/
%
s/"
%
template_id
))
self
.
wait_and_accept_operation
()
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
CLASS_NAME
,
'alert-success'
)))
url
=
urlparse
.
urlparse
(
self
.
driver
.
current_url
)
if
"/template/list/"
not
in
url
.
path
:
raise
Exception
()
except
:
raise
Exception
(
'Selenium cannot delete the desired template'
)
def
create_random_vm
(
self
):
def
create_random_vm
(
self
):
try
:
try
:
...
@@ -364,10 +403,9 @@ class UtilityMixin(object):
...
@@ -364,10 +403,9 @@ class UtilityMixin(object):
'vm-create-template-summary'
)
'vm-create-template-summary'
)
choice
=
random
.
randint
(
0
,
len
(
vm_list
)
-
1
)
choice
=
random
.
randint
(
0
,
len
(
vm_list
)
-
1
)
vm_list
[
choice
]
.
click
()
vm_list
[
choice
]
.
click
()
create
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
element_to_be_clickable
((
EC
.
element_to_be_clickable
((
By
.
CLASS_NAME
,
'vm-create-start'
)))
By
.
CLASS_NAME
,
'vm-create-start'
)))
.
click
()
create
.
click
()
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
visibility_of_element_located
((
EC
.
visibility_of_element_located
((
By
.
CLASS_NAME
,
'alert-success'
)))
By
.
CLASS_NAME
,
'alert-success'
)))
...
@@ -406,12 +444,10 @@ class UtilityMixin(object):
...
@@ -406,12 +444,10 @@ class UtilityMixin(object):
driver
=
self
.
driver
driver
=
self
.
driver
driver
.
get
(
'
%
s/dashboard/vm/
%
s/'
%
(
host
,
pk
))
driver
.
get
(
'
%
s/dashboard/vm/
%
s/'
%
(
host
,
pk
))
status_span
=
driver
.
find_element_by_id
(
'vm-details-state'
)
status_span
=
driver
.
find_element_by_id
(
'vm-details-state'
)
destroy_link
=
self
.
get_link_by_href
(
self
.
get_link_by_href
(
"/dashboard/vm/
%
s/op/destroy/"
%
pk
)
"/dashboard/vm/
%
s/op/destroy/"
%
pk
)
.
click
()
destroy_link
.
click
()
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
destroy
=
WebDriverWait
(
self
.
driver
,
wait_max_sec
)
.
until
(
EC
.
element_to_be_clickable
((
By
.
ID
,
'op-form-send'
)))
.
click
()
EC
.
element_to_be_clickable
((
By
.
ID
,
'op-form-send'
)))
destroy
.
click
()
WebDriverWait
(
status_span
,
wait_max_sec
)
.
until
(
WebDriverWait
(
status_span
,
wait_max_sec
)
.
until
(
EC
.
visibility_of_element_located
((
EC
.
visibility_of_element_located
((
By
.
CLASS_NAME
,
'fa-trash-o'
)))
By
.
CLASS_NAME
,
'fa-trash-o'
)))
...
@@ -478,15 +514,11 @@ class VmDetailTest(UtilityMixin, SeleniumTestCase):
...
@@ -478,15 +514,11 @@ class VmDetailTest(UtilityMixin, SeleniumTestCase):
def
test_04_create_template_from_base
(
self
):
def
test_04_create_template_from_base
(
self
):
self
.
login
(
'test_
%
s'
%
random_accents
,
random_accents
)
self
.
login
(
'test_
%
s'
%
random_accents
,
random_accents
)
template_name
=
self
.
create_template_from_base
()
created_template_id
=
self
.
get_template_id
(
self
.
driver
.
get
(
'
%
s/dashboard/template/list/'
%
host
)
self
.
create_template_from_base
())
templates
=
self
.
driver
.
find_elements_by_css_selector
(
"td.name"
)
found
=
created_template_id
is
not
None
found
=
False
if
found
:
for
template
in
templates
:
self
.
template_ids
.
extend
(
created_template_id
)
if
template_name
in
template
.
text
:
found
=
True
self
.
template_ids
.
append
(
re
.
search
(
r'\d+'
,
template
.
text
)
.
group
())
self
.
assertTrue
(
self
.
assertTrue
(
found
,
found
,
"Coud not found the created template in the template list"
)
"Coud not found the created template in the template list"
)
...
@@ -494,9 +526,13 @@ class VmDetailTest(UtilityMixin, SeleniumTestCase):
...
@@ -494,9 +526,13 @@ class VmDetailTest(UtilityMixin, SeleniumTestCase):
def
test_05_delete_templates
(
self
):
def
test_05_delete_templates
(
self
):
self
.
login
(
'test_
%
s'
%
random_accents
,
random_accents
)
self
.
login
(
'test_
%
s'
%
random_accents
,
random_accents
)
for
template_id
in
self
.
template_ids
:
for
template_id
in
self
.
template_ids
:
# self.driver.get('%s/dashboard/template/%s/' % (host, template_id))
self
.
delete_template
(
template_id
)
pass
existing_templates
=
self
.
get_template_id
()
assert
False
for
template_id
in
self
.
template_ids
:
if
template_id
not
in
existing_templates
:
self
.
template_ids
.
remove
(
template_id
)
self
.
assertListEqual
([],
self
.
template_ids
,
"Could not delete (all) the test template(s)"
)
# def test_10_able_to_create_vm(self):
# def test_10_able_to_create_vm(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