37
37
from lava_tool.utils import (
39
39
verify_and_create_url,
43
from lava.job import Job
44
from lava.job.templates import (
45
LAVA_TEST_SHELL_TAR_REPO,
46
LAVA_TEST_SHELL_TAR_REPO_KEY,
47
LAVA_TEST_SHELL_TESDEF_KEY,
50
from lava.testdef import TestDefinition
51
from lava.testdef.templates import (
42
54
CONFIG = InteractiveConfig()
122
134
raise CommandError("Job file '{0}' does not exists, or it is not "
123
135
"a file.".format(job_file))
137
def create_tar_repo_job(self, job_file, testdef_file, tar_content):
138
"""Creates a job file based on the tar-repo template.
140
The tar repo is not kept on the file system.
142
:param job_file: The path of the job file to create.
143
:param testdef_file: The path of the test definition file.
144
:param tar_content: What should go into the tarball repository.
145
:return The path of the job file created.
148
tar_repo = create_tar(tar_content)
150
job_instance = Job(LAVA_TEST_SHELL_TAR_REPO, job_file)
151
job_instance.update(self.config)
153
job_instance.set(LAVA_TEST_SHELL_TAR_REPO_KEY,
154
base64_encode(tar_repo))
155
job_instance.set(LAVA_TEST_SHELL_TESDEF_KEY,
156
os.path.basename(testdef_file))
160
return job_instance.file_name
162
if os.path.isfile(tar_repo):
165
def create_test_definition(self, testdef_file, template=TESTDEF_TEMPLATE):
166
"""Creates a test definition YAML file.
168
:param testdef_file: The file to create.
169
:return The path of the file created.
171
testdef = TestDefinition(template, testdef_file)
172
testdef.update(self.config)
175
print >> sys.stdout, ("Create test definition "
176
"'{0}'.".format(testdef.file_name))
178
return testdef.file_name