forked from fedora-modularity/baseruntime-docker-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brtconfig.py
102 lines (74 loc) · 3 KB
/
brtconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
get configuration parameters for base runtime smoke testing
"""
import os
import logging
from moduleframework import module_framework
def get_mockcfg(self):
"""
Get the path to the base runtime mock configuration file
This is provided by the avocado 'mockcfg' parameter if supplied,
otherwise it is set to "resources/base-runtime-mock.cfg" relative to
the test script directory.
"""
script_dir = os.path.abspath(os.path.dirname(__file__))
self.log.info("running script from directory: %s" % script_dir)
mockcfg = self.params.get('mockcfg', default=os.path.join(
script_dir, "resources", "base-runtime-mock.cfg"))
mockcfg = str(mockcfg)
if not mockcfg.endswith(".cfg"):
self.error("mock configuration file %s must have the extension '.cfg'" %
mockcfg)
if not os.path.isfile(mockcfg):
self.error("mock configuration file %s does not exist" %
mockcfg)
self.log.info("mock configuration file: %s" % mockcfg)
return mockcfg
def get_compiler_test_dir(self):
"""
Get the path to the base runtime compiler test resource directory
This is provided by the avocado 'compiler-test-dir' parameter if supplied,
otherwise it is set to "resources/hello-world" relative to
the test script directory.
"""
script_dir = os.path.abspath(os.path.dirname(__file__))
self.log.info("running script from directory: %s" % script_dir)
compdir = self.params.get(
'compiler-test-dir', default=os.path.join(script_dir, "resources", "hello-world"))
compdir = str(compdir)
if not os.path.isdir(compdir):
self.error("Compiler test resource directory %s does not exist" % compdir)
self.log.info("Compiler test resource directory: %s" % compdir)
return compdir
def get_docker_image_name(self):
"""
Get the name to use for the base runtime docker image
"""
container_helper = module_framework.ContainerHelper()
#It tries to get the name from URL env variable
#If URL is not defined it tries to get the name from config.yaml
image_name = container_helper.getDockerInstanceName()
if not image_name:
self.error("Could not find docker image name to use")
self.log.info("base runtime image name: %s" % image_name)
return image_name
def get_docker_labels(self):
"""
From config file get the labels that should be added to the image
"""
config = module_framework.get_config()
if not config:
self.error("Could not get config file")
if 'module' not in config.keys():
self.error("Config file does not have module section")
if 'docker' not in config['module'].keys():
self.error("Config file does not have docker module section")
docker_cfg = config['module']['docker']
if 'labels' not in docker_cfg.keys():
return None
return docker_cfg['labels']
def get_test_profile(self):
"""
From config file get the labels that should be added to the image
"""
return "container"