fix apt-source test cases to run (or skip) in buildd environment

Bug #1589174 reported by Scott Moser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Christian Ehrhardt 

Bug Description

Christian added a bunch of tests under https://code.launchpad.net/~paelzer/cloud-init/test-apt-source/+merge/294521 .

Those failed to buidl first at [1] and then i patched a few of them under revno 1226 which made them work in my local sbuild environment. But they still failed in buildd environment at [2].

I'm going to just skip the last failing test so i can get an upload, but want to fix these tests to either mock more or disable/skip conditionally if that is right.

[1] https://launchpad.net/ubuntu/+source/cloud-init/0.7.7~bzr1225-0ubuntu1
[2] https://launchpad.net/ubuntu/+source/cloud-init/0.7.7~bzr1226-0ubuntu1/+build/

Related branches

Scott Moser (smoser)
Changed in cloud-init:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi,
sorry - I missed to test in that kind of isolated environments on the merge.

Thanks for faking the get_release, as you have seen in test_handler_apt_configure_sources_list.py I already cared about being release independent (but only thought on release independence, not unavailability of lsb_release back then).

To summarize what we have to cover now:
1. getkeybyid will only work in network enabled environments that can reach keyserver.ubuntu.com (Note that I already avoided to use non .ubuntu.com addresses in the test)
=> We need to restore (undo the mocking of getkeybyid) in a way that it will work in network capable environments, but gracefully skip in others.

2. The capability to make the tests independent to a underlying ubuntu/debian environment. That in my opinion is a bit special, as all of the feature that it tests is debian/ubuntu special (apt / apt-key)
=> still it should detect and fail gracefully in those cases.

First I had to try recreate without bothering LP each time, I chose - if I go into it I can make it better anyway - and added a test for a third party keyserver.
Using that with a bad KS intentionally I had a test for failing network.

Also this was the right time to re-include the improvements we made when thinking through the same thing on the curtin side of things.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I finally found your skipIf (not in bzr, but in the last upload).
+ @t_help.skipIf(True, "LP: #1589174")
Is a bit too generic :-)

That is actually no dependency to the local Debian/Ubuntu filesystem layout as we first assumed - but instead happening in generate_sources_list.

That should actually always happen except:
- apt_configure_enabled = False
- apt_preserve_sources_list = True
- the specific path depends on apt_custom_sources_list OR is template_fn = cloud.get_template_filename('sources.list.%s' % (cloud.distro.name))

None of the first two apply, distro name is Debian.
But what I didn't expect can be seen in the log:
tests.unittests.test_handler.test_handler_apt_configure_sources_list: DEBUG: Skipping module named notimportant, no package 'mirror' located

That means in this particular case find_apt_mirror_info failed which I didn't expect - looking into it.

That said we might still (if you want) guard quite a lot of the tests with soemthing like "if apt is here" as the feature and thereby the tests only make sens in that case.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Ah btw - I think I have the networking issue in the test handled, it unittests via network, detects issues and falls back to a fake key.
So we test as good as possible in any given environment.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I will need to reproduce that failing test_apt_srcl_debian_mirrorfail in the failing environment to see why find_apt_mirror_info fails there.

Is the packaging as easy as throwing the /debian I can get from a pull-lp into the curtin dir or are there special tricks to know when wanting to adt/ppa build a custom curtin bzr branch?

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

For the Ubunut/Debian dependency I added:

BIN_APT = "/usr/bin/apt"
# This feature is apt specific and thereby is disabled in environments without
@t_help.skipIf(not os.path.isfile(BIN_APT), "no apt")

On both classes.
If we ever add isolated tests for the gpg portion that will be distribution neutral, but the skipIf as written will prevent that non Ubunut/Debian reuse will run into issues due to the unittests.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

That only leaves the "build in adt/ppa" for the yet unclear issue with find_apt_mirror_info until I can create an MP

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The last one was in fact a networking issue as well which just surfaced as this misleading:
AssertionError: isfile('/etc/cloud/templates/sources.list.debian.tmpl') call not found

The test it happens is there to check the code for networking fallback.
Yet due to no networking there was no fallback left.

It is now skipped in case it can't reach the intended fallback, looking like this:
Test rendering of a source.list from template for debian ... SKIP: Test skipped: no network connectivity to httpredir.debian.org

That way it tests nicely on all environments where it is possible but avoids issues in locked down environments.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

my test just built fine in https://launchpad.net/~paelzer/+archive/ubuntu/derived-repository-testbuilds/+packages

It is now time to look at CentOS in a container ...

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tested and added fixes for CentOS as discussed.

Changed in cloud-init:
assignee: nobody → ChristianEhrhardt (paelzer)
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Confirmed → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.