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

Gentoo Integration Tests #115

Merged
merged 36 commits into from
Jan 17, 2018
Merged

Gentoo Integration Tests #115

merged 36 commits into from
Jan 17, 2018

Conversation

allenh1
Copy link
Collaborator

@allenh1 allenh1 commented Jan 10, 2018

Opening for visibility. This is very, very rough.

Step one here (to me, at least) is to get docker to update a Gentoo image to be ready to emerge ros-lunar/ros_base, which is currently hard-coded into the script.

Not sure if this is working, as we are emerging ~300 packages after the USE flag changes, so I'll report back whenever that finishes (hopefully no webkit).

@allenh1 allenh1 self-assigned this Jan 10, 2018
@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 11, 2018

@tfoote This is the current testing framework. Do you think this will suffice?

allenh1@hunter-laptop ~/work/superflore
$ python3
Python 3.5.4 (default, Nov 11 2017, 15:58:51) 
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from superflore.test_integration.gentoo.build_base import GentooBuilder
>>> bob = GentooBuilder()
>>> bob.add_target('indigo', 'catkin')
>>> bob.run()
>>>> testing gentoo package integrity
>>>> testing package 'ros-indigo/catkin'
>>>> Running container with command string 'bash -c 'emaint sync -r ros-overlay && emerge ros-indigo/catkin''...
>>>> Docker container exited.
>>>> 'ros-indigo/catkin': building
{'ros-indigo/catkin': 'building'}

@tfoote
Copy link
Member

tfoote commented Jan 11, 2018

That looks reasonable. Where building means that it successfully builds? Then it will be trivial to create a nose test for a select set of packages.

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 11, 2018

allenh1@hunter-laptop ~/work/superflore
$ python3                        
Python 3.5.4 (default, Nov 11 2017, 15:58:51) 
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from superflore.test_integration.gentoo.build_base import GentooBuilder
>>> bob = GentooBuilder()
>>> bob.add_target('indigo', 'fake_package')
>>> bob.add_target('indigo', 'catkin')
>>> bob.run()
>>>> testing gentoo package integrity
>>>> testing package 'ros-indigo/catkin'
>>>> Running container with command string 'bash -c 'emaint sync -r ros-overlay && emerge ros-indigo/catkin''...
>>>> Docker container exited.
>>>> 'ros-indigo/catkin': building
>>>> testing package 'ros-indigo/fake_package'
>>>> Running container with command string 'bash -c 'emaint sync -r ros-overlay && emerge ros-indigo/fake_package''...
!!!! 'ros-indigo/fake_package': failing
{'ros-indigo/catkin': 'building', 'ros-indigo/fake_package': 'failing'}

Newly fixed output.

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 11, 2018

That looks reasonable. Where building means that it successfully builds?

Yes.

Then it will be trivial to create a nose test for a select set of packages.

That's how I'm seeing it, at least. This tech has already proven itself invaluable.

I think there should be a follow-up PR with the actual test mechanism built into it. My current thought is that the list is saved in the branch we are testing on the overlay, gento-bot-[random-ascii], and then superflore will be run by travis (or other CI) to check the PR.

Something like this:

superflore-check-ebuilds -f [ebuild-file]

As an added advantage, this may be run locally.

superflore-check-ebuilds ros-indigo/desktop_full ros-kinetic/desktop_full ros-lunar/desktop_full

def build(self):
if not self.dockerfile_directory:
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the only place that the dockerfile is used so maybe it should be an argument for this method instead of a constructor argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that's a good point.

@@ -20,9 +20,10 @@


class Docker(object):
def __init__(self, dockerfile, name):
def __init__(self, dockerfile=None, name=None):
Copy link
Member

Choose a reason for hiding this comment

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

I don't see self.name being used anywhere is it necessary here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess I missed that. It certainly isn't used.

@allenh1 allenh1 requested a review from tfoote January 11, 2018 22:00
Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

Two small comments. And it would be good to have some simple tests for pull and build.


def build(self, dockerfile):
dockerfile_directory = os.path.dirname(dockerfile)
if not dockerfile_directory:
Copy link
Member

Choose a reason for hiding this comment

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

This check doesn't seem right at the moment. It should somehow verify that the Dockefile is a valid dockerfile not that the directory exists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I meant that you should not just check that it's a directory but check that the Dockerfile itself exists. (aka check the file that is passed exists and then lookup the directory to pass on.) And even better would be to see if the Dockerfile parses/validates but that's extra.

@@ -18,14 +18,12 @@

class TestDocker(unittest.TestCase):
def get_image(self):
docker_file = resource_filename('repoman_docker', 'Dockerfile')
dock = Docker(docker_file, 'gentoo_repoman')
dock = Docker()
Copy link
Member

Choose a reason for hiding this comment

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

This whole function seems outdated now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was keeping it for legacy reasons. ;)

Removed.

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 13, 2018

@tfoote new coverage report.

allenh1@hunter-laptop ~/work/superflore
$ coverage run --source=superflore -m nose && coverage report -m
.............................
----------------------------------------------------------------------
Ran 29 tests in 2.391s

OK
Name                                               Stmts   Miss  Cover   Missing
--------------------------------------------------------------------------------
superflore/CacheManager.py                            20     13    35%   23-24, 28-33, 37-41
superflore/TempfileManager.py                         34     12    65%   32-37, 48-56
superflore/__init__.py                                10      4    60%   5-8
superflore/docker.py                                  40     26    35%   24-27, 30-32, 35, 38, 41-47, 50, 53-69, 74
superflore/exceptions.py                              12      3    75%   18, 28, 33
superflore/generate_installers.py                     57     48    16%   32-86
superflore/generators/__init__.py                      0      0   100%
superflore/generators/bitbake/__init__.py              3      1    67%   3
superflore/generators/bitbake/gen_packages.py        115     92    20%   40-103, 110-166, 174-182, 188
superflore/generators/bitbake/ros_meta.py             27     18    33%   24-27, 30-35, 38-51, 54-55
superflore/generators/bitbake/run.py                 113     94    17%   39-44, 51-199
superflore/generators/bitbake/yocto_recipe.py        112     92    18%   43-64, 67, 70-74, 77-89, 92-96, 99-101, 104-105, 113-116, 125-177
superflore/generators/ebuild/__init__.py               3      1    67%   3
superflore/generators/ebuild/ebuild.py               143      7    95%   125-127, 131-136
superflore/generators/ebuild/gen_packages.py         151    125    17%   45-113, 118-150, 155-211, 216-233, 236, 239
superflore/generators/ebuild/metadata_xml.py          33      0   100%
superflore/generators/ebuild/overlay_instance.py      37     25    32%   27-32, 35-45, 48-64, 67-68
superflore/generators/ebuild/run.py                  157    137    13%   40-43, 47-52, 59-250
superflore/repo_instance.py                           49     34    31%   26-35, 38-46, 49-57, 63, 69, 75, 81, 84-91
superflore/rosdep_support.py                          34      2    94%   83-84
superflore/test_integration/__init__.py                0      0   100%
superflore/test_integration/gentoo/__init__.py         0      0   100%
superflore/test_integration/gentoo/build_base.py      27     27     0%   15-51
superflore/utils.py                                  118     41    65%   50, 54-59, 108, 114, 121-124, 126, 132, 138-139, 144, 148-149, 156-177
--------------------------------------------------------------------------------
TOTAL                                               1295    802    38%

EDIT: Ok, I'm actually not sure why it's not counting most of the docker.py file. Do you have any idea why that would be the case?

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 13, 2018

Figured it out. If you have a folder named test_thing and a test_thing.py file, the tests are not run. I'm going to see if this is an issue with the latest version of nose.

@allenh1 allenh1 removed the request for review from tfoote January 13, 2018 19:36
@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 14, 2018

The issue here seems to be an authentication error, since one needs to login before they can pull. As such, I'm adding a login function to the Docker class, as well as looking into OAuth for CI login.

@tfoote
Copy link
Member

tfoote commented Jan 17, 2018

ubuntu is an official repository so it doesn't have an organization/username element to the image you should use ubuntu:xenial as xenial is the tag

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 17, 2018

it doesn't have an organization/username element to the image you should use ubuntu:xenial as xenial is the tag

Yep, figured it was just me. Thanks! Working fine now.

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 17, 2018

@tfoote Travis is really slow atm, but I suspect this one will pass.

for pkg in sorted(self.package_list.keys()):
self.container.add_bash_command('emaint sync -r ros-overlay')
self.container.add_bash_command('emerge %s' % pkg)
self.conainter.login()
Copy link
Member

Choose a reason for hiding this comment

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

spelling conainter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. That line didn't need to be there in the first place, actually.

def login(self):
# TODO(allenh1): add OAuth here, and fall back on user input
# if the OAuth doesn't exist (however one finds that).
user = getpass('Docker user:')
Copy link
Member

Choose a reason for hiding this comment

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

Does this fallback if in non-interactive shells?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope. No it does not. I'll use the environment variables I set on the CI if they are available, then do a os.isatty(0) to throw an exception if they aren't on a tty.

@@ -0,0 +1,52 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

This whole file is not used yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not at the moment. My plan was to use it in a follow up PR (since we're many commits in at this point).

But I suppose I can start the superflore-check-ebuilds in this PR.

@allenh1
Copy link
Collaborator Author

allenh1 commented Jan 17, 2018

@tfoote Ok, added the superflore-check-ebuilds command. I've got some documenting to do.

…er to use extended permissions (such as SYS_PTRACE, which is needed for building glibc).
@allenh1 allenh1 requested a review from tfoote January 17, 2018 18:12
@allenh1 allenh1 merged commit 59d1412 into master Jan 17, 2018
@allenh1 allenh1 deleted the add-gentoo-integration-test branch January 17, 2018 19:45
This was referenced Jan 29, 2018
zffgithub pushed a commit to zffgithub/superflore that referenced this pull request Apr 11, 2023
* superflore.docker.py: Add pull function, as well
as relax the requiered dockerfile directory arg
in the __init__ function.

* Add a GentooBuilder class that will spawn a docker container and attempt to build the requested target.

* Add a function to clear the bash commands.

* Add run function to build_base.py. This function tests each of the desired packages in the spawned docker container.

* Added output to run function.

* Refactor docker class to reduce parameters.


* Remove outdated code and fix build condition.

* Remove unused function.

* Add test docker build.

* Add test pull and test run.

* Fix typo in setup.py.

* Add a login function to the docker class

* Build the test Dockerfile to test the run function.

* Add tag flag to pull function.

* Add support for environment variable login and detection of a tty for login.

* Add a superflore-check-ebuilds command.

* Add support for the yaml file holding the packages to test.

* Document the new script.

* Add privileged flag to the run function to allow docker to allow docker to use extended permissions (such as SYS_PTRACE, which is needed for building glibc).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants