mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
Merge branch 'dev' into refactor/extract-state-out-of-engine-event
This commit is contained in:
16
README.md
16
README.md
@@ -18,12 +18,11 @@
|
||||
<img src="https://raw.githubusercontent.com/Qovery/public-resources/master/qovery_kubernetes_cloudproviders.svg" height="450px" alt="Qovery stack on top of Kubernetes and Cloud providers" />
|
||||
</p>
|
||||
|
||||
**Qovery Engine** is an open-source abstraction layer library that turns easy apps deployment on **AWS**, **GCP**, **Azure**, and other Cloud providers in just a few minutes. The Qovery Engine is written in [Rust](https://www.rust-lang.org) and takes advantage of [Terraform](https://www.terraform.io), [Helm](https://helm.sh), [Kubectl](https://kubernetes.io/docs/reference/kubectl/overview), and [Docker](https://www.docker.com) to manage resources.
|
||||
**Qovery Engine** is an open-source abstraction layer library that turns easy application deployment on **AWS**, **GCP**, **Azure**, and other Cloud providers in just a few minutes. The Qovery Engine is written in [Rust](https://www.rust-lang.org) and takes advantage of [Terraform](https://www.terraform.io), [Helm](https://helm.sh), [Kubectl](https://kubernetes.io/docs/reference/kubectl/overview), and [Docker](https://www.docker.com) to manage resources.
|
||||
|
||||
- Website: https://www.qovery.com
|
||||
- Full doc: https://docs.qovery.com
|
||||
- Qovery Engine doc: *coming soon*
|
||||
- Community: [Join us](https://discord.qovery.com) on Discord and on our [Q&A forum](https://community.qovery.com)
|
||||
- Qovery documentation: https://hub.qovery.com/docs
|
||||
- Community: [Join us](https://discord.qovery.com) on Discord and on our [Q&A forum](https://discuss.qovery.com)
|
||||
|
||||
**Please note**: We take Qovery's security and our users' trust very seriously. If you believe you have found a security issue in Qovery, please responsibly disclose by contacting us at security@qovery.com.
|
||||
|
||||
@@ -42,9 +41,9 @@
|
||||
</p>
|
||||
|
||||
Qovery engine supports a number of different plugins to compose your own deployment flow:
|
||||
- **Cloud providers:** [AWS](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/amazon-web-services/), Digital Ocean ([in beta](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/digital-ocean/)), Azure ([vote](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/azure/)), GCP ([vote](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/google-cloud-platform/)), Scaleway ([vote](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/scaleway/))
|
||||
- **Build platforms:** [Qovery CI](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/qovery-ci/), Circle CI ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/circle-ci/)), Gitlab CI ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/gitlab-ci/)), Github Actions ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/github-actions/))
|
||||
- **Container registries:** [ECR](https://docs.qovery.com/docs/using-qovery/configuration/business/container-registry/elastic-container-registry/), [DockerHub](https://docs.qovery.com/docs/using-qovery/configuration/business/container-registry/docker-hub/), DOCR ([vote](https://docs.qovery.com/docs/using-qovery/configuration/business/container-registry/digital-ocean-container-registry/)), ACR ([vote](https://docs.qovery.com/docs/using-qovery/configuration/business/container-registry/azure-container-registry/)), SCR ([vote](https://docs.qovery.com/docs/using-qovery/configuration/business/container-registry/scaleway-container-registry/))
|
||||
- **Cloud providers:** [AWS](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/amazon-web-services/), Digital Ocean ([in beta](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/digital-ocean/)), Scaleway ([in beta](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/scaleway/)), Azure ([vote](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/azure/)), GCP ([vote](https://hub.qovery.com/docs/using-qovery/configuration/cloud-service-provider/google-cloud-platform/))
|
||||
- **Build platforms:** [Qovery CI](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/qovery-ci/), Circle CI ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/circle-ci/)), Gitlab CI ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/gitlab-ci/)), GitHub Actions ([vote](https://hub.qovery.com/docs/using-qovery/addon/continuous-integration/github-actions/))
|
||||
- **Container registries:** AWS ECR, DockerHub, Digital Ocean CR, ACR, Scaleway Container Registry
|
||||
- **DNS providers:** Cloudflare
|
||||
- **Monitoring services:** Datadog ([vote](https://hub.qovery.com/docs/using-qovery/addon/monitoring/datadog/)), Newrelic ([vote](https://hub.qovery.com/docs/using-qovery/addon/monitoring/new-relic/))
|
||||
|
||||
@@ -145,7 +144,7 @@ Full, comprehensive documentation is available on the Qovery website: https://do
|
||||
Please read our [Contributing Guide](./CONTRIBUTING.md) before submitting a Pull Request to the project.
|
||||
|
||||
## Community support
|
||||
For general help using Qovery Engine, please refer to [the official Qovery Engine documentation](https://docs.qovery.com). For additional help, you can use one of these channels to ask a question:
|
||||
For general help to use Qovery Engine, please refer to [the official Qovery Engine documentation](https://hub.qovery.com/docs). For additional help, you can use one of these channels to ask a question:
|
||||
|
||||
- [Discord](https://discord.qovery.com) (For live discussion with the Community and Qovery team)
|
||||
- [GitHub](https://github.com/qovery/engine) (Bug reports, Contributions)
|
||||
@@ -174,7 +173,6 @@ The Qovery Engine is designed to operate as an administrator and takes decisions
|
||||
|
||||
See the [LICENSE](./LICENSE) file for licensing information.
|
||||
|
||||
|
||||
## Qovery
|
||||
|
||||
Qovery is a [CNCF](https://landscape.cncf.io/format=members&selected=qovery-member) and [Linux Foundation](https://www.linuxfoundation.org/membership/members/) silver member.
|
||||
|
||||
@@ -71,4 +71,6 @@ resource "aws_s3_bucket_public_access_block" "loki_access" {
|
||||
|
||||
ignore_public_acls = true
|
||||
restrict_public_buckets = true
|
||||
block_public_policy = true
|
||||
block_public_acls = true
|
||||
}
|
||||
@@ -13,6 +13,7 @@ resource "aws_s3_bucket" "kubeconfigs_bucket" {
|
||||
"Name" = "Kubernetes kubeconfig"
|
||||
}
|
||||
)
|
||||
|
||||
server_side_encryption_configuration {
|
||||
rule {
|
||||
apply_server_side_encryption_by_default {
|
||||
@@ -21,7 +22,6 @@ resource "aws_s3_bucket" "kubeconfigs_bucket" {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resource "aws_kms_key" "s3_kubeconfig_kms_encryption" {
|
||||
@@ -39,4 +39,6 @@ resource "aws_s3_bucket_public_access_block" "kubeconfigs_access" {
|
||||
|
||||
ignore_public_acls = true
|
||||
restrict_public_buckets = true
|
||||
block_public_policy = true
|
||||
block_public_acls = true
|
||||
}
|
||||
@@ -56,9 +56,6 @@ resource "scaleway_rdb_instance" "mysql_instance" {
|
||||
|
||||
tags = local.tags_mysql_list
|
||||
|
||||
publicly_accessible = var.publicly_accessible
|
||||
|
||||
|
||||
# TODO:(benjaminch): features to be added at some point but be discussed with Scaleway
|
||||
# - port
|
||||
# - instance create timeout
|
||||
|
||||
@@ -56,9 +56,6 @@ resource "scaleway_rdb_instance" "postgresql_instance" {
|
||||
|
||||
tags = local.tags_postgresql_list
|
||||
|
||||
publicly_accessible = var.publicly_accessible
|
||||
|
||||
|
||||
# TODO:(benjaminch): features to be added at some point but be discussed with Scaleway
|
||||
# - port
|
||||
# - instance create timeout
|
||||
|
||||
@@ -6,8 +6,8 @@ use git2::{Cred, CredentialType};
|
||||
use sysinfo::{Disk, DiskExt, SystemExt};
|
||||
|
||||
use crate::build_platform::{docker, Build, BuildPlatform, BuildResult, CacheResult, Credentials, Image, Kind};
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::error::{EngineError, EngineErrorCause, EngineErrorScope, SimpleError, SimpleErrorKind};
|
||||
use crate::cmd::command::{CommandError, QoveryCommand};
|
||||
use crate::error::{EngineError, EngineErrorCause, EngineErrorScope, SimpleError};
|
||||
use crate::fs::workspace_directory;
|
||||
use crate::git;
|
||||
use crate::models::{
|
||||
@@ -79,6 +79,7 @@ impl LocalDocker {
|
||||
env_var_args: Vec<String>,
|
||||
use_build_cache: bool,
|
||||
lh: &ListenersHelper,
|
||||
is_task_canceled: &dyn Fn() -> bool,
|
||||
) -> Result<BuildResult, EngineError> {
|
||||
let mut docker_args = if !use_build_cache {
|
||||
vec!["build", "--no-cache"]
|
||||
@@ -126,7 +127,7 @@ impl LocalDocker {
|
||||
// docker build
|
||||
let mut cmd = QoveryCommand::new("docker", &docker_args, &self.get_docker_host_envs());
|
||||
|
||||
let exit_status = cmd.exec_with_timeout(
|
||||
let exit_status = cmd.exec_with_abort(
|
||||
Duration::minutes(BUILD_DURATION_TIMEOUT_MIN),
|
||||
|line| {
|
||||
info!("{}", line);
|
||||
@@ -152,10 +153,14 @@ impl LocalDocker {
|
||||
self.context.execution_id(),
|
||||
));
|
||||
},
|
||||
is_task_canceled,
|
||||
);
|
||||
|
||||
match exit_status {
|
||||
Ok(_) => Ok(BuildResult { build }),
|
||||
Err(CommandError::Killed(msg)) => Err(
|
||||
self.engine_error(EngineErrorCause::Canceled, msg)
|
||||
),
|
||||
Err(err) => Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"It looks like there is something wrong in your Dockerfile. Try building the application locally with `docker build --no-cache`.",
|
||||
@@ -176,13 +181,13 @@ impl LocalDocker {
|
||||
env_var_args: Vec<String>,
|
||||
use_build_cache: bool,
|
||||
lh: &ListenersHelper,
|
||||
is_task_canceled: &dyn Fn() -> bool,
|
||||
) -> Result<BuildResult, EngineError> {
|
||||
let name_with_tag = build.image.name_with_tag();
|
||||
|
||||
let args = self.context.docker_build_options();
|
||||
|
||||
let mut exit_status: Result<(), SimpleError> =
|
||||
Err(SimpleError::new(SimpleErrorKind::Other, Some("no builder names")));
|
||||
let mut exit_status: Result<(), CommandError> = Ok(());
|
||||
|
||||
for builder_name in BUILDPACKS_BUILDERS.iter() {
|
||||
let mut buildpacks_args = if !use_build_cache {
|
||||
@@ -268,35 +273,34 @@ impl LocalDocker {
|
||||
|
||||
// buildpacks build
|
||||
let mut cmd = QoveryCommand::new("pack", &buildpacks_args, &self.get_docker_host_envs());
|
||||
exit_status = cmd
|
||||
.exec_with_timeout(
|
||||
Duration::minutes(BUILD_DURATION_TIMEOUT_MIN),
|
||||
|line| {
|
||||
info!("{}", line);
|
||||
exit_status = cmd.exec_with_abort(
|
||||
Duration::minutes(BUILD_DURATION_TIMEOUT_MIN),
|
||||
|line| {
|
||||
info!("{}", line);
|
||||
|
||||
lh.deployment_in_progress(ProgressInfo::new(
|
||||
ProgressScope::Application {
|
||||
id: build.image.application_id.clone(),
|
||||
},
|
||||
ProgressLevel::Info,
|
||||
Some(line),
|
||||
self.context.execution_id(),
|
||||
));
|
||||
},
|
||||
|line| {
|
||||
error!("{}", line);
|
||||
lh.deployment_in_progress(ProgressInfo::new(
|
||||
ProgressScope::Application {
|
||||
id: build.image.application_id.clone(),
|
||||
},
|
||||
ProgressLevel::Info,
|
||||
Some(line),
|
||||
self.context.execution_id(),
|
||||
));
|
||||
},
|
||||
|line| {
|
||||
error!("{}", line);
|
||||
|
||||
lh.deployment_in_progress(ProgressInfo::new(
|
||||
ProgressScope::Application {
|
||||
id: build.image.application_id.clone(),
|
||||
},
|
||||
ProgressLevel::Warn,
|
||||
Some(line),
|
||||
self.context.execution_id(),
|
||||
));
|
||||
},
|
||||
)
|
||||
.map_err(|err| SimpleError::new(SimpleErrorKind::Other, Some(format!("{:?}", err))));
|
||||
lh.deployment_in_progress(ProgressInfo::new(
|
||||
ProgressScope::Application {
|
||||
id: build.image.application_id.clone(),
|
||||
},
|
||||
ProgressLevel::Warn,
|
||||
Some(line),
|
||||
self.context.execution_id(),
|
||||
));
|
||||
},
|
||||
is_task_canceled,
|
||||
);
|
||||
|
||||
if exit_status.is_ok() {
|
||||
// quit now if the builder successfully build the app
|
||||
@@ -306,6 +310,7 @@ impl LocalDocker {
|
||||
|
||||
match exit_status {
|
||||
Ok(_) => Ok(BuildResult { build }),
|
||||
Err(CommandError::Killed(msg)) => Err(self.engine_error(EngineErrorCause::Canceled, msg)),
|
||||
Err(err) => {
|
||||
warn!("{:?}", err);
|
||||
|
||||
@@ -352,11 +357,11 @@ impl BuildPlatform for LocalDocker {
|
||||
}
|
||||
|
||||
fn is_valid(&self) -> Result<(), EngineError> {
|
||||
if !crate::cmd::utilities::does_binary_exist("docker") {
|
||||
if !crate::cmd::command::does_binary_exist("docker") {
|
||||
return Err(self.engine_error(EngineErrorCause::Internal, String::from("docker binary not found")));
|
||||
}
|
||||
|
||||
if !crate::cmd::utilities::does_binary_exist("pack") {
|
||||
if !crate::cmd::command::does_binary_exist("pack") {
|
||||
return Err(self.engine_error(EngineErrorCause::Internal, String::from("pack binary not found")));
|
||||
}
|
||||
|
||||
@@ -391,8 +396,19 @@ impl BuildPlatform for LocalDocker {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn build(&self, build: Build, force_build: bool) -> Result<BuildResult, EngineError> {
|
||||
fn build(
|
||||
&self,
|
||||
build: Build,
|
||||
force_build: bool,
|
||||
is_task_canceled: &dyn Fn() -> bool,
|
||||
) -> Result<BuildResult, EngineError> {
|
||||
info!("LocalDocker.build() called for {}", self.name());
|
||||
if is_task_canceled() {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::Canceled,
|
||||
"Notified to cancel current task".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let listeners_helper = ListenersHelper::new(&self.listeners);
|
||||
|
||||
@@ -439,6 +455,12 @@ impl BuildPlatform for LocalDocker {
|
||||
}
|
||||
|
||||
// git clone
|
||||
if is_task_canceled() {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::Canceled,
|
||||
"Notified to cancel current task".to_string(),
|
||||
));
|
||||
}
|
||||
if let Err(clone_error) = git::clone_at_commit(
|
||||
&build.git_repository.url,
|
||||
&build.git_repository.commit_id,
|
||||
@@ -538,6 +560,7 @@ impl BuildPlatform for LocalDocker {
|
||||
env_var_args,
|
||||
!disable_build_cache,
|
||||
&listeners_helper,
|
||||
is_task_canceled,
|
||||
)
|
||||
} else {
|
||||
// build container with Buildpacks
|
||||
@@ -547,13 +570,28 @@ impl BuildPlatform for LocalDocker {
|
||||
env_var_args,
|
||||
!disable_build_cache,
|
||||
&listeners_helper,
|
||||
is_task_canceled,
|
||||
)
|
||||
};
|
||||
|
||||
let msg = match &result {
|
||||
Ok(_) => format!("✅ Container {} is built", self.name_with_id()),
|
||||
Err(engine_err) if engine_err.is_cancel() => {
|
||||
format!("🚫 Container {} build has been canceled", self.name_with_id())
|
||||
}
|
||||
Err(engine_err) => {
|
||||
format!(
|
||||
"❌ Container {} failed to be build: {}",
|
||||
self.name_with_id(),
|
||||
engine_err.message.as_ref().map(|x| x.as_str()).unwrap_or_default()
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
listeners_helper.deployment_in_progress(ProgressInfo::new(
|
||||
ProgressScope::Application { id: app_id },
|
||||
ProgressLevel::Info,
|
||||
Some(format!("container {} is built ✔", self.name_with_id())),
|
||||
Some(msg),
|
||||
self.context.execution_id(),
|
||||
));
|
||||
|
||||
|
||||
@@ -22,7 +22,12 @@ pub trait BuildPlatform: Listen {
|
||||
}
|
||||
fn is_valid(&self) -> Result<(), EngineError>;
|
||||
fn has_cache(&self, build: &Build) -> Result<CacheResult, EngineError>;
|
||||
fn build(&self, build: Build, force_build: bool) -> Result<BuildResult, EngineError>;
|
||||
fn build(
|
||||
&self,
|
||||
build: Build,
|
||||
force_build: bool,
|
||||
is_task_canceled: &dyn Fn() -> bool,
|
||||
) -> Result<BuildResult, EngineError>;
|
||||
fn build_error(&self, build: Build) -> Result<BuildResult, EngineError>;
|
||||
fn engine_error_scope(&self) -> EngineErrorScope {
|
||||
EngineErrorScope::BuildPlatform(self.id().to_string(), self.name().to_string())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Borrow;
|
||||
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DoVpc {
|
||||
|
||||
@@ -113,7 +113,7 @@ pub trait Service: ToTransmitter {
|
||||
let binaries = ["kubectl", "helm", "terraform", "aws-iam-authenticator"];
|
||||
|
||||
for binary in binaries.iter() {
|
||||
if !crate::cmd::utilities::does_binary_exist(binary) {
|
||||
if !crate::cmd::command::does_binary_exist(binary) {
|
||||
return Err(NewEngineError::new_missing_required_binary(
|
||||
self.get_event_details(Stage::General(GeneralStep::ValidateSystemRequirements)),
|
||||
binary.to_string(),
|
||||
|
||||
@@ -319,7 +319,7 @@ impl fmt::Display for VersionsNumber {
|
||||
}
|
||||
}
|
||||
|
||||
fn google_dns_resolver() -> Resolver {
|
||||
fn dns_resolvers() -> Vec<Resolver> {
|
||||
let mut resolver_options = ResolverOpts::default();
|
||||
|
||||
// We want to avoid cache and using host file of the host, as some provider force caching
|
||||
@@ -335,7 +335,13 @@ fn google_dns_resolver() -> Resolver {
|
||||
//);
|
||||
|
||||
//Resolver::new(resolver, resolver_options).unwrap()
|
||||
Resolver::new(ResolverConfig::google(), resolver_options).expect("Invalid google DNS resolver configuration")
|
||||
vec![
|
||||
Resolver::new(ResolverConfig::google(), resolver_options).expect("Invalid google DNS resolver configuration"),
|
||||
Resolver::new(ResolverConfig::cloudflare(), resolver_options)
|
||||
.expect("Invalid cloudflare DNS resolver configuration"),
|
||||
Resolver::new(ResolverConfig::quad9(), resolver_options).expect("Invalid quad9 DNS resolver configuration"),
|
||||
Resolver::from_system_conf().expect("Invalid system DNS resolver configuration"),
|
||||
]
|
||||
}
|
||||
|
||||
fn get_cname_record_value(resolver: &Resolver, cname: &str) -> Option<String> {
|
||||
@@ -359,7 +365,7 @@ pub fn check_cname_for(
|
||||
cname_to_check: &str,
|
||||
execution_id: &str,
|
||||
) -> Result<String, String> {
|
||||
let resolver = google_dns_resolver();
|
||||
let resolvers = dns_resolvers();
|
||||
let listener_helper = ListenersHelper::new(listeners);
|
||||
|
||||
let send_deployment_progress = |msg: &str| {
|
||||
@@ -389,9 +395,15 @@ pub fn check_cname_for(
|
||||
);
|
||||
|
||||
// Trying for 5 min to resolve CNAME
|
||||
let mut ix: usize = 0;
|
||||
let mut next_resolver = || {
|
||||
let resolver = &resolvers[ix % resolvers.len()];
|
||||
ix += 1;
|
||||
resolver
|
||||
};
|
||||
let fixed_iterable = Fixed::from_millis(Duration::seconds(5).num_milliseconds() as u64).take(6 * 5);
|
||||
let check_result = retry::retry(fixed_iterable, || {
|
||||
match get_cname_record_value(&resolver, cname_to_check) {
|
||||
match get_cname_record_value(next_resolver(), cname_to_check) {
|
||||
Some(domain) => OperationResult::Ok(domain),
|
||||
None => {
|
||||
let msg = format!(
|
||||
@@ -427,7 +439,7 @@ pub fn check_domain_for(
|
||||
execution_id: &str,
|
||||
context_id: &str,
|
||||
) -> Result<(), EngineError> {
|
||||
let resolver = google_dns_resolver();
|
||||
let resolvers = dns_resolvers();
|
||||
|
||||
for domain in domains_to_check {
|
||||
listener_helper.deployment_in_progress(ProgressInfo::new(
|
||||
@@ -442,8 +454,14 @@ pub fn check_domain_for(
|
||||
execution_id,
|
||||
));
|
||||
|
||||
let mut ix: usize = 0;
|
||||
let mut next_resolver = || {
|
||||
let resolver = &resolvers[ix % resolvers.len()];
|
||||
ix += 1;
|
||||
resolver
|
||||
};
|
||||
let fixed_iterable = Fixed::from_millis(3000).take(100);
|
||||
let check_result = retry::retry(fixed_iterable, || match resolver.lookup_ip(domain) {
|
||||
let check_result = retry::retry(fixed_iterable, || match next_resolver().lookup_ip(domain) {
|
||||
Ok(lookup_ip) => OperationResult::Ok(lookup_ip),
|
||||
Err(err) => {
|
||||
let x = format!("Domain resolution check for '{}' is still in progress...", domain);
|
||||
@@ -585,8 +603,8 @@ pub fn print_action(cloud_provider_name: &str, struct_name: &str, fn_name: &str,
|
||||
mod tests {
|
||||
use crate::cloud_provider::models::CpuLimits;
|
||||
use crate::cloud_provider::utilities::{
|
||||
convert_k8s_cpu_value_to_f32, get_cname_record_value, google_dns_resolver,
|
||||
validate_k8s_required_cpu_and_burstable, VersionsNumber,
|
||||
convert_k8s_cpu_value_to_f32, dns_resolvers, get_cname_record_value, validate_k8s_required_cpu_and_burstable,
|
||||
VersionsNumber,
|
||||
};
|
||||
use crate::error::StringError;
|
||||
use crate::models::ListenersHelper;
|
||||
@@ -633,8 +651,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_cname_resolution() {
|
||||
let resolver = google_dns_resolver();
|
||||
let cname = get_cname_record_value(&resolver, "ci-test-no-delete.qovery.io");
|
||||
let resolvers = dns_resolvers();
|
||||
let cname = get_cname_record_value(&resolvers[0], "ci-test-no-delete.qovery.io");
|
||||
|
||||
assert_eq!(cname, Some(String::from("qovery.io.")));
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::ffi::OsStr;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::path::Path;
|
||||
use std::process::{Command, ExitStatus, Stdio};
|
||||
use std::process::{Child, Command, ExitStatus, Stdio};
|
||||
|
||||
use crate::cmd::utilities::CommandError::{ExecutionError, ExitStatusError, TimeoutError};
|
||||
use crate::cmd::utilities::CommandOutputType::{STDERR, STDOUT};
|
||||
use crate::cmd::command::CommandError::{ExecutionError, ExitStatusError, Killed, TimeoutError};
|
||||
use crate::cmd::command::CommandOutputType::{STDERR, STDOUT};
|
||||
|
||||
use chrono::Duration;
|
||||
use itertools::Itertools;
|
||||
@@ -27,6 +27,9 @@ pub enum CommandError {
|
||||
|
||||
#[error("Command killed due to timeout: {0}")]
|
||||
TimeoutError(String),
|
||||
|
||||
#[error("Command killed by user request: {0}")]
|
||||
Killed(String),
|
||||
}
|
||||
|
||||
pub struct QoveryCommand {
|
||||
@@ -49,27 +52,20 @@ impl QoveryCommand {
|
||||
self.command.current_dir(root_dir);
|
||||
}
|
||||
|
||||
fn kill(cmd_handle: &mut Child) {
|
||||
let _ = cmd_handle
|
||||
.kill() //Fire
|
||||
.map(|_| cmd_handle.wait())
|
||||
.map_err(|err| error!("Cannot kill process {:?} {}", cmd_handle, err));
|
||||
}
|
||||
|
||||
pub fn exec(&mut self) -> Result<(), CommandError> {
|
||||
info!("command: {:?}", self.command);
|
||||
|
||||
let mut cmd_handle = self
|
||||
.command
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
.map_err(ExecutionError)?;
|
||||
|
||||
let exit_status = cmd_handle.wait().map_err(ExecutionError)?;
|
||||
|
||||
if !exit_status.success() {
|
||||
debug!(
|
||||
"command: {:?} terminated with error exist status {:?}",
|
||||
self.command, exit_status
|
||||
);
|
||||
return Err(ExitStatusError(exit_status));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
self.exec_with_abort(
|
||||
Duration::max_value(),
|
||||
|line| info!("{}", line),
|
||||
|line| warn!("{}", line),
|
||||
|| false,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn exec_with_output<STDOUT, STDERR>(
|
||||
@@ -81,18 +77,33 @@ impl QoveryCommand {
|
||||
STDOUT: FnMut(String),
|
||||
STDERR: FnMut(String),
|
||||
{
|
||||
self.exec_with_timeout(Duration::max_value(), stdout_output, stderr_output)
|
||||
self.exec_with_abort(Duration::max_value(), stdout_output, stderr_output, || false)
|
||||
}
|
||||
|
||||
pub fn exec_with_timeout<STDOUT, STDERR>(
|
||||
&mut self,
|
||||
timeout: Duration,
|
||||
mut stdout_output: STDOUT,
|
||||
mut stderr_output: STDERR,
|
||||
stdout_output: STDOUT,
|
||||
stderr_output: STDERR,
|
||||
) -> Result<(), CommandError>
|
||||
where
|
||||
STDOUT: FnMut(String),
|
||||
STDERR: FnMut(String),
|
||||
{
|
||||
self.exec_with_abort(timeout, stdout_output, stderr_output, || false)
|
||||
}
|
||||
|
||||
pub fn exec_with_abort<STDOUT, STDERR, F>(
|
||||
&mut self,
|
||||
timeout: Duration,
|
||||
mut stdout_output: STDOUT,
|
||||
mut stderr_output: STDERR,
|
||||
should_be_killed: F,
|
||||
) -> Result<(), CommandError>
|
||||
where
|
||||
STDOUT: FnMut(String),
|
||||
STDERR: FnMut(String),
|
||||
F: Fn() -> bool,
|
||||
{
|
||||
assert!(timeout.num_seconds() > 0, "Timeout cannot be a 0 or negative duration");
|
||||
|
||||
@@ -136,6 +147,10 @@ impl QoveryCommand {
|
||||
STDERR(Err(err)) => error!("Error on stderr of cmd {:?}: {:?}", self.command, err),
|
||||
}
|
||||
|
||||
if should_be_killed() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (process_start_time.elapsed().as_secs() as i64) >= timeout.num_seconds() {
|
||||
break;
|
||||
}
|
||||
@@ -151,28 +166,31 @@ impl QoveryCommand {
|
||||
break;
|
||||
}
|
||||
Ok(None) => {
|
||||
if (process_start_time.elapsed().as_secs() as i64) < timeout.num_seconds() {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
continue;
|
||||
// Does the process should be killed ?
|
||||
if should_be_killed() {
|
||||
let msg = format!("Killing process {:?}", self.command);
|
||||
warn!("{}", msg);
|
||||
Self::kill(&mut cmd_handle);
|
||||
return Err(Killed(msg));
|
||||
}
|
||||
|
||||
// Timeout !
|
||||
let msg = format!(
|
||||
"Killing process {:?} due to timeout {}m reached",
|
||||
self.command,
|
||||
timeout.num_minutes()
|
||||
);
|
||||
warn!("{}", msg);
|
||||
|
||||
let _ = cmd_handle
|
||||
.kill() //Fire
|
||||
.map(|_| cmd_handle.wait())
|
||||
.map_err(|err| error!("Cannot kill process {:?} {}", cmd_handle, err));
|
||||
|
||||
return Err(TimeoutError(msg));
|
||||
// Does the timeout has been reached ?
|
||||
if (process_start_time.elapsed().as_secs() as i64) >= timeout.num_seconds() {
|
||||
let msg = format!(
|
||||
"Killing process {:?} due to timeout {}m reached",
|
||||
self.command,
|
||||
timeout.num_minutes()
|
||||
);
|
||||
warn!("{}", msg);
|
||||
Self::kill(&mut cmd_handle);
|
||||
return Err(TimeoutError(msg));
|
||||
}
|
||||
}
|
||||
Err(err) => return Err(ExecutionError(err)),
|
||||
};
|
||||
|
||||
// Sleep a bit and retry to check
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
|
||||
if !exit_status.success() {
|
||||
@@ -222,8 +240,11 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cmd::utilities::{does_binary_exist, run_version_command_for, CommandError, QoveryCommand};
|
||||
use crate::cmd::command::{does_binary_exist, run_version_command_for, CommandError, QoveryCommand};
|
||||
use chrono::Duration;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Barrier};
|
||||
use std::{thread, time};
|
||||
|
||||
#[test]
|
||||
fn test_binary_exist() {
|
||||
@@ -262,4 +283,27 @@ mod tests {
|
||||
let ret = cmd.exec_with_timeout(Duration::seconds(2), |_| {}, |_| {});
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_command_with_abort() {
|
||||
let mut cmd = QoveryCommand::new("sleep", &vec!["120"], &vec![]);
|
||||
let should_kill = Arc::new(AtomicBool::new(false));
|
||||
let should_kill2 = should_kill.clone();
|
||||
let barrier = Arc::new(Barrier::new(2));
|
||||
|
||||
let _ = thread::spawn({
|
||||
let barrier = barrier.clone();
|
||||
move || {
|
||||
barrier.wait();
|
||||
thread::sleep(time::Duration::from_secs(2));
|
||||
should_kill.store(true, Ordering::Release);
|
||||
}
|
||||
});
|
||||
|
||||
let cmd_killer = move || should_kill2.load(Ordering::Acquire);
|
||||
barrier.wait();
|
||||
let ret = cmd.exec_with_abort(Duration::max_value(), |_| {}, |_| {}, cmd_killer);
|
||||
|
||||
assert!(matches!(ret, Err(CommandError::Killed(_))));
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ use std::path::{Path, PathBuf};
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::cloud_provider::helm::ChartInfo;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::cmd::helm::HelmCommand::{LIST, ROLLBACK, STATUS, UNINSTALL, UPGRADE};
|
||||
use crate::cmd::helm::HelmError::{CannotRollback, CmdError, InvalidKubeConfig, ReleaseDoesNotExist};
|
||||
use crate::cmd::structs::{HelmChart, HelmListItem};
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::errors::{CommandError, EngineError};
|
||||
use crate::events::EventDetails;
|
||||
use chrono::Duration;
|
||||
@@ -561,8 +561,8 @@ pub fn to_engine_error(event_details: &EventDetails, error: HelmError) -> Engine
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cloud_provider::helm::{ChartInfo, ChartSetValue};
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::cmd::helm::{helm_exec_with_output, Helm, HelmError};
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use std::sync::{Arc, Barrier};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -7,12 +7,12 @@ use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::cloud_provider::digitalocean::models::svc::DoLoadBalancer;
|
||||
use crate::cloud_provider::metrics::KubernetesApiMetrics;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::cmd::structs::{
|
||||
Configmap, Daemonset, Item, KubernetesEvent, KubernetesJob, KubernetesKind, KubernetesList, KubernetesNode,
|
||||
KubernetesPod, KubernetesPodStatusPhase, KubernetesPodStatusReason, KubernetesService, KubernetesVersion,
|
||||
LabelsContent, Namespace, Secrets, HPA, PDB, PVC, SVC,
|
||||
};
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::constants::KUBECONFIG;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use crate::errors::CommandError;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod command;
|
||||
pub mod helm;
|
||||
pub mod kubectl;
|
||||
pub mod structs;
|
||||
pub mod terraform;
|
||||
pub mod utilities;
|
||||
|
||||
@@ -2,7 +2,7 @@ use dirs::home_dir;
|
||||
use retry::delay::Fixed;
|
||||
use retry::OperationResult;
|
||||
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::constants::TF_PLUGIN_CACHE_DIR;
|
||||
use crate::errors::CommandError;
|
||||
use rand::Rng;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::cmd;
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::container_registry::Kind;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use chrono::Duration;
|
||||
@@ -78,7 +78,7 @@ pub fn docker_manifest_inspect(
|
||||
image_with_tag,
|
||||
registry_provider,
|
||||
registry_url,
|
||||
cmd::utilities::command_to_string(binary, &args, &envs),
|
||||
cmd::command::command_to_string(binary, &args, &envs),
|
||||
e,
|
||||
);
|
||||
None
|
||||
@@ -118,7 +118,7 @@ pub fn docker_login(
|
||||
"error while trying to login to registry {} {}, command `{}`: {:?}",
|
||||
registry_provider,
|
||||
registry_url,
|
||||
cmd::utilities::command_to_string(binary, &args, &docker_envs),
|
||||
cmd::command::command_to_string(binary, &args, &docker_envs),
|
||||
e,
|
||||
);
|
||||
error!("{}", error_message);
|
||||
|
||||
@@ -3,7 +3,7 @@ extern crate reqwest;
|
||||
use reqwest::StatusCode;
|
||||
|
||||
use crate::build_platform::Image;
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::container_registry::docker::{docker_pull_image, docker_tag_and_push_image};
|
||||
use crate::container_registry::{ContainerRegistry, EngineError, Kind, PullResult, PushResult};
|
||||
use crate::error::EngineErrorCause;
|
||||
|
||||
@@ -4,7 +4,7 @@ use reqwest::StatusCode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::build_platform::Image;
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::container_registry::docker::{docker_pull_image, docker_tag_and_push_image};
|
||||
use crate::container_registry::{ContainerRegistry, EngineError, Kind, PullResult, PushResult};
|
||||
use crate::error::{cast_simple_error_to_engine_error, EngineErrorCause, SimpleError, SimpleErrorKind};
|
||||
|
||||
@@ -9,7 +9,7 @@ use rusoto_ecr::{
|
||||
use rusoto_sts::{GetCallerIdentityRequest, Sts, StsClient};
|
||||
|
||||
use crate::build_platform::Image;
|
||||
use crate::cmd::utilities::QoveryCommand;
|
||||
use crate::cmd::command::QoveryCommand;
|
||||
use crate::container_registry::docker::{docker_pull_image, docker_tag_and_push_image};
|
||||
use crate::container_registry::{ContainerRegistry, Kind, PullResult, PushResult};
|
||||
use crate::error::{EngineError, EngineErrorCause};
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct Engine {
|
||||
cloud_provider: Box<dyn CloudProvider>,
|
||||
dns_provider: Box<dyn DnsProvider>,
|
||||
logger: Box<dyn Logger>,
|
||||
pub is_task_canceled: Box<dyn Fn() -> bool>,
|
||||
}
|
||||
|
||||
impl Engine {
|
||||
@@ -26,6 +27,7 @@ impl Engine {
|
||||
cloud_provider: Box<dyn CloudProvider>,
|
||||
dns_provider: Box<dyn DnsProvider>,
|
||||
logger: Box<dyn Logger>,
|
||||
is_task_canceled: Box<dyn Fn() -> bool>,
|
||||
) -> Engine {
|
||||
Engine {
|
||||
context,
|
||||
@@ -34,6 +36,7 @@ impl Engine {
|
||||
cloud_provider,
|
||||
dns_provider,
|
||||
logger,
|
||||
is_task_canceled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ impl EngineError {
|
||||
message: message.map(|message| message.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_cancel(&self) -> bool {
|
||||
self.cause == EngineErrorCause::Canceled
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -60,9 +64,10 @@ impl From<Transmitter> for EngineErrorScope {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum EngineErrorCause {
|
||||
Internal,
|
||||
Canceled,
|
||||
User(&'static str),
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ impl Display for QoveryIdentifier {
|
||||
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum EnvironmentAction {
|
||||
Environment(TargetEnvironment),
|
||||
EnvironmentWithFailover(TargetEnvironment, FailoverEnvironment),
|
||||
}
|
||||
|
||||
pub type TargetEnvironment = Environment;
|
||||
|
||||
@@ -118,17 +118,6 @@ impl<'a> Transaction<'a> {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
},
|
||||
EnvironmentAction::EnvironmentWithFailover(te, fe) => {
|
||||
match te.is_valid() {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
|
||||
match fe.is_valid() {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
@@ -201,7 +190,11 @@ impl<'a> Transaction<'a> {
|
||||
let _ = self.load_build_app_cache(app);
|
||||
|
||||
// only if the build is forced OR if the image does not exist in the registry
|
||||
self.engine.build_platform().build(app.to_build(), option.force_build)
|
||||
self.engine.build_platform().build(
|
||||
app.to_build(),
|
||||
option.force_build,
|
||||
&self.engine.is_task_canceled,
|
||||
)
|
||||
} else {
|
||||
// use the cache
|
||||
Ok(BuildResult::new(app.to_build()))
|
||||
@@ -348,34 +341,6 @@ impl<'a> Transaction<'a> {
|
||||
};
|
||||
|
||||
match environment_action {
|
||||
EnvironmentAction::EnvironmentWithFailover(target_environment, failover_environment) => {
|
||||
// let's reverse changes and rollback on the provided failover version
|
||||
let target_qe_environment = qe_environment(target_environment);
|
||||
let failover_qe_environment = qe_environment(failover_environment);
|
||||
|
||||
let action = match failover_environment.action {
|
||||
Action::Create => {
|
||||
let _ = kubernetes.deploy_environment_error(&target_qe_environment);
|
||||
kubernetes.deploy_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Pause => {
|
||||
let _ = kubernetes.pause_environment_error(&target_qe_environment);
|
||||
kubernetes.pause_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Delete => {
|
||||
let _ = kubernetes.delete_environment_error(&target_qe_environment);
|
||||
kubernetes.delete_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Nothing => Ok(()),
|
||||
};
|
||||
|
||||
let _ = match action {
|
||||
Ok(_) => {}
|
||||
Err(err) => return Err(RollbackError::CommitError(err.to_legacy_engine_error())),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
EnvironmentAction::Environment(te) => {
|
||||
// revert changes but there is no failover environment
|
||||
let target_qe_environment = qe_environment(te);
|
||||
@@ -451,56 +416,43 @@ impl<'a> Transaction<'a> {
|
||||
// build applications
|
||||
let target_environment = match environment_action {
|
||||
EnvironmentAction::Environment(te) => te,
|
||||
EnvironmentAction::EnvironmentWithFailover(te, _) => te,
|
||||
};
|
||||
|
||||
let apps_result = match self.build_applications(target_environment, option) {
|
||||
Ok(applications) => match self.push_applications(applications, option) {
|
||||
Ok(results) => {
|
||||
let applications = results.into_iter().map(|(app, _)| app).collect::<Vec<_>>();
|
||||
|
||||
Ok(applications)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
|
||||
if apps_result.is_err() {
|
||||
let commit_error = apps_result.err().unwrap();
|
||||
warn!("ROLLBACK STARTED! an error occurred {:?}", commit_error);
|
||||
|
||||
return match self.rollback() {
|
||||
Ok(_) => TransactionResult::Rollback(commit_error),
|
||||
Err(err) => {
|
||||
error!("ROLLBACK FAILED! fatal error: {:?}", err);
|
||||
return TransactionResult::UnrecoverableError(commit_error, err);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let applications = apps_result.ok().unwrap();
|
||||
applications_by_environment.insert(target_environment, applications);
|
||||
|
||||
// build as well the failover environment, retention could remove the application image
|
||||
if let EnvironmentAction::EnvironmentWithFailover(_, fe) = environment_action {
|
||||
let apps_result = match self.build_applications(fe, option) {
|
||||
Ok(applications) => match self.push_applications(applications, option) {
|
||||
Ok(results) => {
|
||||
let applications = results.into_iter().map(|(app, _)| app).collect::<Vec<_>>();
|
||||
|
||||
Ok(applications)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
if apps_result.is_err() {
|
||||
// should never be triggered because core always should ask for working failover environment
|
||||
let commit_error = apps_result.err().unwrap();
|
||||
error!("An error occurred on failover application {:?}", commit_error);
|
||||
let applications_builds = match self.build_applications(target_environment, option) {
|
||||
Ok(apps) => apps,
|
||||
Err(engine_err) => {
|
||||
warn!("ROLLBACK STARTED! an error occurred {:?}", engine_err);
|
||||
return if engine_err.is_cancel() {
|
||||
TransactionResult::Canceled
|
||||
} else {
|
||||
TransactionResult::Rollback(engine_err)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if (self.engine.is_task_canceled)() {
|
||||
return TransactionResult::Canceled;
|
||||
}
|
||||
|
||||
let applications = match self.push_applications(applications_builds, option) {
|
||||
Ok(results) => {
|
||||
let applications = results.into_iter().map(|(app, _)| app).collect::<Vec<_>>();
|
||||
|
||||
applications
|
||||
}
|
||||
Err(engine_err) => {
|
||||
warn!("ROLLBACK STARTED! an error occurred {:?}", engine_err);
|
||||
return match self.rollback() {
|
||||
Ok(_) => TransactionResult::Rollback(engine_err),
|
||||
Err(err) => {
|
||||
error!("ROLLBACK FAILED! fatal error: {:?}", err);
|
||||
TransactionResult::UnrecoverableError(engine_err, err)
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
applications_by_environment.insert(target_environment, applications);
|
||||
}
|
||||
Step::DeployEnvironment(kubernetes, environment_action) => {
|
||||
// deploy complete environment
|
||||
@@ -645,7 +597,6 @@ impl<'a> Transaction<'a> {
|
||||
{
|
||||
let target_environment = match environment_action {
|
||||
EnvironmentAction::Environment(te) => te,
|
||||
EnvironmentAction::EnvironmentWithFailover(te, _) => te,
|
||||
};
|
||||
|
||||
let empty_vec = Vec::with_capacity(0);
|
||||
@@ -787,6 +738,7 @@ pub enum RollbackError {
|
||||
#[derive(Debug)]
|
||||
pub enum TransactionResult {
|
||||
Ok,
|
||||
Canceled,
|
||||
Rollback(EngineError),
|
||||
UnrecoverableError(EngineError, RollbackError),
|
||||
}
|
||||
|
||||
87
test_utilities/Cargo.lock
generated
87
test_utilities/Cargo.lock
generated
@@ -889,7 +889,7 @@ dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"log",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
@@ -1106,9 +1106,9 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.10.1"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
|
||||
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest 0.9.0",
|
||||
@@ -1221,7 +1221,7 @@ dependencies = [
|
||||
"itoa",
|
||||
"log",
|
||||
"net2",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
"time 0.1.44",
|
||||
"tokio 0.1.22",
|
||||
"tokio-buf",
|
||||
@@ -1591,10 +1591,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||
|
||||
[[package]]
|
||||
name = "md5"
|
||||
version = "0.7.0"
|
||||
name = "md-5"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
|
||||
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
@@ -1855,7 +1860,7 @@ checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
|
||||
dependencies = [
|
||||
"lock_api 0.3.4",
|
||||
"parking_lot_core 0.6.2",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1879,7 +1884,7 @@ dependencies = [
|
||||
"cloudabi",
|
||||
"libc",
|
||||
"redox_syscall 0.1.57",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
"smallvec 0.6.13",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
@@ -2632,9 +2637,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_core"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02aff20978970d47630f08de5f0d04799497818d16cafee5aec90c4b4d0806cf"
|
||||
checksum = "5b4f000e8934c1b4f70adde180056812e7ea6b1a247952db8ee98c94cd3116cc"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.13.0",
|
||||
@@ -2648,7 +2653,7 @@ dependencies = [
|
||||
"log",
|
||||
"rusoto_credential",
|
||||
"rusoto_signature",
|
||||
"rustc_version",
|
||||
"rustc_version 0.4.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio 1.10.0",
|
||||
@@ -2657,9 +2662,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_credential"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e91e4c25ea8bfa6247684ff635299015845113baaa93ba8169b9e565701b58e"
|
||||
checksum = "6a46b67db7bb66f5541e44db22b0a02fed59c9603e146db3a9e633272d3bac2f"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"chrono",
|
||||
@@ -2675,9 +2680,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_dynamodb"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f26af40f36409cb8fae3069690f78f638f747b55c7b90f338d5ed36016b0cda"
|
||||
checksum = "7935e1f9ca57c4ee92a4d823dcd698eb8c992f7e84ca21976ae72cd2b03016e7"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
@@ -2689,9 +2694,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_ecr"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ab222491e156f033926d40c663d57a6b60a5c5ec94e696e66f52a0c64d20dbf"
|
||||
checksum = "93ec4a28e4fb276307c2129abb16cf7d5573da4ec24d9e3895cc5c8a8bc21a4d"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
@@ -2703,9 +2708,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_eks"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91d7e1e577d4102a9d80d5eafc0547064d3e8817d094f00e95ae45d03ae3accb"
|
||||
checksum = "7bada849ce4a4836ae23920613144339b23dc0ebfc4d19fbc20f6b7b9d3cb6d9"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
@@ -2718,23 +2723,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_iam"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0268b898abed79c59f8468c4991d0f97ed0925049db228cff623ecac44c5b3a6"
|
||||
checksum = "eeb3a551b0fea2882b7caafc7dcdc74c80e73f16c41bfb722f4ea88e3e21625d"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
"futures 0.3.15",
|
||||
"rusoto_core",
|
||||
"serde_urlencoded 0.6.1",
|
||||
"serde_urlencoded 0.7.0",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_s3"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abc3f56f14ccf91f880b9a9c2d0556d8523e8c155041c54db155b384a1dd1119"
|
||||
checksum = "048c2fe811a823ad5a9acc976e8bf4f1d910df719dcf44b15c3e96c5b7a51027"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
@@ -2745,41 +2750,42 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_signature"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5486e6b1673ab3e0ba1ded284fb444845fe1b7f41d13989a54dd60f62a7b2baa"
|
||||
checksum = "6264e93384b90a747758bcc82079711eacf2e755c3a8b5091687b5349d870bcc"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bytes 1.0.1",
|
||||
"chrono",
|
||||
"digest 0.9.0",
|
||||
"futures 0.3.15",
|
||||
"hex",
|
||||
"hmac",
|
||||
"http 0.2.1",
|
||||
"hyper 0.14.7",
|
||||
"log",
|
||||
"md5",
|
||||
"md-5",
|
||||
"percent-encoding 2.1.0",
|
||||
"pin-project-lite 0.2.6",
|
||||
"rusoto_credential",
|
||||
"rustc_version",
|
||||
"rustc_version 0.4.0",
|
||||
"serde",
|
||||
"sha2",
|
||||
"time 0.2.24",
|
||||
"tokio 1.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusoto_sts"
|
||||
version = "0.46.0"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f93005e0c3b9e40a424b50ca71886d2445cc19bb6cdac3ac84c2daff482eb59"
|
||||
checksum = "4e7edd42473ac006fd54105f619e480b0a94136e7f53cf3fb73541363678fd92"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
"chrono",
|
||||
"futures 0.3.15",
|
||||
"rusoto_core",
|
||||
"serde_urlencoded 0.6.1",
|
||||
"serde_urlencoded 0.7.0",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
@@ -2817,6 +2823,15 @@ dependencies = [
|
||||
"semver 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||
dependencies = [
|
||||
"semver 1.0.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.6"
|
||||
@@ -3027,9 +3042,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "0.1.1"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
@@ -3107,7 +3122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
|
||||
dependencies = [
|
||||
"discard",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
"stdweb-derive",
|
||||
"stdweb-internal-macros",
|
||||
"stdweb-internal-runtime",
|
||||
|
||||
@@ -80,6 +80,7 @@ impl Cluster<AWS, Options> for AWS {
|
||||
cloud_provider,
|
||||
dns_provider,
|
||||
logger,
|
||||
Box::new(|| false),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -991,7 +991,7 @@ pub fn test_db(
|
||||
|
||||
let app_id = generate_id();
|
||||
let database_username = "superuser".to_string();
|
||||
let database_password = generate_id();
|
||||
let database_password = generate_password(true);
|
||||
let db_kind_str = db_kind.name().to_string();
|
||||
let db_id = generate_id();
|
||||
let database_host = format!("{}-{}", db_id, db_kind_str.clone());
|
||||
@@ -1076,11 +1076,8 @@ pub fn test_db(
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(provider_kind.clone(), &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
}
|
||||
let ret = environment.deploy_environment(provider_kind.clone(), &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match database_mode.clone() {
|
||||
DatabaseMode::CONTAINER => {
|
||||
@@ -1142,11 +1139,8 @@ pub fn test_db(
|
||||
}
|
||||
}
|
||||
|
||||
match environment_delete.delete_environment(provider_kind.clone(), &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
}
|
||||
let ret = environment_delete.delete_environment(provider_kind.clone(), &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
}
|
||||
@@ -1390,11 +1384,7 @@ pub fn cluster_test(
|
||||
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),
|
||||
};
|
||||
assert!(matches!(deploy_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
// Deploy env if any
|
||||
if let Some(env) = environment_to_deploy {
|
||||
@@ -1404,11 +1394,8 @@ pub fn cluster_test(
|
||||
if let Err(err) = deploy_env_tx.deploy_environment(kubernetes.as_ref(), env) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match deploy_env_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
assert!(matches!(deploy_env_tx.commit(), TransactionResult::Ok));
|
||||
}
|
||||
|
||||
if let Err(err) = metrics_server_test(
|
||||
@@ -1430,21 +1417,14 @@ pub fn cluster_test(
|
||||
if let Err(err) = pause_tx.pause_kubernetes(kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match pause_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
assert!(matches!(pause_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
// Resume
|
||||
if let Err(err) = resume_tx.create_kubernetes(kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
let _ = match resume_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
assert!(matches!(resume_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
if let Err(err) = metrics_server_test(
|
||||
kubernetes
|
||||
@@ -1478,11 +1458,7 @@ pub fn cluster_test(
|
||||
if let Err(err) = upgrade_tx.create_kubernetes(upgraded_kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
let _ = match upgrade_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
assert!(matches!(upgrade_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
if let Err(err) = metrics_server_test(
|
||||
upgraded_kubernetes
|
||||
@@ -1501,11 +1477,7 @@ pub fn cluster_test(
|
||||
if let Err(err) = delete_tx.delete_kubernetes(upgraded_kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match delete_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
assert!(matches!(delete_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
}
|
||||
@@ -1519,22 +1491,14 @@ pub fn cluster_test(
|
||||
if let Err(err) = destroy_env_tx.delete_environment(kubernetes.as_ref(), env) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match destroy_env_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
assert!(matches!(destroy_env_tx.commit(), TransactionResult::Ok));
|
||||
}
|
||||
|
||||
// Delete
|
||||
if let Err(err) = delete_tx.delete_kubernetes(kubernetes.as_ref()) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match delete_tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
assert!(matches!(delete_tx.commit(), TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ impl Cluster<DO, DoksOptions> for DO {
|
||||
cloud_provider,
|
||||
dns_provider,
|
||||
logger,
|
||||
Box::new(|| false),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ impl Cluster<Scaleway, KapsuleOptions> for Scaleway {
|
||||
cloud_provider,
|
||||
dns_provider,
|
||||
logger,
|
||||
Box::new(|| false),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@ use crate::digitalocean::{
|
||||
DO_SELF_HOSTED_DATABASE_INSTANCE_TYPE,
|
||||
};
|
||||
use qovery_engine::cloud_provider::digitalocean::application::DoRegion;
|
||||
use qovery_engine::cmd::command::QoveryCommand;
|
||||
use qovery_engine::cmd::kubectl::{kubectl_get_pvc, kubectl_get_svc};
|
||||
use qovery_engine::cmd::structs::{KubernetesList, KubernetesPod, PVC, SVC};
|
||||
use qovery_engine::cmd::utilities::QoveryCommand;
|
||||
use qovery_engine::errors::CommandError;
|
||||
use qovery_engine::logger::{Logger, StdIoLogger};
|
||||
use qovery_engine::models::DatabaseMode::MANAGED;
|
||||
|
||||
@@ -64,17 +64,11 @@ fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -123,17 +117,11 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment.pause_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.pause_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this db
|
||||
let app_name = format!("postgresql{}-0", environment.databases[0].name);
|
||||
@@ -147,11 +135,8 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), true);
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -210,11 +195,9 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_for_deletion = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// 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);
|
||||
@@ -222,11 +205,8 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_for_deletion, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_for_deletion, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -334,17 +314,13 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_to_redeploy.deploy_environment(Kind::Aws, &context_for_redeploy, &ea_redeploy, logger.clone())
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret =
|
||||
environment_to_redeploy.deploy_environment(Kind::Aws, &context_for_redeploy, &ea_redeploy, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// TO CHECK: DATABASE SHOULDN'T BE RESTARTED AFTER A REDEPLOY
|
||||
let database_name = format!("postgresql{}-0", &environment_check.databases[0].name);
|
||||
match is_pod_restarted_env(
|
||||
@@ -358,11 +334,11 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
(false, _) => assert!(false),
|
||||
}
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(
|
||||
ret,
|
||||
TransactionResult::Ok | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
|
||||
@@ -62,17 +62,11 @@ fn deploy_a_working_environment_with_no_router_on_aws_eks() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -128,7 +122,8 @@ fn test_build_cache() {
|
||||
PullResult::None => assert!(true),
|
||||
};
|
||||
|
||||
let build_result = local_docker.build(app.to_build(), false).unwrap();
|
||||
let cancel_task = || false;
|
||||
let build_result = local_docker.build(app.to_build(), false, &cancel_task).unwrap();
|
||||
|
||||
let _ = match ecr.push(&build_result.build.image, false) {
|
||||
Ok(_) => assert!(true),
|
||||
@@ -205,11 +200,8 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let selector = format!("appId={}", environment.clone().applications[0].id);
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -221,11 +213,8 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
match environment.pause_environment(Kind::Aws, &context_for_delete, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.pause_environment(Kind::Aws, &context_for_delete, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this app
|
||||
let ret = get_pods(
|
||||
@@ -275,11 +264,8 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
|
||||
// Check we can resume the env
|
||||
let ctx_resume = context.clone_not_same_execution_id();
|
||||
match environment.deploy_environment(Kind::Aws, &ctx_resume, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &ctx_resume, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -331,11 +317,9 @@ fn deploy_a_working_environment_and_pause_it_eks() {
|
||||
assert!(filtered_pdb);
|
||||
|
||||
// Cleanup
|
||||
match environment.delete_environment(Kind::Aws, &context_for_delete, &ea, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.delete_environment(Kind::Aws, &context_for_delete, &ea, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
}
|
||||
@@ -381,17 +365,14 @@ fn deploy_a_not_working_environment_with_no_router_on_aws_eks() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(
|
||||
ret,
|
||||
TransactionResult::Ok | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -456,17 +437,11 @@ fn build_with_buildpacks_and_deploy_a_working_environment() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -531,17 +506,11 @@ fn build_worker_with_buildpacks_and_deploy_a_working_environment() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -587,17 +556,11 @@ fn deploy_a_working_environment_with_domain() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -662,11 +625,8 @@ fn deploy_a_working_environment_with_storage_on_aws_eks() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Aws, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -676,11 +636,8 @@ fn deploy_a_working_environment_with_storage_on_aws_eks() {
|
||||
Err(_) => assert!(false),
|
||||
};
|
||||
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -750,11 +707,8 @@ fn redeploy_same_app_with_ebs() {
|
||||
let ea2 = EnvironmentAction::Environment(environment_redeploy.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Aws, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -773,11 +727,8 @@ fn redeploy_same_app_with_ebs() {
|
||||
secrets.clone(),
|
||||
);
|
||||
|
||||
match environment_redeploy.deploy_environment(Kind::Aws, &context_bis, &ea2, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_redeploy.deploy_environment(Kind::Aws, &context_bis, &ea2, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let (_, number2) = is_pod_restarted_env(
|
||||
context.clone(),
|
||||
@@ -788,11 +739,9 @@ fn redeploy_same_app_with_ebs() {
|
||||
);
|
||||
//nothing change in the app, so, it shouldn't be restarted
|
||||
assert!(number.eq(&number2));
|
||||
match environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
}
|
||||
@@ -854,26 +803,19 @@ fn deploy_a_not_working_environment_and_after_working_environment() {
|
||||
let ea_not_working = EnvironmentAction::Environment(environment_for_not_working.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment_for_not_working.deploy_environment(
|
||||
let ret = environment_for_not_working.deploy_environment(
|
||||
Kind::Aws,
|
||||
&context_for_not_working,
|
||||
&ea_not_working,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
);
|
||||
assert!(matches!(ret, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -946,48 +888,39 @@ fn deploy_ok_fail_fail_ok_environment() {
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
// OK
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// FAIL and rollback
|
||||
match not_working_env_1.deploy_environment(
|
||||
let ret = not_working_env_1.deploy_environment(
|
||||
Kind::Aws,
|
||||
&context_for_not_working_1,
|
||||
&ea_not_working_1,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
ret,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// FAIL and Rollback again
|
||||
match not_working_env_2.deploy_environment(
|
||||
let ret = not_working_env_2.deploy_environment(
|
||||
Kind::Aws,
|
||||
&context_for_not_working_2,
|
||||
&ea_not_working_2,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
ret,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// Should be working
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match delete_env.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = delete_env.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -1033,214 +966,11 @@ fn deploy_a_non_working_environment_with_no_failover_on_aws_eks() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match delete_env.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-aws-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn deploy_a_non_working_environment_with_a_working_failover_on_aws_eks() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
|
||||
// context for non working environment
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let logger = logger();
|
||||
let context = context(
|
||||
secrets
|
||||
.AWS_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_ORGANIZATION_ID is not set")
|
||||
.as_str(),
|
||||
secrets
|
||||
.AWS_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_CLUSTER_ID is not set")
|
||||
.as_str(),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::working_minimal_environment(&context, test_domain.as_str());
|
||||
// context for deletion
|
||||
let context_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::working_minimal_environment(&context_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let ea = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match delete_env.delete_environment(Kind::Aws, &context_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-aws-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn deploy_2_non_working_environments_with_2_working_failovers_on_aws_eks() {
|
||||
init();
|
||||
|
||||
let test_name = function_name!();
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
|
||||
let logger = logger();
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
|
||||
// context for non working environment
|
||||
let context_failover_1 = context(
|
||||
secrets
|
||||
.AWS_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_ORGANIZATION_ID is not set")
|
||||
.as_str(),
|
||||
secrets
|
||||
.AWS_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_CLUSTER_ID is not set")
|
||||
.as_str(),
|
||||
);
|
||||
let context_failover_2 = context_failover_1.clone_not_same_execution_id();
|
||||
|
||||
let context_first_fail_deployment_1 = context_failover_1.clone_not_same_execution_id();
|
||||
let context_second_fail_deployment_2 = context_failover_1.clone_not_same_execution_id();
|
||||
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let failover_environment_1 =
|
||||
test_utilities::common::echo_app_environment(&context_failover_1, test_domain.as_str());
|
||||
let fail_app_1 =
|
||||
test_utilities::common::non_working_environment(&context_first_fail_deployment_1, test_domain.as_str());
|
||||
let mut failover_environment_2 =
|
||||
test_utilities::common::echo_app_environment(&context_failover_2, test_domain.as_str());
|
||||
let fail_app_2 =
|
||||
test_utilities::common::non_working_environment(&context_second_fail_deployment_2, test_domain.as_str());
|
||||
|
||||
failover_environment_2.applications = failover_environment_2
|
||||
.applications
|
||||
.into_iter()
|
||||
.map(|mut app| {
|
||||
app.environment_vars = btreemap! {
|
||||
"ECHO_TEXT".to_string() => base64::encode("Lilou".to_string())
|
||||
};
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
|
||||
// context for deletion
|
||||
let context_deletion = context_failover_1.clone_not_same_execution_id();
|
||||
let mut delete_env = test_utilities::common::echo_app_environment(&context_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
// first deployment
|
||||
let ea1 = EnvironmentAction::EnvironmentWithFailover(fail_app_1, failover_environment_1.clone());
|
||||
let ea2 = EnvironmentAction::EnvironmentWithFailover(fail_app_2, failover_environment_2.clone());
|
||||
|
||||
match failover_environment_1.deploy_environment(Kind::Aws, &context_failover_1, &ea1, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match failover_environment_2.deploy_environment(Kind::Aws, &context_failover_2, &ea2, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match delete_env.delete_environment(Kind::Aws, &context_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-aws-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn deploy_a_non_working_environment_with_a_non_working_failover_on_aws_eks() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let logger = logger();
|
||||
let context = context(
|
||||
secrets
|
||||
.AWS_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_ORGANIZATION_ID is not set")
|
||||
.as_str(),
|
||||
secrets
|
||||
.AWS_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("AWS_TEST_CLUSTER_ID is not set")
|
||||
.as_str(),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::non_working_environment(&context_for_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
// environment action initialize
|
||||
let ea_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let ea = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match delete_env.delete_environment(Kind::Aws, &context_for_deletion, &ea_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret = delete_env.delete_environment(Kind::Aws, &context_for_delete, &ea_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
return test_name.to_string();
|
||||
})
|
||||
@@ -1287,21 +1017,15 @@ fn aws_eks_deploy_a_working_environment_with_sticky_session() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Aws, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Aws, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// checking if cookie is properly set on the app
|
||||
assert!(routers_sessions_are_sticky(environment.routers.clone()));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &env_action_for_delete, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret =
|
||||
environment_for_delete.delete_environment(Kind::Aws, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
})
|
||||
|
||||
@@ -65,17 +65,11 @@ fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets, DO_TEST_REGION) {
|
||||
@@ -127,17 +121,11 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action.clone(), logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action.clone(), logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment.pause_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.pause_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this db
|
||||
let app_name = format!("postgresql{}-0", environment.databases[0].name);
|
||||
@@ -151,11 +139,8 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), true);
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets.clone(), DO_TEST_REGION) {
|
||||
@@ -217,11 +202,9 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_deletion = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// 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);
|
||||
@@ -229,11 +212,9 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
assert_eq!(con, true);
|
||||
}*/
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_for_deletion, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret =
|
||||
environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_for_deletion, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(
|
||||
@@ -360,21 +341,17 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_to_redeploy.deploy_environment(
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = environment_to_redeploy.deploy_environment(
|
||||
Kind::Do,
|
||||
&context_for_redeploy,
|
||||
&env_action_redeploy,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// TO CHECK: DATABASE SHOULDN'T BE RESTARTED AFTER A REDEPLOY
|
||||
let database_name = format!("postgresql-{}-0", &environment_check.databases[0].name);
|
||||
match is_pod_restarted_env(
|
||||
@@ -388,11 +365,11 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
(false, _) => assert!(false),
|
||||
}
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret = environment_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(
|
||||
ret,
|
||||
TransactionResult::Ok | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets, DO_TEST_REGION) {
|
||||
|
||||
@@ -62,17 +62,12 @@ fn digitalocean_doks_deploy_a_working_environment_with_no_router() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret =
|
||||
environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -130,7 +125,8 @@ fn test_build_cache() {
|
||||
PullResult::None => assert!(true),
|
||||
};
|
||||
|
||||
let build_result = local_docker.build(app.to_build(), false).unwrap();
|
||||
let cancel_task = || false;
|
||||
let build_result = local_docker.build(app.to_build(), false, &cancel_task).unwrap();
|
||||
|
||||
let _ = match docr.push(&build_result.build.image, false) {
|
||||
Ok(_) => assert!(true),
|
||||
@@ -210,18 +206,12 @@ fn digitalocean_doks_deploy_a_not_working_environment_with_no_router() {
|
||||
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let ret =
|
||||
environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(ret, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -267,11 +257,8 @@ fn digitalocean_doks_deploy_a_working_environment_and_pause() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let selector = format!("appId={}", environment.applications[0].id);
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -283,11 +270,8 @@ fn digitalocean_doks_deploy_a_working_environment_and_pause() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
match environment.pause_environment(Kind::Do, &context_for_delete, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.pause_environment(Kind::Do, &context_for_delete, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this app
|
||||
let ret = get_pods(
|
||||
@@ -302,11 +286,8 @@ fn digitalocean_doks_deploy_a_working_environment_and_pause() {
|
||||
|
||||
// Check we can resume the env
|
||||
let ctx_resume = context.clone_not_same_execution_id();
|
||||
match environment.deploy_environment(Kind::Do, &ctx_resume, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.deploy_environment(Kind::Do, &ctx_resume, &env_action, logger.clone());
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -319,11 +300,8 @@ fn digitalocean_doks_deploy_a_working_environment_and_pause() {
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
// Cleanup
|
||||
match environment.delete_environment(Kind::Do, &context_for_delete, &env_action, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = environment.delete_environment(Kind::Do, &context_for_delete, &env_action, logger);
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -391,17 +369,12 @@ fn digitalocean_doks_build_with_buildpacks_and_deploy_a_working_environment() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -450,17 +423,12 @@ fn digitalocean_doks_deploy_a_working_environment_with_domain() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -527,11 +495,8 @@ fn digitalocean_doks_deploy_a_working_environment_with_storage() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Do, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -541,11 +506,8 @@ fn digitalocean_doks_deploy_a_working_environment_with_storage() {
|
||||
Err(_) => assert!(false),
|
||||
};
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -617,11 +579,8 @@ fn digitalocean_doks_redeploy_same_app() {
|
||||
let env_action_redeploy = EnvironmentAction::Environment(environment_redeploy.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Do, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -640,11 +599,9 @@ fn digitalocean_doks_redeploy_same_app() {
|
||||
secrets.clone(),
|
||||
);
|
||||
|
||||
match environment_redeploy.deploy_environment(Kind::Do, &context_bis, &env_action_redeploy, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_redeploy.deploy_environment(Kind::Do, &context_bis, &env_action_redeploy, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let (_, number2) = is_pod_restarted_env(
|
||||
context.clone(),
|
||||
@@ -657,11 +614,8 @@ fn digitalocean_doks_redeploy_same_app() {
|
||||
// nothing changed in the app, so, it shouldn't be restarted
|
||||
assert!(number.eq(&number2));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment_delete.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -728,26 +682,18 @@ fn digitalocean_doks_deploy_a_not_working_environment_and_then_working_environme
|
||||
let env_action_not_working = EnvironmentAction::Environment(environment_for_not_working.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment_for_not_working.deploy_environment(
|
||||
let result = environment_for_not_working.deploy_environment(
|
||||
Kind::Do,
|
||||
&context_for_not_working,
|
||||
&env_action_not_working,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
);
|
||||
assert!(matches!(result, TransactionResult::UnrecoverableError(_, _)));
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -822,48 +768,39 @@ fn digitalocean_doks_deploy_ok_fail_fail_ok_environment() {
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
// OK
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// FAIL and rollback
|
||||
match not_working_env_1.deploy_environment(
|
||||
let result = not_working_env_1.deploy_environment(
|
||||
Kind::Do,
|
||||
&context_for_not_working_1,
|
||||
&env_action_not_working_1,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// FAIL and Rollback again
|
||||
match not_working_env_2.deploy_environment(
|
||||
let result = not_working_env_2.deploy_environment(
|
||||
Kind::Do,
|
||||
&context_for_not_working_2,
|
||||
&env_action_not_working_2,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// Should be working
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match delete_env.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = delete_env.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -912,17 +849,11 @@ fn digitalocean_doks_deploy_a_non_working_environment_with_no_failover() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
match delete_env.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = delete_env.delete_environment(Kind::Do, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -932,138 +863,6 @@ fn digitalocean_doks_deploy_a_non_working_environment_with_no_failover() {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-do-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn digitalocean_doks_deploy_a_non_working_environment_with_a_working_failover() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name,);
|
||||
let _enter = span.enter();
|
||||
|
||||
let logger = logger();
|
||||
|
||||
// context for non working environment
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let context = context(
|
||||
secrets
|
||||
.DIGITAL_OCEAN_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("DIGITAL_OCEAN_TEST_ORGANIZATION_ID is not set"),
|
||||
secrets
|
||||
.DIGITAL_OCEAN_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("DIGITAL_OCEAN_TEST_CLUSTER_ID is not set"),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::working_minimal_environment(&context, test_domain.as_str());
|
||||
|
||||
// context for deletion
|
||||
let context_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::working_minimal_environment(&context_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let env_action = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match delete_env.delete_environment(Kind::Do, &context_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
if let Err(e) = clean_environments(
|
||||
&context,
|
||||
vec![environment.clone(), failover_environment.clone()],
|
||||
secrets.clone(),
|
||||
DO_TEST_REGION,
|
||||
) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
}
|
||||
|
||||
test_name.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-do-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn digitalocean_doks_deploy_a_non_working_environment_with_a_non_working_failover() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name,);
|
||||
let _enter = span.enter();
|
||||
|
||||
let logger = logger();
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let context = context(
|
||||
secrets
|
||||
.DIGITAL_OCEAN_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("DIGITAL_OCEAN_TEST_ORGANIZATION_ID is not set"),
|
||||
secrets
|
||||
.DIGITAL_OCEAN_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("DIGITAL_OCEAN_TEST_CLUSTER_ID is not set"),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::non_working_environment(&context_for_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
|
||||
// environment action initialize
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let env_action = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match delete_env.delete_environment(Kind::Do, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
if let Err(e) = clean_environments(
|
||||
&context,
|
||||
vec![environment.clone(), failover_environment.clone()],
|
||||
secrets.clone(),
|
||||
DO_TEST_REGION,
|
||||
) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
}
|
||||
|
||||
test_name.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-do-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
@@ -1105,20 +904,15 @@ fn digitalocean_doks_deploy_a_working_environment_with_sticky_session() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Do, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// checking cookie is properly set on the app
|
||||
assert!(routers_sessions_are_sticky(environment.routers.clone()));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Do, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), DO_TEST_REGION) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
|
||||
@@ -66,11 +66,8 @@ fn create_digitalocean_kubernetes_doks_test_cluster() {
|
||||
if let Err(err) = tx.create_kubernetes(&kubernetes) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
let _ = match tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = tx.commit();
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
});
|
||||
@@ -132,11 +129,8 @@ fn destroy_digitalocean_kubernetes_doks_test_cluster() {
|
||||
if let Err(err) = tx.delete_kubernetes(&kubernetes) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = tx.commit();
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
});
|
||||
|
||||
@@ -69,17 +69,12 @@ fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets, SCW_TEST_ZONE) {
|
||||
@@ -133,17 +128,11 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment.pause_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.pause_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this db
|
||||
let app_name = format!("postgresql{}-0", environment.databases[0].name);
|
||||
@@ -157,16 +146,9 @@ fn deploy_an_environment_with_db_and_pause_it() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), true);
|
||||
|
||||
match environment_delete.delete_environment(
|
||||
Kind::Scw,
|
||||
&context_for_deletion,
|
||||
&env_action_delete,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets.clone(), SCW_TEST_ZONE) {
|
||||
@@ -229,18 +211,12 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_deletion = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_for_deletion, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_for_deletion, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(
|
||||
@@ -371,21 +347,17 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_to_redeploy.deploy_environment(
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let result = environment_to_redeploy.deploy_environment(
|
||||
Kind::Scw,
|
||||
&context_for_redeploy,
|
||||
&env_action_redeploy,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// TO CHECK: DATABASE SHOULDN'T BE RESTARTED AFTER A REDEPLOY
|
||||
let database_name = format!("postgresql-{}-0", &environment_check.databases[0].name);
|
||||
match is_pod_restarted_env(
|
||||
@@ -399,11 +371,11 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
(false, _) => assert!(false),
|
||||
}
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let result = environment_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Ok | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// delete images created during test from registries
|
||||
if let Err(e) = clean_environments(&context, vec![environment], secrets, SCW_TEST_ZONE) {
|
||||
|
||||
@@ -64,18 +64,12 @@ fn scaleway_kapsule_deploy_a_working_environment_with_no_router() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -135,7 +129,8 @@ fn test_build_cache() {
|
||||
PullResult::None => assert!(true),
|
||||
};
|
||||
|
||||
let build_result = local_docker.build(app.to_build(), false).unwrap();
|
||||
let cancel_task = || false;
|
||||
let build_result = local_docker.build(app.to_build(), false, &cancel_task).unwrap();
|
||||
|
||||
let _ = match scr.push(&build_result.build.image, false) {
|
||||
Ok(_) => assert!(true),
|
||||
@@ -218,18 +213,15 @@ fn scaleway_kapsule_deploy_a_not_working_environment_with_no_router() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Ok | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -277,11 +269,8 @@ fn scaleway_kapsule_deploy_a_working_environment_and_pause() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let selector = format!("appId={}", environment.applications[0].id);
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -293,11 +282,8 @@ fn scaleway_kapsule_deploy_a_working_environment_and_pause() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
match environment.pause_environment(Kind::Scw, &context_for_delete, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.pause_environment(Kind::Scw, &context_for_delete, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this app
|
||||
let ret = get_pods(
|
||||
@@ -312,11 +298,8 @@ fn scaleway_kapsule_deploy_a_working_environment_and_pause() {
|
||||
|
||||
// Check we can resume the env
|
||||
let ctx_resume = context.clone_not_same_execution_id();
|
||||
match environment.deploy_environment(Kind::Scw, &ctx_resume, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &ctx_resume, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -329,11 +312,8 @@ fn scaleway_kapsule_deploy_a_working_environment_and_pause() {
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
// Cleanup
|
||||
match environment.delete_environment(Kind::Scw, &context_for_delete, &env_action, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.delete_environment(Kind::Scw, &context_for_delete, &env_action, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -403,18 +383,12 @@ fn scaleway_kapsule_build_with_buildpacks_and_deploy_a_working_environment() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -465,17 +439,12 @@ fn scaleway_kapsule_deploy_a_working_environment_with_domain() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -544,11 +513,8 @@ fn scaleway_kapsule_deploy_a_working_environment_with_storage() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Scw, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -558,11 +524,9 @@ fn scaleway_kapsule_deploy_a_working_environment_with_storage() {
|
||||
Err(_) => assert!(false),
|
||||
};
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -609,11 +573,8 @@ fn deploy_a_working_environment_and_pause_it() {
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let selector = format!("appId={}", environment.applications[0].id);
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &ea, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -625,11 +586,8 @@ fn deploy_a_working_environment_and_pause_it() {
|
||||
assert_eq!(ret.is_ok(), true);
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
match environment.pause_environment(Kind::Scw, &context_for_delete, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.pause_environment(Kind::Scw, &context_for_delete, &ea, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// Check that we have actually 0 pods running for this app
|
||||
let ret = get_pods(
|
||||
@@ -644,11 +602,8 @@ fn deploy_a_working_environment_and_pause_it() {
|
||||
|
||||
// Check we can resume the env
|
||||
let ctx_resume = context.clone_not_same_execution_id();
|
||||
match environment.deploy_environment(Kind::Scw, &ctx_resume, &ea, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &ctx_resume, &ea, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let ret = get_pods(
|
||||
context.clone(),
|
||||
@@ -661,11 +616,8 @@ fn deploy_a_working_environment_and_pause_it() {
|
||||
assert_eq!(ret.unwrap().items.is_empty(), false);
|
||||
|
||||
// Cleanup
|
||||
match environment.delete_environment(Kind::Scw, &context_for_delete, &ea, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.delete_environment(Kind::Scw, &context_for_delete, &ea, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
return test_name.to_string();
|
||||
})
|
||||
}
|
||||
@@ -735,11 +687,8 @@ fn scaleway_kapsule_redeploy_same_app() {
|
||||
let env_action_redeploy = EnvironmentAction::Environment(environment_redeploy.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match get_pvc(context.clone(), Kind::Scw, environment.clone(), secrets.clone()) {
|
||||
Ok(pvc) => assert_eq!(
|
||||
@@ -758,11 +707,9 @@ fn scaleway_kapsule_redeploy_same_app() {
|
||||
secrets.clone(),
|
||||
);
|
||||
|
||||
match environment_redeploy.deploy_environment(Kind::Scw, &context_bis, &env_action_redeploy, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_redeploy.deploy_environment(Kind::Scw, &context_bis, &env_action_redeploy, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let (_, number2) = is_pod_restarted_env(
|
||||
context.clone(),
|
||||
@@ -775,11 +722,9 @@ fn scaleway_kapsule_redeploy_same_app() {
|
||||
// nothing changed in the app, so, it shouldn't be restarted
|
||||
assert!(number.eq(&number2));
|
||||
|
||||
match environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_delete.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -848,26 +793,20 @@ fn scaleway_kapsule_deploy_a_not_working_environment_and_then_working_environmen
|
||||
let env_action_not_working = EnvironmentAction::Environment(environment_for_not_working.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment_for_not_working.deploy_environment(
|
||||
let result = environment_for_not_working.deploy_environment(
|
||||
Kind::Scw,
|
||||
&context_for_not_working,
|
||||
&env_action_not_working,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
match environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
);
|
||||
assert!(matches!(result, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -945,48 +884,39 @@ fn scaleway_kapsule_deploy_ok_fail_fail_ok_environment() {
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
// OK
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// FAIL and rollback
|
||||
match not_working_env_1.deploy_environment(
|
||||
let result = not_working_env_1.deploy_environment(
|
||||
Kind::Scw,
|
||||
&context_for_not_working_1,
|
||||
&env_action_not_working_1,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// FAIL and Rollback again
|
||||
match not_working_env_2.deploy_environment(
|
||||
let result = not_working_env_2.deploy_environment(
|
||||
Kind::Scw,
|
||||
&context_for_not_working_2,
|
||||
&env_action_not_working_2,
|
||||
logger.clone(),
|
||||
) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(true),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
TransactionResult::Rollback(_) | TransactionResult::UnrecoverableError(_, _)
|
||||
));
|
||||
|
||||
// Should be working
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
match delete_env.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = delete_env.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -1038,17 +968,11 @@ fn scaleway_kapsule_deploy_a_non_working_environment_with_no_failover() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::UnrecoverableError(_, _)));
|
||||
|
||||
match delete_env.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = delete_env.delete_environment(Kind::Scw, &context_for_delete, &env_action_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
@@ -1058,144 +982,6 @@ fn scaleway_kapsule_deploy_a_non_working_environment_with_no_failover() {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-scw-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn scaleway_kapsule_deploy_a_non_working_environment_with_a_working_failover() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name,);
|
||||
let _enter = span.enter();
|
||||
|
||||
let logger = logger();
|
||||
|
||||
// context for non working environment
|
||||
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let context = context(
|
||||
secrets
|
||||
.SCALEWAY_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("SCALEWAY_TEST_ORGANIZATION_ID")
|
||||
.as_str(),
|
||||
secrets
|
||||
.SCALEWAY_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("SCALEWAY_TEST_CLUSTER_ID")
|
||||
.as_str(),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::working_minimal_environment(&context, test_domain.as_str());
|
||||
|
||||
// context for deletion
|
||||
let context_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::working_minimal_environment(&context_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let env_action = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match delete_env.delete_environment(Kind::Scw, &context_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
if let Err(e) = clean_environments(
|
||||
&context,
|
||||
vec![environment.clone(), failover_environment.clone()],
|
||||
secrets.clone(),
|
||||
SCW_TEST_ZONE,
|
||||
) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
}
|
||||
|
||||
test_name.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-scw-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
fn scaleway_kapsule_deploy_a_non_working_environment_with_a_non_working_failover() {
|
||||
let test_name = function_name!();
|
||||
engine_run_test(|| {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name,);
|
||||
let _enter = span.enter();
|
||||
|
||||
let logger = logger();
|
||||
|
||||
let secrets = FuncTestsSecrets::new();
|
||||
let context = context(
|
||||
secrets
|
||||
.SCALEWAY_TEST_ORGANIZATION_ID
|
||||
.as_ref()
|
||||
.expect("SCALEWAY_TEST_ORGANIZATION_ID")
|
||||
.as_str(),
|
||||
secrets
|
||||
.SCALEWAY_TEST_CLUSTER_ID
|
||||
.as_ref()
|
||||
.expect("SCALEWAY_TEST_CLUSTER_ID")
|
||||
.as_str(),
|
||||
);
|
||||
let test_domain = secrets
|
||||
.DEFAULT_TEST_DOMAIN
|
||||
.as_ref()
|
||||
.expect("DEFAULT_TEST_DOMAIN is not set in secrets");
|
||||
|
||||
let environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
let failover_environment = test_utilities::common::non_working_environment(&context, test_domain.as_str());
|
||||
|
||||
let context_for_deletion = context.clone_not_same_execution_id();
|
||||
let mut delete_env =
|
||||
test_utilities::common::non_working_environment(&context_for_deletion, test_domain.as_str());
|
||||
delete_env.action = Action::Delete;
|
||||
|
||||
// environment action initialize
|
||||
let env_action_delete = EnvironmentAction::Environment(delete_env.clone());
|
||||
let env_action = EnvironmentAction::EnvironmentWithFailover(environment.clone(), failover_environment.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(false),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
match delete_env.delete_environment(Kind::Scw, &context_for_deletion, &env_action_delete, logger) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(true),
|
||||
};
|
||||
|
||||
if let Err(e) = clean_environments(
|
||||
&context,
|
||||
vec![environment.clone(), failover_environment.clone()],
|
||||
secrets.clone(),
|
||||
SCW_TEST_ZONE,
|
||||
) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
}
|
||||
|
||||
test_name.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-scw-self-hosted")]
|
||||
#[named]
|
||||
#[test]
|
||||
@@ -1237,21 +1023,15 @@ fn scaleway_kapsule_deploy_a_working_environment_with_sticky_session() {
|
||||
let env_action = EnvironmentAction::Environment(environment.clone());
|
||||
let env_action_for_delete = EnvironmentAction::Environment(environment_for_delete.clone());
|
||||
|
||||
match environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone()) {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result = environment.deploy_environment(Kind::Scw, &context, &env_action, logger.clone());
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
// checking cookie is properly set on the app
|
||||
assert!(routers_sessions_are_sticky(environment.routers.clone()));
|
||||
|
||||
match environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger)
|
||||
{
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let result =
|
||||
environment_for_delete.delete_environment(Kind::Scw, &context_for_delete, &env_action_for_delete, logger);
|
||||
assert!(matches!(result, TransactionResult::Ok));
|
||||
|
||||
if let Err(e) = clean_environments(&context, vec![environment.clone()], secrets.clone(), SCW_TEST_ZONE) {
|
||||
warn!("cannot clean environments, error: {:?}", e);
|
||||
|
||||
@@ -65,11 +65,8 @@ fn create_scaleway_kubernetes_kapsule_test_cluster() {
|
||||
if let Err(err) = tx.create_kubernetes(&kubernetes) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
let _ = match tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
|
||||
assert!(matches!(tx.commit(), TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
});
|
||||
@@ -130,11 +127,8 @@ fn destroy_scaleway_kubernetes_kapsule_test_cluster() {
|
||||
if let Err(err) = tx.delete_kubernetes(&kubernetes) {
|
||||
panic!("{:?}", err)
|
||||
}
|
||||
match tx.commit() {
|
||||
TransactionResult::Ok => assert!(true),
|
||||
TransactionResult::Rollback(_) => assert!(false),
|
||||
TransactionResult::UnrecoverableError(_, _) => assert!(false),
|
||||
};
|
||||
let ret = tx.commit();
|
||||
assert!(matches!(ret, TransactionResult::Ok));
|
||||
|
||||
test_name.to_string()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user