mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
feat: review changes
This commit is contained in:
@@ -850,7 +850,7 @@ pub fn is_kubernetes_upgradable<P>(kubernetes_config: P, envs: Vec<(&str, &str)>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
match kubernetes_get_all_pdbs(kubernetes_config, envs) {
|
||||
match kubernetes_get_all_pdbs(kubernetes_config, envs, None) {
|
||||
Ok(pdbs) => match pdbs.items.is_some() {
|
||||
false => Ok(()),
|
||||
true => {
|
||||
|
||||
@@ -1229,24 +1229,44 @@ where
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn kubernetes_get_all_pdbs<P>(kubernetes_config: P, envs: Vec<(&str, &str)>) -> Result<PDB, SimpleError>
|
||||
pub fn kubernetes_get_all_pdbs<P>(
|
||||
kubernetes_config: P,
|
||||
envs: Vec<(&str, &str)>,
|
||||
namespace: Option<&str>,
|
||||
) -> Result<PDB, SimpleError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
kubectl_exec::<P, PDB>(
|
||||
vec!["get", "pdb", "--all-namespaces", "-o", "json"],
|
||||
kubernetes_config,
|
||||
envs,
|
||||
)
|
||||
let mut cmd_args = vec!["get", "pdb", "-o", "json"];
|
||||
|
||||
match namespace {
|
||||
Some(n) => {
|
||||
cmd_args.push("-n");
|
||||
cmd_args.push(n);
|
||||
}
|
||||
None => cmd_args.push("--all-namespaces"),
|
||||
}
|
||||
|
||||
kubectl_exec::<P, PDB>(cmd_args, kubernetes_config, envs)
|
||||
}
|
||||
|
||||
pub fn kubernetes_get_all_hpas<P>(kubernetes_config: P, envs: Vec<(&str, &str)>) -> Result<HPA, SimpleError>
|
||||
pub fn kubernetes_get_all_hpas<P>(
|
||||
kubernetes_config: P,
|
||||
envs: Vec<(&str, &str)>,
|
||||
namespace: Option<&str>,
|
||||
) -> Result<HPA, SimpleError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
kubectl_exec::<P, HPA>(
|
||||
vec!["get", "hpa", "--all-namespaces", "-o", "json"],
|
||||
kubernetes_config,
|
||||
envs,
|
||||
)
|
||||
let mut cmd_args = vec!["get", "hpa", "-o", "json"];
|
||||
|
||||
match namespace {
|
||||
Some(n) => {
|
||||
cmd_args.push("-n");
|
||||
cmd_args.push(n);
|
||||
}
|
||||
None => cmd_args.push("--all-namespaces"),
|
||||
}
|
||||
|
||||
kubectl_exec::<P, HPA>(cmd_args, kubernetes_config, envs)
|
||||
}
|
||||
|
||||
@@ -1393,14 +1393,14 @@ pub fn cluster_test(
|
||||
);
|
||||
|
||||
// Deploy
|
||||
// if let Err(err) = deploy_tx.create_kubernetes(kubernetes.as_ref()) {
|
||||
// panic!("{:?}", err)
|
||||
// }
|
||||
// let _ = match deploy_tx.commit() {
|
||||
// TransactionResult::Ok => assert!(true),
|
||||
// TransactionResult::Rollback(_) => assert!(false),
|
||||
// TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
// };
|
||||
if let Err(err) = deploy_tx.create_kubernetes(kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
let _ = match deploy_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// Deploy env if any
|
||||
if let Some(env) = environment_to_deploy {
|
||||
@@ -1549,25 +1549,23 @@ pub fn metrics_server_test<P>(kubernetes_config: P, envs: Vec<(&str, &str)>) ->
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let result = kubernetes_get_all_hpas(kubernetes_config, envs);
|
||||
let result = kubernetes_get_all_hpas(kubernetes_config, envs, None);
|
||||
|
||||
match result {
|
||||
Ok(hpas) => {
|
||||
for hpa in hpas.items.expect("No hpa item").into_iter() {
|
||||
if hpa.metadata.annotations.is_some() {
|
||||
if hpa
|
||||
.metadata
|
||||
.annotations
|
||||
.unwrap()
|
||||
.conditions
|
||||
.expect("No hpa condition")
|
||||
.contains("FailedGetResourceMetric")
|
||||
{
|
||||
return Err(SimpleError {
|
||||
kind: SimpleErrorKind::Other,
|
||||
message: Some("Metrics server doesn't work".to_string()),
|
||||
});
|
||||
}
|
||||
if !hpa
|
||||
.metadata
|
||||
.annotations
|
||||
.expect("No hpa annotation.")
|
||||
.conditions
|
||||
.expect("No hpa condition.")
|
||||
.contains("ValidMetricFound")
|
||||
{
|
||||
return Err(SimpleError {
|
||||
kind: SimpleErrorKind::Other,
|
||||
message: Some("Metrics server doesn't work".to_string()),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -173,6 +173,7 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
.as_str(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
);
|
||||
for pdb in pdbs.expect("Unable to get pdbs").items.expect("Unable to get pdbs") {
|
||||
assert_eq!(pdb.metadata.name.contains(&environment.applications[0].name), false)
|
||||
@@ -224,6 +225,7 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
.as_str(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
);
|
||||
let mut filtered_pdb = false;
|
||||
for pdb in pdbs.expect("Unable to get pdbs").items.expect("Unable to get pdbs") {
|
||||
|
||||
Reference in New Issue
Block a user