According to cjwatson, cdimage deals with projects, not distribution, fix TouchManifest accordingly.

Fix boottest-britney location to match production.
Fix TestTouchManifest test failures, now that we retry on manifest download errors, the tests should inhibit the retries when testing the failures.

5 out of the 8 TestBoottestEnd2End are still failing because the excuse says the tests are skipped instead of running/failing/being in progress, etc.
bzr-import-20160707
Vincent Ladeuil 10 years ago
parent 92a2156b10
commit 01fdb16995

@ -42,7 +42,7 @@ class TouchManifest(object):
Only binary name matters, version is ignored, so callsites can:
>>> manifest = TouchManifest('ubuntu', 'vivid')
>>> manifest = TouchManifest('ubuntu-touch', 'vivid')
>>> 'webbrowser-app' in manifest
True
>>> 'firefox' in manifest
@ -50,37 +50,42 @@ class TouchManifest(object):
"""
def __init__(self, distribution, series, verbose=False, fetch=True):
def __init__(self, project, series, verbose=False, fetch=True):
self.verbose = verbose
self.path = "boottest/images/{}/{}/manifest".format(
distribution, series)
project, series)
success = False
if fetch:
retries = FETCH_RETRIES
success = self.__fetch_manifest(distribution, series)
success = self.__fetch_manifest(project, series)
while retries > 0 and not success:
success = self.__fetch_manifest(distribution, series)
success = self.__fetch_manifest(project, series)
retries -= 1
if not success:
print("E: [%s] - Unable to fetch manifest: %s %s" % (
time.asctime(), distribution, series))
time.asctime(), project, series))
self._manifest = self._load()
def __fetch_manifest(self, distribution, series):
url = "http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/" \
"pending/{}-preinstalled-touch-armhf.manifest".format(series)
def __fetch_manifest(self, project, series):
url = "http://cdimage.ubuntu.com/{}/daily-preinstalled/" \
"pending/{}-preinstalled-touch-armhf.manifest".format(
project, series
)
success = False
if self.verbose:
print(
"I: [%s] - Fetching manifest from %s" % (
time.asctime(), url))
print("I: [%s] - saving it to %s" % (time.asctime(), self.path))
response = urllib.urlopen(url)
# Only [re]create the manifest file if one was successfully downloaded
# this allows for an existing image to be used if the download fails.
if response.code == 200:
if not os.path.exists(os.path.dirname(self.path)):
os.makedirs(os.path.dirname(self.path))
path_dir = os.path.dirname(self.path)
if not os.path.exists(path_dir):
os.makedirs(path_dir)
with open(self.path, 'w') as fp:
fp.write(response.read())
success = True
@ -125,7 +130,8 @@ class BootTest(object):
"RUNNING": '<span style="background:#99ddff">Test in progress</span>',
}
script_path = "boottest/jenkins/boottest-britney"
script_path = os.path.expanduser(
"~/auto-package-testing/jenkins/boottest-britney")
def __init__(self, britney, distribution, series, debug=False):
self.britney = britney
@ -137,7 +143,7 @@ class BootTest(object):
manifest_fetch = getattr(
self.britney.options, "boottest_fetch", "no") == "yes"
self.phone_manifest = TouchManifest(
self.distribution, self.series, fetch=manifest_fetch,
'ubuntu-touch', self.series, fetch=manifest_fetch,
verbose=self.britney.options.verbose)
@property

@ -17,11 +17,8 @@ import unittest
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, PROJECT_DIR)
import boottest
from tests import TestBase
from boottest import (
BootTest,
TouchManifest,
)
def create_manifest(manifest_dir, lines):
@ -36,7 +33,7 @@ class FakeResponse(object):
def __init__(self, code=404, content=''):
self.code = code
self.content = content
def read(self):
return self.content
@ -54,10 +51,15 @@ class TestTouchManifest(unittest.TestCase):
self.mocked_urlopen = _p.start()
self.mocked_urlopen.side_effect = [FakeResponse(code=404),]
self.addCleanup(_p.stop)
self.fetch_retries_orig = boottest.FETCH_RETRIES
def restore_fetch_retries():
boottest.FETCH_RETRIES = self.fetch_retries_orig
boottest.FETCH_RETRIES = 0
self.addCleanup(restore_fetch_retries)
def test_missing(self):
# Missing manifest file silently results in empty contents.
manifest = TouchManifest('ubuntu', 'vivid')
manifest = boottest.TouchManifest('I-dont-exist', 'vivid')
self.assertEqual([], manifest._manifest)
self.assertNotIn('foo', manifest)
@ -66,24 +68,24 @@ class TestTouchManifest(unittest.TestCase):
self.mocked_urlopen.side_effect = [
FakeResponse(code=200, content='foo 1.0'),
]
manifest = TouchManifest('ubuntu-touch', 'vivid')
manifest = boottest.TouchManifest('ubuntu-touch', 'vivid')
self.assertNotEqual([], manifest._manifest)
def test_fetch_disabled(self):
# Manifest auto-fetching can be disabled.
manifest = TouchManifest('ubuntu-touch', 'vivid', fetch=False)
manifest = boottest.TouchManifest('ubuntu-touch', 'vivid', fetch=False)
self.mocked_urlopen.assert_not_called()
self.assertEqual([], manifest._manifest)
def test_fetch_fails(self):
distribution = 'fake'
project = 'fake'
series = 'fake'
manifest_dir = os.path.join(self.imagesdir, distribution, series)
manifest_dir = os.path.join(self.imagesdir, project, series)
manifest_lines = [
'foo:armhf 1~beta1',
]
create_manifest(manifest_dir, manifest_lines)
manifest = TouchManifest(distribution, series)
manifest = boottest.TouchManifest(project, series)
self.assertEqual(1, len(manifest._manifest))
self.assertIn('foo', manifest)
@ -98,7 +100,7 @@ class TestTouchManifest(unittest.TestCase):
]
create_manifest(manifest_dir, manifest_lines)
manifest = TouchManifest('ubuntu', 'vivid')
manifest = boottest.TouchManifest('ubuntu', 'vivid')
# We can dig deeper on the manifest package names list ...
self.assertEqual(
['bar', 'boing1-1.2', 'foo'], manifest._manifest)
@ -243,7 +245,7 @@ args.func()
context,
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['RUNNING']),
boottest.BootTest.EXCUSE_LABELS['RUNNING']),
'<li>Not considered'])
# The `boottest-britney` input (recorded for testing purposes),
@ -266,7 +268,7 @@ args.func()
context,
[r'\bpyqt5-src\b.*\(- to .*>1.1~beta<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['PASS']),
boottest.BootTest.EXCUSE_LABELS['PASS']),
'<li>Valid candidate'])
def test_fail(self):
@ -281,7 +283,7 @@ args.func()
context,
[r'\bpyqt5-src\b.*\(- to .*>1.1<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['FAIL']),
boottest.BootTest.EXCUSE_LABELS['FAIL']),
'<li>Not considered'])
def create_hint(self, username, content):
@ -321,7 +323,7 @@ args.func()
context,
[r'\bpyqt5-src\b.*\(- to .*>1.1<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['FAIL']),
boottest.BootTest.EXCUSE_LABELS['FAIL']),
'<li>Should wait for pyqt5-src 1.1 boottest, '
'but forced by cjwatson',
'<li>Valid candidate'])
@ -337,7 +339,7 @@ args.func()
context,
[r'\bgreen\b.*>1</a> to .*>1.1~beta<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['RUNNING']),
boottest.BootTest.EXCUSE_LABELS['RUNNING']),
'<li>Should wait for green 1.1~beta boottest, but forced '
'by cjwatson',
'<li>Valid candidate'])
@ -354,7 +356,7 @@ args.func()
context,
[r'\bapache2-src\b.*\(- to .*>2.4.8-1ubuntu1<',
'<li>Boottest result: {}'.format(
BootTest.EXCUSE_LABELS['SKIPPED']),
boottest.BootTest.EXCUSE_LABELS['SKIPPED']),
'<li>Valid candidate'])
def test_skipped_architecture_not_allowed(self):

Loading…
Cancel
Save