test: make osbuild.compile method take output_dir as a parameter
Previously, the osbuild executor had its internal temporary directory that served as the output directory. However, this approach gives no power to the caller to control the lifetime of the produced artifacts. When more images are built using one executor, the results will accumulate in one place possibly leading to exhaustion of disk space. This commit removes the executor's internal output directory. The output directory can now be passed to osbuild.compile, so the caller can control its lifetime. If no directory is passed in, the compile method will use its own temporary directory - this is useful in cases when the caller doesn't care about the built artifacts or the manifest doesn't have any outputs.
This commit is contained in:
parent
c5925fd185
commit
5842bbb93e
3 changed files with 57 additions and 72 deletions
|
|
@ -24,11 +24,11 @@ class TestBoot(test.TestBase):
|
|||
"manifests/fedora-boot.json")
|
||||
|
||||
with self.osbuild as osb:
|
||||
osb.compile_file(manifest)
|
||||
with osb.map_output("fedora-boot.qcow2") as qcow2, \
|
||||
tempfile.TemporaryDirectory() as d:
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as temp_dir:
|
||||
osb.compile_file(manifest, output_dir=temp_dir)
|
||||
qcow2 = os.path.join(temp_dir, "fedora-boot.qcow2")
|
||||
output_file = os.path.join(temp_dir, "output")
|
||||
|
||||
output_file = os.path.join(d, "output")
|
||||
subprocess.run(["qemu-system-x86_64",
|
||||
"-snapshot",
|
||||
"-m", "1024",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue