Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updog: use compile time specific json payloads in unit tests #2367

Merged
merged 1 commit into from
Aug 23, 2022
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
13 changes: 7 additions & 6 deletions sources/updater/updog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,9 @@ mod tests {

#[test]
fn older_versions() {
// A manifest with two updates, both less than 0.1.3
let path = "tests/data/example_3.json";
// A manifest with two updates, both less than 0.1.3.
// Use a architecture specific JSON payload, otherwise updog will ignore the update
let path = format!("tests/data/example_3_{}.json", TARGET_ARCH);
let manifest: Manifest = serde_json::from_reader(File::open(path).unwrap()).unwrap();
let config = Config {
metadata_base_url: String::from("foo"),
Expand Down Expand Up @@ -736,10 +737,10 @@ mod tests {
#[test]
fn test_multiple() {
// A manifest with four updates; two valid, one which exceeds the max
// version, and one which is for an aarch64 target. This asserts that
// version, and one which is for the opposite target architecture. This asserts that
// upgrading from the version 1.10.0 results in updating to 1.15.0
// instead of 1.13.0 (lower), 1.25.0 (too high), or 1.16.0 (wrong arch).
let path = "tests/data/multiple.json";
let path = format!("tests/data/multiple_{}.json", TARGET_ARCH);
let manifest: Manifest = serde_json::from_reader(File::open(path).unwrap()).unwrap();
let config = Config {
metadata_base_url: String::from("foo"),
Expand Down Expand Up @@ -778,10 +779,10 @@ mod tests {
#[test]
fn force_update_version() {
// A manifest with four updates; two valid, one which exceeds the max
// version, and one which is for an aarch64 target. This tests forces
// version, and one which is for the opposite target architecture. This tests forces
// a downgrade to 1.13.0, instead of 1.15.0 like it would be in the
// above test, test_multiple.
let path = "tests/data/multiple.json";
let path = format!("tests/data/multiple_{}.json", TARGET_ARCH);
let manifest: Manifest = serde_json::from_reader(File::open(path).unwrap()).unwrap();
let config = Config {
metadata_base_url: String::from("foo"),
Expand Down
35 changes: 35 additions & 0 deletions sources/updater/updog/tests/data/example_3_aarch64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"updates": [
{
"variant": "aws-k8s-1.15",
"arch": "aarch64",
"version": "0.1.1",
"max_version": "0.1.2",
"waves": {
"0": "2019-09-20T23:00:00Z",
"2047": "2019-09-20T23:00:00Z"
},
"images": {
"boot": "bottlerocket-aarch64-boot.ext4.lz4",
"root": "bottlerocket-aarch64-root.ext4.lz4",
"hash": "bottlerocket-aarch64-root.verity.lz4"
}
},
{
"variant": "aws-k8s-1.15",
"arch": "aarch64",
"version": "0.1.2",
"max_version": "0.1.2",
"waves": {
"0": "2019-09-27T17:55:03Z",
"2047": "2019-09-27T18:55:03Z"
},
"images": {
"boot": "bottlerocket-aarch64-0.2.1-boot.ext4.lz4",
"root": "bottlerocket-aarch64-0.2.1-root.ext4.lz4",
"hash": "bottlerocket-aarch64-0.2.1-root.verity.lz4"
}
}
],
"migrations": {}
}
69 changes: 69 additions & 0 deletions sources/updater/updog/tests/data/multiple_aarch64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"updates": [
{
"variant": "bottlerocket-aws-eks",
"arch": "aarch64",
"version": "1.13.0",
"status": "Ready",
"max_version": "1.20.0",
"waves": {
"0": "2019-10-06T15:00:00Z",
"858993459":"2019-10-07T15:00:00Z"
},
"images": {
"boot": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191006.img",
"root": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191006.img",
"hash": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191006.img"
}
},
{
"variant": "bottlerocket-aws-eks",
"arch": "aarch64",
"version": "1.25.0",
"status": "Ready",
"max_version": "1.20.0",
"waves": {
"0": "2019-10-06T15:00:00Z",
"858993459":"2019-10-07T15:00:00Z"
},
"images": {
"boot": "stuff-boot-bottlerocket-aws-eks-1.25-m1.20191015.img",
"root": "stuff-boot-bottlerocket-aws-eks-1.25-m1.20191015.img",
"hash": "stuff-boot-bottlerocket-aws-eks-1.25-m1.20191015.img"
}
},
{
"variant": "bottlerocket-aws-eks",
"arch": "aarch64",
"version": "1.15.0",
"status": "Ready",
"max_version": "1.20.0",
"waves": {
"0": "2019-10-06T15:00:00Z",
"858993459":"2019-10-07T15:00:00Z"
},
"images": {
"boot": "stuff-boot-bottlerocket-aws-eks-1.15-m1.20191009.img",
"root": "stuff-boot-bottlerocket-aws-eks-1.15-m1.20191009.img",
"hash": "stuff-boot-bottlerocket-aws-eks-1.15-m1.20191009.img"
}
},
{
"variant": "bottlerocket-aws-eks",
"arch": "x86_64",
"version": "1.16.0",
"status": "Ready",
"max_version": "1.20.0",
"waves": {
"0": "2019-10-06T15:00:00Z",
"858993459":"2019-10-07T15:00:00Z"
},
"images": {
"boot": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191010.img",
"root": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191010.img",
"hash": "stuff-boot-bottlerocket-aws-eks-1.13-m1.20191010.img"
}
}
],
"migrations": {}
}