mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
add failover test
This commit is contained in:
@@ -713,3 +713,60 @@ pub fn non_working_environment(context: &Context) -> Environment {
|
||||
|
||||
environment
|
||||
}
|
||||
|
||||
|
||||
pub fn echo_app_environment(context: &Context) -> Environment {
|
||||
let suffix = generate_id();
|
||||
Environment {
|
||||
execution_id: context.execution_id().to_string(),
|
||||
id: generate_id(),
|
||||
kind: Kind::Development,
|
||||
owner_id: generate_id(),
|
||||
project_id: generate_id(),
|
||||
organization_id: ORGANIZATION_ID.to_string(),
|
||||
action: Action::Create,
|
||||
applications: vec![Application {
|
||||
id: generate_id(),
|
||||
name: format!("{}-{}", "echo-app".to_string(), &suffix),
|
||||
/*name: "simple-app".to_string(),*/
|
||||
git_url: "https://github.com/Qovery/engine-testing.git".to_string(),
|
||||
commit_id: "2205adea1db295547b99f7b17229afd7e879b6ff".to_string(),
|
||||
dockerfile_path: "Dockerfile".to_string(),
|
||||
action: Action::Create,
|
||||
git_credentials: GitCredentials {
|
||||
login: "x-access-token".to_string(),
|
||||
access_token: "CHANGE-ME/GITHUB_ACCESS_TOKEN".to_string(),
|
||||
expired_at: Utc::now(),
|
||||
},
|
||||
storage: vec![],
|
||||
environment_variables: vec![
|
||||
EnvironmentVariable {
|
||||
key: "ECHO_TEXT".to_string(),
|
||||
value: "42".to_string(),
|
||||
},
|
||||
],
|
||||
branch: "echo-app".to_string(),
|
||||
private_port: Some(5678),
|
||||
total_cpus: "100m".to_string(),
|
||||
total_ram_in_mib: 256,
|
||||
total_instances: 2,
|
||||
cpu_burst: "100m".to_string(),
|
||||
start_timeout_in_seconds: 60,
|
||||
}],
|
||||
routers: vec![Router {
|
||||
id: generate_id(),
|
||||
name: "main".to_string(),
|
||||
action: Action::Create,
|
||||
default_domain: generate_id() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN",
|
||||
public_port: 443,
|
||||
custom_domains: vec![],
|
||||
routes: vec![Route {
|
||||
path: "/".to_string(),
|
||||
application_name: format!("{}-{}", "echo-app".to_string(), &suffix),
|
||||
}],
|
||||
}],
|
||||
databases: vec![],
|
||||
external_services: vec![],
|
||||
clone_from_environment_id: None,
|
||||
}
|
||||
}
|
||||
720
tests/aws/aws_databases.rs
Normal file
720
tests/aws/aws_databases.rs
Normal file
@@ -0,0 +1,720 @@
|
||||
extern crate test_utilities;
|
||||
|
||||
use chrono::Utc;
|
||||
use rusoto_core::region::Region::Custom;
|
||||
|
||||
use self::test_utilities::cloudflare::dns_provider_cloudflare;
|
||||
use self::test_utilities::utilities::generate_id;
|
||||
use qovery_engine::cloud_provider::aws::common;
|
||||
use qovery_engine::cloud_provider::service::Router;
|
||||
use qovery_engine::cmd;
|
||||
use qovery_engine::models::Kind::Production;
|
||||
use qovery_engine::models::{
|
||||
Action, Clone2, Context, CustomDomain, Database, DatabaseKind, Environment, EnvironmentAction,
|
||||
EnvironmentVariable, ExternalService, GitCredentials, Kind, Storage, StorageType,
|
||||
};
|
||||
use qovery_engine::transaction::{DeploymentOption, TransactionResult};
|
||||
use test_utilities::aws::{aws_access_key_id, aws_default_region, aws_secret_access_key, context};
|
||||
use test_utilities::utilities::{init, is_pod_restarted};
|
||||
use crate::aws::aws_environment::{deploy_environment, delete_environment};
|
||||
|
||||
// to check overload between several databases and apps
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
init();
|
||||
let context = context();
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
let mut environment = test_utilities::aws::environment_3_apps_3_routers_3_databases(&context);
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// TODO: should be uncommented as soon as cert-manager is fixed
|
||||
// for the moment this assert report a SSL issue on the second router, so it's works well
|
||||
/* let connections = test_utilities::utilities::check_all_connections(&env_to_check);
|
||||
for con in connections {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match delete_environment(&context_for_deletion, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
**
|
||||
** PostgreSQL PART
|
||||
**
|
||||
**/
|
||||
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_development_environment_with_all_options_and_psql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::environnement_2_app_2_routers_1_psql(&context);
|
||||
let mut env_to_check = environment.clone();
|
||||
let mut environment_delete =
|
||||
test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
|
||||
environment.kind = Kind::Development;
|
||||
environment_delete.kind = Kind::Development;
|
||||
environment_delete.action = Action::Delete;
|
||||
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_for_deletion = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
// TODO: should be uncommented as soon as cert-manager is fixed
|
||||
// for the moment this assert report a SSL issue on the second router, so it's works well
|
||||
/* let connections = test_utilities::utilities::check_all_connections(&env_to_check);
|
||||
for con in connections {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match delete_environment(&context_for_deletion, &ea_for_deletion) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host =
|
||||
"postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "my-postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "11.8.0".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deploy_a_working_environment_and_redeploy_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_redeploy = context.clone_not_same_execution_id();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host = "postgresql-".to_string() + generate_id().as_str() + ".oom.sh"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "my-postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "11.8.0".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
let mut environment_to_redeploy = environment.clone();
|
||||
let environment_check = environment.clone();
|
||||
let ea_redeploy = EnvironmentAction::Environment(environment_to_redeploy);
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match deploy_environment(&context_for_redeploy, &ea_redeploy) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
// TO CHECK: DATABASE SHOULDN'T BE RESTARTED AFTER A REDEPLOY
|
||||
let database_name = format!("{}-0", &environment_check.databases[0].name);
|
||||
match is_pod_restarted(environment_check, database_name.as_str()) {
|
||||
(true, _) => assert!(true),
|
||||
(false, _) => assert!(false),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_production_environment_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
|
||||
let database_host =
|
||||
"postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "12.4".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "100m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
fn test_mongodb_configuration(context: Context, mut environment: Environment, version: &str) {
|
||||
init();
|
||||
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 27017;
|
||||
let database_db_name = "my-mongodb".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
let database_uri = format!(
|
||||
"mongodb://{}:{}@{}:{}/{}",
|
||||
database_username, database_password, database_host, database_port, database_db_name
|
||||
);
|
||||
// while waiting the info to be given directly in the database info, we're using this
|
||||
let is_documentdb = match environment.kind {
|
||||
Kind::Production => true,
|
||||
Kind::Development => false,
|
||||
};
|
||||
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mongodb,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: version.to_string(),
|
||||
fqdn_id: "mongodb-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t3.medium".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mongodb-app".to_string();
|
||||
app.commit_id = "158ea8ebc9897c50a7c56b910db33ce837ac1e61".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.dockerfile_path = format!("Dockerfile-{}", version);
|
||||
app.environment_variables = vec![
|
||||
// EnvironmentVariable {
|
||||
// key: "ENABLE_DEBUG".to_string(),
|
||||
// value: "true".to_string(),
|
||||
// },
|
||||
// EnvironmentVariable {
|
||||
// key: "DEBUG_PAUSE".to_string(),
|
||||
// value: "true".to_string(),
|
||||
// },
|
||||
EnvironmentVariable {
|
||||
key: "IS_DOCUMENTDB".to_string(),
|
||||
value: is_documentdb.to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_FQDN".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_MY_DDB_CONNECTION_URI".to_string(),
|
||||
value: database_uri.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MONGODB_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mongodb-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
**
|
||||
** MongoDB PART
|
||||
**
|
||||
**/
|
||||
|
||||
|
||||
/// test mongodb v3.6 with development environment
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_mongodb_v3_6() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "3.6");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_0() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.0");
|
||||
}
|
||||
|
||||
/// test mongodb v4.2 with development environment
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_2() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.2");
|
||||
}
|
||||
|
||||
/// test mongodb v4.4 with development environment
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_4() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.4");
|
||||
}
|
||||
|
||||
/// test mongodb v3.6 with production environment (DocumentDB)
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_production_mongodb_v3_6() {
|
||||
let context = context();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
|
||||
test_mongodb_configuration(context, environment, "3.6");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**
|
||||
** MySQL PART
|
||||
**
|
||||
**/
|
||||
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mysql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let deletion_context = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host =
|
||||
"mysql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 3306;
|
||||
let database_db_name = "mydb".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mysql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "5.7.30".to_string(),
|
||||
fqdn_id: "mysql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mysql-app".to_string();
|
||||
app.commit_id = "222295112d58d78227c21060d3a707687302e86f".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mysql-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&deletion_context, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
//Todo: remove the namespace (or project)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
/// Tests the creation of a simple environment on AWS, with the DB provisioned on RDS.
|
||||
fn deploy_a_working_production_environment_with_mysql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let deletion_context = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Production;
|
||||
|
||||
let database_host =
|
||||
"mysql-app-".to_string() + generate_id().as_str() + "-svc.CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 3306;
|
||||
let database_db_name = "mysql".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mysql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "5.7.30".to_string(),
|
||||
fqdn_id: "mysql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mysql-app".to_string();
|
||||
app.commit_id = "222295112d58d78227c21060d3a707687302e86f".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mysql-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&deletion_context, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,7 @@ use test_utilities::utilities::{init, is_pod_restarted};
|
||||
// args are function you want to use and how many context you want to have
|
||||
// it permit you to create several different workspaces for each steps
|
||||
// TODO implement it well
|
||||
fn generate_contexts_and_environments(
|
||||
pub fn generate_contexts_and_environments(
|
||||
number: u8,
|
||||
func: fn(&Context) -> Environment,
|
||||
) -> (Vec<Context>, Vec<Environment>) {
|
||||
@@ -36,7 +36,7 @@ fn generate_contexts_and_environments(
|
||||
(context_vec, env_vec)
|
||||
}
|
||||
|
||||
fn deploy_environment(
|
||||
pub fn deploy_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
@@ -61,7 +61,7 @@ fn deploy_environment(
|
||||
tx.commit()
|
||||
}
|
||||
|
||||
fn pause_environment(
|
||||
pub fn pause_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
@@ -79,7 +79,7 @@ fn pause_environment(
|
||||
tx.commit()
|
||||
}
|
||||
|
||||
fn delete_environment(
|
||||
pub fn delete_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
@@ -188,40 +188,6 @@ fn deploy_a_not_working_environment_with_no_router_on_aws_eks() {
|
||||
//Todo: remove the namespace (or project)
|
||||
}
|
||||
|
||||
// to check overload between several databases and apps
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
init();
|
||||
let context = context();
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
let mut environment = test_utilities::aws::environment_3_apps_3_routers_3_databases(&context);
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// TODO: should be uncommented as soon as cert-manager is fixed
|
||||
// for the moment this assert report a SSL issue on the second router, so it's works well
|
||||
/* let connections = test_utilities::utilities::check_all_connections(&env_to_check);
|
||||
for con in connections {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match delete_environment(&context_for_deletion, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_domain() {
|
||||
@@ -370,191 +336,6 @@ fn deploy_a_working_environment_with_storage_on_aws_eks() {
|
||||
//Todo: remove the namespace (or project)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host =
|
||||
"postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "my-postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "11.8.0".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deploy_a_working_environment_and_redeploy_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_redeploy = context.clone_not_same_execution_id();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host = "postgresql-".to_string() + generate_id().as_str() + ".oom.sh"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "my-postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "11.8.0".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
let mut environment_to_redeploy = environment.clone();
|
||||
let environment_check = environment.clone();
|
||||
let ea_redeploy = EnvironmentAction::Environment(environment_to_redeploy);
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match deploy_environment(&context_for_redeploy, &ea_redeploy) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
// TO CHECK: DATABASE SHOULDN'T BE RESTARTED AFTER A REDEPLOY
|
||||
let database_name = format!("{}-0", &environment_check.databases[0].name);
|
||||
match is_pod_restarted(environment_check, database_name.as_str()) {
|
||||
(true, _) => assert!(true),
|
||||
(false, _) => assert!(false),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
// to check if app redeploy or not, it shouldn't
|
||||
#[test]
|
||||
fn redeploy_same_app_with_ebs() {
|
||||
@@ -616,248 +397,6 @@ fn redeploy_same_app_with_ebs() {
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_production_environment_with_postgresql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
|
||||
let database_host =
|
||||
"postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Postgresql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "12.4".to_string(),
|
||||
fqdn_id: "postgresql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "100m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "postgres-app".to_string();
|
||||
app.commit_id = "5990752647af11ef21c3d46a51abbde3da1ab351".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "PG_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "PG_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "postgres-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
fn test_mongodb_configuration(context: Context, mut environment: Environment, version: &str) {
|
||||
init();
|
||||
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 27017;
|
||||
let database_db_name = "my-mongodb".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
let database_uri = format!(
|
||||
"mongodb://{}:{}@{}:{}/{}",
|
||||
database_username, database_password, database_host, database_port, database_db_name
|
||||
);
|
||||
// while waiting the info to be given directly in the database info, we're using this
|
||||
let is_documentdb = match environment.kind {
|
||||
Kind::Production => true,
|
||||
Kind::Development => false,
|
||||
};
|
||||
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mongodb,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: version.to_string(),
|
||||
fqdn_id: "mongodb-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t3.medium".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mongodb-app".to_string();
|
||||
app.commit_id = "158ea8ebc9897c50a7c56b910db33ce837ac1e61".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.dockerfile_path = format!("Dockerfile-{}", version);
|
||||
app.environment_variables = vec![
|
||||
// EnvironmentVariable {
|
||||
// key: "ENABLE_DEBUG".to_string(),
|
||||
// value: "true".to_string(),
|
||||
// },
|
||||
// EnvironmentVariable {
|
||||
// key: "DEBUG_PAUSE".to_string(),
|
||||
// value: "true".to_string(),
|
||||
// },
|
||||
EnvironmentVariable {
|
||||
key: "IS_DOCUMENTDB".to_string(),
|
||||
value: is_documentdb.to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_FQDN".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_MY_DDB_CONNECTION_URI".to_string(),
|
||||
value: database_uri.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MONGODB_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "QOVERY_DATABASE_TESTING_DATABASE_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mongodb-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&context_for_delete, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
}
|
||||
|
||||
/// test mongodb v3.6 with development environment
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_mongodb_v3_6() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "3.6");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_0() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.0");
|
||||
}
|
||||
|
||||
/// test mongodb v4.2 with development environment
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_2() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.2");
|
||||
}
|
||||
|
||||
/// test mongodb v4.4 with development environment
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_mongodb_v4_4() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mongodb_configuration(context, environment, "4.4");
|
||||
}
|
||||
|
||||
/// test mongodb v3.6 with production environment (DocumentDB)
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_production_mongodb_v3_6() {
|
||||
let context = context();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
|
||||
test_mongodb_configuration(context, environment, "3.6");
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn deploy_a_working_environment_with_external_service() {
|
||||
// init();
|
||||
@@ -911,223 +450,6 @@ fn deploy_a_working_environment_with_production_mongodb_v3_6() {
|
||||
// // TODO: remove the namespace (or project)
|
||||
// }
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_mysql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let deletion_context = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host =
|
||||
"mysql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 3306;
|
||||
let database_db_name = "mydb".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mysql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "5.7.30".to_string(),
|
||||
fqdn_id: "mysql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mysql-app".to_string();
|
||||
app.commit_id = "222295112d58d78227c21060d3a707687302e86f".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mysql-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&deletion_context, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
//Todo: remove the namespace (or project)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
/// Tests the creation of a simple environment on AWS, with the DB provisioned on RDS.
|
||||
fn deploy_a_working_production_environment_with_mysql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let deletion_context = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Production;
|
||||
|
||||
let database_host =
|
||||
"mysql-app-".to_string() + generate_id().as_str() + "-svc.CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 3306;
|
||||
let database_db_name = "mysql".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
environment.databases = vec![Database {
|
||||
kind: DatabaseKind::Mysql,
|
||||
action: Action::Create,
|
||||
id: generate_id(),
|
||||
name: database_db_name.clone(),
|
||||
version: "5.7.30".to_string(),
|
||||
fqdn_id: "mysql-".to_string() + generate_id().as_str(),
|
||||
fqdn: database_host.clone(),
|
||||
port: database_port.clone(),
|
||||
username: database_username.clone(),
|
||||
password: database_password.clone(),
|
||||
total_cpus: "500m".to_string(),
|
||||
total_ram_in_mib: 512,
|
||||
disk_size_in_gib: 10,
|
||||
database_instance_type: "db.t2.micro".to_string(),
|
||||
database_disk_type: "gp2".to_string(),
|
||||
}];
|
||||
environment.applications = environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.branch = "mysql-app".to_string();
|
||||
app.commit_id = "222295112d58d78227c21060d3a707687302e86f".to_string();
|
||||
app.private_port = Some(1234);
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_HOST".to_string(),
|
||||
value: database_host.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PORT".to_string(),
|
||||
value: database_port.clone().to_string(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_DBNAME".to_string(),
|
||||
value: database_db_name.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_USERNAME".to_string(),
|
||||
value: database_username.clone(),
|
||||
},
|
||||
EnvironmentVariable {
|
||||
key: "MYSQL_PASSWORD".to_string(),
|
||||
value: database_password.clone(),
|
||||
},
|
||||
];
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
environment.routers[0].routes[0].application_name = "mysql-app".to_string();
|
||||
|
||||
let mut environment_delete = environment.clone();
|
||||
environment_delete.action = Action::Delete;
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
// todo: check the database disk is here and with correct size
|
||||
|
||||
match delete_environment(&deletion_context, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_development_environment_with_all_options_and_psql() {
|
||||
init();
|
||||
|
||||
let context = context();
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
|
||||
let mut environment = test_utilities::aws::environnement_2_app_2_routers_1_psql(&context);
|
||||
let mut env_to_check = environment.clone();
|
||||
let mut environment_delete =
|
||||
test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
|
||||
environment.kind = Kind::Development;
|
||||
environment_delete.kind = Kind::Development;
|
||||
environment_delete.action = Action::Delete;
|
||||
|
||||
let ea = EnvironmentAction::Environment(environment);
|
||||
let ea_for_deletion = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
// TODO: should be uncommented as soon as cert-manager is fixed
|
||||
// for the moment this assert report a SSL issue on the second router, so it's works well
|
||||
/* let connections = test_utilities::utilities::check_all_connections(&env_to_check);
|
||||
for con in connections {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match delete_environment(&context_for_deletion, &ea_for_deletion) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
/*#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_working_production_environment_with_all_options_on_aws_eks() {
|
||||
@@ -1340,6 +662,67 @@ fn deploy_a_non_working_environment_with_a_working_failover_on_aws_eks() {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_2_non_working_environments_with_2_working_failovers_on_aws_eks() {
|
||||
init();
|
||||
// context for non working environment
|
||||
let context_failover_1 = context();
|
||||
let context_failover_2 = context.clone_not_same_execution_id();
|
||||
|
||||
let context_first_fail_deployement_1 = context.clone_not_same_execution_id();
|
||||
let context_second_fail_deployement_2 = context.clone_not_same_execution_id();
|
||||
|
||||
let mut failover_environment_1 = test_utilities::aws::echo_app_environment(&context_failover_1);
|
||||
let mut fail_app_1 = test_utilities::aws::non_working_environment(&context_first_fail_deployement_1);
|
||||
let mut failover_environment_1 = test_utilities::aws::echo_app_environment(&context_failover_2);
|
||||
let mut fail_app_2 = test_utilities::aws::non_working_environment(&context_second_fail_deployement_2);
|
||||
|
||||
failover_environment.applications = failover_environment
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app |{
|
||||
app.environment_variables = vec![
|
||||
EnvironmentVariable {
|
||||
key: "ECHO_TEXT".to_string(),
|
||||
value: "Lilou".to_string(),
|
||||
},
|
||||
],
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
|
||||
// context for deletion
|
||||
let context_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env = test_utilities::aws::echo_app_environment(&context_deletion);
|
||||
delete_env.action = Action::Delete;
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env);
|
||||
|
||||
// first deployement
|
||||
let ea1 = EnvironmentAction::EnvironmentWithFailover(fail_app_1, failover_environment_1);
|
||||
let ea2 = EnvironmentAction::EnvironmentWithFailover(fail_app_2, failover_environment_2);
|
||||
|
||||
|
||||
match deploy_environment(&context_failover_1, &ea1) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match deploy_environment(&context_failover_2, &ea2) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match delete_environment(&context_deletion, &ea_delete) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_a_non_working_environment_with_a_non_working_failover_on_aws_eks() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mod aws_databases;
|
||||
mod aws_environment;
|
||||
mod aws_kubernetes;
|
||||
mod deletion;
|
||||
|
||||
Reference in New Issue
Block a user