Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Add build metadata #1137

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions squad/ci/backend/tuxsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def parse_build_results(self, test_job, job_url, results, settings):
# Make metadata
metadata_keys = settings.get('BUILD_METADATA_KEYS', [])
metadata = {k: results.get(k) for k in metadata_keys}

# Add extra metadata from metadata file if it exists
self.update_metadata_from_file(results=results, metadata=metadata)

metadata['job_url'] = job_url
metadata['job_id'] = test_job.job_id
metadata['config'] = urljoin(results.get('download_url') + '/', 'config')
Expand Down Expand Up @@ -296,10 +300,10 @@ def update_metadata_from_file(self, results, metadata):
if "download_url" in results:
download_url = results["download_url"]
try:
test_metadata_response = self.fetch_url(download_url + '/' + 'metadata.json')
metadata_response = self.fetch_url(download_url + '/' + 'metadata.json')
# If fetching the metadata file did not error, decode it as json
if test_metadata_response.ok:
metadata.update(test_metadata_response.json())
if metadata_response.ok:
metadata.update(metadata_response.json())
except TemporaryFetchIssue:
pass

Expand Down
318 changes: 318 additions & 0 deletions test/ci/backend/test_tuxsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,324 @@ def test_job_url(self):
expected = urljoin(TUXSUITE_URL, endpoint)
self.assertEqual(expected, self.tuxsuite.job_url(testjob))

def test_parse_build_metadata(self):
results = {
'download_url': 'http://builds.tuxbuild.com/123',
}

metadata = {
"example_metadata": "blah",
}

metadata_file = {
"build": {
"environment": {
"KBUILD_BUILD_HOST": "tuxmake",
"KBUILD_BUILD_TIMESTAMP": "@1715675769",
"KBUILD_BUILD_USER": "tuxmake",
"KCFLAGS": "-ffile-prefix-map=/home/tuxbuild/.cache/tuxmake/builds/2/build/=",
"SCCACHE_BUCKET": "sccache.tuxbuild.com",
},
"jobs": 8,
"kconfig": "clps711x_defconfig",
"kconfig_add": [],
"reproducer_cmdline": [
"tuxmake",
"--target-arch=arm",
"--kconfig=clps711x_defconfig",
"--toolchain=clang-18",
"--wrapper=sccache",
"--environment=KBUILD_BUILD_TIMESTAMP=@1715675769",
"--environment=KBUILD_BUILD_USER=tuxmake",
"--environment=KBUILD_BUILD_HOST=tuxmake",
"--environment=KCFLAGS=-ffile-prefix-map=/home/tuxbuild/.cache/tuxmake/builds/2/build/=",
"--environment=SCCACHE_BUCKET=sccache.tuxbuild.com",
"--runtime=podman",
"--image=855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18",
"LLVM=1",
"LLVM_IAS=1",
"config",
"default",
"kernel",
"xipkernel",
"modules",
"dtbs",
"dtbs-legacy",
"debugkernel",
"headers",
],
"runtime": "podman",
"target_arch": "arm",
"targets": [
"config",
"default",
"kernel",
"xipkernel",
"modules",
"dtbs",
"dtbs-legacy",
"debugkernel",
"headers",
],
"toolchain": "clang-18",
"verbose": False,
"wrapper": "sccache",
},
"compiler": {
"name": "clang",
"version": "18.1.4",
"version_full": "Debian clang version 18.1.4 (++20240416103102+1deeee3f5da4-1~exp1~20240416223224.98)",
},
"hardware": {"cores": 8, "free_disk_space": 58738, "ram": 14974},
"os": {"name": "Debian GNU/Linux", "version": "11"},
"resources": {"disk_space": 136},
"results": {
"artifacts": {
"config": ["config"],
"debugkernel": ["vmlinux.xz", "System.map"],
"default": [],
"dtbs": ["dtbs.tar.xz"],
"dtbs-legacy": ["dtbs.tar.xz"],
"headers": ["headers.tar.xz"],
"kernel": ["zImage"],
"log": ["build.log", "build-debug.log"],
"modules": [],
"xipkernel": [],
},
"duration": {
"build": 186.54648447036743,
"cleanup": 1.350804090499878,
"copy": 0.006262302398681641,
"metadata": 0.7471709251403809,
"prepare": 70.95046162605286,
"validate": 0.00015616416931152344,
},
"errors": 0,
"status": "PASS",
"targets": {
"config": {"duration": 4.253992795944214, "status": "PASS"},
"debugkernel": {
"duration": 2.8869056701660156,
"status": "PASS",
},
"default": {"duration": 167.16954827308655, "status": "PASS"},
"dtbs": {"duration": 2.950917959213257, "status": "PASS"},
"dtbs-legacy": {
"duration": 0.525646448135376,
"status": "SKIP",
},
"headers": {"duration": 5.598230361938477, "status": "PASS"},
"kernel": {"duration": 2.525160551071167, "status": "PASS"},
"modules": {"duration": 0.32180237770080566, "status": "SKIP"},
"xipkernel": {"duration": 0.314225435256958, "status": "SKIP"},
},
"warnings": 0,
},
"runtime": {
"image_digest": "855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18@sha256:087c232cbeee1d92a541614852bbd298ef8406315c1461b67692b29d4fb2090a",
"image_name": "855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18",
"image_tag": None,
"version": "podman version 4.6.2",
},
"sccache": {"cache_hits": 66, "cache_misses": 0},
"source": {
"kernelrelease": "6.9.0-next-20240514",
"kernelversion": "6.9.0",
},
"system_map": {"text_offset": "0xc0008000"},
"tools": {
"ar": "GNU ar (GNU Binutils for Debian) 2.35.2",
"as": "GNU assembler (GNU Binutils for Debian) 2.35.2",
"bc": "bc 1.07.1",
"bison": "bison (GNU Bison) 3.7.5",
"ccache": "ccache version 4.2",
"clang": "Debian clang version 18.1.4 (++20240416103102+1deeee3f5da4-1~exp1~20240416223224.98)",
"depmod": "kmod version 28",
"fdformat": "fdformat from util-linux 2.36.1",
"flex": "flex 2.6.4",
"gcc": "gcc (Debian 10.2.1-6) 10.2.1 20210110",
"ld": "GNU ld (GNU Binutils for Debian) 2.35.2",
"lld": "Debian LLD 18.1.4 (compatible with GNU linkers)",
"make": "GNU Make 4.3",
"openssl": "OpenSSL 1.1.1w 11 Sep 2023",
"pahole": "v1.25",
"ps": "ps from procps-ng 3.3.17",
"sccache": "sccache 0.2.9",
},
"tuxmake": {"version": "1.23.2"},
"uname": {
"kernel": "Linux",
"kernel_release": "6.5.0-1014-aws",
"kernel_version": "#14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024",
"machine": "x86_64",
"operating_system": "GNU/Linux",
},
"vmlinux": {
"bss_size": 96144,
"data_size": 806948,
"file_size": 6236152,
"text_size": 4193860,
},
}

