Retire tempest-tripleo-ui

Depends-On: https://review.opendev.org/#/c/667949/
Change-Id: I1ce89cce5df90b0e5329b560c1256af31520054c
This commit is contained in:
Alex Schultz 2019-06-27 08:52:27 -06:00
parent dc5ad09f1d
commit 8fb9012a16
31 changed files with 3 additions and 1591 deletions

4
.gitignore vendored
View File

@ -1,4 +0,0 @@
*.pyc
.eggs
.tox
tempest_tripleo_ui.egg-info

View File

@ -1,5 +0,0 @@
- project:
templates:
- check-requirements
- tempest-plugin-jobs
- release-notes-jobs-python3

202
LICENSE
View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,87 +1,5 @@
========================
Team and repository tags
========================
This project is no longer maintained.
.. image:: http://governance.openstack.org/badges/tempest-tripleo-ui.svg
:target: http://governance.openstack.org/reference/tags/index.html
The contents of this repository are still available in the Git source code management system. To see the contents of this repository before it reached its end of life, please check out the previous commit with "git checkout HEAD^1".
==================
tempest-tripleo-ui
==================
Tempest Plugin for TripleO UI
* Free software: Apache 2.0 license
Using
--------
Install this plugin in the same python environment as tempest.
Installing the web driver
-------------------------
Selenium drives the browser by using a web driver. Currently Firefox and Chrome are supported.
#. To install the Firefox driver:
Download the latest driver from https://github.com/mozilla/geckodriver/releases/. Place the
executable somewhere in your ``$PATH``, and configure your tempest.conf with the full path to
it. See an example tempest.conf file below.
#. To install the Chrome driver:
Download the latest driver from https://sites.google.com/a/chromium.org/chromedriver/downloads.
Unzip the downloaded file you'll get an executable called "chromedriver". Place the executable
somewhere in your ``$PATH``.
Configuration for testing
-------------------------
If your undercloud has been installed with tripleo-quickstart, you can test the
tempest-tripleo-ui plugin without much difficulty.
On your undercloud:
* ``cd ~``
* Clone the tempest-tripleo-ui repo ``git clone https://git.openstack.org/openstack/tempest-tripleo-ui``
* Install it ``cd tempest-tripleo-ui; sudo python setup.py install; cd ..``
* Modify ``tempest-setup.sh`` to add ``tripleo_ui.url http://192.168.24.1:3000`` to the ``$TEMPESTCONF`` command
* Modify ``whitelist_file.conf`` to add ``tempest_tripleo_ui.tests.scenario.test_basic.TestBasic``
* Run ``./tempest-setup.sh``
This will run all of the tests contained in the tempest-tripleo-ui plugin
against your undercloud.
Sample tempest.conf
-------------------
For the UI tests to work, a minimal tempest.conf should include:
1) The credentials to log in (same credentials which are used on the command line)
2) The URL where the login screen to the UI can be found
3) The webdriver to use, which could be one of: "Chrome" or "Firefox"
4) If using Firefox, set marionette_binary to point to the path to the driver
[DEFAULT]
log_dir = /home/tester/src/tempest/cloud-01/logs
log_file = tempest.log
[oslo_concurrency]
lock_path = /home/tester/src/tempest/cloud-01/tempest_lock
[auth]
admin_username = admin
admin_password = password
admin_project_name = admin
admin_domain_name = default
[identity]
auth_version = v3
uri_v3 = https://server:443/keystone/v3
[tripleo_ui]
webdriver = "Chrome"
marionette_binary = "/home/tester/bin/wires"
url = "https://server"
[logger_root]
level=DEBUG
handlers=file
For any further questions, please email openstack-discuss@lists.openstack.org or join #openstack-dev on Freenode.

View File

@ -1,3 +0,0 @@
openstackdocstheme>=1.24.1 # Apache-2.0
reno>=2.5.0 # Apache-2.0
sphinx!=1.6.6,!=1.6.7,>=1.6.2

View File

