test-case-generator: use --output-directory of osbuild
Use the --output-directory switch of osbuild to avoid poking into the osbuild-cache.
This commit is contained in:
parent
edd7b37ea2
commit
8dd4554491
1 changed files with 13 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ import subprocess
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This script generates a json test case. It accepts a test_case_request as input through standard input.
|
This script generates a json test case. It accepts a test_case_request as input through standard input.
|
||||||
|
|
@ -35,10 +36,14 @@ def get_subprocess_stdout(*args, **kwargs):
|
||||||
return sp.stdout
|
return sp.stdout
|
||||||
|
|
||||||
|
|
||||||
def run_osbuild(manifest, store):
|
def run_osbuild(manifest, store, output):
|
||||||
osbuild_cmd = ["osbuild", "--store", store, "--json", "-"]
|
subprocess.run(["osbuild",
|
||||||
result = json.loads(get_subprocess_stdout(osbuild_cmd, encoding="utf-8", input=json.dumps(manifest)))
|
"--store", store,
|
||||||
return result.get("output_id")
|
"--output-directory", output,
|
||||||
|
"--json", "-"],
|
||||||
|
check=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
input=json.dumps(manifest))
|
||||||
|
|
||||||
|
|
||||||
def main(test_case, store):
|
def main(test_case, store):
|
||||||
|
|
@ -52,9 +57,10 @@ def main(test_case, store):
|
||||||
test_case["rpmmd"] = json.loads(get_subprocess_stdout(pipeline_command, input=compose_request, encoding="utf-8"))
|
test_case["rpmmd"] = json.loads(get_subprocess_stdout(pipeline_command, input=compose_request, encoding="utf-8"))
|
||||||
|
|
||||||
if boot_type != "nspawn-extract":
|
if boot_type != "nspawn-extract":
|
||||||
output_id = run_osbuild(test_case["manifest"], store)
|
with tempfile.TemporaryDirectory(dir=store, prefix="test-case-output-") as output:
|
||||||
image_file = os.path.join(store, "refs", output_id, test_case["compose-request"]["filename"])
|
run_osbuild(test_case["manifest"], store, output)
|
||||||
test_case["image-info"] = json.loads(get_subprocess_stdout(["tools/image-info", image_file], encoding="utf-8"))
|
image_file = os.path.join(output, test_case["compose-request"]["filename"])
|
||||||
|
test_case["image-info"] = json.loads(get_subprocess_stdout(["tools/image-info", image_file], encoding="utf-8"))
|
||||||
|
|
||||||
return test_case
|
return test_case
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue