Added deployment script and automated tests.

This commit is contained in:
Timur Nurlygayanov 2013-03-04 19:18:42 +04:00
parent 93044d53f6
commit 3fe5e8d6fb
6 changed files with 258 additions and 0 deletions

83
tests/deploy.sh Normal file
View File

@ -0,0 +1,83 @@
#!/usr/bin/expect -d
# The following directories should be created for this script:
# /opt/stack/devstack
# /opt/stack/keero
# the ssh key should be in directory /opt/stack/.ssh/
# the iso file with windows should be in directory /opt/stack/
set timeout 1200
send_user "\n\nStart to login to the test bed...\n\n"
spawn /usr/bin/ssh [lindex $argv 0]@[lindex $argv 1]
expect "password"
send -- "EVYiMCVZX9\n"
expect "*#*"
send -- "su - stack\n"
expect "*$*"
send -- "sudo killall python\n"
expect "*$*"
send -- "cd ~/devstack\n"
expect "*$*"
send -- "./unstack.sh\n"
expect "*$*"
send -- "./stack.sh\n"
expect "*Would you like to start it now?*"
send -- "y\n"
expect "*stack.sh completed*"
send -- "source openrc admin admin\n"
expect "*$*"
send -- "cd ~\n"
expect "*$*"
send -- "nova keypair-add keero-linux-keys > heat_key.priv\n"
expect "*$*"
send -- "glance image-create --name 'ws-2012-full-agent' --is-public true --container-format ovf --disk-format qcow2 < ws-2012-full-agent.qcow2\n"
expect "*$*"
send -- "cd ~/keero\n"
expect "*$*"
send -- "git pull\n"
expect "/.ssh/id_rsa"
send -- "swordfish\n"
expect "*$*"
send -- "cp -Rf ~/keero/dashboard/windc /opt/stack/horizon/openstack_dashboard/dashboards/project\n"
expect "*$*"
send -- "cp -f ~/keero/dashboard/api/windc.py /opt/stack/horizon/openstack_dashboard/api/\n"
expect "*$*"
send -- "cp -Rf ~/keero/dashboard/windcclient /opt/stack/horizon/\n"
expect "*$*"
send -- "cd ~/keero/windc\n"
expect "*$*"
send -- "rm -rf windc.sqlite\n"
expect "*$*"
send -- "./tools/with_venv.sh ./bin/windc-api --config-file=./etc/windc-api-paste.ini --dbsync\n"
expect "*$*"
send -- "logout\n"
expect "*#*"
send -- "rabbitmq-plugins enable rabbitmq_management\n"
expect "*#*"
send -- "service rabbitmq-server restart\n"
expect "*#*"
send -- "rabbitmqctl add_user keero keero\n"
expect "*#*"
send -- "rabbitmqctl set_user_tags keero administrator\n"
expect "*#*"
send -- "cd /opt/stack/devstack\n"
expect "*#*"
send -- "source openrc admin admin\n"
expect "*#*"
send -- "cd /opt/stack/keero/windc\n"
expect "*#*"
send -- "./tools/with_venv.sh ./bin/windc-api --config-file=./etc/windc-api-paste.ini &\n"
expect "*DEBUG Call factory*"
send -- "\n"
expect "*#*"

4
tests/selenium/conf.ini Normal file
View File

@ -0,0 +1,4 @@
[server]
address=http://172.18.124.101
user=admin
password=AkvareL707

View File

@ -0,0 +1,54 @@
import re
from login_page import LoginPage
class DataCentersPage():
page = None
def __init__(self):
start_page = LoginPage()
self.page = start_page.login()
self.page.find_element_by_link_text('Project').click()
self.page.find_element_by_link_text('Windows Data Centers').click()
def create_data_center(self, name):
button_text = 'Create Windows Data Center'
self.page.find_element_by_link_text(button_text).click()
name_field = self.page.find_element_by_id('id_name')
xpath = "//input[@value='Create']"
button = self.page.find_element_by_xpath(xpath)
name_field.clear()
name_field.send_keys(name)
button.click()
return self.page
def find_data_center(self, name):
return self.page.find_element_by_link_text(name)
def delete_data_center(self, name):
datacenter = self.find_data_center(name)
link = datacenter.get_attribute('href')
datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]
xpath = ".//*[@id='windc__row__%s']/td[3]/div/a[2]" % datacenter_id
more_button = self.page.find_element_by_xpath(xpath)
more_button.click()
delete_button_id = "windc__row_%s__action_delete" % datacenter_id
delete_button = self.page.find_element_by_id(delete_button_id)
delete_button.click()
self.page.find_element_by_link_text("Delete Data Center").click()
return self.page
def select_data_center(self, name):
datacenter = self.page.find_data_center(name)
datacenter.click()
return self.page

View File

@ -0,0 +1,29 @@
import ConfigParser
from selenium import webdriver
class LoginPage():
def login(self):
config = ConfigParser.RawConfigParser()
config.read('conf.ini')
url = config.get('server', 'address')
user = config.get('server', 'user')
password = config.get('server', 'password')
page = webdriver.Firefox()
page.set_page_load_timeout(30)
page.implicitly_wait(30)
page.get(url)
name = page.find_element_by_name('username')
pwd = page.find_element_by_name('password')
xpath = "//button[@type='submit']"
button = page.find_element_by_xpath(xpath)
name.clear()
name.send_keys(user)
pwd.clear()
pwd.send_keys(password)
button.click()
return page

View File

@ -0,0 +1,54 @@
import ConfigParser
from selenium import webdriver
class ServicesPage():
page = None
def __init__(self, page):
self.page = page
def create_service(self, service_type, parameters):
button_id = 'services__action_CreateService'
button = self.page.find_element_by_id(button_id)
button.click()
self.select_type_of_service(service_type)
for parameter in parameters:
field = self.page.find_element_by_name(parameter.key)
field.clear()
field.send_keys(parameter.value)
xpath = "//input[@value='Deploy']"
deploy_button = self.page.find_element_by_xpath(xpath)
deploy_button.click()
return page
def select_type_of_service(self, service_type):
tab = find_element_by_link_text(service_type)
tab.click()
return self.page
def find_service(self, name):
return self.page.find_element_by_link_text(name)
def delete_service(self, name):
service = self.find_data_center(name)
link = service.get_attribute('href')
service_id = re.search('windc/(\S+)', link).group(0)[6:-1]
xpath = ".//*[@id='services__row__%s']/td[5]/div/a[2]" % service_id
more_button = self.page.find_element_by_xpath(xpath)
more_button.click()
delete_button_id = "services__row_%s__action_delete" % datacenter_id
delete_button = self.page.find_element_by_id(delete_button_id)
delete_button.click()
self.page.find_element_by_link_text("Delete Service").click()
return self.page

34
tests/selenium/test.py Normal file
View File

@ -0,0 +1,34 @@
import untitests
from datacenters_page import DataCentersPage
class SanityTests():
def setUp(self):
self.page = DataCentersPage()
def tearDown(self):
self.page.close()
def test_01_create_data_center(self):
self.page.create_data_center('dc1')
assert self.page.find_data_center('dc1') is not None
def test_02_delete_data_center(self):
page.delete_data_center('dc1')
assert self.page.find_data_center('dc1') is None
def test_03_create_data_centers(self):
for i in range(1,20):
name = 'datacenter' + str(i)
self.page.create_data_center(name)
assert self.page.find_data_center(name) is not None
def test_04_delete_data_centers(self):
page.delete_data_center('datacenter1')
page.delete_data_center('datacenter20')
assert self.page.find_data_center('datacenter1') is None
assert self.page.find_data_center('datacenter20') is None
for i in range(2,19):
name = 'datacenter' + str(i)
assert self.page.find_data_center(name) is not None