test/koji: remove the old code for testing koji API
Koji API is no more, let's drop the test and rename koji-compose-v2.py to koji-compose.py. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
e779562f3c
commit
0adbce3606
4 changed files with 20 additions and 137 deletions
|
|
@ -201,7 +201,6 @@ install -m 0755 -vp tools/gen-ssh.sh %{buildroot}%
|
|||
install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/run-koji-container.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/koji-compose.py %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/koji-compose-v2.py %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/libvirt_test.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/s3_test.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/generic_s3_test.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
|
|
|
|||
|
|
@ -56,13 +56,8 @@ elif [[ "$DISTRO_CODE" == rhel-9* ]]; then
|
|||
DISTRO_CODE=rhel-91
|
||||
fi
|
||||
|
||||
if [ "${COMPOSER_API:=true}" == "true" ]; then
|
||||
greenprint "Pushing compose to Koji (/api/image-builder-comoser/v2/"
|
||||
sudo /usr/libexec/osbuild-composer-test/koji-compose-v2.py "$DISTRO_CODE" "${ARCH}"
|
||||
else
|
||||
greenprint "Pushing compose to Koji (/api/comoser-koji/v1/"
|
||||
sudo /usr/libexec/osbuild-composer-test/koji-compose.py "$DISTRO_CODE" "${ARCH}"
|
||||
fi
|
||||
greenprint "Pushing compose to Koji (/api/image-builder-comoser/v2/"
|
||||
sudo /usr/libexec/osbuild-composer-test/koji-compose.py "$DISTRO_CODE" "${ARCH}"
|
||||
|
||||
greenprint "Show Koji task"
|
||||
koji --server=http://localhost:8080/kojihub taskinfo 1
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
# Composer API for Koji uses a slightly different repository format
|
||||
# that osbuild-composer does in /usr/share/osbuild-composer/repositories.
|
||||
#
|
||||
# This function does the conversion.
|
||||
def composer_repository_to_koji_repository(repository):
|
||||
koji_repository = {
|
||||
"baseurl": repository["baseurl"]
|
||||
}
|
||||
|
||||
if repository.get("check_gpg", False):
|
||||
koji_repository["gpgkey"] = repository["gpgkey"]
|
||||
|
||||
return koji_repository
|
||||
|
||||
|
||||
def compose_request(distro, koji, arch):
|
||||
with open(f"/usr/share/tests/osbuild-composer/repositories/{distro}.json") as f:
|
||||
test_repositories = json.load(f)
|
||||
|
||||
repositories = [composer_repository_to_koji_repository(repo) for repo in test_repositories[arch]]
|
||||
image_requests = [
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "guest-image",
|
||||
"repositories": repositories
|
||||
},
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "aws",
|
||||
"repositories": repositories
|
||||
}
|
||||
]
|
||||
|
||||
req = {
|
||||
"distribution": distro,
|
||||
"koji": {
|
||||
"server": koji,
|
||||
"task_id": 1,
|
||||
"name": "name",
|
||||
"version": "version",
|
||||
"release": "release",
|
||||
},
|
||||
"image_requests": image_requests
|
||||
}
|
||||
|
||||
return req
|
||||
|
||||
|
||||
def main(distro, arch):
|
||||
cr = compose_request(distro, "https://localhost:4343/kojihub", arch)
|
||||
print(json.dumps(cr))
|
||||
|
||||
r = requests.post("https://localhost/api/image-builder-composer/v2/compose", json=cr,
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
if r.status_code != 201:
|
||||
print("Failed to create compose")
|
||||
print(r.text)
|
||||
sys.exit(1)
|
||||
|
||||
print(r.text)
|
||||
compose_id = r.json()["id"]
|
||||
|
||||
while True:
|
||||
r = requests.get(f"https://localhost/api/image-builder-composer/v2/composes/{compose_id}",
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
if r.status_code != 200:
|
||||
print("Failed to get compose status")
|
||||
print(r.text)
|
||||
sys.exit(1)
|
||||
status = r.json()["status"]
|
||||
print(status)
|
||||
if status == "success":
|
||||
print("Compose worked!")
|
||||
print(r.text)
|
||||
break
|
||||
elif status == "failure":
|
||||
print("compose failed!")
|
||||
print(r.text)
|
||||
sys.exit(1)
|
||||
elif status != "pending" and status != "running":
|
||||
print(f"unexpected status: {status}")
|
||||
print(r.text)
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
r = requests.get(f"https://localhost/api/image-builder-composer/v2/composes/{compose_id}/logs",
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
logs = r.json()
|
||||
assert "image_builds" in logs
|
||||
assert type(logs["image_builds"]) == list
|
||||
assert len(logs["image_builds"]) == len(cr["image_requests"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print(f"usage: {sys.argv[0]} DISTRO ARCH", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
|
|
@ -26,28 +26,27 @@ def compose_request(distro, koji, arch):
|
|||
test_repositories = json.load(f)
|
||||
|
||||
repositories = [composer_repository_to_koji_repository(repo) for repo in test_repositories[arch]]
|
||||
image_requests = [{
|
||||
image_requests = [
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "qcow2",
|
||||
"image_type": "guest-image",
|
||||
"repositories": repositories
|
||||
}]
|
||||
|
||||
#TODO: Remove this condition once there is rhel9 support for AMI image type
|
||||
if distro != "rhel-90":
|
||||
image_requests.append({
|
||||
},
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "ami",
|
||||
"image_type": "aws",
|
||||
"repositories": repositories
|
||||
})
|
||||
}
|
||||
]
|
||||
|
||||
req = {
|
||||
"name": "name",
|
||||
"version": "version",
|
||||
"release": "release",
|
||||
"distribution": distro,
|
||||
"koji": {
|
||||
"server": koji,
|
||||
"task_id": 1
|
||||
"task_id": 1,
|
||||
"name": "name",
|
||||
"version": "version",
|
||||
"release": "release",
|
||||
},
|
||||
"image_requests": image_requests
|
||||
}
|
||||
|
|
@ -59,7 +58,7 @@ def main(distro, arch):
|
|||
cr = compose_request(distro, "https://localhost:4343/kojihub", arch)
|
||||
print(json.dumps(cr))
|
||||
|
||||
r = requests.post("https://localhost/api/composer-koji/v1/compose", json=cr,
|
||||
r = requests.post("https://localhost/api/image-builder-composer/v2/compose", json=cr,
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
if r.status_code != 201:
|
||||
|
|
@ -71,7 +70,7 @@ def main(distro, arch):
|
|||
compose_id = r.json()["id"]
|
||||
|
||||
while True:
|
||||
r = requests.get(f"https://localhost/api/composer-koji/v1/compose/{compose_id}",
|
||||
r = requests.get(f"https://localhost/api/image-builder-composer/v2/composes/{compose_id}",
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
if r.status_code != 200:
|
||||
|
|
@ -95,13 +94,13 @@ def main(distro, arch):
|
|||
|
||||
time.sleep(10)
|
||||
|
||||
r = requests.get(f"https://localhost/api/composer-koji/v1/compose/{compose_id}/logs",
|
||||
r = requests.get(f"https://localhost/api/image-builder-composer/v2/composes/{compose_id}/logs",
|
||||
cert=("/etc/osbuild-composer/worker-crt.pem", "/etc/osbuild-composer/worker-key.pem"),
|
||||
verify="/etc/osbuild-composer/ca-crt.pem")
|
||||
logs = r.json()
|
||||
assert "image_logs" in logs
|
||||
assert type(logs["image_logs"]) == list
|
||||
assert len(logs["image_logs"]) == len(cr["image_requests"])
|
||||
assert "image_builds" in logs
|
||||
assert type(logs["image_builds"]) == list
|
||||
assert len(logs["image_builds"]) == len(cr["image_requests"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue