Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

travis: build and test webui as new build environment #97

Merged
merged 5 commits into from
Oct 9, 2018
Merged

travis: build and test webui as new build environment #97

merged 5 commits into from
Oct 9, 2018

Conversation

thraizz
Copy link
Contributor

@thraizz thraizz commented Jul 19, 2018

  • Modify travis files to build the webui as new environment
  • Modify selenium test to test the webui over saucelabs if built over travis
  • Clean dead code in webui
  1. Travis CI builds the core and webui components over multiple build.
  2. The separated webui build executes a proxy service for Saucelabs, called Sauce Connect.
  3. It also executes Selenium Tests. These selenium tests don't open a browser instance for executing commands on the webui, they open a remote connection that handles the commands.
  4. The remote connection goes out of the Travis build and into Saucelabs, which spawns browser instances that connect into the travis build over the open proxy.

How it works as a diagram
Latest build in private travis
Example webui test in Saucelabs

Copy link
Contributor Author

@thraizz thraizz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain the changes in detail for faster approval 😸

.travis.yml Outdated
sauce_connect: true
apt:
packages:
- libjansson-dev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional build environment for webui is build with postgresql database, sets BUILD_WEBUI to true, requires the sauce_connect addon and depends on libjannson-dev package

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add libjannson-dev to the general Debian build dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Into the dependencies handed out over downloads.bareos.org ? Or in the general travis build dependencies ? If you meant the first, I'll ask tomorrow how to do so.

sudo xargs --arg-file /tmp/build_depends apt-get -q --assume-yes install fakeroot
dpkg -l
sed -e "s/^.*:.*:\s//" -e "s/\s([^)]*)//g" -e "s/|/ /g" -e "s/ /\n/g" /tmp/dpkg-builddeps > /tmp/build_depends
sudo apt-get -q --assume-yes install fakeroot
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex for scanning the build dependencies had to be modified as the pipe in the webui dependencies (apache2-dev | apache2-prefork-dev ) resulted in errors

@@ -10,7 +10,7 @@
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets by Bill Allombert 2001

