debian-forge/test
Tom Gundersen 26f5135a5f tests: move from dnf- to rpm-based pipelines
This should produce the same images (except for no more dnf metadata),
but avoids depsolving (and network access) from stages.

The following helper script around osbuild-composer's dnf-json was
used for the translation:

```

import json
import os
import subprocess
import sys

def fetch_repos(sources, repo):
    if isinstance(repo, str):
        repo = sources["org.osbuild.dnf"]["repos"][repo]

    return repo, repo["gpgkey"]

def convert_stage(sources, stage, cachedir):
    gpgkeys = []
    repos = []
    for repoid, repo in enumerate(stage["options"]["repos"]):
        repo, gpgkey = fetch_repos(sources, repo)
        repo["id"] = repoid
        repo["name"] = f"repo-{repoid}"
        repos.append(repo)
        gpgkeys.append(gpgkey)

    arguments = {}
    arguments["cachedir"] = cachedir
    arguments["module_platform_id"] = stage["options"]["module_platform_id"]
    arguments["package-specs"] = stage["options"]["packages"]
    arguments["exclude-specs"] = stage["options"].get("exclude_packages", [])
    arguments["repos"] = repos

    call = {}
    call["command"] = "depsolve"
    call["arguments"] = arguments

    r = subprocess.run(["./dnf-json"],
                   input=json.dumps(call),
                   stdout=subprocess.PIPE,
                   encoding="utf-8",
                   check=True)
    pkgs = json.loads(r.stdout)["dependencies"]

    packages = []
    urls = {}
    for p in pkgs:
        packages.append(p["checksum"])
        urls[p["checksum"]] = p["remote_location"]

    options = {}
    options["gpgkeys"] = gpgkeys
    options["packages"] = packages

    stage["name"] = "org.osbuild.rpm"
    stage["options"] = options

    return urls

def convert_pipeline(sources, pipeline, cachedir):
    urls = {}
    if "build" in pipeline:
        u = convert_pipeline(sources, pipeline["build"]["pipeline"], cachedir)
        urls = {**urls, **u}
    for stage in pipeline["stages"]:
        if stage["name"] == "org.osbuild.dnf":
            u = convert_stage(sources, stage, cachedir)
            urls = {**urls, **u}
    return urls

manifest = json.load(sys.stdin)
urls = convert_pipeline(manifest["sources"], manifest["pipeline"], f"{os.getcwd()}/dnf-cache")
sources = { "org.osbuild.files": { "urls": urls }}
json.dump({"sources": sources, "pipeline": manifest["pipeline"]}, sys.stdout)
                                                                                                                                                                                                                            75,9          Bot
```

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-03 00:05:26 +01:00
..
os-release test: add 2 more os-release tests 2020-02-29 12:35:19 +01:00
pipelines tests: move from dnf- to rpm-based pipelines 2020-03-03 00:05:26 +01:00
sources_tests/org.osbuild.files sources: add org.osbuild.files source 2020-02-06 19:01:12 +01:00
stages_tests tests: move from dnf- to rpm-based pipelines 2020-03-03 00:05:26 +01:00
testing-rpms improve vagrant test and its documentation 2019-07-25 12:46:53 +02:00
.gitignore introduce testing script 2019-07-09 10:29:48 +02:00
__init__.py osbuild: add description() methods 2019-08-07 10:01:17 +02:00
osbuildtest.py tests/pipelines: embed all sources with their respective pipelines 2020-03-03 00:05:26 +01:00
README.md improve vagrant test and its documentation 2019-07-25 12:46:53 +02:00
test_assemblers.py tests/pipelines: embed all sources with their respective pipelines 2020-03-03 00:05:26 +01:00
test_boot.py tests/pipelines: embed all sources with their respective pipelines 2020-03-03 00:05:26 +01:00
test_objectstore.py objectstore: use a context also for Object.write 2020-02-29 01:14:24 +01:00
test_osbuild.py pipeline: pin the sources options in the pipeline object 2020-02-19 15:59:11 +01:00
test_osrelease.py pipeline: detect_os() -> describe_os() 2020-02-29 12:35:19 +01:00
test_sources.py sources: add org.osbuild.files source 2020-02-06 19:01:12 +01:00
test_stageinfo.py Add STAGE_DESC, STAGE_INFO, and STAGE_OPTS to stages 2019-11-13 21:47:03 +01:00
test_stages.py tests/pipelines: embed all sources with their respective pipelines 2020-03-03 00:05:26 +01:00

Setup

To run the tests in vagrant virtual machine, please follow this tutorial: https://developer.fedoraproject.org/tools/vagrant/vagrant-libvirt.html

(run also sudo systemctl start libvirtd)

Using Vagrant

To start a Vagrant box by hand, run vagrant up in this directory. To stop and remove all volumes run vagrant destroy again in this directory.

Troubleshooting

In case you accidentally deleted .vagrant directory, you can use some of these commands in order to get rid of running instance:

$ virsh list # this should display test_default
$ virsh managedsave-remove test_default
$ virsh undefine test_default
# or using vagrant cli tool
$ vagrant global-status
$ vagrant destroy <id>
$ vagrant global-status --prune