Add screenshot test to fuego-release-test
cover Add screenshot test to fuego-release-test
Hello, everyone.
This series of patches adds a new test case class to the fuego_release_test functional test. The name of this new test class is "CheckScreenshot", and its purpose is to get a screenshot of a web-page (in this specific case, Fuego's Jenkins' webpage) and compare it with a reference image.
Currently, CheckScreenshot supports:
- Taking screenshot of an HTML element of a page and compare it with a reference image.
- Taking screenshot of the full viewport (full page if it fits in the viewport) and also compare it with a reference image.
- Take a screenshot (full or element) and compare only specific regions of interest with a reference image. The mask is a black-and-white image in which black regions are ignored by the comparison algorithm.
On these patches we have also added a helper script (take_screenshot.py) that may be used for collecting reference screenshots and a few test cases to serve as example of usage.
A README.md file has also been to explain the usage of fuego_release_test and the helper script, including a few examples.
# Running
Currently this test requires a modified version of Fuego to be executed, given that it needs to install some dependencies and needs to map the dockerd socket from the host to the fuego container.
The modified version can be found in two different branches on Profusion's fuego fork.
1 - Branch master: Just a few commits that are necessary for making this test work, applied on top of fuego/next. We plan to try to integrate these commits into fuego/next in the future.
2 - Branch fuego-base-image: A more complex change on fuego, that makes the necessary changes for allowing it to be shipped as a docker image through dockerhub.
The steps for each one of the versions above are given below:
## Building the image (from the branch fuego-test)
To run the test, execute the following commands:
``` git clone --branch master https://bitbucket.org/profusionmobi/fuego-core.git git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego.git cd fuego ./install fuego-to-test-fuego ./fuego-host-scripts/docker-create-container.sh fuego-to-test-fuego fuego-to-test-fuego-container ./fuego-host-scripts/docker-start-container.sh fuego-to-test-fuego-container ```
Then, add the fuego-test board and the Functional.fuegotest and start the test through Jenkins (localhost:8080/fuego/)
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```
## Using the modified Fuego Base Image from Dockerhub (fuego-base-image):
You can also use the fuego base image that's being developed in Profusion's fuego-base-image branch in our fork:
https://bitbucket.org/profusionmobi/fuego/branch/fuego-base-image
The image is already available on dockerhub and can be downloaded/executed with:
``` docker pull fuegotest/fuego docker run -it \ -p 8080:8080 \ -v $(pwd)/host_fuego_home:/var/fuego_home \ -e JENKINS_UID=$(id -u) \ -e JENKINS_GID=$(id -g) \ -v /var/run/docker.sock:/var/run/docker.sock \ fuegotest/fuego:latest ```
Wait for the shell to be available and add fuego-test board and Functional.fuegotest as explained in the last section.
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```
You can also run the test in standalone mode (given that you have all the dependencies installed in your system). See the test README.md for more instructions.
Thanks.
Guilherme Campos Camargo (14):
Add a SeleniumCommand that compares screenshots
Minor style fix
Add a CheckScreenshot command into the COMMANDS_TO_TEST list Increase the size of the webdriver viewport
Allow working_dir and install_dirs to be different Prevent exception NameError when removing container
Add an example reference screenshot
Add helper script for taking element/full-page screenshots Add mask-img-path argument to CheckScreenshot for ignored areas Add a README.md
Allow Full viewport Screenshots
Allow compare-with-mask to work with ImageMagick 6 and ImageMagick 7 Improve logging
Set logging level to INFO by default
.../Functional.fuego_release_test/README.md | 182 +++++++++ .../fuego_test.sh | 6 +- .../helpers/take_screenshot.py | 145 ++++++++ .../screenshots/footer.png | Bin 0 -> 7371 bytes .../screenshots/footer_mask.png | Bin 0 -> 302 bytes .../screenshots/full_screenshot.png | Bin 0 -> 46323 bytes .../screenshots/full_screenshot_mask.png | Bin 0 -> 10717 bytes .../screenshots/side-panel-tasks.png | Bin 0 -> 9609 bytes .../Functional.fuego_release_test/test_run.py | 347 ++++++++++++++++-- 9 files changed, 639 insertions(+), 41 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/README.md create mode 100755 engine/tests/Functional.fuego_release_test/helpers/take_screenshot.py create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/side-panel-tasks.png
Signature · 1 line
2.17.0
PATCH 1/14 Add a SeleniumCommand that compares screenshots
The newly added test takes a screenshot of an element present on the current webpage and compares it to a reference image. An optional argument 'threshold' may be provided to the CheckScreenshot constructor to allow a certain amount of difference to be disconsidered.
This value represents the normalized root mean squared error (-metric rmse as briefly explained in
https://www.imagemagick.org/script/command-line-options.php#. By default, this 'threshold' is set to 0.0.
For the image comparison we're using ImageMagick
--- .../Functional.fuego_release_test/test_run.py | 148 +++++++++++++++++- 1 file changed, 145 insertions(+), 3 deletions(-)
engine/tests/Functional.fuego_release_test/test_run.py +145 -3
@@ -9,13 +9,15 @@ import re import subprocess import sys import time +from io import BytesIO import docker import pexpect import requests +import selenium.common.exceptions as selenium_exceptions from selenium import webdriver from selenium.webdriver.common.by import By -import selenium.common.exceptions as selenium_exceptions +from PIL import Image LOGGER = logging.getLogger('test_run') STREAM_HANDLER = logging.StreamHandler()
@@ -39,6 +41,13 @@ def loop_until_timeout(func, timeout=10, num_tries=5): return False +def silent_remove(filename): + try: + os.remove(filename) + except (FileNotFoundError, IsADirectoryError): + pass + + class SeleniumCommand: def exec(self, selenium_ctx): self.driver = selenium_ctx.driver
@@ -86,6 +95,20 @@ class SeleniumCommand: LOGGER.debug(" Element found") return element + @staticmethod + def get_element_screenshot(context, element): + location = element.location_once_scrolled_into_view + size = element.size + + viewport_screenshot = Image.open( + BytesIO(context.driver.get_screenshot_as_png())) + element_screenshot = viewport_screenshot.\ + crop((location['x'], location['y'], + location['x'] + size['width'], + location['y'] + size['height'],)) + + return element_screenshot + class Visit(SeleniumCommand): def __init__(self, url, timeout=10, expected_result=200):
@@ -122,12 +145,121 @@ class CheckText(SeleniumCommand): element = SeleniumCommand.\ find_element(selenium_ctx, self.locator, self.pattern) - if element: - result = SeleniumCommand.check_element_text(element, self.text) + if not element: + return False + result = SeleniumCommand.check_element_text(element, self.text) return result == self.expected_result +class CheckScreenshot(SeleniumCommand): + def __init__(self, locator, pattern, ref_img, diff_img=None, + expected_result=True, threshold=0.0, + rm_images_on_success=True): + def add_suffix(filename, suffix): + head, sep, tail = ref_img.rpartition('.') + if sep: + return head + sep + suffix + '.' + tail + + return tail + '.' + suffix + + self.pattern = pattern + self.locator = locator + self.reference_img_path = ref_img + self.expected_result = expected_result + self.threshold = threshold + self.rm_images_on_success = rm_images_on_success + + if diff_img is None: + self.diff_img_path = add_suffix(ref_img, 'diff') + else: + self.diff_img_path = diff_img + + self.test_img_path = add_suffix(ref_img, 'test') + + def compare_images(self, current_img_path, reference_img_path, + diff_img_path, threshold): + cmd = ['magick', + 'compare', + '-verbose', + '-metric', + 'RMSE', + '-highlight-color', + 'Red', + '-compose', + 'Src', + current_img_path, + reference_img_path, + diff_img_path + ] + + LOGGER.debug(' Comparing images...') + LOGGER.debug(' cmd: $ %s', ' '.join(cmd)) + process = subprocess.Popen(cmd, universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + process_stdout, process_stderr = process.communicate() + LOGGER.debug(' Results:') + LOGGER.debug(' return code: %s', process.returncode) + LOGGER.debug(' stdout: %s', process_stdout.strip()) + LOGGER.debug(' stderr: %s', process_stderr.strip()) + + RESULTS_REGEX = re.compile(".*all:.*\(([0-9\-\.]*)\).*") + result = RESULTS_REGEX.search(process_stderr) + + if not result: + LOGGER.error(" Error processing the output.") + return False + + difference = float(result.group(1)) + if difference > threshold: + LOGGER.debug(" Resulting difference (%s) above threshold (%s). ", + difference, threshold) + LOGGER.debug(" Element's screenshot does not match the reference." + " See %s for a visual representation of the " + " differences.", diff_img_path) + return False + + LOGGER.debug(" Resulting difference (%s) below threshold (%s).", + difference, threshold) + LOGGER.debug(" Element's screenshot matches the reference.") + return True + + def exec(self, selenium_ctx): + super().exec(selenium_ctx) + + element = SeleniumCommand.\ + find_element(selenium_ctx, self.locator, self.pattern) + if not element: + return False + + screenshot = SeleniumCommand.\ + get_element_screenshot(selenium_ctx, element) + + try: + screenshot.save(self.test_img_path, format='PNG') + except FileNotFoundError: + LOGGER.error( + " Unable to save the screenshot to '%s'. Does the directory " + "exist and can you write to it?", self.test_img_path) + return False + + result = self.compare_images(self.test_img_path, + self.reference_img_path, + self.diff_img_path, + self.threshold) + + if result != self.expected_result: + return False + + # Remove diff and test images if there's a match + if self.rm_images_on_success: + silent_remove(self.diff_img_path) + silent_remove(self.test_img_path) + + return True + + class Click(SeleniumCommand): def __init__(self, locator, pattern): self.pattern = pattern
@@ -474,6 +606,16 @@ def main(): if container: container.delete() + def get_abs_working_dirs(): + abs_install_dir = os.path.abspath(args.install_dir) + + if args.working_dir: + abs_working_dir = os.path.abspath(args.working_dir) + else: + abs_working_dir = abs_install_dir + + return abs_install_dir, abs_working_dir + def execute_tests(timeout): LOGGER.debug("Starting tests")
Signature · 1 line
2.17.0
PATCH 2/14 Minor style fix
In reply to Guilherme Campos CamargoMinor indentation fix.
--- engine/tests/Functional.fuego_release_test/test_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
engine/tests/Functional.fuego_release_test/test_run.py +2 -2
@@ -316,8 +316,8 @@ class ShExpect(): self.client.sendline( 'echo "%s${%s}%s"' % (self.COMMAND_OUTPUT_DELIM, - self.OUTPUT_VARIABLE, - self.COMMAND_OUTPUT_DELIM)) + self.OUTPUT_VARIABLE, + self.COMMAND_OUTPUT_DELIM)) self.client.expect(self.COMMAND_OUTPUT_PATTERN) out = self.client.match.group(1)
Signature · 1 line
2.17.0
PATCH 3/14 Add a CheckScreenshot command into the COMMANDS_TO_TEST list
In reply to Guilherme Campos CamargoThis test will take a screenshot of 'tasks' element from the side-panel of the Jenkins UI (that contains the 'New Item', 'People', 'Build History' and the 'Manage Jenkins' buttons) and compare it with an image that's stored in the workdir, called 'side-panel-tasks.png'. The allowed threshold is 0.1 (10%).
--- engine/tests/Functional.fuego_release_test/test_run.py | 6 ++++++ 1 file changed, 6 insertions(+)
engine/tests/Functional.fuego_release_test/test_run.py +6 -0
@@ -725,6 +725,12 @@ def main(): 'docker.default.Functional.hello_world"]'), CheckText(By.ID, 'executors', text='docker.default.Functional.hello_world'), + + # Compare screenshot of an element of Jenkins UI + CheckScreenshot(By.ID, 'tasks', + rm_images_on_success=True, + ref_img='screenshots/side-panel-tasks.png', + threshold=0.1) ] if not execute_tests(args.timeout):
Signature · 1 line
2.17.0
Re: [Fuego] [PATCH 03/14] Add a CheckScreenshot command into the COMMANDS_TO_TEST list
Looks good. My only comment (which is not specific to this patch or test case) is that it would be good if each 'Check...' test in COMMANDS_TO_TEST was an individual test case for the full release test.
-- Tim
Quoted 38 lines
-----Original Message-----
From: Guilherme Campos Camargo
This test will take a screenshot of 'tasks' element from the side-panel of the Jenkins UI (that contains the 'New Item', 'People', 'Build History' and the 'Manage Jenkins' buttons) and compare it with an image that's stored in the workdir, called 'side-panel-tasks.png'. The allowed threshold is 0.1 (10%).Signed-off-by Guilherme Campos Camargo <[email protected]>--- engine/tests/Functional.fuego_release_test/test_run.py | 6 ++++++ 1 file changed, 6 insertions(+)engine/tests/Functional.fuego_release_test/test_run.py +6
-1@@ -725,6 +725,12 @@ def main(): 'docker.default.Functional.hello_world"]'), CheckText(By.ID, 'executors', text='docker.default.Functional.hello_world'), + + # Compare screenshot of an element of Jenkins UI + CheckScreenshot(By.ID, 'tasks', + rm_images_on_success=True, + ref_img='screenshots/side-panel-tasks.png', + threshold=0.1) ] if not execute_tests(args.timeout): --2.17.0
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 03/14] Add a CheckScreenshot command into the COMMANDS_TO_TEST list
Quoted 5 lines · On Wed, Apr 25, 2018 at 8:17 PM, <[email protected]> wrote:
Looks good. My only comment (which is not specific to this patch or test case)
is that it would be good if each 'Check...' test inCOMMANDS_TO_TESTwas an individual test case for the full release test.
Tim, not sure if I got it right. You mean that we should wrap each one of the 'Check...' tests in a python script and call them individually from within fuego_test.sh?
Thanks
Quoted 41 lines
-- Tim
Quoted 38 lines
-----Original Message-----
From: Guilherme Campos Camargo
This test will take a screenshot of 'tasks' element from the side-panel of the Jenkins UI (that contains the 'New Item', 'People', 'Build History' and the 'Manage Jenkins' buttons) and compare it with an image that's stored in the workdir, called 'side-panel-tasks.png'. The allowed threshold is 0.1 (10%).Signed-off-by Guilherme Campos Camargo <[email protected]>--- engine/tests/Functional.fuego_release_test/test_run.py | 6 ++++++ 1 file changed, 6 insertions(+)engine/tests/Functional.fuego_release_test/test_run.py +6
-1@@ -725,6 +725,12 @@ def main(): 'docker.default.Functional.hello_world"]'), CheckText(By.ID, 'executors', text='docker.default.Functional.hello_world'), + + # Compare screenshot of an element of Jenkins UI + CheckScreenshot(By.ID, 'tasks', + rm_images_on_success=True, + ref_img='screenshots/side-panel-tasks.png', + threshold=0.1) ] if not execute_tests(args.timeout): --2.17.0
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 03/14] Add a CheckScreenshot command into the COMMANDS_TO_TEST list
Quoted 15 lines
-----Original Message-----
From: Guilherme Camargo
On Wed, Apr 25, 2018 at 8:17 PM, Tim Bird wrote:Looks good. My only comment (which is not specific to this patch or
test case)
is that it would be good if each 'Check...' test inCOMMANDS_TO_TEST
was an individual test case for the full release test.
Quoted 3 lines
Tim, not sure if I got it right. You mean that we should wrap each one of the 'Check...' tests in a python script and call them individually from within
fuego_test.sh?
No. Nothing like that. Just add some extra text to the output (like I described in wrapping the LOGGER.info output), and so that the test yields a testcase per major comparison operation.
e.g. add to CheckScreenshot a test description, and have it output the actual result of the testcase in TAP format. See below:
Quoted 19 lines
> -----Original Message-----
> From: Guilherme Campos Camargo
> This test will take a screenshot of 'tasks' element from the side-
panel
> of the Jenkins UI (that contains the 'New Item', 'People', 'Build > History' and the 'Manage Jenkins' buttons) and compare it with an
image
> that's stored in the workdir, called 'side-panel-tasks.png'. The
allowed> threshold is 0.1 (10%). > > Signed-off-by: Guilherme Campos Camargo <[email protected] <mailto:[email protected]> > > --- > engine/tests/Functional.fuego_release_test/test_run.py | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git
Quoted 15 lines
a/engine/tests/Functional.fuego_release_test/test_run.py
>b/engine/tests/Functional.fuego_release_test/test_run.py> index b380acd..2075862 100755
> ---a/engine/tests/Functional.fuego_release_test/test_run.py> +++b/engine/tests/Functional.fuego_release_test/test_run.py> @@ -725,6 +725,12 @@ defmain():
> 'docker.default.Functional.hello_world"]'),
> CheckText(By.ID, 'executors',
> text='docker.default.Functional.hello_world'),
> +
> + # Compare screenshot of an element of Jenkins UI
> + CheckScreenshot(By.ID, 'tasks',
> + rm_images_on_success=True,
> + ref_img='screenshots/side-panel-tasks.png',
> + threshold=0.1)
Maybe add another parameter 'test_id', so that this looks like:
CheckScreenshot(By.ID, 'check tasks panel', 'tasks',
rm_images_on_success=True,
ref_img='screenshots/side-panel-tasks.png',
threshold=0.1)Which would end up emitting:
ok 4 check tasks panel
(if the test passed, and this happened to be the 4th test, that is).
Then modify the parser.py to read all the TAP entries (it may already do this).
Right now there's only a single testcase output for the entire release test, but it would be nice to get more detailed results from this test (on a testcase-by-testcase basis).
-- Tim
I
Quoted 15 lines
> ] > > if not execute_tests(args.timeout): > -- > 2.17.0 > > _______________________________________________ > Fuego mailing list > [email protected]<mailto:[email protected]>
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
<https://lists.linuxfoundation.org/mailman/listinfo/fuego>
PATCH 4/14 Increase the size of the webdriver viewport
In reply to Guilherme Campos CamargoIncrease the viewport size to 1920x1080 to allow large elements to fit the screenshot.
--- engine/tests/Functional.fuego_release_test/test_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
engine/tests/Functional.fuego_release_test/test_run.py +1 -1
@@ -576,7 +576,7 @@ class SeleniumContainerSession(): options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('no-sandbox') - options.add_argument('window-size=1200x600') + options.add_argument('window-size=1920x1080') options.add_experimental_option( 'prefs', {'intl.accept_languages': 'en,en_US'})
Signature · 1 line
2.17.0
PATCH 5/14 Allow working_dir and install_dirs to be different
In reply to Guilherme Campos CamargoThe working_dir is where all the test assets reside and also where all the results (for instance the resulting images for the CheckScreenshot test) will be stored after the tests.
The install_dir is where the install script can be found.
install_dir is a required argument, while working_dir is optional and defaults to install_dir.
On this patch we're also modifying fuego_test.sh to copy the required assets from the test directory to the buildzone.
--- .../Functional.fuego_release_test/fuego_test.sh | 6 ++++-- .../Functional.fuego_release_test/test_run.py | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-)
engine/tests/Functional.fuego_release_test/fuego_test.sh +4 -2
@@ -18,11 +18,13 @@ function test_build { echo "Cloning fuego-core from ${fuego_core_repo}:${fuego_core_branch}" git clone --depth 1 --single-branch --branch "${fuego_core_branch}" \ "${fuego_core_repo}" "${fuego_release_dir}/fuego-core" - cd - + + echo "Copying assets from ${TEST_HOME} to the buildzone." + cp -r "${TEST_HOME}/screenshots" . } function test_run { - sudo -n ${TEST_HOME}/test_run.py "${fuego_release_dir}/fuego" + sudo -n "${TEST_HOME}/test_run.py" "${fuego_release_dir}/fuego" -w . if [ "${?}" = 0 ]; then report "echo ok 1 fuego release test" else
engine/tests/Functional.fuego_release_test/test_run.py +14 -3
@@ -638,7 +638,12 @@ def main(): return tests_ok parser = argparse.ArgumentParser() - parser.add_argument('working_dir', help="The working directory", type=str) + parser.add_argument('install_dir', help="The directory where the install " + "script resides.", type=str) + parser.add_argument('-w', '--working_dir', help="The working directory. " + "Location of the test assets and where test results " + "will be stored. Defaults to install_dir.", + default=None, type=str) parser.add_argument('-s', '--install-script', help="The script that will be used to install the " + "docker image. Defaults to '%s'" %
@@ -672,8 +677,10 @@ def main(): default=True, action='store_false') args = parser.parse_args() - LOGGER.debug("Changing working dir to '%s'", args.working_dir) - os.chdir(args.working_dir) + args.install_dir, args.working_dir = get_abs_working_dirs() + + LOGGER.debug("Changing working dir to '%s'", args.install_dir) + os.chdir(args.install_dir) container = FuegoContainer(args.install_script, args.image_name, args.container_name, args.jenkins_port,
@@ -690,6 +697,10 @@ def main(): if not selenium_session.start(): return 1 + if os.getcwd != args.working_dir: + LOGGER.debug("Changing working dir to '%s'", args.working_dir) + os.chdir(args.working_dir) + COMMANDS_TO_TEST = [ # Set Selenium Browser root Visit(url=container.get_url()),
Signature · 1 line
2.17.0
Re: [Fuego] [PATCH 05/14] Allow working_dir and install_dirs to be different
Quoted 9 lines
-----Original Message-----
From: Guilherme Campos CamargoThe
working_diris where all the test assets reside and also where all the results (for instance the resulting images for the CheckScreenshot test) will be stored after the tests.
Quoted 7 lines
The
install_diris where the install script can be found.
install_diris a required argument, whileworking_diris optional and defaults toinstall_dir.On this patch we're also modifying
fuego_test.shto copy the required assets from the test directory to the buildzone.
I'm not sure why this is needed. I hate duplicating the files unnecessarily. We could have lots of them eventually.
Why can't the assets just be accessed from the TEST_HOME directory?
-- Tim
Quoted 81 lines
Signed-off-by Guilherme Campos Camargo <[email protected]>--- .../Functional.fuego_release_test/fuego_test.sh | 6 ++++-- .../Functional.fuego_release_test/test_run.py | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-)engine/tests/Functional.fuego_release_test/fuego_test.sh +0
-0@@ -18,11 +18,13 @@ function test_build { echo "Cloning fuego-core from${fuego_core_repo}:${fuego_core_branch}"
git clone --depth 1 --single-branch --branch "${fuego_core_branch}" \ "${fuego_core_repo}" "${fuego_release_dir}/fuego-core"engine/tests/Functional.fuego_release_test/fuego_test.sh +4
-2- cd - + + echo "Copying assets from ${TEST_HOME} to the buildzone." + cp -r "${TEST_HOME}/screenshots" . } function test_run { - sudo -n ${TEST_HOME}/test_run.py "${fuego_release_dir}/fuego" + sudo -n "${TEST_HOME}/test_run.py" "${fuego_release_dir}/fuego" -w . if [ "${?}" = 0 ]; then report "echo ok 1 fuego release test" elseengine/tests/Functional.fuego_release_test/test_run.py +3
-1@@ -638,7 +638,12 @@ def main(): return tests_ok parser = argparse.ArgumentParser() - parser.add_argument('working_dir', help="The working directory", type=str) + parser.add_argument('install_dir', help="The directory where the install " + "script resides.", type=str) + parser.add_argument('-w', '--working_dir', help="The working directory."
engine/tests/Functional.fuego_release_test/test_run.py +11
-3+ "Location of the test assets and where test results " + "will be stored. Defaults to install_dir.", + default=None, type=str) parser.add_argument('-s', '--install-script', help="The script that will be used to install the " + "docker image. Defaults to '%s'" %@@ -672,8 +677,10 @@ def main(): default=True, action='store_false') args = parser.parse_args() - LOGGER.debug("Changing working dir to '%s'", args.working_dir) - os.chdir(args.working_dir) + args.install_dir, args.working_dir = get_abs_working_dirs() + + LOGGER.debug("Changing working dir to '%s'", args.install_dir) + os.chdir(args.install_dir) container = FuegoContainer(args.install_script, args.image_name, args.container_name, args.jenkins_port,@@ -690,6 +697,10 @@ def main(): if not selenium_session.start(): return 1 + if os.getcwd != args.working_dir: + LOGGER.debug("Changing working dir to '%s'", args.working_dir) + os.chdir(args.working_dir) + COMMANDS_TO_TEST = [ # Set Selenium Browser root Visit(url=container.get_url()), --2.17.0
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 05/14] Allow working_dir and install_dirs to be different
Quoted 17 lines · On Wed, Apr 25, 2018 at 8:20 PM, <[email protected]> wrote:
Quoted 9 lines
-----Original Message-----
From: Guilherme Campos CamargoThe
working_diris where all the test assets reside and also where all the results (for instance the resulting images for the CheckScreenshot test) will be stored after the tests.Quoted 7 lines
The
install_diris where the install script can be found.
install_diris a required argument, whileworking_diris optional and defaults toinstall_dir.On this patch we're also modifying
fuego_test.shto copy the required assets from the test directory to the buildzone.
Quoted 7 lines
I'm not sure why this is needed. I hate duplicating the files unnecessarily.
We could have lots of them eventually.Why can't the assets just be accessed from the
TEST_HOMEdirectory?
-- Tim
We currently have two working dirs: one in which fuego - and the install script - resides (install-dir) , and another (-w) in which the test will look for assets and store things (as screenshot diff results, etc.).
I don't like the idea of having things stored in the TEST_HOME, given that it's the TEST_HOME is inside fuego-core and I also don't think we should store these files in the install-dir, one option for cleaning this up would be:
- Add a new argument to test_run.sh to separate the assets dir (TEST_HOME/screenshots)
from where the captured screenshots and diffs will be stored), having something like:
$ test_run.py" "${fuego_release_dir}/fuego" -a ${assets_path} -w
${output_path}What do you think?
Quoted 6 lines
Review
Quoted 3 lines
function
test_run{(quoted diff) +1
-1- sudo -n ${TEST_HOME}/test_run.py "${fuego_release_dir}/fuego" +
sudo -n "${TEST_HOME}/test_run.py" "${fuego_release_dir}/fuego" -w .
We would do this instead:
sudo -n "${TEST_HOME}/test_run.py" "${fuego_release_dir}/fuego" -a ${TEST_HOME} -w .
Quoted 4 lines
if [ "${?}" = 0 ]; thenQuoted 2 lines
report "echo ok 1 fuego release test"
else
Re: [Fuego] [PATCH 05/14] Allow working_dir and install_dirs to be different
Quoted 48 lines
-----Original Message-----
From: Guilherme CamargoOn Wed, Apr 25, 2018 at 8:20 PM, Tim Bird wrote:
> -----Original Message----- > From: Guilherme Campos Camargo > > The `working_dir` is where all the test assets reside and also whereall
> the results (for instance the resulting images for the
CheckScreenshot
> test) will be stored after the tests.
>
> Theinstall_diris where the install script can be found. >
>install_diris a required argument, whileworking_diris optional > and defaults toinstall_dir.
>
> On this patch we're also modifyingfuego_test.shto copy the
required
> assets from the test directory to the buildzone.I'm not sure why this is needed. I hate duplicating the files
unnecessarily.
We could have lots of them eventually.Why can't the assets just be accessed from the
TEST_HOME
directory?-- TimWe currently have two working dirs: one in which fuego - and the install script - resides (install-dir) , and another (-w) in which the test will look for assets and store things (as screenshot diff results, etc.).
I don't like the idea of having things stored in the
TEST_HOME, given that it's theTEST_HOMEis inside fuego-core and I also don't think we should store these files in the install-dir, one option for cleaning this up would be:- Add a new argument to
test_run.shto separate the assets dir (TEST_HOME/screenshots)
from where the captured screenshots and diffs will be stored), having something like:
Quoted 4 lines
$ test_run.py" "${fuego_release_dir}/fuego" -a ${assets_path} -w ${output_path}What do you think?
OK - I understand the design better. I didn't realize that we have artifacts we are saving from the run. What you have proposed looks good to me. There are pros and cons to putting the reference assets in the same directory as the artifacts generated from the run. It's easier for users to look at them and see what happened if they're all in the same directory. But it's also nice to not replicate the reference assets for every run of the test.
I would put the generated artifacts in the run directory (the log directory), not the build directory. (I didn't check to see where you're putting them now).
In any event, specifying the reference asset path seems like a good idea.
-- Tim
PATCH 6/14 Prevent exception NameError when removing container
In reply to Guilherme Campos CamargoA NameError exception was being raised on early script exits, for example when the usage was being printed by argparse.
The exception was due to the FuegoContainer object (container) not having been declared when atexit cleanup routine is called.
--- engine/tests/Functional.fuego_release_test/test_run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
engine/tests/Functional.fuego_release_test/test_run.py +3 -1
@@ -603,8 +603,10 @@ def main(): @atexit.register def cleanup(): - if container: + try: container.delete() + except NameError: + pass def get_abs_working_dirs(): abs_install_dir = os.path.abspath(args.install_dir)
Signature · 1 line
2.17.0
PATCH 7/14 Add an example reference screenshot
In reply to Guilherme Campos CamargoAdd a reference image to serve as an example.
--- .../screenshots/side-panel-tasks.png | Bin 0 -> 9609 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/side-panel-tasks.png
engine/tests/Functional.fuego_release_test/screenshots/side-panel-tasks.png new file binary +0 -0
Signature · 1 line
2.17.0
PATCH 8/14 Add helper script for taking element/full-page screenshots
In reply to Guilherme Campos CamargoAdd the helper script take_screenshot.py that navigates to a given URL and takes a screenshot of an element - or from the full viewport when the element is not provided.
This script is useful for generating reference screenshots to be compared through the fuego-release-test's CheckScreenshot Selenium Command.
--- .../helpers/take_screenshot.py | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100755 engine/tests/Functional.fuego_release_test/helpers/take_screenshot.py
engine/tests/Functional.fuego_release_test/helpers/take_screenshot.py new file +145 -0
@@ -0,0 +1,145 @@ +#!/usr/bin/env python3 +import argparse +import requests +import sys +from io import BytesIO + +import selenium.common.exceptions as selenium_exceptions +from selenium import webdriver +from selenium.webdriver.common.by import By +from PIL import Image + + +def public_attributes(obj): + return [attr for attr in dir(By) if not attr.startswith('__')] + + +AVAILABLE_LOCATORS = public_attributes(By) +DEFAULT_VIEWPORT_RESOLUTION = "1920x1080" + + +class SeleniumSession: + def __init__(self, resolution): + options = webdriver.ChromeOptions() + options.add_argument('headless') + options.add_argument('no-sandbox') + options.add_argument('window-size=%s' % resolution) + options.add_experimental_option( + 'prefs', {'intl.accept_languages': 'en,en_US'}) + + self.driver = webdriver.Chrome(chrome_options=options) + self.driver.implicitly_wait(3) + + def __del__(self): + if self.driver: + self.driver.quit() + + def go(self, url): + try: + r = requests.get(url) + except (requests.exceptions.MissingSchema, + requests.exceptions.ConnectionError, + requests.exceptions.ConnectTimeout) as e: + print(e) + return 404 + + if r.status_code != requests.codes.ok: + print("Unable to navigate to the page %s" % url) + print("Please provide a valid URL") + return r.status_code + + self.driver.get(url) + return r.status_code + + def take_screenshot(self, locator_str, pattern): + def take_element_screenshot(locator, pattern): + try: + element = self.driver.find_element(locator, pattern) + except selenium_exceptions.NoSuchElementException: + print("Element not found") + return None + + location = element.location_once_scrolled_into_view + size = element.size + + viewport_screenshot = Image.open( + BytesIO(self.driver.get_screenshot_as_png())) + element_screenshot = viewport_screenshot.\ + crop((location['x'], location['y'], + location['x'] + size['width'], + location['y'] + size['height'],)) + + return element_screenshot + + def take_full_screenshot(): + return Image.open( + BytesIO(self.driver.get_screenshot_as_png())) + + if not locator_str or not pattern: + print("Taking full screenshot (locator and/or pattern are empty)") + return take_full_screenshot() + + locator = getattr(By, locator_str, None) + if not locator: + print("Locator '%s' is not supported" % locator_str) + return None + + print("Taking element screenshot") + return take_element_screenshot(locator, pattern) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('url', help="""The URL from where a screenshot will be + taken""", type=str) + parser.add_argument('-l', '--locator', help="the " + """locator that will be used to find the element on the + page. Available locators are: %s""" % + AVAILABLE_LOCATORS, default=None, type=str) + parser.add_argument('-p', '--pattern', help="""The pattern that will be + used for locating the element.""", + default=None, type=str) + parser.add_argument('-o', '--out', help="""Resulting screenshot filename. + Defaults to '${locator}_${pattern}.png' if those + arguments are given or 'full_viewport.png' if not.""", + default=None, type=int) + parser.add_argument('-r', '--resolution', help="""Viewport resolution. + Defaults to %s. Make sure your page or element fits + this resolution, otherwise the results might be + cropped.""" % DEFAULT_VIEWPORT_RESOLUTION, + default=DEFAULT_VIEWPORT_RESOLUTION, type=str) + args = parser.parse_args() + + def generate_out_filename(): + if not args.locator or not args.pattern: + return 'full_screenshot.png' + else: + return args.locator + '_' + args.pattern + '.png' + + if not args.out: + args.out = generate_out_filename() + + selenium = SeleniumSession(args.resolution) + + status_code = selenium.go(args.url) + if status_code != requests.codes.ok: + print("Unable to navigate to URL") + return 1 + + screenshot = selenium.take_screenshot(args.locator, args.pattern) + if not screenshot: + print("Unable to take a screenshot") + return 1 + + try: + screenshot.save(args.out, format='PNG') + except FileNotFoundError as e: + print("Unable to save the screenshot to '%s'" % args.out) + print(" Reason: %s" % e) + return 1 + + return 0 + + +if __name__ == '__main__': + sys.exit(main())
Signature · 1 line
2.17.0
PATCH 9/14 Add mask-img-path argument to CheckScreenshot for ignored areas
In reply to Guilherme Campos CamargoThe new mask-img-path argument that has been added to CheckScreenshot can be used to provide a mask image that will determine which parts of the screenshots will be compared.
The mask needs to be a Black and White .png image in which the Black areas will be ignored on the comparison, while the White areas will be compared normally.
A new CheckScreenshot has been added to check the 'page_generated' element of the Jenkins web-interface. That element is positioned in the lower right corner of the page and contains a DateTime field that changes continually.
The assets used as reference and mask have also been included in this commit.
--- .../screenshots/page-generated-mask.png | Bin 0 -> 183 bytes .../screenshots/page-generated.png | Bin 0 -> 4583 bytes .../Functional.fuego_release_test/test_run.py | 25 +++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated-mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated.png
engine/tests/Functional.fuego_release_test/screenshots/page-generated-mask.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/page-generated.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/test_run.py +19 -6
@@ -153,7 +153,7 @@ class CheckText(SeleniumCommand): class CheckScreenshot(SeleniumCommand): - def __init__(self, locator, pattern, ref_img, diff_img=None, + def __init__(self, locator, pattern, ref_img, mask_img=None, diff_img=None, expected_result=True, threshold=0.0, rm_images_on_success=True): def add_suffix(filename, suffix):
@@ -166,6 +166,7 @@ class CheckScreenshot(SeleniumCommand): self.pattern = pattern self.locator = locator self.reference_img_path = ref_img + self.mask_img_path = mask_img self.expected_result = expected_result self.threshold = threshold self.rm_images_on_success = rm_images_on_success
@@ -178,8 +179,8 @@ class CheckScreenshot(SeleniumCommand): self.test_img_path = add_suffix(ref_img, 'test') def compare_images(self, current_img_path, reference_img_path, - diff_img_path, threshold): - cmd = ['magick', + mask_img_path, diff_img_path, threshold): + cmd = ('magick', 'compare', '-verbose', '-metric',
@@ -188,10 +189,14 @@ class CheckScreenshot(SeleniumCommand): 'Red', '-compose', 'Src', + '-read-mask' if mask_img_path else None, + mask_img_path if mask_img_path else None, current_img_path, reference_img_path, - diff_img_path - ] + diff_img_path, + ) + + cmd = list(filter(None, cmd)) LOGGER.debug(' Comparing images...') LOGGER.debug(' cmd: $ %s', ' '.join(cmd))
@@ -246,6 +251,7 @@ class CheckScreenshot(SeleniumCommand): result = self.compare_images(self.test_img_path, self.reference_img_path, + self.mask_img_path, self.diff_img_path, self.threshold)
@@ -743,7 +749,14 @@ def main(): CheckScreenshot(By.ID, 'tasks', rm_images_on_success=True, ref_img='screenshots/side-panel-tasks.png', - threshold=0.1) + threshold=0.1), + + # Compare screenshot of an element of Jenkins UI ignoring an area + CheckScreenshot(By.CLASS_NAME, 'page_generated', + rm_images_on_success=False, + mask_img='screenshots/page-generated-mask.png', + ref_img='screenshots/page-generated.png', + threshold=0.1), ] if not execute_tests(args.timeout):
Signature · 1 line
2.17.0
Re: [Fuego] [PATCH 09/14] Add mask-img-path argument to CheckScreenshot for ignored areas
Quoted 10 lines
-----Original Message-----
From: Guilherme Campos CamargoThe new mask-img-path argument that has been added to CheckScreenshot can be used to provide a mask image that will determine which parts of the screenshots will be compared.
The mask needs to be a Black and White .png image in which the Black areas will be ignored on the comparison, while the White areas will be compared normally.
How do you generate these?
It seems like it would be nice to be able to use a chroma-key color (like magenta), for the to-ignore regions, and have all other colors be interpreted as white, for the "to-compare" regions. This would allow creation of the masks by just drawing a rectangle of magenta on the reference image.
That is, you could pull in the mask image in the above-described format, and convert all colors but magenta to white, and magenta to black, and then use the mask image like you are doing now.
But maybe you have a workflow where it's already easy to create the masks.
One good thing about this is you could look at the mask and more easily tell what part of the image you intend to ignore.
-- Tim
Quoted 308 lines
A new CheckScreenshot has been added to check the '
page_generated' element of the Jenkins web-interface. That element is positioned in the lower right corner of the page and contains a DateTime field that changes continually.The assets used as reference and mask have also been included in this commit.
Signed-off-by Guilherme Campos Camargo <[email protected]>--- .../screenshots/page-generated-mask.png | Bin 0 -> 183 bytes .../screenshots/page-generated.png | Bin 0 -> 4583 bytes .../Functional.fuego_release_test/test_run.py | 25 +++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated- mask.png create mode 100644engine/tests/Functional.fuego_release_test/screenshots/page- generated.png
(quoted diff) +0
-0generated-mask.png b/engine/tests/Functional.fuego_release_test/screenshots/page- generated-mask.png
new file mode 100644
index 0000000000000000000000000000000000000000..a565ba4dd4b8cbd5ab4be9c7050d8046f63e238a
GIT binary patch
literal 183 zcmeAS@N?(olHyuVBq!ia0y~yU{nCI8e2sWPi}XA|S<<<n8Xl@E- &h>|H(?D8gCb
z5n0T@z%2~Ij105pNB{- dOFVsD*&ne8i79f=*0Tx$3b}Z?IEG~0dwXRgFM|Qk;SIa~ z|9=xV!PeoVu!%-)b%bgsN6kYo1_^- #2L?7434sPiMmClN2OtF(I`D*X)n68A7Wv8g QK=T+pUHx3vIVCg!0HVY$sQ>@~literal 0
HcmV?d00001(quoted diff) +0
-0generated.png b/engine/tests/Functional.fuego_release_test/screenshots/page- generated.png
new file mode 100644
index 0000000000000000000000000000000000000000..9b16d92e5cc3ec6c9f57723115e21f8f23f5eab9
GIT binary patch
literal 4583 zcmV<D5g6?P)<h;3K|Lk000e1NJLTq00AHX000gM0ssI205Dc1000rLNkl<Zc%1E 8 zXF!ulx1Kizl2Aek5Q>6yWEH^%Hae&v0wOEc#j@BC*Ig?jNE5pvh=LRmP?|~+0 RfS2 z>d-VDxDBI2}vLcy!Xer*+^6O?sxCE_xk+doik^iIp<6}GXY_98Q?p<<2(L6zyJWy z&+)%)(%+A7^^47BFPdjDz!~`4nI|9_&GSuzGM@67^1s~U1hrq;a6C&U_VJ7T ezDUD z^e12*Qw<#p<GG0g0EC_kPfJM$0FX!|Ep5%6UfXqav=IcEz~O%ua_;1o6qkgY4 F21l
z+T*pifbha>@- nP(Z9yf(cW?D#F@8ms(X5R(=$@!<>jE9#bTW~dG2A=qoJYU8Ab+s ze%mc4M;VXg@uMf#t|q>#sm0@Q#wK%jdTl3@$*?Lms&TJTYUbIm5t@D- 8)1?L;wIG
zK__0kc- 7L};^XISZDT12OMF~H#_cR7gQ>1D#nWrM{tx;iB6i}~sprpMwludKIqGd? zZ7GnKm6V5vUFvA>Fqkp@p!Yt?C{xo@Z{Eqe+uYnjmLe~6uv@ob4F- c@v)SGUeBRf7 z;BW?1RaG~8xEq_y9X&>6CFK{xFVoxTGYkz59NHQM~DCbv{u@>)$Rr}rk^@{ d_=?h zg~h%;{wRv#a5!aUrJpvfx3aeE?d@||>ZGWocs=DB27fdcC>fF;cz+mnIjl%ES8= + zd)#2gbXZKekycgt@JF|m+hw*dO@b&PR5IfLTJzmsK$O7*s_CODljYgblwV nNv
z=$4i)032yl>+>NhKGm88_WM#peQ;tH1t2&BdwM8;vJiLCQ- jCf<OB!RPaZiwFi|
zGSAq@&wIq^UX8t0U*8xTe<e9R5k- e1!Y&UFjXNmq?H%?GORpwGU$}U_si?UGy;xb ze%&z+gazr&Rk81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PAK`{o=K^x2IQ5o?^euZm#hh8(X WU z#-<$}yQF2L=Pxip5Co?EjSY=inRiB9f%0?jEnaFvRip}pD^@y%o(<cwbrXt$B}*5d zKXak(W4(^9HoVaO;l&usjL+v=n}2!(T(xp7002JBdi~;g{_KU-uIq+|hPAXceU5rV zo{si*lX=F-=TzC5cbLq6?}JBRQCwU+Gv_7_hqGO5- O}9Rx!nu?4kqwox96{~UcLqZ z91A>tEbw^9i6E2t#!f37J32ad?cCGP>{nEzuHAFR8kx<G4^=vg%8}p0U^NwA;( Vz z8=K5kR#Eo$IdC!jaz}f|32v%M-IYP!lAoyJ+-r=bKUAs6Jy>2lb~b%2nLgsc%$xP zJr;{qo1z*J><8~%@R7rQnVqz>l(LHQ;Ufpb!!C9Bbr{T;?(K5gTW981o&7703eY_ zcsyQKR%S$CKc7UO$>E2#w$>QcLU3F2Bag>Be9*VMt6ND)(R25XnX>P;};qQF )^{Q zh|nuhF^Bg1^!4^BDp4)1EHt$=kZ=80DZ$xYU0ri%zfbDT>l0rLMkD!p>bsg+AHP H2 z)asuCf8W5Vg$&|EB+niLqkLE>o;GCy$pXZ{*M2AeB1j8kH>ph^=No_n8{?uM 8z&x zIR7iJ7EO)KA3l6UQM9q4>DJAR1q<i>C2Rk1B=DRC&qqXUH>4AzkUfP!x@gj#Ns
z!sBtX=givTvGFStUlyz1- !Hhgr<Wu~va?@eW?}l5to=ve|IWXdeaC+v{{{QoPnL8U RPL==w002ovPDHLkV1i3q$F=|fliteral 0
HcmV?d00001engine/tests/Functional.fuego_release_test/test_run.py +1
-1@@ -153,7 +153,7 @@ class CheckText(SeleniumCommand): class CheckScreenshot(SeleniumCommand): - def __init__(self, locator, pattern, ref_img, diff_img=None, + def __init__(self, locator, pattern, ref_img, mask_img=None, diff_img=None, expected_result=True, threshold=0.0, rm_images_on_success=True):def
add_suffix(filename, suffix):engine/tests/Functional.fuego_release_test/test_run.py +18
-6@@ -166,6 +166,7 @@ class CheckScreenshot(SeleniumCommand): self.pattern = pattern self.locator = locator self.reference_img_path = ref_img + self.mask_img_path = mask_img self.expected_result = expected_result self.threshold = threshold self.rm_images_on_success = rm_images_on_success@@ -178,8 +179,8 @@ class CheckScreenshot(SeleniumCommand): self.test_img_path = add_suffix(ref_img, 'test') def compare_images(self, current_img_path, reference_img_path, - diff_img_path, threshold): - cmd = ['magick', + mask_img_path, diff_img_path, threshold): + cmd = ('magick', 'compare', '-verbose', '-metric',@@ -188,10 +189,14 @@ class CheckScreenshot(SeleniumCommand): 'Red', '-compose', 'Src', + '-read-mask' if mask_img_path else None, + mask_img_path if mask_img_path else None, current_img_path, reference_img_path, - diff_img_path - ] + diff_img_path, + ) + + cmd = list(filter(None, cmd)) LOGGER.debug(' Comparing images...') LOGGER.debug(' cmd: $ %s', ' '.join(cmd))@@ -246,6 +251,7 @@ class CheckScreenshot(SeleniumCommand): result = self.compare_images(self.test_img_path, self.reference_img_path, + self.mask_img_path, self.diff_img_path, self.threshold)@@ -743,7 +749,14 @@ def main(): CheckScreenshot(By.ID, 'tasks', rm_images_on_success=True, ref_img='screenshots/side-panel-tasks.png', - threshold=0.1) + threshold=0.1), + + # Compare screenshot of an element of Jenkins UI ignoring an area + CheckScreenshot(By.CLASS_NAME, 'page_generated', + rm_images_on_success=False, + mask_img='screenshots/page-generated-mask.png', + ref_img='screenshots/page-generated.png', + threshold=0.1), ] if not execute_tests(args.timeout): --2.17.0
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 09/14] Add mask-img-path argument to CheckScreenshot for ignored areas
Quoted 7 lines · On Wed, Apr 25, 2018 at 8:28 PM, <[email protected]> wrote:
Quoted 7 lines
-----Original Message-----
From: Guilherme Campos CamargoThe new mask-img-path argument that has been added to CheckScreenshot can be used to provide a mask image that will determine which parts of the screenshots will be compared.
Quoted 6 lines
Quoted 3 lines
The mask needs to be a Black and White .png image in which the Black areas will be ignored on the comparison, while the White areas will be compared normally.
How do you generate these?
Actually, it's pretty straightforward with Gimp (or any other image editor with layers).
I just add a new transparent layer above the original image, paint black the areas
that I want to remove (in the new layer) - right on top of the original image - then
add a new white layer in between the two and export.
Quoted 11 lines
It seems like it would be nice to be able to use a chroma-key color (like magenta),
for the to-ignore regions, and have all other colors be interpreted as white,
for the "to-compare" regions. This would allow creation of the masks by just drawing a rectangle of magenta on the reference image. That is, you could pull in the mask image in the above-described format, and
convert all colors but magenta to white, and magenta to black, and then use the mask image like you are doing now.
That's an option, but the problem with that is that magenta would need to be a prohibited color on the original image.
Quoted 319 lines
But maybe you have a workflow where it's already easy to create the masks.
One good thing about this is you could look at the mask and more easily tell
what part of the image you intend to ignore.
-- TimQuoted 19 lines
A new CheckScreenshot has been added to check the '
page_generated' element of the Jenkins web-interface. That element is positioned in the lower right corner of the page and contains a DateTime field that changes continually.The assets used as reference and mask have also been included in this commit.
Signed-off-by Guilherme Campos Camargo <[email protected]>--- .../screenshots/page-generated-mask.png | Bin 0 -> 183 bytes .../screenshots/page-generated.png | Bin 0 -> 4583 bytes .../Functional.fuego_release_test/test_run.py | 25 +++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated- mask.png create mode 100644Review
Quoted 4 lines
engine/tests/Functional.fuego_release_test/screenshots/page- generated.png
(quoted diff) +0
-0screenshots/page-
Quoted 17 lines
generated-mask.png b/engine/tests/Functional.fuego_release_test/screenshots/page- generated-mask.png
new file mode 100644
index 0000000000000000000000000000000000000000..a565ba4dd4b8cbd5ab4be9c7050d8046f63e238a
GIT binary patch
literal 183 zcmeAS@N?(olHyuVBq!ia0y~yU{nCI8e2sWPi}XA|S<<<n8Xl@E- &h>|H(?D8gCb
z5n0T@z%2~Ij105pNB{- dOFVsD*&ne8i79f=*0Tx$3b}Z?IEG~0dwXRgFM|Qk;SIa~ z|9=xV!PeoVu!%-)b%bgsN6kYo1_^- #2L?7434sPiMmClN2OtF(I`D*X)n68A7Wv8g QK=T+pUHx3vIVCg!0HVY$sQ>@~Review
Quoted 4 lines
literal 0
HcmV?d00001(quoted diff) +0
-0screenshots/page-
Quoted 242 lines
generated.png b/engine/tests/Functional.fuego_release_test/screenshots/page- generated.png
new file mode 100644
index 0000000000000000000000000000000000000000..9b16d92e5cc3ec6c9f57723115e21f8f23f5eab9
GIT binary patch
literal 4583 zcmV<D5g6?P)<h;3K|Lk000e1NJLTq00AHX000gM0ssI205Dc1000rLNkl<Zc%1E 8 zXF!ulx1Kizl2Aek5Q>6yWEH^%Hae&v0wOEc#j@BC*Ig?jNE5pvh=LRmP?|~+0 RfS2 z>d-VDxDBI2}vLcy!Xer*+^6O?sxCE_xk+doik^iIp<6}GXY_98Q?p<<2(L6zyJWy z&+)%)(%+A7^^47BFPdjDz!~`4nI|9_&GSuzGM@67^1s~U1hrq;a6C&U_VJ7T ezDUD z^e12*Qw<#p<GG0g0EC_kPfJM$0FX!|Ep5%6UfXqav=IcEz~O%ua_;1o6qkgY4 F21l
z+T*pifbha>@- nP(Z9yf(cW?D#F@8ms(X5R(=$@!<>jE9#bTW~dG2A=qoJYU8Ab+s ze%mc4M;VXg@uMf#t|q>#sm0@Q#wK%jdTl3@$*?Lms&TJTYUbIm5t@D- 8)1?L;wIG
zK__0kc- 7L};^XISZDT12OMF~H#_cR7gQ>1D#nWrM{tx;iB6i}~sprpMwludKIqGd? zZ7GnKm6V5vUFvA>Fqkp@p!Yt?C{xo@Z{Eqe+uYnjmLe~6uv@ob4F- c@v)SGUeBRf7 z;BW?1RaG~8xEq_y9X&>6CFK{xFVoxTGYkz59NHQM~DCbv{u@>)$Rr}rk^@{ d_=?h zg~h%;{wRv#a5!aUrJpvfx3aeE?d@||>ZGWocs=DB27fdcC>fF;cz+mnIjl%ES8= + zd)#2gbXZKekycgt@JF|m+hw*dO@b&PR5IfLTJzmsK$O7*s_CODljYgblwV nNv
z=$4i)032yl>+>NhKGm88_WM#peQ;tH1t2&BdwM8;vJiLCQ- jCf<OB!RPaZiw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TB@Y#n#kv)0#ctqIcbEhw0u^1g)?LEKkhQ<inBgo6Ys4O sB zK|w)FTXTxK8myT$%jlMZyraE~grr1La{R{4KPAK`{o=K^x2IQ5o?^euZm#hh8(X WU z#-<$}yQF2L=Pxip5Co?EjSY=inRiB9f%0?jEnaFvRip}pD^@y%o(<cwbrXt$B}*5d zKXak(W4(^9HoVaO;l&usjL+v=n}2!(T(xp7002JBdi~;g{_KU-uIq+|hPAXceU5rV zo{si*lX=F-=TzC5cbLq6?}JBRQCwU+Gv_7_hqGO5- O}9Rx!nu?4kqwox96{~UcLqZ z91A>tEbw^9i6E2t#!f37J32ad?cCGP>{nEzuHAFR8kx<G4^=vg%8}p0U^NwA;( Vz z8=K5kR#Eo$IdC!jaz}f|32v%M-IYP!lAoyJ+-r=bKUAs6Jy>2lb~b%2nLgsc%$xP zJr;{qo1z*J><8~%@R7rQnVqz>l(LHQ;Ufpb!!C9Bbr{T;?(K5gTW981o&7703eY_ zcsyQKR%S$CKc7UO$>E2#w$>QcLU3F2Bag>Be9*VMt6ND)(R25XnX>P;};qQF )^{Q zh|nuhF^Bg1^!4^BDp4)1EHt$=kZ=80DZ$xYU0ri%zfbDT>l0rLMkD!p>bsg+AHP H2 z)asuCf8W5Vg$&|EB+niLqkLE>o;GCy$pXZ{*M2AeB1j8kH>ph^=No_n8{?uM 8z&x zIR7iJ7EO)KA3l6UQM9q4>DJAR1q<i>C2Rk1B=DRC&qqXUH>4AzkUfP!x@gj#Ns
z!sBtX=givTvGFStUlyz1- !Hhgr<Wu~va?@eW?}l5to=ve|IWXdeaC+v{{{QoPnL8U RPL==w002ovPDHLkV1i3q$F=|fliteral 0
HcmV?d00001engine/tests/Functional.fuego_release_test/test_run.py +1
-1@@ -153,7 +153,7 @@ class CheckText(SeleniumCommand): class CheckScreenshot(SeleniumCommand): - def __init__(self, locator, pattern, ref_img, diff_img=None, + def __init__(self, locator, pattern, ref_img, mask_img=None, diff_img=None, expected_result=True, threshold=0.0, rm_images_on_success=True):def
add_suffix(filename, suffix):engine/tests/Functional.fuego_release_test/test_run.py +10
-4@@ -166,6 +166,7 @@ class CheckScreenshot(SeleniumCommand): self.pattern = pattern self.locator = locator self.reference_img_path = ref_img + self.mask_img_path = mask_img self.expected_result = expected_result self.threshold = threshold self.rm_images_on_success = rm_images_on_success@@ -178,8 +179,8 @@ class CheckScreenshot(SeleniumCommand): self.test_img_path = add_suffix(ref_img, 'test') def compare_images(self, current_img_path, reference_img_path, - diff_img_path, threshold): - cmd = ['magick', + mask_img_path, diff_img_path, threshold): + cmd = ('magick', 'compare', '-verbose', '-metric',@@ -188,10 +189,14 @@ class CheckScreenshot(SeleniumCommand): 'Red', '-compose', 'Src', + '-read-mask' if mask_img_path else None, + mask_img_path if mask_img_path else None, current_img_path, reference_img_path, - diff_img_path - ] + diff_img_path, + ) + + cmd = list(filter(None, cmd)) LOGGER.debug(' Comparing images...') LOGGER.debug(' cmd: $ %s', ' '.join(cmd))@@ -246,6 +251,7 @@ class CheckScreenshot(SeleniumCommand): result = self.compare_images(self.test_img_path, self.reference_img_path, + self.mask_img_path, self.diff_img_path, self.threshold)engine/tests/Functional.fuego_release_test/test_run.py def main(): · line 754
Quoted 7 lines
engine/tests/Functional.fuego_release_test/test_run.py +3
-1@@ -743,7 +749,14 @@ def main(): CheckScreenshot(By.ID, 'tasks', rm_images_on_success=True, ref_img='screenshots/side-panel-tasks.png', - threshold=0.1) + threshold=0.1), + + # Compare screenshot of an element of Jenkins UI ignoring anarea
Quoted 15 lines
engine/tests/Functional.fuego_release_test/test_run.py +5
-1+ CheckScreenshot(By.CLASS_NAME, 'page_generated', + rm_images_on_success=False, + mask_img='screenshots/page-generated-mask.png', + ref_img='screenshots/page-generated.png', + threshold=0.1), ] if not execute_tests(args.timeout): --2.17.0
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 09/14] Add mask-img-path argument to CheckScreenshot for ignored areas
Quoted 18 lines · Guilherme Camargo
Quoted 8 lines · On Wed, Apr 25, 2018 at 8:28 PM, <[email protected]> wrote:
Quoted 8 lines
-----Original Message-----
From: Guilherme Campos CamargoThe new mask-img-path argument that has been added to CheckScreenshot can be used to provide a mask image that will determine which parts of the screenshots will be compared.
Quoted 5 lines
Quoted 3 lines
The mask needs to be a Black and White .png image in which the Black areas will be ignored on the comparison, while the White areas will be compared normally.
How do you generate these?
Quoted 8 lines
Actually, it's pretty straightforward with Gimp (or any other image editor with layers).
I just add a new transparent layer above the original image, paint black the areas
that I want to remove (in the new layer) - right on top of the original image - then
add a new white layer in between the two and export.
IOW: just "draw" a hole in the image, lots of tools allow that, be the complex layer-mask that Guilherme explained, or simply select the region and "cut". If the image has a transparent layer, this will be transparent (if it becomes white/black, then first add the transparency to the image and repeat).
Signature · 6 lines
Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN, GTalk, FaceTime: [email protected] Skype: gsbarbieri Mobile: +55 (16) 99354-9890
Re: [Fuego] [PATCH 09/14] Add mask-img-path argument to CheckScreenshot for ignored areas
In reply to Guilherme CamargoQuoted 28 lines
-----Original Message-----
From: Guilherme CamargoOn Wed, Apr 25, 2018 at 8:28 PM, <[email protected] <mailto:[email protected]> > wrote:
> -----Original Message----- > From: Guilherme Campos Camargo > > The new mask-img-path argument that has been added toCheckScreenshot
> can be used to provide a mask image that will determine which
parts of
> the screenshots will be compared.
>
> The mask needs to be a Black and White .png image in which the
Black
> areas will be ignored on the comparison, while the White areas will
be
> compared normally.How do you generate these?
Quoted 8 lines
Actually, it's pretty straightforward with Gimp (or any other image editor with layers).
I just add a new transparent layer above the original image, paint black the areas
that I want to remove (in the new layer) - right on top of the original image - then
add a new white layer in between the two and export.
That seems pretty easy.
Quoted 16 lines
It seems like it would be nice to be able to use a chroma-key color
(like magenta),
for the to-ignore regions, and have all other colors be interpreted as
white,
for the "to-compare" regions. This would allow creation of the masks
by
just drawing a rectangle of magenta on the reference image. That is, you could pull in the mask image in the above-described
format, and
convert all colors but magenta to white, and magenta to black, and
then
use the mask image like you are doing now.
Quoted 2 lines
That's an option, but the problem with that is that magenta would need to be a prohibited color on the original image.
Yeah, but magenta is a fairly seldom-used color, and even if some other screen pixels ended up not being compared, I don't think it would be a problem. Most images are not going to have contiguous blocks of magenta in them.
Quoted 10 lines
But maybe you have a workflow where it's already easy to create the
masks.One good thing about this is you could look at the mask and more
easily tell
what part of the image you intend to ignore.
Having the rectangle mask in the context of the original image, viewable without a special tool, seems like it would be nice.
However, this was just brainstorming on my part. If I find myself making lots of masks and I think the workflow is cumbersome, I'll just try some things myself, to see if it has the advantages I'm postulating.
Quoted 393 lines
-- Tim > > A new CheckScreenshot has been added to check the'
page_generated'
> element of the Jenkins web-interface. That element is positioned
in the
> lower right corner of the page and contains a DateTime field that > changes continually.
>
> The assets used as reference and mask have also been included in
this> commit. > > Signed-off-by: Guilherme Campos Camargo <[email protected] <mailto:[email protected]> > > --- > .../screenshots/page-generated-mask.png | Bin 0 -> 183 bytes > .../screenshots/page-generated.png | Bin 0 -> 4583 bytes > .../Functional.fuego_release_test/test_run.py | 25 +++++++++++++----- > 3 files changed, 19 insertions(+), 6 deletions(-) > create mode 100644 > engine/tests/Functional.fuego_release_test/screenshots/page- generated- > mask.png > create mode 100644 > engine/tests/Functional.fuego_release_test/screenshots/page- > generated.png > > diff --git a/engine/tests/Functional.fuego_release_test/screenshots/page- > generated-mask.png > b/engine/tests/Functional.fuego_release_test/screenshots/page- > generated-mask.png > new file mode 100644 > index > 0000000000000000000000000000000000000000..a565ba4dd4b8cbd5ab4be9c70 > 50d8046f63e238a > GIT binary patch > literal 183 > zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI`8e2sWPi}XA|S<<<n8Xl@E- > &h>|H(?D8gCb > z5n0T@z%2~Ij105pNB{- > dOFVsD*&ne8i79f=*0Tx$3b}Z?IEG~0dwXRgFM|Qk;SIa~ > z|9=xV!PeoVu!%-)b%bgsN6kYo1_^- > #2L?7434sPiMmClN2OtF(I`D*X)n68A7Wv8g > QK=T+pUHx3vIVCg!0HVY$sQ>@~ > > literal 0 > HcmV?d00001 > > diff --git a/engine/tests/Functional.fuego_release_test/screenshots/page- > generated.png > b/engine/tests/Functional.fuego_release_test/screenshots/page- > generated.png > new file mode 100644 > index >0000000000000000000000000000000000000000..9b16d92e5cc3ec6c9f57723115
> e21f8f23f5eab9 > GIT binary patch > literal 4583 > zcmV<D5g6`?P)<h;3K|Lk000e1NJLTq00AHX000gM0ssI205Dc1000rLNkl<Zc%1E > 8 > zXF!ulx1Kizl2Aek5Q>6yWEH^%Hae&v0wOEc#j@BC*Ig?jNE5pvh=LRmP?|~+0 > RfS2 > z`>d- VDxDBI2}vLcy!Xer*+^6O?sxCE_xk+doik^iIp<6}GXY_98Q?p<<2(L6zyJWy > z&+)%)(%+A7^^47BFPdjDz!~`4nI|9_&GSuzGM@67^1s~U1hrq;a6C&U_VJ7T > ezDUD > z^e12*Qw<#p<GG0g0EC_kPfJM$0FX!|Ep5%6UfXqav=IcEz~O%ua_;1o6qkgY4 > F21l > z+T*pi`fbha>@- > nP(Z9yf(cW?D#F@8ms(X5R(=$@!<>jE9#bTW~dG2A=qoJYU8Ab+s > ze%mc4M;VXg@uMf#t|q>#sm0@Q#wK%jdTl3@$*?Lm`s&TJTYUbIm5t@D- > 8)1?L;wIG > zK__0kc- > 7L};^XISZDT12OMF~H#_cR7gQ>1D#nWrM{tx;iB6i}~sprpMwludKIqGd? > zZ7GnKm6V5vUFvA>Fqkp@p!Yt?C{xo@Z{Eqe+uYnjmLe~6uv@ob4F- > c@v)SGUeBRf7 > z;BW?1RaG~8xEq_y9X&>6CFK{xFVoxTGYkz59NH`QM~DCbv{u@>)$Rr}rk^@{ > d_=?h > zg~h%;{wRv#a5!aUrJpvfx3aeE?d@||>ZGWocs=DB27`fdcC>fF;cz+mnIjl%ES8= > + > zd)#2gbXZKekycgt@JF|m`+hw*dO@b&PR5IfL`TJzmsK$O7*s_CODl`jYgb`lwV > nNv > z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WXdeaC+v{{{QoPnL8U > RPL==w002ovPDHLkV1i3q$F=|f > > literal 0 > HcmV?d00001 > > diff --git
a/engine/tests/Functional.fuego_release_test/test_run.py
>b/engine/tests/Functional.fuego_release_test/test_run.py> index ba840b6..5fa2ca1 100755
> ---a/engine/tests/Functional.fuego_release_test/test_run.py> +++b/engine/tests/Functional.fuego_release_test/test_run.py> @@ -153,7 +153,7 @@ class CheckText(SeleniumCommand):
>
>
> class CheckScreenshot(SeleniumCommand):
> - def __init__(self, locator, pattern,ref_img, diff_img=None,
> + def __init__(self, locator, pattern,ref_img, mask_img=None,
> diff_img=None,
> expected_result=True, threshold=0.0,
> rm_images_on_success=True):
> defadd_suffix(filename, suffix):
> @@ -166,6 +166,7 @@ class
CheckScreenshot(SeleniumCommand):> self.pattern = pattern > self.locator = locator > self.reference_img_path = ref_img > + self.mask_img_path = mask_img > self.expected_result = expected_result > self.threshold = threshold > self.rm_images_on_success = rm_images_on_success > @@ -178,8 +179,8 @@ classCheckScreenshot(SeleniumCommand):
> self.test_img_path =add_suffix(ref_img, 'test')
>
> def compare_images(self,current_img_path,reference_img_path,> - diff_img_path, threshold): > - cmd = ['magick', > + mask_img_path, diff_img_path, threshold): > + cmd = ('magick', > 'compare', > '-verbose', > '-metric', > @@ -188,10 +189,14 @@ class CheckScreenshot(SeleniumCommand): > 'Red', > '-compose', > 'Src', > + '-read-mask' if mask_img_path else None, > + mask_img_path if mask_img_path else None, > current_img_path, > reference_img_path, > - diff_img_path > - ] > + diff_img_path, > + ) > + > + cmd = list(filter(None, cmd)) > > LOGGER.debug(' Comparing images...') > LOGGER.debug(' cmd: $ %s', ' '.join(cmd)) > @@ -246,6 +251,7 @@ classCheckScreenshot(SeleniumCommand):
>
> result = self.compare_images(self.test_img_path,
> self.reference_img_path,
> + self.mask_img_path,
> self.diff_img_path,
> self.threshold)
>
> @@ -743,7 +749,14 @@ defmain():
> CheckScreenshot(By.ID, 'tasks',
> rm_images_on_success=True,
> ref_img='screenshots/side-panel-tasks.png',
> - threshold=0.1)
> + threshold=0.1),
> +
> + # Compare screenshot of an element of Jenkins UI ignoring an
area
> + CheckScreenshot(By.CLASS_NAME, 'page_generated',
> + rm_images_on_success=False,
> + mask_img='screenshots/page-generated-mask.png',
> + ref_img='screenshots/page-generated.png',
> + threshold=0.1),
> ]
>
> if notexecute_tests(args.timeout):
> --
> 2.17.0
>> _______________________________________________ > Fuego mailing list
> [email protected]
<mailto:[email protected]>
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
<https://lists.linuxfoundation.org/mailman/listinfo/fuego>
PATCH 10/14 Add a README.md
In reply to Guilherme Campos CamargoAdd a README.md that explains the usage of the fuego-release-test as well as the usage of the helper scripts.
--- .../Functional.fuego_release_test/README.md | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 engine/tests/Functional.fuego_release_test/README.md
engine/tests/Functional.fuego_release_test/README.md new file +182 -0
@@ -0,0 +1,182 @@ +# Fuego Release Test + +This Fuego Functional test may be used for automating tests of new Fuego +Releases through Fuego itself, or may be used in standalone mode (outside +Fuego) to test a Fuego version that's present in your filesystem. + +## Dependencies + + - Docker + - Python3 + - Python-Pillow + - Pexpect + - Chromium + - SeleniumHQ + +## Usage + +### Within Fuego + +For using it within Fuego, simply add a `fuego-test` board and associate this +test to it (`Functional.fuego_release_test`) with the following commands on +Fuego shell. + +``` +$ ftc add-nodes fuego-test +$ ftc add-jobs -b fuegotest -t Functional.fuego_release_test +``` + +After doing that, use Fuego as usual to trigger the `fuego_release_test` and +check the results. + +By default `fuego_release_test` clones Fuego and Fuego-Core from the official +master branches (default specs on `spec.json`), but `test` and a `next` specs +are also already available on the `specs.json`. You can always edit the specs +to add your preferred repos/branches. + +### Standalone + +Sometimes it's useful to execute `fuego_release_test` outside Fuego, with a +Fuego version that's present locally in your filesystem. + +For doing that, simply execute the `test_run.py` script pointing to your Fuego +installation directory. + +See examples below: + +Test a `Fuego` version that's located at `~/fuego` and use the current +directory as working-dir (location where test assets will be saved and looked +for (screenshots, for example). +``` +$ ./test_run.py -w . ~/fuego +``` + +Same as above, but do not remove (neither stops) the `fuego-container` after +the execution of the tests. You'll be able to access the inner Jenkins (Fuego +that runs inside Fuego) through `${fuego_container_ip}:8080/fuego`. The +`fuego_container ip` is dynamically set by docker, and is displayed in the +first lines of the output of the script. +``` +$ ./test_run.py --no-rm-container -p 8080 -w . ~/fuego +``` + +Output example with the IP of the container: +``` +... +test_run:DEBUG: Container 'fuego-release-container' created +test_run:DEBUG: Starting container 'fuego-release-container' +test_run:DEBUG: Running fetch_ip() +test_run:DEBUG: Try number 1... +test_run:DEBUG: Success +test_run:DEBUG: Trying to reach jenkins at container 'fuego-release-container' via the container's IP '172.17.0.2' at port '8080' +test_run:DEBUG: Running ping_jenkins() +... +``` + +Docker commands will be executed from within the script. For that reason, you +may be required to execute it with `sudo` or as a user with root permissions. + +## Test Classes + +Fuego Release Test implements a few wrapper classes on top of SeleniumHQ and +Pexpect. Those classes are used for the instantiation of Test Case objects that +are executed sequentially through `execute_tests()`. + +A few examples are given below: + +### Pexpect Commands + +#### ShExpect +Execute a shell command expecting its output to match a given regexp. + +``` +ShExpect('ftc list-nodes -q', r'.*docker.*') +``` + +### Selenium Commands + +#### Visit +Ask for SeleniumHQ to visit a given URL. + +``` +Visit(url='http://localhost:8080/fuego') +``` + +#### Click +Find the first element containing a partial link text matching 'docker' and +click it. + +``` +Click(By.PARTIAL_LINK_TEXT, 'docker'), +``` + +#### CheckText +Find the element whose id is 'executors' and check if its text matches the +given string ('docker.defaut...') +``` +CheckText(By.ID, 'executors', + text='docker.default.Functional.hello_world'), +``` + +#### CheckScreenshot + +Find an element whose class name is 'page_generated', take a screenshot of it +and compare with a reference screenshot, given a comparison mask (B/W in which +Black regions will not be compared) and a threshold (percentage of non-matching +pixels that are tolerated) +``` +CheckScreenshot(By.CLASS_NAME, 'page_generated', + rm_images_on_success=False, + mask_img='screenshots/page-generated-mask.png', + ref_img='screenshots/page-generated.png', + threshold=0.1), +``` + +Take a full screenshot and compare with the image in +`screenshots/full_screenshot.png` using the ignore-mask +`screenshots/full_screenshot_mask.png`. The viewport resolution can be set on +the SeleniumContext constructor. +``` +CheckScreenshot(ref_img='screenshots/full_screenshot.png', + rm_images_on_success=False, + mask_img='screenshots/full_screenshot_mask.png', + threshold=0.01), +``` + +Note that the test by default does not store the currently captured screenshot +and the diff image in case of success. If you'd like to see those images, set +`rm_images_on_success` to False, and those images will be available in the +working directory (script's -w argument). + +## Helpers + +A `take_screenshot.py` helper script has been implemented to aid the generation +of reference screenshots (used by CheckScreenshot tests). + +The usage of the script is documented on `take_screnshot.py --help` and a few +examples are given below: + +#### Full Screen + +Take a full viewport screenshot (default resolution is 1920x1080) from +`http://localhost:8080/fuego` and save it in the current directory as +`full_viewport.png`. + +``` +./take_screenshot.py http://localhost:8080/fuego +``` + +Take a full viewport screenshot as above, but sets the viewport to 800x600 + +``` +./take_screenshot.py http://localhost:8080/fuego -r 800x600 +``` + +#### Element Screenshot +Finds a element by CLASS_NAME (-l locator) that matches the string +'page_generated' (-p pattern) saving it in the current directory as +`CLASS_NAME_page_generated.png`. + +``` +./take_screenshot.py http://172.17.0.2:8080/fuego/ -l CLASS_NAME -p page_generated +```
Signature · 1 line
2.17.0
PATCH 11/14 Allow Full viewport Screenshots
In reply to Guilherme Campos CamargoThe locator and pattern arguments from CheckScreenshot are now optional. If CheckScreenshot is instantiated without those arguments, a full screenshot of the viewport will be captured.
Additionally, viewport_width and viewport_height have been added as optional arguments allowing the resolution of the viewport to be chosen.
--- .../screenshots/footer.png | Bin 0 -> 7371 bytes .../screenshots/footer_mask.png | Bin 0 -> 302 bytes .../screenshots/full_screenshot.png | Bin 0 -> 46323 bytes .../screenshots/full_screenshot_mask.png | Bin 0 -> 10717 bytes .../screenshots/page-generated-mask.png | Bin 183 -> 0 bytes .../screenshots/page-generated.png | Bin 4583 -> 0 bytes .../Functional.fuego_release_test/test_run.py | 52 ++++++++++++------ 7 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot_mask.png delete mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated-mask.png delete mode 100644 engine/tests/Functional.fuego_release_test/screenshots/page-generated.png
engine/tests/Functional.fuego_release_test/screenshots/footer.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/footer_mask.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/full_screenshot.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/full_screenshot_mask.png new file binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/page-generated-mask.png deleted binary +0 -0
engine/tests/Functional.fuego_release_test/screenshots/page-generated.png deleted binary +0 -0
engine/tests/Functional.fuego_release_test/test_run.py +34 -18
119 lines not on this page · raw message
Signature · 1 line
2.17.0
PATCH 12/14 Allow compare-with-mask to work with ImageMagick 6 and ImageMagick 7
In reply to Guilherme Campos CamargoThe compare command on ImageMagick 7+ supports the --read-mask modifier, that simplifies the comparison by allowing an ignore-mask to be provided. ImageMagick 6 does not support that option, so in order to ignore regions we need to compose two intermediate images, from the reference and from the test, in which the ignored regions are painted black. On this patch, we're implementing that logic, allowing Magick 7 and Magick 6 to be used.
The reason why we're allowing Magick 6 to be used is because Magick 7 is not yet officially available neither on Jessie nor on Stretch, and if we wanted to install it from source on Fuego, we would need to upgrade a few dependencies (as libc) what could possibly end up causing negative side effects.
On the other hand we're not dropping completely ImageMagick 7 implementation because users may want to execute the test outside Fuego (as explained on the README), taking advantage of the new features if ImageMagick 7 is installed in their system.
--- .../Functional.fuego_release_test/test_run.py | 104 ++++++++++++++---- 1 file changed, 83 insertions(+), 21 deletions(-)
engine/tests/Functional.fuego_release_test/test_run.py +83 -21
@@ -183,10 +183,44 @@ class CheckScreenshot(SeleniumCommand): self.test_img_path = add_suffix(ref_img, 'test') - def compare_images(self, current_img_path, reference_img_path, - mask_img_path, diff_img_path, threshold): - cmd = ('magick', - 'compare', + def compare_cmd_magick_v7(test_img, ref_img, mask_img, diff_img): + """ + This compare command uses the --read-mask option that works only with + ImagMagick V7.0.3.9+. That option allows a mask to be used for limiting + the regions to be compared. + """ + cmd = ('compare', + '-verbose', + '-metric', + 'RMSE', + '-highlight-color', + 'Red', + '-compose', + 'Src', + '-read-mask' if mask_img else None, + mask_img if mask_img else None, + test_img, + ref_img, + diff_img, + ) + return ' '.join(list(filter(None, cmd))) + + def compare_cmd_magick_v6(test_img, ref_img, mask_img, diff_img): + """ + This compare command does not use the option --read-mask that is + available only on ImageMagic V7.0.3.9+. It has been tested with + ImageMagick V6.0 and works fine. The strategy being used here is to + multiply test and ref by the same B/W mask, in which black regions will + be ignored during the comparison. + """ + def apply_mask_cmd(img, mask=None): + if not mask: + return (img,) + + return ( + '<(composite -compose Multiply %s %s png:)' % (img, mask),) + + cmd = ('compare', '-verbose', '-metric', 'RMSE',
@@ -194,28 +228,56 @@ class CheckScreenshot(SeleniumCommand): 'Red', '-compose', 'Src', - '-read-mask' if mask_img_path else None, - mask_img_path if mask_img_path else None, - current_img_path, - reference_img_path, - diff_img_path, ) + cmd += apply_mask_cmd(test_img, mask_img) + cmd += apply_mask_cmd(ref_img, mask_img) + cmd += (diff_img,) - cmd = list(filter(None, cmd)) + return ' '.join(list(cmd)) - LOGGER.debug(' Comparing images...') - LOGGER.debug(' cmd: $ %s', ' '.join(cmd)) - process = subprocess.Popen(cmd, universal_newlines=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - process_stdout, process_stderr = process.communicate() - LOGGER.debug(' Results:') - LOGGER.debug(' return code: %s', process.returncode) - LOGGER.debug(' stdout: %s', process_stdout.strip()) - LOGGER.debug(' stderr: %s', process_stderr.strip()) + def compare_images(self, current_img_path, reference_img_path, + mask_img_path, diff_img_path, threshold): + def exec_cmd(cmd): + LOGGER.debug(' cmd: $ %s', cmd) + process = subprocess.Popen(cmd, universal_newlines=True, + executable='/bin/bash', shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + process_stdout, process_stderr = process.communicate() + LOGGER.debug(' Results:') + LOGGER.debug(' return code: %s', process.returncode) + LOGGER.debug(' stdout: %s', process_stdout.strip()) + LOGGER.debug(' stderr: %s', process_stderr.strip()) + + return (process.returncode, process_stdout, process_stderr,) + + def cmd_failed(ret): + """ + ImageMagick Compare command returns 2 if the command failed, 1 if + the images are dissimilar and 0 if the images are similar. This + function checks if the return code represents an error, returning + True if so. + """ + MAGICK_CMP_ERROR = 2 + return ret == MAGICK_CMP_ERROR + + LOGGER.debug(' Comparing images with ImageMagick v7 API...') + ret, stdout, stderr = exec_cmd( + CheckScreenshot.compare_cmd_magick_v7(current_img_path, + reference_img_path, + mask_img_path, + diff_img_path)) + + if cmd_failed(ret): + LOGGER.debug(' Comparing images with ImageMagick v6 API...') + ret, stdout, stderr = exec_cmd( + CheckScreenshot.compare_cmd_magick_v6(current_img_path, + reference_img_path, + mask_img_path, + diff_img_path)) RESULTS_REGEX = re.compile(".*all:.*\(([0-9\-\.e]*)\).*") - result = RESULTS_REGEX.search(process_stderr) + result = RESULTS_REGEX.search(stderr) if not result: LOGGER.error(" Error processing the output.")
Signature · 1 line
2.17.0
PATCH 13/14 Improve logging
In reply to Guilherme Campos CamargoUse LOGGER.info for the messages that are required to identify which tests are running and if they passed.
Use Logger.error for test failures.
Use Logger.debug for additional information that may be useful while debugging the tests' execution.
--- .../Functional.fuego_release_test/test_run.py | 81 +++++++++++-------- 1 file changed, 49 insertions(+), 32 deletions(-)
engine/tests/Functional.fuego_release_test/test_run.py +49 -32
@@ -52,8 +52,8 @@ class SeleniumCommand: def exec(self, selenium_ctx): self.driver = selenium_ctx.driver self.driver.refresh() - LOGGER.debug("Executing Selenium Command '%s'", - self.__class__.__name__) + LOGGER.info("Executing Selenium Command '%s'", + self.__class__.__name__) @staticmethod def check_element_text(element, text):
@@ -62,11 +62,13 @@ class SeleniumCommand: LOGGER.\ debug(" Text '%s' matches element.text '%s'", text, element.text) + LOGGER.info(" Matching text found") return True else: LOGGER.\ debug(" Text '%s' does not match element.text '%s'", text, element.text) + LOGGER.error(" Matching text not found.") return False except (selenium_exceptions.ElementNotVisibleException, selenium_exceptions.NoSuchAttributeException,):
@@ -77,7 +79,7 @@ class SeleniumCommand: def click_element(element): try: element.click() - LOGGER.debug(" Element clicked") + LOGGER.info(" Element clicked") return True except (selenium_exceptions.ElementClickInterceptedException, selenium_exceptions.ElementNotVisibleException,):
@@ -124,17 +126,17 @@ class Visit(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx) - LOGGER.debug(" Visiting '%s'", self.url) + LOGGER.info(" Visiting '%s'", self.url) self.driver.get(self.url) r = requests.get(self.url) if r.status_code != self.expected_result: - LOGGER.debug(" HTTP Status Code '%s' is different " + + LOGGER.error(" HTTP Status Code '%s' is different " + "from the expected '%s'", r.status_cod, self.url) return False - LOGGER.debug(" HTTP Status Code is same as expected '%s'", - r.status_code) + LOGGER.info(" HTTP Status Code is same as expected '%s'", + r.status_code) return True
@@ -280,21 +282,21 @@ class CheckScreenshot(SeleniumCommand): result = RESULTS_REGEX.search(stderr) if not result: - LOGGER.error(" Error processing the output.") + LOGGER.error(" Error processing the output") return False difference = float(result.group(1)) if difference > threshold: - LOGGER.debug(" Resulting difference (%s) above threshold (%s). ", + LOGGER.error(" Resulting difference (%s) above threshold (%s)", difference, threshold) - LOGGER.debug(" Element's screenshot does not match the reference." + LOGGER.error(" Element's screenshot does not match the reference." " See %s for a visual representation of the " " differences.", diff_img_path) return False - LOGGER.debug(" Resulting difference (%s) below threshold (%s).", - difference, threshold) - LOGGER.debug(" Element's screenshot matches the reference.") + LOGGER.info(" Resulting difference (%s) below threshold (%s)", + difference, threshold) + LOGGER.info(" Element's screenshot matches the reference") return True def exec(self, selenium_ctx):
@@ -354,8 +356,8 @@ class Back(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx) - LOGGER.debug(" Going back") self.driver.back() + LOGGER.info(" Went back") return True
@@ -378,7 +380,7 @@ class ShExpect(): def exec(self, pexpect_ctx): self.client = pexpect_ctx.client - LOGGER.debug("Executing command '%s'", self.cmd) + LOGGER.info("Executing command '%s'", self.cmd) try: self.client.sendline('%s=$(%s 2>&1)' % (self.OUTPUT_VARIABLE, self.cmd))
@@ -413,6 +415,9 @@ class ShExpect(): except pexpect.exceptions.EOF: LOGGER.error("Lost connection with docker. Aborting") return False + + LOGGER.info(" Command result and command output matches " + + "the expected result. (Return code: %d)", result) return True
@@ -428,10 +433,10 @@ class FuegoContainer: def delete(self): if self.container: if self.rm_after_test: - LOGGER.debug("Removing Container") + LOGGER.info("Removing Container") self.container.remove(force=True) else: - LOGGER.debug("Not Removing the test container") + LOGGER.info("Not Removing the test container") def install(self): self.docker_client = docker.APIClient()
@@ -476,22 +481,25 @@ class FuegoContainer: mount['source'] = None cmd = './%s %s' % (self.install_script, self.image_name) - LOGGER.debug("Running '%s' to install the docker image. " + - "This may take a while....", cmd) + LOGGER.info("Running '%s' to install the docker image. " + + "This may take a while....", cmd) status = subprocess.call(cmd, shell=True) LOGGER.debug("Install output code: %s", status) if status != 0: + LOGGER.error("Installation Failed") return None + LOGGER.info("Installation Complete") + LOGGER.info("Creating the container '%s'..." % self.container_name) + docker_client = docker.from_env() containers = docker_client.containers.list( all=True, filters={'name': self.container_name}) if containers: - LOGGER.debug( - "Erasing the container '%s', so a new one can be created", - self.container_name) + LOGGER.debug("Container already exists. Removing it, so a new " + + "one can be created") containers[0].remove(force=True) mounts = [
@@ -530,7 +538,7 @@ class FuegoContainer: for m in mounts], name=self.container_name, command='/bin/bash') - LOGGER.debug("Container '%s' created", self.container_name) + LOGGER.info("Container '%s' successfully created", self.container_name) return container def is_running(self):
@@ -584,14 +592,16 @@ class PexpectContainerSession(): self.timeout = timeout def start(self): - LOGGER.debug( - "Starting container '%s'", self.container.container_name) + LOGGER.info( + "Starting container '%s'...", self.container.container_name) self.client = pexpect.spawnu( '%s %s' % (self.start_script, self.container.container_name), echo=False, timeout=self.timeout) PexpectContainerSession.set_ps1(self.client) + LOGGER.info("Container started with the ip '%s'", + self.container.get_ip()) if not self.wait_for_jenkins(): return False
@@ -629,14 +639,13 @@ class PexpectContainerSession(): container_addr = self.container.get_ip() if container_addr is None: return False - LOGGER.debug("Trying to reach jenkins at container '%s' via " + - "the container's IP '%s' at port '%d'", - self.container.container_name, - container_addr, self.container.jenkins_port) + LOGGER.info("Waiting for jenkins on '%s:%d'...", + container_addr, self.container.jenkins_port) if not loop_until_timeout(ping_jenkins, timeout=60): LOGGER.error("Could not connect to jenkins") return False + LOGGER.info("Jenkins is running") return True
@@ -649,6 +658,7 @@ class SeleniumContainerSession(): self.viewport_height = viewport_height def start(self): + LOGGER.info("Starting a Selenium Session on %s...", self.root_url) options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('no-sandbox')
@@ -662,7 +672,7 @@ class SeleniumContainerSession(): self.driver.get(self.root_url) - LOGGER.debug("Started a Selenium Session on %s", self.root_url) + LOGGER.info("Selenium Session started successfully") return True def __del__(self):
@@ -696,7 +706,7 @@ def main(): return abs_install_dir, abs_working_dir def execute_tests(timeout): - LOGGER.debug("Starting tests") + LOGGER.info("Starting tests...") ctx_mapper = { ShExpect: pexpect_session,
@@ -709,10 +719,14 @@ def main(): if isinstance(cmd, base_class): if not cmd.exec(ctx): tests_ok = False + LOGGER.error(" FAIL") break + LOGGER.info(" PASS") if tests_ok: - LOGGER.debug("Tests finished.") + LOGGER.info("All tests finished with SUCCESS") + else: + LOGGER.info("Tests finished with ERRORS") return tests_ok
@@ -770,11 +784,14 @@ def main(): pexpect_session = PexpectContainerSession(container, args.start_script, args.timeout) if not pexpect_session.start(): + LOGGER.error("Pexpect session failed to start") return 1 selenium_session = SeleniumContainerSession(container, viewport_width=1920, viewport_height=1080) + if not selenium_session.start(): + LOGGER.error("Selenium session failed to start") return 1 if os.getcwd != args.working_dir:
Signature · 1 line
2.17.0
Re: [Fuego] [PATCH 13/14] Improve logging
Can we wrapper LOGGER.info and/or LOGGER.error, to have them emit something like a testcase number (or better yet, number and description), so we can convert some of these to individual testcase outputs?
What do you think?
-- Tim
Quoted 297 lines
-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Campos Camargo
Sent: Tuesday, April 24, 2018 10:25 AM
To: [email protected]
Subject: [Fuego] [PATCH 13/14] Improve loggingUse LOGGER.info for the messages that are required to identify which tests are running and if they passed.
Use Logger.error for test failures.
Use Logger.debug for additional information that may be useful while debugging the tests' execution.
Signed-off-by Guilherme Campos Camargo <[email protected]>--- .../Functional.fuego_release_test/test_run.py | 81 +++++++++++-------- 1 file changed, 49 insertions(+), 32 deletions(-)engine/tests/Functional.fuego_release_test/test_run.py +11
-10@@ -52,8 +52,8 @@ class SeleniumCommand: def exec(self, selenium_ctx): self.driver = selenium_ctx.driver self.driver.refresh() - LOGGER.debug("Executing Selenium Command '%s'", - self.__class__.__name__) + LOGGER.info("Executing Selenium Command '%s'", + self.__class__.__name__) @staticmethod def check_element_text(element, text):@@ -62,11 +62,13 @@ class SeleniumCommand: LOGGER.\ debug(" Text '%s' matches element.text '%s'", text, element.text) + LOGGER.info(" Matching text found") return True else: LOGGER.\ debug(" Text '%s' does not match element.text '%s'", text, element.text) + LOGGER.error(" Matching text not found.") return False except (selenium_exceptions.ElementNotVisibleException, selenium_exceptions.NoSuchAttributeException,):@@ -77,7 +79,7 @@ class SeleniumCommand: def click_element(element): try: element.click() - LOGGER.debug(" Element clicked") + LOGGER.info(" Element clicked") return True except (selenium_exceptions.ElementClickInterceptedException, selenium_exceptions.ElementNotVisibleException,):@@ -124,17 +126,17 @@ class Visit(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx) - LOGGER.debug(" Visiting '%s'", self.url) + LOGGER.info(" Visiting '%s'", self.url) self.driver.get(self.url) r = requests.get(self.url) if r.status_code != self.expected_result: - LOGGER.debug(" HTTP Status Code '%s' is different " + + LOGGER.error(" HTTP Status Code '%s' is different " + "from the expected '%s'", r.status_cod, self.url) return False - LOGGER.debug(" HTTP Status Code is same as expected '%s'", - r.status_code) + LOGGER.info(" HTTP Status Code is same as expected '%s'", + r.status_code) return True@@ -280,21 +282,21 @@ class CheckScreenshot(SeleniumCommand): result = RESULTS_REGEX.search(stderr) if not result: - LOGGER.error(" Error processing the output.") + LOGGER.error(" Error processing the output") return False difference = float(result.group(1)) if difference > threshold: - LOGGER.debug(" Resulting difference (%s) above threshold (%s). ", + LOGGER.error(" Resulting difference (%s) above threshold (%s)", difference, threshold) - LOGGER.debug(" Element's screenshot does not match thereference."
+ LOGGER.error(" Element's screenshot does not match the
reference."
" See %s for a visual representation of the " " differences.",diff_img_path)
return Falseengine/tests/Functional.fuego_release_test/test_run.py +19
-13- LOGGER.debug(" Resulting difference (%s) below threshold (%s).", - difference, threshold) - LOGGER.debug(" Element's screenshot matches the reference.") + LOGGER.info(" Resulting difference (%s) below threshold (%s)", + difference, threshold) + LOGGER.info(" Element's screenshot matches the reference") return True def exec(self, selenium_ctx):@@ -354,8 +356,8 @@ class Back(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx) - LOGGER.debug(" Going back") self.driver.back() + LOGGER.info(" Went back") return True@@ -378,7 +380,7 @@ class ShExpect(): def exec(self, pexpect_ctx): self.client = pexpect_ctx.client - LOGGER.debug("Executing command '%s'", self.cmd) + LOGGER.info("Executing command '%s'", self.cmd) try: self.client.sendline('%s=$(%s 2>&1)' % (self.OUTPUT_VARIABLE, self.cmd))@@ -413,6 +415,9 @@ class ShExpect(): except pexpect.exceptions.EOF: LOGGER.error("Lost connection with docker. Aborting") return False + + LOGGER.info(" Command result and command output matches " + + "the expected result. (Return code: %d)", result) return True@@ -428,10 +433,10 @@ class FuegoContainer: def delete(self): if self.container: if self.rm_after_test: - LOGGER.debug("Removing Container") + LOGGER.info("Removing Container") self.container.remove(force=True) else: - LOGGER.debug("Not Removing the test container") + LOGGER.info("Not Removing the test container") def install(self): self.docker_client = docker.APIClient()@@ -476,22 +481,25 @@ class FuegoContainer: mount['source'] = None cmd = './%s %s' % (self.install_script, self.image_name) - LOGGER.debug("Running '%s' to install the docker image. " + - "This may take a while....", cmd) + LOGGER.info("Running '%s' to install the docker image. " + + "This may take a while....", cmd) status = subprocess.call(cmd, shell=True) LOGGER.debug("Install output code: %s", status) if status != 0: + LOGGER.error("Installation Failed") return None + LOGGER.info("Installation Complete") + LOGGER.info("Creating the container '%s'..." % self.container_name) + docker_client = docker.from_env() containers = docker_client.containers.list( all=True, filters={'name': self.container_name}) if containers: - LOGGER.debug( - "Erasing the container '%s', so a new one can be created", - self.container_name) + LOGGER.debug("Container already exists. Removing it, so a new " + + "one can be created") containers[0].remove(force=True) mounts = [@@ -530,7 +538,7 @@ class FuegoContainer: for m in mounts], name=self.container_name, command='/bin/bash') - LOGGER.debug("Container '%s' created", self.container_name) + LOGGER.info("Container '%s' successfully created", self.container_name) return containerdef
is_running(self):engine/tests/Functional.fuego_release_test/test_run.py +18
-9@@ -584,14 +592,16 @@ class PexpectContainerSession(): self.timeout = timeout def start(self): - LOGGER.debug( - "Starting container '%s'", self.container.container_name) + LOGGER.info( + "Starting container '%s'...", self.container.container_name) self.client = pexpect.spawnu( '%s %s' % (self.start_script, self.container.container_name), echo=False, timeout=self.timeout) PexpectContainerSession.set_ps1(self.client) + LOGGER.info("Container started with the ip '%s'", + self.container.get_ip()) if not self.wait_for_jenkins(): return False@@ -629,14 +639,13 @@ class PexpectContainerSession(): container_addr = self.container.get_ip() if container_addr is None: return False - LOGGER.debug("Trying to reach jenkins at container '%s' via " + - "the container's IP '%s' at port '%d'", - self.container.container_name, - container_addr, self.container.jenkins_port) + LOGGER.info("Waiting for jenkins on '%s:%d'...", + container_addr, self.container.jenkins_port) if not loop_until_timeout(ping_jenkins, timeout=60): LOGGER.error("Could not connect to jenkins") return False + LOGGER.info("Jenkins is running") return True@@ -649,6 +658,7 @@ class SeleniumContainerSession(): self.viewport_height = viewport_height def start(self): + LOGGER.info("Starting a Selenium Session on %s...", self.root_url) options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('no-sandbox')@@ -662,7 +672,7 @@ class SeleniumContainerSession(): self.driver.get(self.root_url) - LOGGER.debug("Started a Selenium Session on %s", self.root_url) + LOGGER.info("Selenium Session started successfully") return True def __del__(self):@@ -696,7 +706,7 @@ def main(): return abs_install_dir, abs_working_dir def execute_tests(timeout): - LOGGER.debug("Starting tests") + LOGGER.info("Starting tests...") ctx_mapper = { ShExpect: pexpect_session,@@ -709,10 +719,14 @@ def main(): if isinstance(cmd, base_class): if not cmd.exec(ctx): tests_ok = False + LOGGER.error(" FAIL") break + LOGGER.info(" PASS") if tests_ok: - LOGGER.debug("Tests finished.") + LOGGER.info("All tests finished with SUCCESS") + else: + LOGGER.info("Tests finished with ERRORS") return tests_ok@@ -770,11 +784,14 @@ def main(): pexpect_session = PexpectContainerSession(container, args.start_script, args.timeout) if not pexpect_session.start(): + LOGGER.error("Pexpect session failed to start") return 1 selenium_session = SeleniumContainerSession(container, viewport_width=1920, viewport_height=1080) + if not selenium_session.start(): + LOGGER.error("Selenium session failed to start") return 1if os.getcwd != args.working_dir:--
2.17.0_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Re: [Fuego] [PATCH 13/14] Improve logging
Quoted 5 lines · On Wed, Apr 25, 2018 at 8:38 PM, <[email protected]> wrote:
Can we wrapper LOGGER.info and/or LOGGER.error, to have them emit something like a testcase number (or better yet, number and description), so we can convert
some of these to individual testcase outputs?
I like the idea. We can do that.
Quoted 313 lines
What do you think?
-- TimQuoted 38 lines
-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Campos Camargo
Sent: Tuesday, April 24, 2018 10:25 AM
To: [email protected]
Subject: [Fuego] [PATCH 13/14] Improve loggingUse LOGGER.info for the messages that are required to identify which tests are running and if they passed.
Use Logger.error for test failures.
Use Logger.debug for additional information that may be useful while debugging the tests' execution.
Signed-off-by Guilherme Campos Camargo <[email protected]>--- .../Functional.fuego_release_test/test_run.py | 81 +++++++++++-------- 1 file changed, 49 insertions(+), 32 deletions(-)engine/tests/Functional.fuego_release_test/test_run.py +2
-2@@ -52,8 +52,8 @@ class SeleniumCommand: def exec(self, selenium_ctx): self.driver = selenium_ctx.driver self.driver.refresh() - LOGGER.debug("Executing Selenium Command '%s'", - self.__class__.__name__) + LOGGER.info("Executing Selenium Command '%s'", + self.__class__.__name__) @staticmethod def check_element_text(element, text):engine/tests/Functional.fuego_release_test/test_run.py class SeleniumCommand: · line 69
Quoted 8 lines
engine/tests/Functional.fuego_release_test/test_run.py +1
-0@@ -62,11 +62,13 @@ class SeleniumCommand: LOGGER.\ debug(" Text '%s' matches element.text '%s'", text, element.text) + LOGGER.info(" Matching text found") return True else: LOGGER.\ debug(" Text '%s' does not match element.text'%s'",
Quoted 17 lines
engine/tests/Functional.fuego_release_test/test_run.py +2
-1text, element.text) + LOGGER.error(" Matching text not found.") return False except (selenium_exceptions.ElementNotVisibleException, selenium_exceptions.NoSuchAttributeException,):@@ -77,7 +79,7 @@ class SeleniumCommand: def click_element(element): try: element.click() - LOGGER.debug(" Element clicked") + LOGGER.info(" Element clicked") return True except (selenium_exceptions.ElementClickInterceptedException, selenium_exceptions.ElementNotVisibleException,):@@ -124,17 +126,17 @@ class Visit(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx)engine/tests/Functional.fuego_release_test/test_run.py class Visit(SeleniumCommand): · line 135
Quoted 10 lines
engine/tests/Functional.fuego_release_test/test_run.py +2
-2- LOGGER.debug(" Visiting '%s'", self.url) + LOGGER.info(" Visiting '%s'", self.url) self.driver.get(self.url) r = requests.get(self.url) if r.status_code != self.expected_result: - LOGGER.debug(" HTTP Status Code '%s' is different " + + LOGGER.error(" HTTP Status Code '%s' is different " + "from the expected '%s'", r.status_cod,self.url)
Quoted 10 lines
engine/tests/Functional.fuego_release_test/test_run.py +2
-2return False - LOGGER.debug(" HTTP Status Code is same as expected '%s'", - r.status_code) + LOGGER.info(" HTTP Status Code is same as expected '%s'", + r.status_code) return Trueengine/tests/Functional.fuego_release_test/test_run.py class CheckScreenshot(SeleniumCommand): · line 288
Quoted 10 lines
engine/tests/Functional.fuego_release_test/test_run.py +1
-2@@ -280,21 +282,21 @@ class CheckScreenshot(SeleniumCommand): result = RESULTS_REGEX.search(stderr) if not result: - LOGGER.error(" Error processing the output.") + LOGGER.error(" Error processing the output") return False difference = float(result.group(1)) if difference > threshold: - LOGGER.debug(" Resulting difference (%s) above threshold(%s). ",
engine/tests/Functional.fuego_release_test/test_run.py class CheckScreenshot(SeleniumCommand): · line 290
Quoted 1 line
engine/tests/Functional.fuego_release_test/test_run.py +1
-0+ LOGGER.error(" Resulting difference (%s) above threshold(%s)",
Quoted 10 lines
engine/tests/Functional.fuego_release_test/test_run.py +0
-1difference, threshold) - LOGGER.debug(" Element's screenshot does not match thereference."
+ LOGGER.error(" Element's screenshot does not match the
reference."
" See %s for a visual representation of the " " differences.",diff_img_path)
return False- LOGGER.debug(" Resulting difference (%s) below threshold
(%s).",
Quoted 58 lines
engine/tests/Functional.fuego_release_test/test_run.py +12
-8- difference, threshold) - LOGGER.debug(" Element's screenshot matches the reference.") + LOGGER.info(" Resulting difference (%s) below threshold (%s)", + difference, threshold) + LOGGER.info(" Element's screenshot matches the reference") return True def exec(self, selenium_ctx):@@ -354,8 +356,8 @@ class Back(SeleniumCommand): def exec(self, selenium_ctx): super().exec(selenium_ctx) - LOGGER.debug(" Going back") self.driver.back() + LOGGER.info(" Went back") return True@@ -378,7 +380,7 @@ class ShExpect(): def exec(self, pexpect_ctx): self.client = pexpect_ctx.client - LOGGER.debug("Executing command '%s'", self.cmd) + LOGGER.info("Executing command '%s'", self.cmd) try: self.client.sendline('%s=$(%s 2>&1)' % (self.OUTPUT_VARIABLE, self.cmd))@@ -413,6 +415,9 @@ class ShExpect(): except pexpect.exceptions.EOF: LOGGER.error("Lost connection with docker. Aborting") return False + + LOGGER.info(" Command result and command output matches " + + "the expected result. (Return code: %d)", result) return True@@ -428,10 +433,10 @@ class FuegoContainer: def delete(self): if self.container: if self.rm_after_test: - LOGGER.debug("Removing Container") + LOGGER.info("Removing Container") self.container.remove(force=True) else: - LOGGER.debug("Not Removing the test container") + LOGGER.info("Not Removing the test container") def install(self): self.docker_client = docker.APIClient()@@ -476,22 +481,25 @@ class FuegoContainer: mount['source'] = None cmd = './%s %s' % (self.install_script, self.image_name) - LOGGER.debug("Running '%s' to install the docker image. " + - "This may take a while....", cmd) + LOGGER.info("Running '%s' to install the docker image. " + + "This may take a while....", cmd)engine/tests/Functional.fuego_release_test/test_run.py class FuegoContainer: · line 495
Quoted 10 lines
engine/tests/Functional.fuego_release_test/test_run.py +3
-0status = subprocess.call(cmd, shell=True) LOGGER.debug("Install output code: %s", status) if status != 0: + LOGGER.error("Installation Failed") return None + LOGGER.info("Installation Complete") + LOGGER.info("Creating the container '%s'..." %self.container_name)
engine/tests/Functional.fuego_release_test/test_run.py class FuegoContainer:
Quoted 7 lines
engine/tests/Functional.fuego_release_test/test_run.py +1
-2+ docker_client = docker.from_env() containers = docker_client.containers.list( all=True, filters={'name': self.container_name}) if containers: - LOGGER.debug( - "Erasing the container '%s', so a new one can becreated",
engine/tests/Functional.fuego_release_test/test_run.py class FuegoContainer: · line 501
Quoted 2 lines
engine/tests/Functional.fuego_release_test/test_run.py +1
-1- self.container_name) + LOGGER.debug("Container already exists. Removing it, so anew " +
Quoted 15 lines
engine/tests/Functional.fuego_release_test/test_run.py +2
-1+ "one can be created") containers[0].remove(force=True) mounts = [@@ -530,7 +538,7 @@ class FuegoContainer: for m in mounts], name=self.container_name, command='/bin/bash') - LOGGER.debug("Container '%s' created", self.container_name) + LOGGER.info("Container '%s' successfully created", self.container_name) return containerdef
is_running(self):engine/tests/Functional.fuego_release_test/test_run.py class PexpectContainerSession(): · line 598
Quoted 9 lines
engine/tests/Functional.fuego_release_test/test_run.py +2
-2@@ -584,14 +592,16 @@ class PexpectContainerSession(): self.timeout = timeout def start(self): - LOGGER.debug( - "Starting container '%s'", self.container.container_name) + LOGGER.info( + "Starting container '%s'...", self.container.container_name) self.client = pexpect.spawnu( '%s %s' % (self.start_script, self.container.container_name),
Quoted 28 lines
engine/tests/Functional.fuego_release_test/test_run.py +5
-4echo=False, timeout=self.timeout) PexpectContainerSession.set_ps1(self.client) + LOGGER.info("Container started with the ip '%s'", + self.container.get_ip()) if not self.wait_for_jenkins(): return False@@ -629,14 +639,13 @@ class PexpectContainerSession(): container_addr = self.container.get_ip() if container_addr is None: return False - LOGGER.debug("Trying to reach jenkins at container '%s' via " + - "the container's IP '%s' at port '%d'", - self.container.container_name, - container_addr, self.container.jenkins_port) + LOGGER.info("Waiting for jenkins on '%s:%d'...", + container_addr, self.container.jenkins_port) if not loop_until_timeout(ping_jenkins, timeout=60): LOGGER.error("Could not connect to jenkins") return False + LOGGER.info("Jenkins is running") return Trueengine/tests/Functional.fuego_release_test/test_run.py class SeleniumContainerSession(): · line 661
Quoted 4 lines
engine/tests/Functional.fuego_release_test/test_run.py +1
-0@@ -649,6 +658,7 @@ class SeleniumContainerSession(): self.viewport_height = viewport_height def start(self): + LOGGER.info("Starting a Selenium Session on %s...",self.root_url)
Quoted 38 lines
engine/tests/Functional.fuego_release_test/test_run.py +7
-3options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('no-sandbox')@@ -662,7 +672,7 @@ class SeleniumContainerSession(): self.driver.get(self.root_url) - LOGGER.debug("Started a Selenium Session on %s", self.root_url) + LOGGER.info("Selenium Session started successfully") return True def __del__(self):@@ -696,7 +706,7 @@ def main(): return abs_install_dir, abs_working_dir def execute_tests(timeout): - LOGGER.debug("Starting tests") + LOGGER.info("Starting tests...") ctx_mapper = { ShExpect: pexpect_session,@@ -709,10 +719,14 @@ def main(): if isinstance(cmd, base_class): if not cmd.exec(ctx): tests_ok = False + LOGGER.error(" FAIL") break + LOGGER.info(" PASS") if tests_ok: - LOGGER.debug("Tests finished.") + LOGGER.info("All tests finished with SUCCESS") + else: + LOGGER.info("Tests finished with ERRORS") return tests_okengine/tests/Functional.fuego_release_test/test_run.py def main(): · line 784
Quoted 1 line
engine/tests/Functional.fuego_release_test/test_run.py +0
-0@@ -770,11 +784,14 @@ def main(): pexpect_session = PexpectContainerSession(container,args.start_script,
Quoted 21 lines
engine/tests/Functional.fuego_release_test/test_run.py +3
-0args.timeout) if not pexpect_session.start(): + LOGGER.error("Pexpect session failed to start") return 1 selenium_session = SeleniumContainerSession(container, viewport_width=1920, viewport_height=1080) + if not selenium_session.start(): + LOGGER.error("Selenium session failed to start") return 1if os.getcwd != args.working_dir:--
2.17.0_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
PATCH 14/14 Set logging level to INFO by default
In reply to Guilherme Campos CamargoSet logging level to INFO to log only the necessary information for identifying test passes and failures.
--- engine/tests/Functional.fuego_release_test/test_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
engine/tests/Functional.fuego_release_test/test_run.py +1 -1
@@ -23,7 +23,7 @@ LOGGER = logging.getLogger('test_run') STREAM_HANDLER = logging.StreamHandler() STREAM_HANDLER.setFormatter( logging.Formatter("%(name)s:%(levelname)s: %(message)s")) -LOGGER.setLevel(logging.DEBUG) +LOGGER.setLevel(logging.INFO) LOGGER.addHandler(STREAM_HANDLER)
Signature · 1 line
2.17.0
Quoted 45 lines · Guilherme Campos Camargo
Hello, everyone.
This series of patches adds a new test case class to the
fuego_release_testfunctional test. The name of this new test class is "CheckScreenshot", and its purpose is to get a screenshot of a web-page (in this specific case, Fuego's Jenkins' webpage) and compare it with a reference image.Currently, CheckScreenshot supports:
- Taking screenshot of an HTML element of a page and compare it with a reference image.
- Taking screenshot of the full viewport (full page if it fits in the viewport) and also compare it with a reference image.
- Take a screenshot (full or element) and compare only specific regions of interest with a reference image. The mask is a black-and-white image in which black regions are ignored by the comparison algorithm.On these patches we have also added a helper script (
take_screenshot.py) that may be used for collecting reference screenshots and a few test cases to serve as example of usage.A README.md file has also been to explain the usage of
fuego_release_testand the helper script, including a few examples.# Running
Currently this test requires a modified version of Fuego to be executed, given that it needs to install some dependencies and needs to map the dockerd socket from the host to the fuego container.
The modified version can be found in two different branches on Profusion's fuego fork.
Correction: Branch 'fuego-test'
1 - Branch master: Just a few commits that are necessary for making this test work, applied on top of fuego/next. We plan to try to integrate these commits into fuego/next in the future.
2 - Branch fuego-base-image: A more complex change on fuego, that makes the necessary changes for allowing it to be shipped as a docker image through dockerhub.
Quoted 6 lines
The steps for each one of the versions above are given below:
## Building the image (from the branch fuego-test)
To run the test, execute the following commands:
Instructions are correct:
Quoted 101 lines
``` git clone --branch master https://bitbucket.org/ profusionmobi/fuego-core.git git clone --branch fuego-test https://bitbucket.org/ profusionmobi/fuego.git cd fuego ./install fuego-to-test-fuego ./fuego-host-scripts/docker-create-container.sh fuego-to-test-fuego fuego-to-test-fuego-container ./fuego-host-scripts/docker-start-container.sh fuego-to-test-fuego-container ```Then, add the fuego-test board and the Functional.fuegotest and start the test through Jenkins (localhost:8080/fuego/)
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```## Using the modified Fuego Base Image from Dockerhub (fuego-base-image):
You can also use the fuego base image that's being developed in Profusion's fuego-base-image branch in our fork:
https://bitbucket.org/profusionmobi/fuego/branch/fuego-base-imageThe image is already available on dockerhub and can be downloaded/executed with:
``` docker pull fuegotest/fuego docker run -it \ -p 8080:8080 \ -v $(pwd)/host_fuego_home:/var/fuego_home \ -e JENKINS_UID=$(id -u) \ -e JENKINS_GID=$(id -g) \ -v /var/run/docker.sock:/var/run/docker.sock \ fuegotest/fuego:latest ```Wait for the shell to be available and add fuego-test board and Functional.fuegotest as explained in the last section.
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```You can also run the test in standalone mode (given that you have all the dependencies installed in your system). See the test README.md for more instructions.
Thanks.
Guilherme Campos Camargo (14):
Add a SeleniumCommand that compares screenshots
Minor style fix
Add a CheckScreenshot command into theCOMMANDS_TO_TESTlist Increase the size of the webdriver viewport
Allowworking_dirandinstall_dirsto be different Prevent exception NameError when removing container
Add an example reference screenshot
Add helper script for taking element/full-page screenshots Add mask-img-path argument to CheckScreenshot for ignored areas Add a README.md
Allow Full viewport Screenshots
Allow compare-with-mask to work with ImageMagick 6 and ImageMagick 7 Improve logging
Set logging level to INFO by default.../Functional.fuego_release_test/README.md | 182 +++++++++ .../fuego_test.sh | 6 +- .../helpers/take_screenshot.py | 145 ++++++++ .../screenshots/footer.png | Bin 0 -> 7371 bytes .../screenshots/footer_mask.png | Bin 0 -> 302 bytes .../screenshots/full_screenshot.png | Bin 0 -> 46323 bytes .../screenshots/full_screenshot_mask.png | Bin 0 -> 10717 bytes .../screenshots/side-panel-tasks.png | Bin 0 -> 9609 bytes .../Functional.fuego_release_test/test_run.py | 347 ++++++++++++++++-- 9 files changed, 639 insertions(+), 41 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/README.md create mode 100755 engine/tests/Functional.fuego_ release_test/helpers/take_screenshot.py create mode 100644 engine/tests/Functional.fuego_ release_test/screenshots/footer.png create mode 100644 engine/tests/Functional.fuego_ release_test/screenshots/footer_mask.png create mode 100644 engine/tests/Functional.fuego_ release_test/screenshots/full_screenshot.png create mode 100644 engine/tests/Functional.fuego_ release_test/screenshots/full_screenshot_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/side-panel-tasks.png
--
2.17.0
These look good. I've applied all 14 patches, and pushed them to my master branch.
I have a few questions, which I'll raise in response to individual patches.
Thanks!
-- Tim
Quoted 156 lines
-----Original Message-----
From: Guilherme Campos Camargo
Hello, everyone.This series of patches adds a new test case class to the
fuego_release_testfunctional test. The name of this new test class is "CheckScreenshot", and its purpose is to get a screenshot of a web-page (in this specific case, Fuego's Jenkins' webpage) and compare it with a reference image.Currently, CheckScreenshot supports:
- Taking screenshot of an HTML element of a page and compare it with a reference image.
- Taking screenshot of the full viewport (full page if it fits in the viewport) and also compare it with a reference image.
- Take a screenshot (full or element) and compare only specific regions of interest with a reference image. The mask is a black-and-white image in which black regions are ignored by the comparison algorithm.On these patches we have also added a helper script (
take_screenshot.py) that may be used for collecting reference screenshots and a few test cases to serve as example of usage.A README.md file has also been to explain the usage of
fuego_release_testand the helper script, including a few examples.# Running
Currently this test requires a modified version of Fuego to be executed, given that it needs to install some dependencies and needs to map the dockerd socket from the host to the fuego container.
The modified version can be found in two different branches on Profusion's fuego fork.
1 - Branch master: Just a few commits that are necessary for making this test work, applied on top of fuego/next. We plan to try to integrate these commits into fuego/next in the future.
2 - Branch fuego-base-image: A more complex change on fuego, that makes the necessary changes for allowing it to be shipped as a docker image through dockerhub.
The steps for each one of the versions above are given below:
## Building the image (from the branch fuego-test)
To run the test, execute the following commands:
``` git clone --branch master https://bitbucket.org/profusionmobi/fuego- core.git git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego.git cd fuego ./install fuego-to-test-fuego ./fuego-host-scripts/docker-create-container.sh fuego-to-test-fuego fuego- to-test-fuego-container ./fuego-host-scripts/docker-start-container.sh fuego-to-test-fuego- container ```Then, add the fuego-test board and the Functional.fuegotest and start the test through Jenkins (localhost:8080/fuego/)
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```## Using the modified Fuego Base Image from Dockerhub (fuego-base-image):
You can also use the fuego base image that's being developed in Profusion's fuego-base-image branch in our fork:
https://bitbucket.org/profusionmobi/fuego/branch/fuego-base-imageThe image is already available on dockerhub and can be downloaded/executed with:
``` docker pull fuegotest/fuego docker run -it \ -p 8080:8080 \ -v $(pwd)/host_fuego_home:/var/fuego_home \ -e JENKINS_UID=$(id -u) \ -e JENKINS_GID=$(id -g) \ -v /var/run/docker.sock:/var/run/docker.sock \ fuegotest/fuego:latest ```Wait for the shell to be available and add fuego-test board and Functional.fuegotest as explained in the last section.
``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ```You can also run the test in standalone mode (given that you have all the dependencies installed in your system). See the test README.md for more instructions.
Thanks.
Guilherme Campos Camargo (14):
Add a SeleniumCommand that compares screenshots
Minor style fix
Add a CheckScreenshot command into theCOMMANDS_TO_TESTlist Increase the size of the webdriver viewport
Allowworking_dirandinstall_dirsto be different Prevent exception NameError when removing container
Add an example reference screenshot
Add helper script for taking element/full-page screenshots Add mask-img-path argument to CheckScreenshot for ignored areas Add a README.md
Allow Full viewport Screenshots
Allow compare-with-mask to work with ImageMagick 6 and ImageMagick 7 Improve logging
Set logging level to INFO by default.../Functional.fuego_release_test/README.md | 182 +++++++++ .../fuego_test.sh | 6 +- .../helpers/take_screenshot.py | 145 ++++++++ .../screenshots/footer.png | Bin 0 -> 7371 bytes .../screenshots/footer_mask.png | Bin 0 -> 302 bytes .../screenshots/full_screenshot.png | Bin 0 -> 46323 bytes .../screenshots/full_screenshot_mask.png | Bin 0 -> 10717 bytes .../screenshots/side-panel-tasks.png | Bin 0 -> 9609 bytes .../Functional.fuego_release_test/test_run.py | 347 ++++++++++++++++-- 9 files changed, 639 insertions(+), 41 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/README.md create mode 100755 engine/tests/Functional.fuego_release_test/helpers/take_screenshot.py create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot.p ng create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot_ mask.png create mode 100644engine/tests/Functional.fuego_release_test/screenshots/side-panel- tasks.png
--
2.17.0_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Thanks, Tim, will reply to those.
--
Guilherme
Quoted 167 lines · On Wed, Apr 25, 2018 at 8:10 PM, <[email protected]> wrote:
These look good. I've applied all 14 patches, and pushed them to my master branch.
I have a few questions, which I'll raise in response to individual patches.
Thanks!
-- TimQuoted 46 lines
-----Original Message-----
From: Guilherme Campos Camargo
Hello, everyone.This series of patches adds a new test case class to the
fuego_release_testfunctional test. The name of this new test class is "CheckScreenshot", and its purpose is to get a screenshot of a web-page (in this specific case, Fuego's Jenkins' webpage) and compare it with a reference image.Currently, CheckScreenshot supports:
- Taking screenshot of an HTML element of a page and compare it with a reference image.
- Taking screenshot of the full viewport (full page if it fits in the viewport) and also compare it with a reference image.
- Take a screenshot (full or element) and compare only specific regions of interest with a reference image. The mask is a black-and-white image in which black regions are ignored by the comparison algorithm.On these patches we have also added a helper script (
take_screenshot.py) that may be used for collecting reference screenshots and a few test cases to serve as example of usage.A README.md file has also been to explain the usage of
fuego_release_testand the helper script, including a few examples.# Running
Currently this test requires a modified version of Fuego to be executed, given that it needs to install some dependencies and needs to map the dockerd socket from the host to the fuego container.
The modified version can be found in two different branches on Profusion's fuego fork.
1 - Branch master: Just a few commits that are necessary for making this test work, applied on top of fuego/next. We plan to try to integrate these commits into fuego/next in the future.
2 - Branch fuego-base-image: A more complex change on fuego, that makes the necessary changes for allowing it to be shipped as a docker image through dockerhub.
The steps for each one of the versions above are given below:
Quoted 8 lines
## Building the image (from the branch fuego-test)
To run the test, execute the following commands:
```
git clone --branch master https://bitbucket.org/profusionmobi/fuego-
core.git
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego.git
Quoted 3 lines
cd fuego
./install fuego-to-test-fuego./fuego-host-scripts/docker-create-container.shfuego-to-test-fuegofuego-
Quoted 99 lines
to-test-fuego-container
./fuego-host-scripts/docker-start-container.shfuego-to-test-fuego- container``` Then, add the fuego-test board and the Functional.fuegotest and start the test through Jenkins (localhost:8080/fuego/) ``` ftc add-nodes fuego-test ftc add-jobs -b fuego-test -t Functional.fuegotest ``` ## Using the modified Fuego Base Image from Dockerhub (fuego-base-image): You can also use the fuego base image that's being developed in Profusion's fuego-base-image branch in our fork: https://bitbucket.org/profusionmobi/fuego/branch/fuego-base-image The image is already available on dockerhub and can be downloaded/executed with: ```docker pull fuegotest/fuego
docker run -it \
-p 8080:8080 \
-v $(pwd)/host_fuego_home:/var/fuego_home \
-e JENKINS_UID=$(id -u) \
-e JENKINS_GID=$(id -g) \
-v /var/run/docker.sock:/var/run/docker.sock \
fuegotest/fuego:latest``` Wait for the shell to be available and add fuego-test board and Functional.fuegotest as explained in the last section. ```ftc add-nodes fuego-test
ftc add-jobs -b fuego-test -t Functional.fuegotest ```You can also run the test in standalone mode (given that you have all the dependencies installed in your system). See the test README.md for more instructions.
Thanks.
Guilherme Campos Camargo (14):
Add a SeleniumCommand that compares screenshots
Minor style fix
Add a CheckScreenshot command into theCOMMANDS_TO_TESTlist Increase the size of the webdriver viewport
Allowworking_dirandinstall_dirsto be different Prevent exception NameError when removing container
Add an example reference screenshot
Add helper script for taking element/full-page screenshots Add mask-img-path argument to CheckScreenshot for ignored areas Add a README.md
Allow Full viewport Screenshots
Allow compare-with-mask to work with ImageMagick 6 and ImageMagick 7 Improve logging
Set logging level to INFO by default.../Functional.fuego_release_test/README.md | 182 +++++++++ .../fuego_test.sh | 6 +- .../helpers/take_screenshot.py | 145 ++++++++ .../screenshots/footer.png | Bin 0 -> 7371 bytes .../screenshots/footer_mask.png | Bin 0 -> 302 bytes .../screenshots/full_screenshot.png | Bin 0 -> 46323 bytes .../screenshots/full_screenshot_mask.png | Bin 0 -> 10717 bytes .../screenshots/side-panel-tasks.png | Bin 0 -> 9609 bytes .../Functional.fuego_release_test/test_run.py | 347 ++++++++++++++++-- 9 files changed, 639 insertions(+), 41 deletions(-) create mode 100644 engine/tests/Functional.fuego_release_test/README.md create mode 100755 engine/tests/Functional.fuego_release_test/helpers/take_screenshot.py create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/footer_mask.png create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot.p ng create mode 100644 engine/tests/Functional.fuego_release_test/screenshots/full_screenshot_ mask.png create mode 100644engine/tests/Functional.fuego_release_test/screenshots/side-panel- tasks.png
--
2.17.0_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego