Skip to content

Commit

Permalink
Add a test for generating the trigger queue
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed Nov 20, 2024
1 parent f8916c4 commit 9b24b24
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .test/jq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ for t in "$dir/"*"/test.jq"; do
td="$(dirname "$t")"
echo -n 'test: '
basename "$td"
args=( --tab -L "$dir/.." -f "$t" )
args=( --tab -L "$dir/.." )
if [ -s "$td/in.jq" ]; then
jq "${args[@]}" -n -f "$td/in.jq" > "$td/in.json"
fi
args+=( -f "$t" )
if [ -s "$td/in.json" ]; then
args+=( "$td/in.json" )
else
Expand Down
48 changes: 48 additions & 0 deletions .test/meta-queue/in.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[
# add new test cases here
# each item will be used for each architecture generated
# [ ".build.resloved", "count", "skips" ]
[ null, 1, 0 ], # buildable, tried once
[ null, 23, 0 ], # buildable, tried many but less than skip threshold
[ null, 24, 0 ], # buildable, tried many, just on skip threshold
[ null, 25, 23 ], # buildable, final skip
[ null, 25, 24 ], # buildable, no longer skipped
[ {}, 3, 0 ], # build "complete" (not queued or skipped)
empty # trailing comma
]
| map(
("amd64", "arm32v7") as $arch
| ([ $arch, .[] | tostring ] | join("-")) as $buildId
| {
# give our inputs cuter names
resolved: .[0],
count: .[1],
skips: .[2],
}
| [
{
count,
skips,
},
{
$buildId,
build: {
$arch,
resolved,
},
"source": {
"arches": {
($arch): {
"tags": ["fake:\($buildId)"]
},
},
},
},
empty # trailing comma
]
| map({ ($buildId): . })
)
| transpose
| map(add)
| { pastjobs: .[0], builds: .[1] }

246 changes: 246 additions & 0 deletions .test/meta-queue/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
{
"pastjobs": {
"amd64-null-1-0": {
"count": 1,
"skips": 0
},
"arm32v7-null-1-0": {
"count": 1,
"skips": 0
},
"amd64-null-23-0": {
"count": 23,
"skips": 0
},
"arm32v7-null-23-0": {
"count": 23,
"skips": 0
},
"amd64-null-24-0": {
"count": 24,
"skips": 0
},
"arm32v7-null-24-0": {
"count": 24,
"skips": 0
},
"amd64-null-25-23": {
"count": 25,
"skips": 23
},
"arm32v7-null-25-23": {
"count": 25,
"skips": 23
},
"amd64-null-25-24": {
"count": 25,
"skips": 24
},
"arm32v7-null-25-24": {
"count": 25,
"skips": 24
},
"amd64-{}-3-0": {
"count": 3,
"skips": 0
},
"arm32v7-{}-3-0": {
"count": 3,
"skips": 0
}
},
"builds": {
"amd64-null-1-0": {
"buildId": "amd64-null-1-0",
"build": {
"arch": "amd64",
"resolved": null
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-null-1-0"
]
}
}
}
},
"arm32v7-null-1-0": {
"buildId": "arm32v7-null-1-0",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-1-0"
]
}
}
}
},
"amd64-null-23-0": {
"buildId": "amd64-null-23-0",
"build": {
"arch": "amd64",
"resolved": null
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-null-23-0"
]
}
}
}
},
"arm32v7-null-23-0": {
"buildId": "arm32v7-null-23-0",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-23-0"
]
}
}
}
},
"amd64-null-24-0": {
"buildId": "amd64-null-24-0",
"build": {
"arch": "amd64",
"resolved": null
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-null-24-0"
]
}
}
}
},
"arm32v7-null-24-0": {
"buildId": "arm32v7-null-24-0",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-24-0"
]
}
}
}
},
"amd64-null-25-23": {
"buildId": "amd64-null-25-23",
"build": {
"arch": "amd64",
"resolved": null
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-null-25-23"
]
}
}
}
},
"arm32v7-null-25-23": {
"buildId": "arm32v7-null-25-23",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-25-23"
]
}
}
}
},
"amd64-null-25-24": {
"buildId": "amd64-null-25-24",
"build": {
"arch": "amd64",
"resolved": null
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-null-25-24"
]
}
}
}
},
"arm32v7-null-25-24": {
"buildId": "arm32v7-null-25-24",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-25-24"
]
}
}
}
},
"amd64-{}-3-0": {
"buildId": "amd64-{}-3-0",
"build": {
"arch": "amd64",
"resolved": {}
},
"source": {
"arches": {
"amd64": {
"tags": [
"fake:amd64-{}-3-0"
]
}
}
}
},
"arm32v7-{}-3-0": {
"buildId": "arm32v7-{}-3-0",
"build": {
"arch": "arm32v7",
"resolved": {}
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-{}-3-0"
]
}
}
}
}
}
}
81 changes: 81 additions & 0 deletions .test/meta-queue/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[
{
"buildId": "arm32v7-null-1-0",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-1-0"
]
}
}
},
"identifier": "fake:arm32v7-null-1-0"
},
{
"buildId": "arm32v7-null-23-0",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-23-0"
]
}
}
},
"identifier": "fake:arm32v7-null-23-0"
},
{
"buildId": "arm32v7-null-25-24",
"build": {
"arch": "arm32v7",
"resolved": null
},
"source": {
"arches": {
"arm32v7": {
"tags": [
"fake:arm32v7-null-25-24"
]
}
}
},
"identifier": "fake:arm32v7-null-25-24"
}
]
{
"arm32v7-null-1-0": {
"count": 2,
"skips": 0,
"identifier": "fake:arm32v7-null-1-0"
},
"arm32v7-null-23-0": {
"count": 24,
"skips": 0,
"identifier": "fake:arm32v7-null-23-0"
},
"arm32v7-null-24-0": {
"count": 24,
"skips": 1,
"identifier": "fake:arm32v7-null-24-0"
},
"arm32v7-null-25-23": {
"count": 25,
"skips": 24,
"identifier": "fake:arm32v7-null-25-23"
},
"arm32v7-null-25-24": {
"count": 26,
"skips": 0,
"identifier": "fake:arm32v7-null-25-24"
}
}
2
Loading

0 comments on commit 9b24b24

Please sign in to comment.