expected = {
"example_metadata": "blah",
"build": {
"environment": {
"KBUILD_BUILD_HOST": "tuxmake",
"KBUILD_BUILD_TIMESTAMP": "@1715675769",
"KBUILD_BUILD_USER": "tuxmake",
"KCFLAGS": "-ffile-prefix-map=/home/tuxbuild/.cache/tuxmake/builds/2/build/=",
"SCCACHE_BUCKET": "sccache.tuxbuild.com",
},
"jobs": 8,
"kconfig": "clps711x_defconfig",
"kconfig_add": [],
"reproducer_cmdline": [
"tuxmake",
"--target-arch=arm",
"--kconfig=clps711x_defconfig",
"--toolchain=clang-18",
"--wrapper=sccache",
"--environment=KBUILD_BUILD_TIMESTAMP=@1715675769",
"--environment=KBUILD_BUILD_USER=tuxmake",
"--environment=KBUILD_BUILD_HOST=tuxmake",
"--environment=KCFLAGS=-ffile-prefix-map=/home/tuxbuild/.cache/tuxmake/builds/2/build/=",
"--environment=SCCACHE_BUCKET=sccache.tuxbuild.com",
"--runtime=podman",
"--image=855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18",
"LLVM=1",
"LLVM_IAS=1",
"config",
"default",
"kernel",
"xipkernel",
"modules",
"dtbs",
"dtbs-legacy",
"debugkernel",
"headers",
],
"runtime": "podman",
"target_arch": "arm",
"targets": [
"config",
"default",
"kernel",
"xipkernel",
"modules",
"dtbs",
"dtbs-legacy",
"debugkernel",
"headers",
],
"toolchain": "clang-18",
"verbose": False,
"wrapper": "sccache",
},
"compiler": {
"name": "clang",
"version": "18.1.4",
"version_full": "Debian clang version 18.1.4 (++20240416103102+1deeee3f5da4-1~exp1~20240416223224.98)",
},
"hardware": {"cores": 8, "free_disk_space": 58738, "ram": 14974},
"os": {"name": "Debian GNU/Linux", "version": "11"},
"resources": {"disk_space": 136},
"results": {
"artifacts": {
"config": ["config"],
"debugkernel": ["vmlinux.xz", "System.map"],
"default": [],
"dtbs": ["dtbs.tar.xz"],
"dtbs-legacy": ["dtbs.tar.xz"],
"headers": ["headers.tar.xz"],
"kernel": ["zImage"],
"log": ["build.log", "build-debug.log"],
"modules": [],
"xipkernel": [],
},
"duration": {
"build": 186.54648447036743,
"cleanup": 1.350804090499878,
"copy": 0.006262302398681641,
"metadata": 0.7471709251403809,
"prepare": 70.95046162605286,
"validate": 0.00015616416931152344,
},
"errors": 0,
"status": "PASS",
"targets": {
"config": {"duration": 4.253992795944214, "status": "PASS"},
"debugkernel": {
"duration": 2.8869056701660156,
"status": "PASS",
},
"default": {"duration": 167.16954827308655, "status": "PASS"},
"dtbs": {"duration": 2.950917959213257, "status": "PASS"},
"dtbs-legacy": {
"duration": 0.525646448135376,
"status": "SKIP",
},
"headers": {"duration": 5.598230361938477, "status": "PASS"},
"kernel": {"duration": 2.525160551071167, "status": "PASS"},
"modules": {"duration": 0.32180237770080566, "status": "SKIP"},
"xipkernel": {"duration": 0.314225435256958, "status": "SKIP"},
},
"warnings": 0,
},
"runtime": {
"image_digest": "855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18@sha256:087c232cbeee1d92a541614852bbd298ef8406315c1461b67692b29d4fb2090a",
"image_name": "855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm_clang-18",
"image_tag": None,
"version": "podman version 4.6.2",
},
"sccache": {"cache_hits": 66, "cache_misses": 0},
"source": {
"kernelrelease": "6.9.0-next-20240514",
"kernelversion": "6.9.0",
},
"system_map": {"text_offset": "0xc0008000"},
"tools": {
"ar": "GNU ar (GNU Binutils for Debian) 2.35.2",
"as": "GNU assembler (GNU Binutils for Debian) 2.35.2",
"bc": "bc 1.07.1",
"bison": "bison (GNU Bison) 3.7.5",
"ccache": "ccache version 4.2",
"clang": "Debian clang version 18.1.4 (++20240416103102+1deeee3f5da4-1~exp1~20240416223224.98)",
"depmod": "kmod version 28",
"fdformat": "fdformat from util-linux 2.36.1",
"flex": "flex 2.6.4",
"gcc": "gcc (Debian 10.2.1-6) 10.2.1 20210110",
"ld": "GNU ld (GNU Binutils for Debian) 2.35.2",
"lld": "Debian LLD 18.1.4 (compatible with GNU linkers)",
"make": "GNU Make 4.3",
"openssl": "OpenSSL 1.1.1w 11 Sep 2023",
"pahole": "v1.25",
"ps": "ps from procps-ng 3.3.17",
"sccache": "sccache 0.2.9",
},
"tuxmake": {"version": "1.23.2"},
"uname": {
"kernel": "Linux",
"kernel_release": "6.5.0-1014-aws",
"kernel_version": "#14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024",
"machine": "x86_64",
"operating_system": "GNU/Linux",
},
"vmlinux": {
"bss_size": 96144,
"data_size": 806948,
"file_size": 6236152,
"text_size": 4193860,
},
}

with requests_mock.Mocker() as fake_request:
fake_request.get(results["download_url"] + '/' + 'metadata.json', json=metadata_file)
self.tuxsuite.update_metadata_from_file(results=results, metadata=metadata)

self.assertEqual(expected, metadata)

def test_parse_test_no_metadata(self):
results = {
'download_url': 'http://builds.tuxbuild.com/123',
Expand Down
Loading