@ -1,4 +0,0 @@
---
features:
- |
Set up project structure

View File

@ -1,265 +0,0 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
import openstackdocstheme
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'openstackdocstheme',
'reno.sphinxext',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'tempest-tripleo-ui Release Notes'
copyright = u'2017, OpenStack TripleO-UI Developers'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = ''
# The full version, including alpha/beta/rc tags.
release = ''
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'openstackdocs'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [openstackdocstheme.get_html_theme_path()]
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_domain_indices = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'tripleo-uiReleaseNotesdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'tempest-tripleo-uiReleaseNotes.tex',
u'tempest-tripleo-ui Release Notes Documentation',
u'2017, Puppet OpenStack Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# If true, show page references after internal links.
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'tempest-tripleo-uireleasenotes',
u'tempest-tripleo-ui Release Notes Documentation',
[u'2017, Puppet OpenStack Developers'], 1)
]
# If true, show URL addresses after external links.
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'tempest-tripleo-uiReleaseNotes',
u'tempest-tripleo-ui Release Notes Documentation',
u'2017, Puppet OpenStack Developers', 'tempest-tripleo-uiReleaseNotes',
'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
# If false, no module index is generated.
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False

View File

@ -1,8 +0,0 @@
================================
tempest-tripleo-ui Release Notes
================================
.. toctree::
:maxdepth: 1
unreleased

View File

@ -1,5 +0,0 @@
==============================
Current Series Release Notes
==============================
.. release-notes::

View File

@ -1,5 +0,0 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
oslo.config>=5.1.0 # Apache-2.0
six>=1.10.0 # MIT
tempest>=17.1.0 # Apache-2.0
selenium>=3.14.1 # Apache-2.0

View File

@ -1,27 +0,0 @@
[metadata]
name = tempest-tripleo-ui
summary = Tempest Plugin for TripleO UI
description-file =
README.rst
author = OpenStack
author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
[files]
packages =
tempest_tripleo_ui
[entry_points]
tempest.test_plugins =
tripleo_ui = tempest_tripleo_ui.plugin:TripleOUITempestPlugin

View File

@ -1,30 +0,0 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
pbr=True)

View File

@ -1,68 +0,0 @@
from selenium.common import exceptions
from tempest_tripleo_ui.core import SeleniumElement
from tempest_tripleo_ui.timer import Timer
from time import sleep
import logging
logger = logging.getLogger(__name__)
alert_success_close_button = SeleniumElement.by_xpath(
'//div[contains(@class, "alert-success")]/button[@class="close"]')
alert_success = SeleniumElement.by_xpath(
'//div[contains(@class, "alert-success")]')
alert_danger_close_button = SeleniumElement.by_xpath(
'//div[contains(@class, "alert-danger")]/button[@class="close"]')
alert_danger = SeleniumElement.by_xpath(
'//div[contains(@class, "alert-danger")]')
# the spinner that we see while waiting for dialogs to open etc'
spinner = SeleniumElement.by_xpath(
'//div[contains(@class, "spinner")]')
def clear_success_message(timeout=3):
if alert_success_close_button.wait_for_element(timeout) and \
not alert_success_close_button.is_stale():
try:
logger.info("Clearing message: {}".format(
alert_success.get_all_text()))
alert_success_close_button.click()
except exceptions.WebDriverException:
pass # sometimes the message disappears in this critical moment
return True
return False
def clear_danger_message(timeout=3):
if alert_danger_close_button.wait_for_element(timeout) and \
not alert_danger_close_button.is_stale():
logger.error("Clearing alert: {}".format(
alert_danger.get_all_text()))
alert_danger_close_button.click()
return True
return False
def clear_all_success_messages():
while clear_success_message():
sleep(2)
def clear_all_danger_messages():
while clear_danger_message():
sleep(2)
def wait_for_spinner(timeout=60, spinner_element=None):
logger.debug("waiting for spinners...")
if not spinner_element:
spinner_element = spinner
timer = Timer("spinner")
while spinner_element.wait_for_element(0) and \
timer.get_duration() < timeout:
sleep(3)
# not using timer.assert_timer() because we're not interested
# in the error message it generates
return timer.get_duration() < timeout

View File

@ -1,36 +0,0 @@
import logging
from tempest.lib import exceptions
from tempest import test
from tempest_tripleo_ui import browser
from tempest_tripleo_ui.models import login
logger = logging.getLogger(__name__)
class CouldNotLogIn(exceptions.TempestException):
message = "Could not log in"
class GUITestCase(test.BaseTestCase):
@classmethod
def resource_setup(cls):
"""Login to the GUI. This will also open up the browser and get the
home page - according to the parameters configured in the [UI]
section in the conf file.
"""
super(GUITestCase, cls).resource_setup()
if not login.login():
logger.error(
"Unable to login to TripleO UI (check the "
"credentials in the tempest conf file)")
browser.quit_browser()
raise CouldNotLogIn
cls.addClassResourceCleanup(cls.logout_and_close_browser)
@classmethod
def logout_and_close_browser(cls):
if login.is_logged_in():
login.logout()
browser.quit_browser()

View File

@ -1,111 +0,0 @@
import logging
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from tempest import config
from tempest.lib import exceptions
import uuid
class InvalidWebdriverSetting(exceptions.TempestException):
message = "Invalid webdriver: %(browser_driver)s. Should be either "\
"'Chrome' or 'Firefox'"
logger = logging.getLogger(__name__)
CONF = config.CONF
browser = None
def get_browser():
global browser
if browser is not None:
return browser
browser_driver = CONF.tripleo_ui.webdriver
if browser_driver.lower() == "chrome":
browser_factory = ChromeFactory()
elif browser_driver.lower() == "firefox":
browser_factory = MarionetteFactory(
CONF.tripleo_ui.marionette_binary)
else:
raise InvalidWebdriverSetting(browser_driver=browser_driver)
browser = Browser(browser_factory, CONF.tripleo_ui.url)
return browser
def quit_browser():
global browser
if browser is None:
return
browser.quit_browser()
browser = None
def save_screenshot(filename=None):
global browser
if browser is None:
return
if not filename:
filename = "/tmp/{}.png".format(uuid.uuid4())
browser.get_driver().save_screenshot(filename)
return filename
def execute_script(script_to_run):
return get_browser().execute_script(script_to_run)
class Browser(object):
def __init__(self, browser_factory, homepage=None):
self.session = None
self.driver = browser_factory.create()
if homepage and len(homepage.strip()):
self.get(homepage)
def get_session(self):
if self.session:
return self.session
self.session = uuid.uuid4()
return self.session
def get(self, url):
self.driver.get(url)
def refresh(self):
self.driver.refresh()
def get_driver(self):
return self.driver
def quit_browser(self):
self.driver.quit()
self.driver = None
self.session = None
def execute_script(self, script_to_run):
return self.driver.execute_script(script_to_run)
class ChromeFactory(object):
def create(self):
return webdriver.Chrome()
class MarionetteFactory(object):
def __init__(self, path_to_binary):
self.path_to_binary = path_to_binary
def create(self):
capabilities = DesiredCapabilities.FIREFOX
capabilities['marionette'] = True
args = dict()
args['capabilities'] = capabilities
args['executable_path'] = self.path_to_binary
return webdriver.Firefox(**args)

View File

@ -1,29 +0,0 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
ui_group = cfg.OptGroup(name='tripleo_ui', title='TripleO UI Options')
# NOTE: username and password can be acquired from the [identity] group
UIGroup = [
cfg.StrOpt('url', default='http://localhost',
help='where the TripleO UI can be found'),
cfg.StrOpt('webdriver', default='Chrome',
help='the browser to use for the test [Chrome/Marionette]'),
cfg.StrOpt('marionette_binary', default='path_to_wires',
help='path to the marionette driver binary')
]

View File

@ -1,395 +0,0 @@
import logging
from selenium.common import exceptions
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support import select
from selenium.webdriver.support import ui
from tempest_tripleo_ui import browser
from tempest_tripleo_ui.decorators import selenium_action
from time import sleep
logger = logging.getLogger(__name__)
class Identifier(object):
def __init__(self, by, identifier):
self.by = by
self.identifier = identifier
@classmethod
def xpath(cls, locator):
return Identifier(By.XPATH, locator)
@classmethod
def css_selector(cls, locator):
return Identifier(By.CSS_SELECTOR, locator)
@classmethod
def id(cls, locator):
return Identifier(By.ID, locator)
@classmethod
def class_name(cls, locator):
return Identifier(By.CLASS_NAME, locator)
@classmethod
def link_text(cls, locator):
return Identifier(By.LINK_TEXT, locator)
class SeleniumElement(object):
def __init__(self,
identifier=None,
webelement=None,
session=None):
self.identifier = identifier
self.webelement = webelement
self.session = session
@classmethod
def by_id(cls, name):
return SeleniumElement(Identifier(By.ID, name))
@classmethod
def by_class(cls, name):
return SeleniumElement(Identifier(By.CLASS_NAME, name))
@classmethod
def by_css(cls, name):
return SeleniumElement(Identifier(By.CSS_SELECTOR, name))
@classmethod
def by_xpath(cls, name):
return SeleniumElement(Identifier(By.XPATH, name))
@classmethod
def by_link_text(cls, name):
return SeleniumElement(Identifier(By.LINK_TEXT, name))
@classmethod
def by_element(cls, elem, browser_session):
new_elem = SeleniumElement(webelement=elem, session=browser_session)
return new_elem
def get_element(self):
if self.webelement and \
self.session == browser.get_browser().get_session():
return self.webelement
elem = self.wait_for_element()
if elem is None:
logger.error("can't find element: {}".format(
self.get_identifier_string()))
return elem
def get_identifier_string(self):
name = "No identifier"
if self.identifier:
name = self.identifier.identifier
return name
def wait_for_element(self, timeout_in_seconds=10):
if self.identifier is None:
logger.warning("wait_for_element() is irrelevant for elements "
"that were not found via an identifier")
return self.webelement
try:
self.webelement = ui.WebDriverWait(
browser.get_browser().get_driver(),
timeout_in_seconds).until(
EC.presence_of_element_located(
(self.identifier.by, self.identifier.identifier))
)
self.session = browser.get_browser().get_session()
return self.webelement
except exceptions.TimeoutException:
return None # because the element is not found
def wait_for_present_text(self, text, timeout_in_seconds=10):
try:
if self.identifier is None:
logger.warning(
'wait_for_present_text will not work properly, '
'because there is missing .identifier.')
self.webelement = ui.WebDriverWait(
browser.get_browser().get_driver(),
timeout_in_seconds).until(
EC.text_to_be_present_in_element(
(self.identifier.by, self.identifier.identifier), text)
)
return self.webelement
except exceptions.TimeoutException:
return None
def wait_for_staleness(self, timeout_in_seconds=10):
if self.webelement is None:
logger.warning("wait_for_staleness() is irrelevant for elements "
"that were not found yet")
return True
try:
return ui.WebDriverWait(browser.get_browser().get_driver(),
timeout_in_seconds).until(
EC.staleness_of(self.webelement))
except exceptions.TimeoutException:
return None
def is_stale(self):
try:
self.webelement.is_enabled()
return False
except exceptions.StaleElementReferenceException:
return True
except exceptions.WebDriverException:
return False
@selenium_action
def is_visible(self, webelement):
return webelement.is_displayed()
@selenium_action
def is_selected(self, webelement):
return webelement.is_selected()
@selenium_action
def is_enabled(self, webelement):
return webelement.is_enabled()
@selenium_action
def get_tag_name(self, webelement):
return webelement.tag_name
@selenium_action
def get_text(self, webelement):
return webelement.text
def get_all_text(self):
text = self.get_text()
if text is None or len(text) == 0:
text = ""
child_elements = self.find_child_elements(Identifier.xpath("*"))
if child_elements is not None and len(child_elements) > 0:
for child_element in child_elements:
child_text = child_element.get_all_text()
if child_text is not None and len(child_text) > 0:
if len(text) > 0:
text = text + " " + child_text
else:
text = child_text
return text
@selenium_action
def get_id(self, webelement):
return webelement.get_attribute("id")
@selenium_action
def get_name(self, webelement):
return webelement.get_attribute("name")
@selenium_action
def get_value(self, webelement):
return webelement.get_attribute("value")
@selenium_action
def get_class(self, webelement):
return webelement.get_attribute("class")
@selenium_action
def get_href(self, webelement):
return webelement.get_attribute("href")
@selenium_action
def get_title(self, webelement):
return webelement.get_attribute("title")
@selenium_action
def click_minimum_retries(self, webelement):
webelement.click()
# this WON'T be a @selenium_action because we're handling retries
# internally
def click(self, use_js=False):
# try to click and catch exception
try:
self.click_minimum_retries()
return True
except exceptions.WebDriverException:
pass
sleep(1)
# click failed - scroll the item into view (bottom) and try again
try:
self.scroll_into_view(False)
self.click_minimum_retries()
return True
except exceptions.WebDriverException:
pass
sleep(1)
# click failed again - scroll the item into view (top) and try again
try:
self.scroll_into_view(True)
self.click_minimum_retries()
return True
except exceptions.WebDriverException:
pass
if use_js:
try:
logger.warning("almost giving up on all click attempts !!")
browser.get_browser().save_screenshot()
browser.get_browser().get_driver().execute_script(
'return arguments[0].click();', self.get_element()
)
logger.warning(
"click was successful only when using "
"javascript... {}".format(self.get_identifier_string()))
sleep(1)
browser.get_browser().save_screenshot()
return True
except BaseException:
logger.warning(
"click was unsuccessful even with javascript! {}".format(
self.get_identifier_string()))
# all failed...
logger.error(
"all click attempts failed on: {}".format(
self.get_identifier_string()))
return False
@selenium_action
def click_at_offset(self, webelement, x, y):
actions = webdriver.ActionChains(browser.get_browser().get_driver())
actions.move_to_element_with_offset(webelement, x, y)
actions.click()
return actions.perform()
@selenium_action
def move_to(self, webelement):
actions = webdriver.ActionChains(browser.get_browser().get_driver())
actions.move_to_element(webelement)
actions.perform()
@selenium_action
def scroll_into_view(self, webelement, align_to_top=True):
driver = browser.get_browser().get_driver()
if align_to_top:
driver.execute_script(
"arguments[0].scroll_into_view(true);", webelement)
else:
driver.execute_script(
"arguments[0].scroll_into_view(false);", webelement)
@selenium_action
def submit(self, webelement):
return webelement.submit()
@selenium_action
def clear(self, webelement):
webelement.clear()
return webelement.get_attribute('value') == ''
@selenium_action
def send_keys(self, webelement, text, tokenize=True):
text = "{}".format(text)
if not tokenize:
webelement.send_keys(text)
return
# don't send more than 40 characters at a time, as it
# can hang some scripts
token_size = 40
while len(text) > 0:
webelement.send_keys(text[:token_size])
text = text[token_size:]
@selenium_action
def send_ctrl_something(self, webelement, key):
return webelement.send_keys(Keys.CONTROL, self.key)
# start xpath with ".//"
@selenium_action
def find_child_elements(self, webelement, identifier):
elements = None
try:
elements = webelement.find_elements(
by=self.identifier.by,
value=self.identifier.identifier)
except BaseException:
return None
if elements is not None:
ret = []
for child_element in elements:
ret.append(SeleniumElement.by_element(child_element,
self.session))
return ret
def drag_and_drop(self, target):
if self.is_visible() and target.is_visible():
elem_from = self.get_element()
elem_to = target.get_element()
if elem_from and elem_to:
webdriver.ActionChains(
browser.get_browser().get_driver().drag_and_drop(
elem_from, elem_to).perform())
else:
logger.error("drag-n-drop: items are not visible")
@selenium_action
def deselect_all(self, webelement):
sel = select.Select(webelement)
return sel.deselect_all()
@selenium_action
def select_by_index(self, webelement, index):
sel = select.Select(webelement)
return sel.select_by_index(index)
@selenium_action
def select_by_value(self, webelement, value):
sel = select.Select(webelement)
return sel.select_by_value(value)
@selenium_action
def select_by_visible_text(self, webelement, value):
sel = select.Select(webelement)
return sel.select_by_visible_text(value)
@selenium_action
def deselect_by_index(self, webelement, index):
sel = select.Select(webelement)
return sel.deselect_by_index(index)
@selenium_action
def deselect_by_value(self, webelement, value):
sel = select.Select(webelement)
return sel.deselect_by_value(value)
@selenium_action
def deselect_by_visible_text(self, webelement, value):
sel = select.Select(webelement)
return sel.deselect_by_visible_text(value)
def selenium_elements(identifier):
elements = []
current_browser = browser.get_browser()
browser_session = current_browser.get_session()
results = current_browser.get_driver().find_elements(
by=identifier.by, value=identifier.identifier)
for elem in results:
elements.append(SeleniumElement.by_element(elem, browser_session))
return elements

View File

@ -1,51 +0,0 @@
from functools import wraps
from selenium.common.exceptions import (
StaleElementReferenceException, InvalidElementStateException
)
import logging
logger = logging.getLogger(__name__)
def selenium_action(f):
"""The selenium_action decorator
This decorator can be used to wrap methods of ``SeleniumElement`` to
provide exception handling, and automatic retries.
It expects that the method being decorated accepts a ``webelement``
as its first positional argument after ``self``.
E.g.
@selenium_action
def click_button(self, webelement):
...
"""
@wraps(f)
def wrapper(self, *args, **kwargs):
webelement = self.get_element()
if not webelement:
return
try:
try:
return f(self, webelement, *args, **kwargs)
except (StaleElementReferenceException,
InvalidElementStateException):
logger.debug("stale element: {}".format(
self.get_identifier_string()))
self.wait_for_element(3)
webelement = self.get_element()
if webelement is None:
return None
return f(self, webelement, *args, **kwargs)
except Exception as e:
logger.warning("selenium exception on '{}': {}"
.format(self.get_identifier_string(), e))
raise
return None
return wrapper

View File

@ -1,109 +0,0 @@
from tempest_tripleo_ui.widgets import login_page
from tempest_tripleo_ui import alerts
from tempest_tripleo_ui.timer import Timer
from time import sleep
from tempest import config
import logging
CONF = config.CONF
logger = logging.getLogger(__name__)
def logout():
logger.info("Logging out...")
if not is_logged_in():
logger.warning("Hey! Was already logged out...")
return
while alerts.clear_danger_message(timeout=1) or \
alerts.clear_success_message(timeout=1):
pass
# First, we need to click on the toggle to open the user dropdown menu
if login_page.user_toggle_button.wait_for_element(0):
if not login_page.user_toggle_button.click():
logger.error("click failed on the 'user toggle' button")
if not login_page.logout_button.click():
logger.error("click failed on the 'Logout' button")
# FIXME: this should be an assertion
if not login_page.password.wait_for_element(5):
logger.error("Logout failed (didn't see the login screen after 5 "
"seconds)")
return False
return True
def is_logged_in():
for _retries in range(0, 5):
# find the logout button or the password field,
# whichever comes first
if login_page.logout_button.wait_for_element(1):
return True
if login_page.password.wait_for_element(1):
return False
logger.error("login.is_logged_in(): could not determine if "
"logged in or not, no recognizable elements found "
"on the page within 10 seconds")
return False
def login(username=None, password=None):
logger.info("Logging in...")
if is_logged_in():
logger.error("Already logged in... Make sure "
"you log out first!")
return False
if username is None:
username = CONF.auth.admin_username
if password is None:
password = CONF.auth.admin_password
if username is None or password is None:
logger.error("Missing username or password. Make sure they are "
"configured in the tempest conf file")
return False
login_page.username.clear()
login_page.username.send_keys(username)
login_page.password.clear()
login_page.password.send_keys(password)
login_page.password.submit()
for _retry in range(6):
if not login_page.logout_button.wait_for_element():
if login_page.unauthorized_div.wait_for_element(1):
logger.warning(login_page.unauthorized_div.get_all_text())
return False
if not login_page.logout_button.wait_for_element(0):
logger.error(
"Login failed (waited 60 seconds and no sign of "
"a logout button...)")
return False
# wait for the modal div that covers the page to go away...
timeout = 20
timer = Timer("wait for modal after login", timeout=timeout)
while login_page.modal_div.wait_for_element(1) and \
timer.get_duration() < timeout:
sleep(1)
if not timer.assert_timer():
logger.error("exceeded timer")
return False
if timer.get_duration() > 5:
logger.warning("login took {} seconds".format(
timer.get_duration()))
# wait for all spinners
alerts.wait_for_spinner()
# clear all alerts that sometimes appear straight after login
while alerts.clear_danger_message():
pass
return True

View File

@ -1,39 +0,0 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from tempest import config
from tempest.test_discover import plugins
from tempest_tripleo_ui import config as ui_config
class TripleOUITempestPlugin(plugins.TempestPlugin):
def load_tests(self):
base_path = os.path.split(os.path.dirname(
os.path.abspath(__file__)))[0]
test_dir = "tempest_tripleo_ui/tests"
full_test_dir = os.path.join(base_path, test_dir)
return full_test_dir, base_path
def register_opts(self, conf):
config.register_opt_group(
conf, ui_config.ui_group, ui_config.UIGroup
)
def get_opt_lists(self):
return [
(ui_config.ui_group.name, ui_config.UIGroup)
]

View File

@ -1,25 +0,0 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from tempest_tripleo_ui.base import GUITestCase
CONF = config.CONF
class TestBasic(GUITestCase):
def test_basic_plugin_functionality(self):
pass

View File

@ -1,40 +0,0 @@
from time import time
import logging
logger = logging.getLogger(__name__)
class Timer(object):
def __init__(self, operation_name, timeout=10):
self.timer = time()
self.operation_name = operation_name
self.timeout = timeout
self.duration = None
def assert_timer(self, message=None):
if self.timer is None:
logger.error("trying to use the same timer twice - please "
"create a new timer to start a new measurement")
return
self.duration = time() - self.timer
self.timer = None
if self.duration > self.timeout:
err_msg = ("operation '{}' took {} seconds, allowed timeout "
"is {} seconds").format(self.operation_name,
self.duration,
self.timeout)
if message is not None:
err_msg += ": {}".format(message)
logger.error(err_msg)
return False
return True
def get_duration(self):
if self.duration is not None:
return self.duration
return time() - self.timer

View File

@ -1,13 +0,0 @@
from tempest_tripleo_ui.core import SeleniumElement
username = SeleniumElement.by_id("username")
password = SeleniumElement.by_id("password")
logout_button = SeleniumElement.by_id('NavBar__logoutLink')
user_toggle_button = SeleniumElement.by_id('UserDropdown__toggle')
unauthorized_div = SeleniumElement.by_xpath(
'//div[contains(@class, "login")]/div[contains'
'(@class, "alert-danger")]')
modal_div = SeleniumElement.by_xpath(
'//div[contains(@class, "modal")][contains(@role, "dialog")]')

View File

@ -1 +0,0 @@
flake8>=3.5.0,<4.0.0 # MIT

31
tox.ini
View File

@ -1,31 +0,0 @@
[tox]
minversion = 1.6
envlist = py35,pep8,releasenotes
skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:pep8]
basepython = python3
commands = flake8
[flake8]
show_source = True
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
[testenv:releasenotes]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html