2015-08-11 11:44:26 -04:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
import abc
|
2016-01-08 19:18:56 +08:00
|
|
|
import os
|
2015-10-13 06:57:21 +02:00
|
|
|
import sys
|
2015-08-11 11:44:26 -04:00
|
|
|
|
|
|
|
from mock import patch
|
|
|
|
from oslo_log import fixture as log_fixture
|
|
|
|
from oslo_log import log as logging
|
|
|
|
from oslotest import base
|
2016-01-08 19:18:56 +08:00
|
|
|
import testtools
|
2015-08-11 11:44:26 -04:00
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
sys.path.append(
|
|
|
|
os.path.abspath(os.path.join(os.path.dirname(__file__), '../tools')))
|
2016-06-06 11:37:45 +08:00
|
|
|
from kolla.image import build
|
2015-08-11 11:44:26 -04:00
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class BuildTest(object):
|
|
|
|
excluded_images = abc.abstractproperty()
|
2015-08-11 11:44:26 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(BuildTest, self).setUp()
|
|
|
|
self.useFixture(log_fixture.SetLogLevel([__name__],
|
|
|
|
logging.logging.INFO))
|
2016-01-12 20:52:00 +00:00
|
|
|
self.build_args = [__name__, "--debug", '--threads', '4']
|
2015-08-11 11:44:26 -04:00
|
|
|
|
2016-01-08 19:18:56 +08:00
|
|
|
@testtools.skipUnless(os.environ.get('DOCKER_BUILD_TEST'),
|
|
|
|
'Skip the docker build test')
|
2015-08-13 18:13:52 -04:00
|
|
|
def runTest(self):
|
|
|
|
with patch.object(sys, 'argv', self.build_args):
|
2015-12-29 15:26:45 +08:00
|
|
|
LOG.info("Running with args %s", self.build_args)
|
2016-05-25 04:04:52 -05:00
|
|
|
bad_results, good_results, unmatched_results = build.run_build()
|
2015-08-11 11:44:26 -04:00
|
|
|
|
|
|
|
failures = 0
|
2016-08-23 11:08:25 +08:00
|
|
|
for image, result in bad_results.items():
|
2015-10-13 06:57:21 +02:00
|
|
|
if image in self.excluded_images:
|
2015-08-11 11:44:26 -04:00
|
|
|
if result is 'error':
|
|
|
|
continue
|
|
|
|
failures = failures + 1
|
|
|
|
LOG.warning(">>> Expected image '%s' to fail, please update"
|
|
|
|
" the excluded_images in source file above if the"
|
2015-12-29 15:26:45 +08:00
|
|
|
" image build has been fixed.", image)
|
2015-08-11 11:44:26 -04:00
|
|
|
else:
|
|
|
|
if result is not 'error':
|
|
|
|
continue
|
|
|
|
failures = failures + 1
|
2015-12-29 15:26:45 +08:00
|
|
|
LOG.critical(">>> Expected image '%s' to succeed!", image)
|
2015-08-11 11:44:26 -04:00
|
|
|
|
2015-08-25 15:26:47 +00:00
|
|
|
for image in unmatched_results.keys():
|
2015-12-29 15:26:45 +08:00
|
|
|
LOG.warning(">>> Image '%s' was not matched", image)
|
2015-08-25 15:26:47 +00:00
|
|
|
|
2015-08-11 11:44:26 -04:00
|
|
|
self.assertEqual(failures, 0, "%d failure(s) occurred" % failures)
|
2015-08-13 18:13:52 -04:00
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class BuildTestCentosBinary(BuildTest, base.BaseTestCase):
|
2016-09-14 18:56:00 +00:00
|
|
|
excluded_images = ["kuryr-base",
|
2016-09-13 11:24:53 +01:00
|
|
|
"neutron-sfc-agent",
|
2016-07-04 12:47:07 +01:00
|
|
|
"senlin-base",
|
2016-08-12 13:27:27 +00:00
|
|
|
"vmtp",
|
2016-04-14 12:08:30 +05:30
|
|
|
"watcher-base",
|
2016-05-10 12:17:37 +01:00
|
|
|
"congress-base",
|
2016-08-01 00:12:13 +02:00
|
|
|
"bifrost-base",
|
|
|
|
"cloudkitty-base"]
|
2015-10-13 06:57:21 +02:00
|
|
|
|
2015-08-13 18:13:52 -04:00
|
|
|
def setUp(self):
|
2015-08-28 19:28:48 -07:00
|
|
|
super(BuildTestCentosBinary, self).setUp()
|
2015-08-13 18:13:52 -04:00
|
|
|
self.build_args.extend(["--base", "centos",
|
|
|
|
"--type", "binary"])
|
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class BuildTestCentosSource(BuildTest, base.BaseTestCase):
|
2016-07-28 14:28:20 +00:00
|
|
|
excluded_images = ["mistral-base"]
|
2015-10-13 06:57:21 +02:00
|
|
|
|
2015-08-13 18:13:52 -04:00
|
|
|
def setUp(self):
|
2015-08-28 19:28:48 -07:00
|
|
|
super(BuildTestCentosSource, self).setUp()
|
2015-08-16 13:01:08 -07:00
|
|
|
self.build_args.extend(["--base", "centos",
|
|
|
|
"--type", "source"])
|
|
|
|
|
|
|
|
|
2016-03-15 22:39:30 +08:00
|
|
|
class BuildTestUbuntuBinary(BuildTest, base.BaseTestCase):
|
2016-09-14 18:56:00 +00:00
|
|
|
excluded_images = ["kuryr-base",
|
2016-09-13 11:24:53 +01:00
|
|
|
"neutron-sfc-agent",
|
2016-08-22 16:49:51 +08:00
|
|
|
"senlin-base",
|
2016-08-12 13:27:27 +00:00
|
|
|
"vmtp",
|
2016-04-14 12:08:30 +05:30
|
|
|
"zaqar",
|
2016-08-22 16:49:51 +08:00
|
|
|
"watcher-base",
|
2016-05-10 12:17:37 +01:00
|
|
|
"congress-base",
|
2016-08-01 00:12:13 +02:00
|
|
|
"bifrost-base",
|
|
|
|
"cloudkitty-base"]
|
2016-03-15 22:39:30 +08:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(BuildTestUbuntuBinary, self).setUp()
|
|
|
|
self.build_args.extend(["--base", "ubuntu",
|
|
|
|
"--type", "binary"])
|
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class BuildTestUbuntuSource(BuildTest, base.BaseTestCase):
|
|
|
|
excluded_images = []
|
|
|
|
|
2015-08-16 13:01:08 -07:00
|
|
|
def setUp(self):
|
2015-08-28 19:28:48 -07:00
|
|
|
super(BuildTestUbuntuSource, self).setUp()
|
2015-08-16 13:01:08 -07:00
|
|
|
self.build_args.extend(["--base", "ubuntu",
|
2015-08-28 19:28:48 -07:00
|
|
|
"--type", "source"])
|
2015-10-13 07:01:07 +00:00
|
|
|
|
|
|
|
|
2016-03-01 15:33:46 +00:00
|
|
|
class BuildTestOracleLinuxBinary(BuildTest, base.BaseTestCase):
|
2016-09-14 18:56:00 +00:00
|
|
|
excluded_images = ["kuryr-base",
|
2016-09-13 11:24:53 +01:00
|
|
|
"neutron-sfc-agent",
|
2016-07-04 12:47:07 +01:00
|
|
|
"senlin-base",
|
2016-08-12 13:27:27 +00:00
|
|
|
"vmtp",
|
2016-04-14 12:08:30 +05:30
|
|
|
"watcher-base",
|
2016-05-10 12:17:37 +01:00
|
|
|
"congress-base",
|
2016-08-01 00:12:13 +02:00
|
|
|
"bifrost-base",
|
|
|
|
"cloudkitty-base"]
|
2016-03-01 15:33:46 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(BuildTestOracleLinuxBinary, self).setUp()
|
|
|
|
self.build_args.extend(["--base", "oraclelinux",
|
|
|
|
"--type", "binary"])
|
|
|
|
|
|
|
|
|
|
|
|
class BuildTestOracleLinuxSource(BuildTest, base.BaseTestCase):
|
|
|
|
excluded_images = []
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(BuildTestOracleLinuxSource, self).setUp()
|
|
|
|
self.build_args.extend(["--base", "oraclelinux",
|
|
|
|
"--type", "source"])
|
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class DeployTestCentosBinary(BuildTestCentosBinary):
|
2015-10-13 07:01:07 +00:00
|
|
|
def setUp(self):
|
2015-10-23 20:22:04 +00:00
|
|
|
super(DeployTestCentosBinary, self).setUp()
|
2015-10-13 06:57:21 +02:00
|
|
|
self.build_args.extend(["--profile", "gate"])
|
2015-10-13 07:01:07 +00:00
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class DeployTestCentosSource(BuildTestCentosSource):
|
2015-10-13 07:01:07 +00:00
|
|
|
def setUp(self):
|
2015-10-23 20:22:04 +00:00
|
|
|
super(DeployTestCentosSource, self).setUp()
|
2015-10-13 06:57:21 +02:00
|
|
|
self.build_args.extend(["--profile", "gate"])
|
2015-10-13 07:01:07 +00:00
|
|
|
|
|
|
|
|
2016-03-01 15:33:46 +00:00
|
|
|
class DeployTestOracleLinuxBinary(BuildTestOracleLinuxBinary):
|
|
|
|
def setUp(self):
|
|
|
|
super(DeployTestOracleLinuxBinary, self).setUp()
|
|
|
|
self.build_args.extend(["--profile", "gate"])
|
|
|
|
|
|
|
|
|
|
|
|
class DeployTestOracleLinuxSource(BuildTestOracleLinuxSource):
|
|
|
|
def setUp(self):
|
|
|
|
super(DeployTestOracleLinuxSource, self).setUp()
|
|
|
|
self.build_args.extend(["--profile", "gate"])
|
|
|
|
|
|
|
|
|
2016-03-15 22:39:30 +08:00
|
|
|
class DeployTestUbuntuBinary(BuildTestUbuntuBinary):
|
|
|
|
def setUp(self):
|
|
|
|
super(DeployTestUbuntuBinary, self).setUp()
|
|
|
|
self.build_args.extend(["--profile", "gate"])
|
|
|
|
|
|
|
|
|
2015-10-13 06:57:21 +02:00
|
|
|
class DeployTestUbuntuSource(BuildTestUbuntuSource):
|
2015-10-13 07:01:07 +00:00
|
|
|
def setUp(self):
|
2015-10-23 20:22:04 +00:00
|
|
|
super(DeployTestUbuntuSource, self).setUp()
|
2015-10-13 06:57:21 +02:00
|
|
|
self.build_args.extend(["--profile", "gate"])
|