BAREOS_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' )
BAREOS_VERSION := $(shell sed -n 2p ../core/src/include/version.h | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version that was generated out of the debian/changelog file came from webui/packaging/obs/bareos-webui.changes. This file is no longer maintained so I get the bareos version out of another file.

self.driver = webdriver.Remote(
desired_capabilities=self.desired_capabilities,
command_executor=sauce_url % (self.sauce_username, self.access_key)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens the connection into saucelabs. The desired_capabilities can be extended to use more platforms than just chrome on os x.

job_id = self.job_start_configured()
self.job_cancel(job_id)
self.logout()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this in the git diff, I will add this back into the pull request.

pass
else:
return chromedriverpath

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new method searches for the right path where the chromedriver is located. On os x, /usr/lib/ is reserved for system access only. /usr/local/lib is the right path.

self.assertEqual([], self.verificationErrors)
else:
self.driver.quit()
self.assertEqual([], self.verificationErrors)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.exc_info() is pythons method to check if exceptions were thrown. If there were none we pass the test success to saucelabs by using the sauceclient module.

SeleniumTest.username = 'citest'
SeleniumTest.password = 'citestpass'
SeleniumTest.sauce_username = os.environ.get('SAUCE_USERNAME')
SeleniumTest.access_key = os.environ.get('SAUCE_ACCESS_KEY')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the test variables different if we are currently in a travis build.
SAUCE_USERNAME and SAUCE_ACCESS_KEY need to be set in Travis' build settings so that they will not be exposed.

Copy link
Member

@joergsteffens joergsteffens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides my comments: nice work

.travis.yml Outdated
sauce_connect: true
apt:
packages:
- libjansson-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add libjannson-dev to the general Debian build dependencies.

.travis/all Outdated
export BAREOS_CLIENT_NAME=$HOSTNAME-fd
echo "--------- testing webui over selenium -----------"
echo "configure add console name=citest password=citestpass profile=webui-admin" | bconsole
python /home/travis/build/thraizz/bareos/webui/tests/selenium/webui-selenium-test.py -v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full path is dangerous. And this will not work after merge.

@@ -1,12 +1,20 @@
#!/bin/bash

sudo apt-get -qq update
sudo pip install selenium sauceclient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these not available as Deb packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because they are python modules. The installation and binding handling is always handled by pip.

@@ -9,24 +9,40 @@ print_header()
}

cd core
if [ "${COVERITY_SCAN}" ]; then
if [ "${COVERITY_SCAN}" ]
then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes was not required and does not look better.

@thraizz
Copy link
Contributor Author

thraizz commented Jul 19, 2018

I applied most of the changes and will correct the bareos-webui dependencies tomorrow.
I also rebased ontop of master, again.

thraizz referenced this pull request Jul 19, 2018
Changes no longer tracked in this place.
@joergsteffens
Copy link
Member

joergsteffens commented Jul 20, 2018 via email

@joergsteffens
Copy link
Member

joergsteffens commented Jul 20, 2018 via email

@thraizz
Copy link
Contributor Author

thraizz commented Jul 20, 2018

I will need to revert the installation process of selenium back to installation via pip, as the apt package does not contain selenium.webdriver components. We rely heavily on those, for example all expected conditions are imported out of those components. This is also documented here:
https://packages.debian.org/en/sid/python-selenium

EDIT: The build confirms this; https://travis-ci.org/thraizz/bareos/jobs/406182788#L5024

@thraizz
Copy link
Contributor Author

thraizz commented Jul 26, 2018

  • Rebased on top of master
  • Commit for webui build fix dropped as it was fixed
  • Adds saucelabs badge into the readme

The readme currently contains the saucelabs badge two times. @joergsteffens, choose what looks better, @fbergkemper recommended to add it as a new sponsors section. Maybe we can put it into the SPONSORS.md?

README.md Outdated
@@ -1,6 +1,7 @@
# <img src="https://raw.githubusercontent.com/bareos/bareos/master/webui/public/img/bareos.png" alt="Bareos" />

[![Build Status](https://travis-ci.org/bareos/bareos.png?branch=master)](https://travis-ci.org/bareos/bareos/branches)

[![Build Status](https://travis-ci.org/bareos/bareos.png?branch=master)](https://travis-ci.org/bareos/bareos/branches)<br><a href="https://www.saucelabs.com/"> <img src="webui/public/img/saucelabs_white_badge.svg" alt="Saucelabs" width="90px"/></a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the recommend way to handle this? Not using img src, that refers to an icon provided by sauce Lab? Also, wouldn't it be better to link to our sauce Lab test results?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was only sent to me via email, but I've found it hosted by them. The link will point to our sauce lab results as soon as they go live, I've noted this on my todo list.

[Aron Schueler] added 2 commits August 30, 2018 14:29
- Modify travis files to build the webui as new environment
- Modify selenium test to test the webui over saucelabs if built over travis
- Clean dead code in webui
@joergsteffens joergsteffens self-assigned this Oct 4, 2018
@joergsteffens
Copy link
Member

Unfortunately, the selenium test do all fail: https://travis-ci.org/bareos/bareos/jobs/437528496
Do you have an explanation for this?

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

Python client can't use urllib3 to parse our webcontent. As a solution, we should upgrade both pip (as we use v9.x when there's v18 available) and urllib3 to newest version. I'll do this in the travis_before_script soon as I get home from university 👍

EDIT: line 475-493 in the log you posted contain some warnings about what I expected, urllib3 seems to be outdated.

- Fix an error where python was not able to decode body content due to an older version of urllib3.
@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

I needed to specify to use urllib3 at version 1.22 as python requests dont like versions above (latest is 1.23) or below:
requests 2.18.4 has requirement urllib3<1.23,>=1.21.1, but you'll have urllib3 1.23 which is incompatible.

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

This is a bit difficult to reproduce as my travis builds always fail without a paid saucelabs subscription, but I believe that the commit fixes the failures (and also just run pip commands when we're going to need sauceclient and selenium)
https://travis-ci.org/thraizz/bareos/jobs/438988236

@joergsteffens
Copy link
Member

Luckily your commits are tested by Travis / SauceLabs inside this Pull Request. It still fails, however, the error message has changed. Can you please take another look at it?
I wondering, what have changed as it succeeded Travis before in your branch, right?

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

This is due to security rules of travis, as stated here:

Encrypted variables are not available to untrusted builds such as pull requests coming from another repository.

@joergsteffens joergsteffens merged commit cb4f22b into bareos:master Oct 9, 2018
@joergsteffens
Copy link
Member

I see. So I merged it now to check the status after merge.

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

The tests can be skipped if we add @unittest.skipIf followed by a nice condition, before the unittest class starts. The condition should check if the env var TRAVIS_PULL_REQUEST is set and not false, if both are true we will skip the test case and exit with 0. Something like

@unittest.skipIf((os.environ.get('TRAVIS_PULL_REQUEST') != 'false' and os.environ.get('TRAVIS_PULL_REQUEST') != 'None'), 'Pull requests are not tested.')
would work but doesn't look too good...

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

@joergsteffens
Copy link
Member

One reason for the problems have been, that enviroment variables have not been set in our travis environment. It also needed the variable TRAVIS to be set. Now the sauce connect seams to work fine.
However, another problem did arise, see https://travis-ci.org/bareos/bareos/jobs/439190518:

AttributeError: 'SeleniumTest' object has no attribute 'driver'

Can you please check on that?

@thraizz
Copy link
Contributor Author

thraizz commented Oct 9, 2018

As TRAVIS is a default environment value I thought we could depend on, seems like we can't.
The test fails because all if-conditions for driver determination were false, so no driver was set. Locally they work absolutely fine - tested with travis env vars set and also just with BAREOS_BROWSER=chrome. You could investigate why TRAVIS env is not true or do e.g. BUILD_WEBUI == true instead, we set that env explicitly.

The get_env() method could look like this for saucelabs part:

if(os.environ.get('BUILD_WEBUI') == 'true'):
            sauce_username = os.environ.get('SAUCE_USERNAME')
            access_key = os.environ.get('SAUCE_ACCESS_KEY')
            if sauce_username and access_key:
                SeleniumTest.sauce_username = sauce_username
                SeleniumTest.access_key = access_key
            else:
                raise ValueError("SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables not set.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants