48 Commits

Author SHA1 Message Date
Akihiro Motoki
e6b78f92f2 Use flake8-import-order plugin
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
This flake8 plugin is already used in tempest.
It enforces loose checking so it sounds good to use.

Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.

Change-Id: I8ccd05eb70350a2441cc2a4d1eafc09ee690b83b
2017-07-03 08:02:23 +00:00
Akihiro Motoki
b9d0243c33 Fix H405 (multi line docstring) warnings (openstack_dashboard)
H405: multi line docstring summary not separated with an empty line

Closes-Bug: #1696996

Change-Id: Id895695663b19522d9cdc22f8b012e49680d708b
2017-06-09 16:05:31 +00:00
Akihiro Motoki
f22669058a Clean up logger usage
* Use module-specific logger in integration helper.
  Previously the root logger (returned by getLogger without parameter)
  was used for module-specifc log messages.
  It is better to use module-specific logger for such messages
  and we can easily identify where log messages come from.
* In case of requiring access to the root logger,
  get the root logger explicitly.
* Use 'LOG' for logger name. Almost all modules in horizon use
  'LOG' for logger name, but some do not.
  It is better to follow the convention.

* Use LOG.warning instead of LOG.warn.
  LOG.warning is recommended way in Python3.

Change-Id: Ib9de7ee08a235de9820b95910d8f54724a1f2b91
2017-04-13 04:35:50 +00:00
zhangguoqing
691ab23248 Simplify uuid without dashed
The uuid format of uuidutils.generate_uuid(dashed=False) equal to
uuidutils.generate_uuid().replace("-", "").

Change-Id: Iea46b7ce146e5e7e48b80c0936d1c66d78d047dc
2016-12-07 07:14:57 +00:00
jolie
796625863d Replaces uuid.uuid4 with uuidutils.generate_uuid()
Change-Id: I72e502a07d971de7e5c85519c80c4d054863eabe
Closes-Bug: #1082248
2016-11-08 18:19:34 +08:00
Jenkins
e7f09d758e Merge "Implement video capture for failed tests" 2016-06-08 08:43:07 +00:00
Sergei Chipiga
d63f93a819 Implement video capture for failed tests
Example of video recording Idd218e09c0f8df8ec7740173d5f2d856b8baafa1

Change-Id: I350950095f840f63638175b09ed083109aada2da
Closes-Bug: #1585092
2016-06-07 13:09:47 +03:00
Sergei Chipiga
c80edb161b Do not run exception handlers if test was skipped.
Change-Id: If9f031d010d293db57482f902f28ca29110cacac
Closes-Bug: #1587922
2016-06-03 12:47:46 +03:00
Sergei Chipiga
c3da75ab5a Delegate tearDown logic to addCleanup method
tearDown doesn't work if setUp is failed, for ex.
https://bugs.launchpad.net/searchlight/+bug/1557287
https://bugs.launchpad.net/horizon/+bug/1405553

Change-Id: I4e02dfbd6dc902d50dd47f8441919aa5e29b3101
Closed-Bug: #1405553
2016-06-01 18:39:19 +03:00
Sergei Chipiga
4619696ec4 Attach test logs individually for each test
Reports-Example: Ic35c95e720211bce8659baeb0cd4470308e25ea4

Change-Id: Ie5d972d2a560d4f59666c49dc3bf22fdb48071e8
Depends-On: I124973d9adbaaacf5d3429e6f6684f15de27dc7f
Closes-Bug: #1572999
2016-04-25 14:30:49 +03:00
Yury Tregubov
d44eebecfa Added update image metadata test
Updated forms.py with MetadataFormRegion.
Updated tables.py with method to bind anchor row column.
Added test for update image metadata.

Implements blueprint: horizon-integration-tests-coverage
Change-Id: Idd3651955b8f0e1a0c08dd43abd657aafa5a3bc2
2016-04-14 16:03:22 +04:00
Martin Pavlasek
8e9b609fc6 Refactor of BaseTestCase
Made code more readable by check conditions first.

Closes-Bug: 1463729
Partially implements blueprint: selenium-integration-testing
Change-Id: I34edd7261022f7a0a441e0716be8b84f90e8cde9
2016-04-03 21:15:02 +00:00
Yury Tregubov
243394ae61 Added test for image create from local file
Implements blueprint: horizon-integration-tests-coverage

Change-Id: Id1075a3812d4da020e78d2cd3266e7ab889cf2d5
2016-03-28 17:35:47 +04:00
Timur Sufiev
d1f08df329 Fix exceptions_captured manager in i9n tests
Recently introduced manager handled only 'bad' failure scenarios when
Selenium became non responsive and caused again cryptic failures for
failures that were perfectly reported before exceptions_captured
introduction. Now both kind of (responsive and non responsive
Selenium) failures are addressed inside it.

Change-Id: I564b5e8b35fb2e84c27374bcac8a49cb6262b058
Closes-Bug: #1545042
2016-02-12 18:46:05 +03:00
Jenkins
5af1205c9d Merge "Add configuration mechanism to turn off browser maximisation" 2016-02-11 12:05:06 +00:00
Jenkins
6d43960fd6 Merge "Ensure that integration tests are being run in proper project" 2016-02-11 06:37:59 +00:00
Richard Jones
af505dacd1 Add configuration mechanism to turn off browser maximisation
Having the window maximise during a test run makes it difficult
to work with other windows, especially on a single-monitor
computer. This patch removes the maximisation call.

This patch also adds a "local" configuration mechanism to allow
developers to have local configuration of the integration test
environment without it affecting the git repository.

Change-Id: I8a7acbe40deaec5cca904526e3f3c8bc3357744c
Closes-Bug: 1540719
2016-02-11 07:05:22 +11:00
Timur Sufiev
0419b0e2e6 Ensure that integration tests are being run in proper project
Admin users run tests in an admin project, regular users run them in a
demo project. That should prevent situations when tests don't have an
access to a resources created in a project different from the current
one.

Closes-Bug: #1542211
Change-Id: I497648ce5126e187744b5795bd524b7aba22c7a6
2016-02-10 09:40:52 +00:00
Timur Sufiev
51f35099bc Don't overwrite original traceback in certain cases of i9n failures
Achieve this by muffling exceptions (raised due to Selenium became not
resposive) while taking integration test failure screenshot.

Also extract the pattern of muffling and capturing exceptions common
for dump_browser_log, dump_html_page and save_screenshot in a common
@exceptions_captured context manager.

Closes-Bug: #1543541
Change-Id: I37fa18a302c553b43529df056d2beacff70f6189
2016-02-09 21:29:58 +03:00
Jenkins
8f459658e6 Merge "Merge the two webdrivers" 2016-02-08 14:28:56 +00:00
Timur Sufiev
5a9413c28b Zoom out pages in i9n tests
Since Selenium 2.50.1 release it's no longer possible to click
elements which are outside of visible viewport. To keep both tests
working and error screenshots still visible, standard xvfb screensize
is set to 1920x1080 and page scale is set to 67%.

Also temporarily disable create_instance test since it fails on some
nodes due to missing network.

Related-Bug: #1542211
Closes-Bug: #1541876
Change-Id: Ie96606cf52860dd8bb3286971962a16cb3415daf
2016-02-05 11:56:44 +03:00
Victor Stinner
78bfa9727d Support xvfbwrapper 0.2.8
xvfbwrapper 0.2.8 renamed the xvfb_cmd attribute of xvfbwrapper.Xvfb
to extra_xvfb_args. This change checks if the new attribute name is
available to support new and old xvfbwrapper version.

xvfbwrapper commit changing the API:
9a8c0e80f6

Closes-Bug: #1540495
Change-Id: I45704450ff396787453937362029945b94887189
2016-02-02 21:49:55 +01:00
Richard Jones
a17612ed97 Merge the two webdrivers
Horizon currently has two webdrivers for selenium-based
testing; this patch merges them into one so all tests
(selenium functional tests and integration tests) benefit
from improvements we make to the webdriver.

Change-Id: Iac471c2c7e40c799711746ef9e3e4ef87aecf098
2016-01-30 11:54:19 +00:00
Timur Sufiev
d9d6a73047 Use the horizon.conf's dir as the basedir for i9n screenshots
This prevents screenshots in plugins integration tests being placed
into places like .tox/py27integration/horizon/openstack_dashboard...

Change-Id: Idf831a2fee4eb9b0c34fdf03c50317e253a082b9
2015-12-31 15:27:01 +03:00
Richard Jones
0c9628de93 Increase default Python socket timeout
This change increses the timeout for the communications between the
test process and the selenium web driver process.

Change-Id: I79e46713338a59d45c117dc86bf59b9992dbdd94
Fixes-Bug: 1526611
2015-12-16 22:44:35 +00:00
Timur Sufiev
f77080bd87 Dump browser log on integration test failure
Having all messages from browser console inside a test log sometimes
may be very valuable in understanding the cause of test failure.

Change-Id: I9ef39e412e0b9f1faacf0a3e42418ca138c52d66
Related-Bug: #1505320
2015-10-14 14:41:35 -07:00
Serhii Vasheka
bc109d33ed Add _save_screenshot functionality to helpers.
Having screenshot of failed test might increase speed of
understanding the failure reason.

partially-implements blueprint: selenium-integration-testing

Depends-On: I0fd89ede7a3d04ce9b4bd4c8fba0789770048d40
Change-Id: Ibc4a6235423736e5938fb348bbe83211917b08d1
2015-09-16 12:40:38 +03:00
Tomáš Nováčik
e74296fb20 Add html source code on test failure for debugging
Sometimes it is not possible to reproduce failure in integration test
locally. Adding html source code of page where failure happened should
increase our ability to debug properly errors on the gates. For this
purpose the addDetail method from testtools package is used.

Following changes were done:

* TestCase and AdminTestCase classes were modified in order to share
  common functionality and remove code repetition.

* Testcases have been modified in order to use newly introduce class
  variables(TEST_USER_NAME, TEST_PASSWORD, CONFIG).

* Methods _get_page_html_source and _dump_page_html_source have been created
  in the BaseTestCase class. _get_page_html_source uses javascript innerHTML
  attribute in order to make javascript modification to the page visible
  in the output. (javascript modificaton would not have been visible if
  webdriver's property page_source was used)

Partially implements blueprint: selenium-integration-testing

Change-Id: I064405337fb68c966da007f2a5bf91d5c0ec2b3d
2015-03-20 17:43:56 +01:00
Jenkins
0bf58f63af Merge "Add general function for generating random names" 2015-02-21 01:00:44 +00:00
Jenkins
effcb1cf9c Merge "Modified teardown method to handle login and logout failure." 2015-01-28 17:32:27 +00:00
Tomáš Nováčik
ee8bc19159 Add general function for generating random names
Adding function gen_random_resource_name for generation random resources
that should be used in the integration tests. Mentioned method
automatically adds horizon string into the resource name in order to clearly
distinguish resource origin.

Also timestamp is added for better debugging of the tests in more
complex testcases.

uuid4 function is used to minimize resource name collisions.

Closes-Bug: #1399219
Partially implements blueprint: selenium-integration-testing

Change-Id: Id5cb26e50b7b442af69798a2928be514adf7d8fe
2015-01-27 12:41:15 +01:00
Jenkins
6308069eac Merge "Remove unused wait_for_title method" 2015-01-26 16:32:17 +00:00
Martin Pavlasek
4f3b6bf09d Remove unused wait_for_title method
Verified by grep, the method wasn't used anywhere, so there is no
purpose to have it there.

Partially implements blueprint: selenium-integration-testing
Closes-Bug: #1414296
Change-Id: I2646ae988d45af81a4dd75e918806465748eeea3
2015-01-24 13:30:31 +00:00
Tomáš Nováčik
2ebb804c05 Adding -ac and -noreset arguments to Xvfb
There is outstanding memory leak issue with Xvfb, that should be fixed
by -noreset argument.

-ac disables X access control - which i believe is not necessary for
                                testing

Partially implements blueprint: selenium-integration-testing
Closes-Bug: #1412469

Change-Id: I5f603266f891728bb8e83331f5a4e57799f07f79
2015-01-20 19:32:14 +01:00
mavinagi
cc373e3244 Modified teardown method to handle login and logout failure.
In TestCase and AdminTestCase
	* Added condition to check login status inside teardown method.
	* Added try and finally, in case logout fails.
In BaseTestCase->teardown:
	* replaced driver.close() with driver.quit()

Partially implements blueprint: selenium-integration-testing
Closes-Bug: #1405553

Change-Id: Id1b520ec0a747ace89864bf7cc6b5d9b670fdc60
2015-01-14 13:07:38 -06:00
imran
8edb9f1bc3 Fix method passed to selenium way it suggests
A lambda function is passed to selenium wait call until() but the docstrings
of that call suggest a better way of passing the lambda function.
Its redundant to return a specific driver instance when until() function
already takes care of that.

Change-Id: Ie0916587bf6a7488b3828d91ad553a3944619dfc
Partially implements blueprint: selenium-integration-testing
Closes-Bug: #1404416
2014-12-22 11:13:56 -08:00
Jenkins
9d5aa8e864 Merge "Add _wait_till_text_present_in_element method" 2014-12-12 11:49:28 +00:00
Vlad Okhrimenko
a026b2d554 Add "login as admin" for integration tests
Add class AdminTestCase for login as admin.

Partially implements blueprint: selenium-integration-testing

Change-Id: I514f83088931bfa2a4838ceb13d46b9973fd6778
2014-12-10 11:20:19 +02:00
Tomas Novacik
e5ab83caf3 Add _wait_till_text_present_in_element method
* add selenium configuration group
* add implicit/explicit wait and set page timeout

Partially implements blueprint: selenium-integration-testing

Change-Id: If39a5dcbac45635ad9988edfdc1830aeabc663a4
2014-12-07 15:48:31 +01:00
Tomas Novacik
4495e8cafe Add workaround for StaleElementReferenceException
StaleElementReferenceException occurres when accessing web element that
was reloaded but looks the same. It happens for example when trying to access
form under Project/Data processing/image registry -> register image. It
is ussually caused by javascript that is loading the page or by mistake
in script logic.

This patch wraps the WebDriver and WebElement classes and catches the
occurrence of StaleElementReferenceException and tries to find the web
element again. Till maximum limit is reached or top element is reached
as this suggest that mistake was made by programmer.

Closes-Bug: #1353342

Partially implements blueprint: selenium-integration-testing

Change-Id: I8e24e952e0fb81bed21b7139870d6d7506509c93
2014-10-08 11:21:17 +03:00
Jenkins
792668d723 Merge "Settings page ChangePassword page and their tests" 2014-07-23 04:29:10 +00:00
Daniel Korn
2a27c7f4e6 Settings page ChangePassword page and their tests
Two new pages added: Settings page and ChangePassword page.
To test their functionality I wrote two tests:
1. test_user_settings_change
 * changes the system's language
 * changes the timezone
 * changes the number of items per page (page size)
2. test_password_change:
   changes the password, verifies it was indeed changed and
   resets to default password.

To allow the above I've made few changes in other places:
* projectpage - added the go_to_settings_page method.
* helpers - added Selenium's implicit wait for self.driver
  in order to use page_timeout for pages that don't load
  instantly.

https://wiki.openstack.org/wiki/Horizon/Testing/UI

Partially implements blueprint: selenium-integration-testing

Change-Id: I24e01cd13d4a63ffd82505e4fd9cc95ba887e882
2014-07-20 11:47:48 +03:00
Daniel Korn
42b24326e1 Run integration tests full screen
I added self.driver.maximize_window() to helpers's setUp,
making all integration tests run full screen (maximizing
the browser's window).

Closes-Bug: #1338630
Change-Id: Idd185ef3a29eb4731d35fa957bf1e7d636237dc8
2014-07-07 15:37:55 +00:00
marianitadn
44055c1676 Add CLI option for running Selenium tests headless
- Add requirement for xfvbwrapper
- Add CLI option for running tests headless
- Update Selenium TestCase to start virtual display if the option is set
- Update documentation about running Selenium tests

Change-Id: Icb1ac3491b8eef6c168bf1421cf073da67600982
Closes-Bug: #1290329
2014-06-05 15:44:04 +03:00
Jenkins
cacd93ea49 Merge "Integration tests - base class for all tests" 2014-05-19 18:55:22 +00:00
Daniel Korn
a62f4b914b Integration tests - base class for all tests
The TestCase class will be the base for all tests, except the login
tests.
It contains two methods:
setUp - opens the login page, and performs the login to allow all test
start from the home page.

tearDown - returns the driver to the home page and logs out.

https://wiki.openstack.org/wiki/Horizon/Testing/UI

Partially implements blueprint: selenium-integration-testing

Change-Id: I748174108844c26eab0d375dafcd1f429f0e83dc
2014-05-06 19:07:19 +03:00
He Yongli
e790ac070e Remove extraneous vim configuration comments
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

at the top of source code files, except for files in
openstack/common.

Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
2014-05-06 15:30:10 +08:00
Julie Pichon
b4b0e1a887 Integration tests - running the tests
Initial setup for running the integration tests. A basic test is
included to ensure this works, although it will be rewritten to follow
the Page Object pattern. Thanks to Daniel Korn for the initial test.

https://wiki.openstack.org/wiki/Horizon/Testing/UI

Implements blueprint: selenium-integration-testing

Change-Id: Id5b62cdeac5295667a3922f7bed1db3c7617f841
2014-02-26 10:45:21 +00:00