forked from dfinity/ic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'eero/inject-deployment' into 'master'
[NODE-1089] Add deployment settings to `setupos-inject-configuration` See merge request dfinity-lab/public/ic!15179
- Loading branch information
Showing
5 changed files
with
218 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use serde_with::{serde_as, DisplayFromStr}; | ||
use url::Url; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct DeploymentJson { | ||
pub deployment: Deployment, | ||
pub logging: Logging, | ||
pub nns: Nns, | ||
pub dns: Dns, | ||
pub resources: Resources, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct Deployment { | ||
pub name: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct Logging { | ||
pub hosts: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct Nns { | ||
pub url: Url, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct Dns { | ||
pub name_servers: String, | ||
} | ||
|
||
#[serde_as] | ||
#[derive(Serialize, Deserialize, PartialEq, Debug)] | ||
pub struct Resources { | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub memory: u32, | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use once_cell::sync::Lazy; | ||
|
||
const DEPLOYMENT_STR: &str = r#"{ | ||
"deployment": { | ||
"name": "mainnet" | ||
}, | ||
"logging": { | ||
"hosts": "elasticsearch-node-0.mercury.dfinity.systems:443 elasticsearch-node-1.mercury.dfinity.systems:443 elasticsearch-node-2.mercury.dfinity.systems:443 elasticsearch-node-3.mercury.dfinity.systems:443" | ||
}, | ||
"nns": { | ||
"url": "https://dfinity.org/" | ||
}, | ||
"dns": { | ||
"name_servers": "2606:4700:4700::1111 2606:4700:4700::1001 2001:4860:4860::8888 2001:4860:4860::8844" | ||
}, | ||
"resources": { | ||
"memory": "490" | ||
} | ||
}"#; | ||
|
||
static DEPLOYMENT_STRUCT: Lazy<DeploymentJson> = Lazy::new(|| { | ||
DeploymentJson { | ||
deployment: Deployment { name: "mainnet".to_string() }, | ||
logging: Logging { hosts: "elasticsearch-node-0.mercury.dfinity.systems:443 elasticsearch-node-1.mercury.dfinity.systems:443 elasticsearch-node-2.mercury.dfinity.systems:443 elasticsearch-node-3.mercury.dfinity.systems:443".to_string() }, | ||
nns: Nns { url: Url::parse("https://dfinity.org").unwrap() }, | ||
dns: Dns { name_servers: "2606:4700:4700::1111 2606:4700:4700::1001 2001:4860:4860::8888 2001:4860:4860::8844".to_string() }, | ||
resources: Resources { memory: 490 }, | ||
} | ||
}); | ||
|
||
#[test] | ||
fn read_deployment() { | ||
let parsed_deployment: DeploymentJson = { serde_json::from_str(DEPLOYMENT_STR).unwrap() }; | ||
|
||
assert_eq!(*DEPLOYMENT_STRUCT, parsed_deployment); | ||
} | ||
|
||
#[test] | ||
fn write_deployment() { | ||
let written_deployment = | ||
serde_json::to_string_pretty::<DeploymentJson>(&DEPLOYMENT_STRUCT).unwrap(); | ||
|
||
assert_eq!(DEPLOYMENT_STR, written_deployment); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters