added docker labels, set LANG to C.utf8 and fixes tests due new version of mtf

This commit is contained in:
Bruno Goncalves 2017-05-31 11:04:59 +02:00
commit 1cd7dd4f3b
6 changed files with 79 additions and 16 deletions

View file

@ -15,7 +15,7 @@ import cleanup
import brtconfig
class BaseRuntimeSetupDocker(module_framework.CommonFunctions, Test):
class BaseRuntimeSetupDocker(Test, module_framework.CommonFunctions):
def setUp(self):
@ -24,6 +24,7 @@ class BaseRuntimeSetupDocker(module_framework.CommonFunctions, Test):
def _process_mockcfg(self):
profile_name = brtconfig.get_test_profile(self)
mockcfg = self.mockcfg
mock_root = ''
@ -64,12 +65,12 @@ class BaseRuntimeSetupDocker(module_framework.CommonFunctions, Test):
if "profiles" not in mod_yaml["data"].keys():
self.error("'profiles' key was not found in 'data' section")
if "container" not in mod_yaml["data"]["profiles"].keys():
self.error("'container' key was not found in 'profiles' section")
if profile_name not in mod_yaml["data"]["profiles"].keys():
self.error("'%s' key was not found in 'profiles' section" % profile_name)
base_profile = mod_yaml["data"]["profiles"]["container"]
base_profile = mod_yaml["data"]["profiles"][profile_name]
if "rpms" not in base_profile.keys():
self.error("'rpms' key was not found in 'container' profile")
self.error("'rpms' key was not found in '%s' profile" % profile_name)
req_pkgs = base_profile["rpms"]
if not req_pkgs:
@ -187,9 +188,27 @@ class BaseRuntimeSetupDocker(module_framework.CommonFunctions, Test):
# "sudo" works, so use it
tar_cmd = "sudo -n " + tar_cmd
img_scratch = "%s-scratch" % self.br_image_name
# Import mock chroot as a docker image
self._run_command("%s | docker import - %s" %
(tar_cmd, self.br_image_name))
(tar_cmd, img_scratch))
docker_labels = brtconfig.get_docker_labels(self)
#Dockerfile to use when building final image
dockerfile = 'EOF\n'
dockerfile += 'FROM %s\n' % img_scratch
#Set default locale to C.utf8
dockerfile += 'ENV LANG C.utf8\n'
if docker_labels:
for key in docker_labels.keys():
dockerfile += 'LABEL %s="%s"\n' % (key, docker_labels[key])
dockerfile += 'EOF\n'
# Build final image with extra information from dockerfile
self._run_command("docker build -t %s - << %s" %
(self.br_image_name, dockerfile))
#Remove temporary image
self._run_command("docker rmi %s" % img_scratch)
if __name__ == "__main__":
main()