fix tests, cargo fmt, introduced crate serial_test to allow sequential testing env sensitive tests
All checks were successful
Run Check Script / check (pull_request) Successful in 56s
All checks were successful
Run Check Script / check (pull_request) Successful in 56s
This commit is contained in:
87
Cargo.lock
generated
87
Cargo.lock
generated
@@ -1809,6 +1809,21 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "example-nats"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cidr",
|
||||||
|
"env_logger",
|
||||||
|
"harmony",
|
||||||
|
"harmony_cli",
|
||||||
|
"harmony_macros",
|
||||||
|
"harmony_types",
|
||||||
|
"log",
|
||||||
|
"tokio",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "example-ntfy"
|
name = "example-ntfy"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -1883,6 +1898,36 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "example-postgresql"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cidr",
|
||||||
|
"env_logger",
|
||||||
|
"harmony",
|
||||||
|
"harmony_cli",
|
||||||
|
"harmony_macros",
|
||||||
|
"harmony_types",
|
||||||
|
"log",
|
||||||
|
"tokio",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "example-public-postgres"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cidr",
|
||||||
|
"env_logger",
|
||||||
|
"harmony",
|
||||||
|
"harmony_cli",
|
||||||
|
"harmony_macros",
|
||||||
|
"harmony_types",
|
||||||
|
"log",
|
||||||
|
"tokio",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "example-pxe"
|
name = "example-pxe"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2435,6 +2480,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
|
"serial_test",
|
||||||
"similar",
|
"similar",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"strum 0.27.2",
|
"strum 0.27.2",
|
||||||
@@ -5116,6 +5162,15 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scc"
|
||||||
|
version = "2.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc"
|
||||||
|
dependencies = [
|
||||||
|
"sdd",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schannel"
|
name = "schannel"
|
||||||
version = "0.1.27"
|
version = "0.1.27"
|
||||||
@@ -5200,6 +5255,12 @@ dependencies = [
|
|||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sdd"
|
||||||
|
version = "3.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sec1"
|
name = "sec1"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
@@ -5437,6 +5498,32 @@ dependencies = [
|
|||||||
"unsafe-libyaml",
|
"unsafe-libyaml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serial_test"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d0b343e184fc3b7bb44dff0705fffcf4b3756ba6aff420dddd8b24ca145e555"
|
||||||
|
dependencies = [
|
||||||
|
"futures-executor",
|
||||||
|
"futures-util",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"parking_lot",
|
||||||
|
"scc",
|
||||||
|
"serial_test_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serial_test_derive"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6f50427f258fb77356e4cd4aa0e87e2bd2c66dbcee41dc405282cae2bfc26c83"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.106",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha1"
|
name = "sha1"
|
||||||
version = "0.10.6"
|
version = "0.10.6"
|
||||||
|
|||||||
@@ -57,5 +57,7 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
info!("Enjoy! You can test your nats cluster by running : `kubectl exec -n {namespace} -it deployment/nats-box -- nats pub test hi`");
|
info!(
|
||||||
|
"Enjoy! You can test your nats cluster by running : `kubectl exec -n {namespace} -it deployment/nats-box -- nats pub test hi`"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ sqlx.workspace = true
|
|||||||
inquire.workspace = true
|
inquire.workspace = true
|
||||||
brocade = { path = "../brocade" }
|
brocade = { path = "../brocade" }
|
||||||
option-ext = "0.2.0"
|
option-ext = "0.2.0"
|
||||||
|
serial_test = "3.3.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions.workspace = true
|
pretty_assertions.workspace = true
|
||||||
|
|||||||
BIN
harmony/src/domain/topology/k8s_anywhere/.k8s_anywhere.rs.swp
Normal file
BIN
harmony/src/domain/topology/k8s_anywhere/.k8s_anywhere.rs.swp
Normal file
Binary file not shown.
@@ -1128,6 +1128,8 @@ impl Ingress for K8sAnywhereTopology {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use serial_test::serial;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
@@ -1167,6 +1169,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_full() {
|
fn test_remote_k8s_from_env_var_full() {
|
||||||
let (config_var, profile_var) =
|
let (config_var, profile_var) =
|
||||||
setup_env_vars(Some("kubeconfig=/foo.kc,context=bar"), Some("testprof"));
|
setup_env_vars(Some("kubeconfig=/foo.kc,context=bar"), Some("testprof"));
|
||||||
@@ -1183,6 +1186,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_only_kubeconfig() {
|
fn test_remote_k8s_from_env_var_only_kubeconfig() {
|
||||||
let (config_var, profile_var) = setup_env_vars(Some("kubeconfig=/foo.kc"), None);
|
let (config_var, profile_var) = setup_env_vars(Some("kubeconfig=/foo.kc"), None);
|
||||||
|
|
||||||
@@ -1195,6 +1199,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_only_context() {
|
fn test_remote_k8s_from_env_var_only_context() {
|
||||||
run_in_isolated_env(|| {
|
run_in_isolated_env(|| {
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1211,6 +1216,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_unknown_key_trim() {
|
fn test_remote_k8s_from_env_var_unknown_key_trim() {
|
||||||
run_in_isolated_env(|| {
|
run_in_isolated_env(|| {
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1230,6 +1236,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_empty_malformed() {
|
fn test_remote_k8s_from_env_var_empty_malformed() {
|
||||||
run_in_isolated_env(|| {
|
run_in_isolated_env(|| {
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1247,6 +1254,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_kubeconfig_fallback() {
|
fn test_remote_k8s_from_env_var_kubeconfig_fallback() {
|
||||||
run_in_isolated_env(|| {
|
run_in_isolated_env(|| {
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1263,6 +1271,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[serial]
|
||||||
fn test_remote_k8s_from_env_var_kubeconfig_no_fallback_if_provided() {
|
fn test_remote_k8s_from_env_var_kubeconfig_no_fallback_if_provided() {
|
||||||
run_in_isolated_env(|| {
|
run_in_isolated_env(|| {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ impl PostgreSQL for K8sAnywhereTopology {
|
|||||||
|
|
||||||
/// Extracts PostgreSQL-specific replication certs (PEM format) from a deployed primary cluster.
|
/// Extracts PostgreSQL-specific replication certs (PEM format) from a deployed primary cluster.
|
||||||
/// Abstracts away storage/retrieval details (e.g., secrets, files).
|
/// Abstracts away storage/retrieval details (e.g., secrets, files).
|
||||||
async fn get_replication_certs(&self, config: &PostgreSQLConfig) -> Result<ReplicationCerts, String> {
|
async fn get_replication_certs(
|
||||||
|
&self,
|
||||||
|
config: &PostgreSQLConfig,
|
||||||
|
) -> Result<ReplicationCerts, String> {
|
||||||
let cluster_name = &config.cluster_name;
|
let cluster_name = &config.cluster_name;
|
||||||
let namespace = &config.namespace;
|
let namespace = &config.namespace;
|
||||||
let k8s_client = self.k8s_client().await.map_err(|e| e.to_string())?;
|
let k8s_client = self.k8s_client().await.map_err(|e| e.to_string())?;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ impl Router for UnmanagedRouter {
|
|||||||
/// hostname: "postgres-cluster-example.public.domain.io".to_string(),
|
/// hostname: "postgres-cluster-example.public.domain.io".to_string(),
|
||||||
/// backend: "postgres-cluster-example-rw".to_string(), // k8s Service or HAProxy upstream
|
/// backend: "postgres-cluster-example-rw".to_string(), // k8s Service or HAProxy upstream
|
||||||
/// target_port: 5432,
|
/// target_port: 5432,
|
||||||
|
/// namespace: "sample-namespace".to_string(),
|
||||||
/// };
|
/// };
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
@@ -115,11 +116,7 @@ pub trait TlsRouter: Send + Sync {
|
|||||||
/// routed to this cluster.
|
/// routed to this cluster.
|
||||||
///
|
///
|
||||||
/// For example, if we have *.apps.nationtech.io pointing to a public load balancer, then this
|
/// For example, if we have *.apps.nationtech.io pointing to a public load balancer, then this
|
||||||
/// function would return
|
/// function would install route apps.nationtech.io
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// Some(String::new("apps.nationtech.io"))
|
|
||||||
/// ```
|
|
||||||
async fn get_wildcard_domain(&self) -> Result<Option<String>, String>;
|
async fn get_wildcard_domain(&self) -> Result<Option<String>, String>;
|
||||||
|
|
||||||
/// Returns the port that this router exposes externally.
|
/// Returns the port that this router exposes externally.
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ use crate::topology::{FailoverTopology, TlsRoute, TlsRouter};
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<T: TlsRouter> TlsRouter for FailoverTopology<T> {
|
impl<T: TlsRouter> TlsRouter for FailoverTopology<T> {
|
||||||
async fn get_wildcard_domain(&self) -> Result<Option<String>, String> {todo!()}
|
async fn get_wildcard_domain(&self) -> Result<Option<String>, String> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the port that this router exposes externally.
|
/// Returns the port that this router exposes externally.
|
||||||
async fn get_router_port(&self) -> u16 {todo!()}
|
async fn get_router_port(&self) -> u16 {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
async fn install_route(&self, config: TlsRoute) -> Result<(), String> {
|
async fn install_route(&self, config: TlsRoute) -> Result<(), String> {
|
||||||
warn!(
|
warn!(
|
||||||
"Failover topology TlsRouter capability currently defers to the primary only. Make sure to check this is OK for you. The Replica Topology WILL NOT be affected here"
|
"Failover topology TlsRouter capability currently defers to the primary only. Make sure to check this is OK for you. The Replica Topology WILL NOT be affected here"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ use crate::topology::{K8sclient, Topology};
|
|||||||
/// backend: "postgres-cluster-rw".to_string(),
|
/// backend: "postgres-cluster-rw".to_string(),
|
||||||
/// hostname: "postgres-rw.example.com".to_string(),
|
/// hostname: "postgres-rw.example.com".to_string(),
|
||||||
/// target_port: 5432,
|
/// target_port: 5432,
|
||||||
|
/// namespace: "example-namespace".to_string(),
|
||||||
/// },
|
/// },
|
||||||
/// };
|
/// };
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ pub trait PostgreSQL: Send + Sync {
|
|||||||
|
|
||||||
/// Extracts PostgreSQL-specific replication certs (PEM format) from a deployed primary cluster.
|
/// Extracts PostgreSQL-specific replication certs (PEM format) from a deployed primary cluster.
|
||||||
/// Abstracts away storage/retrieval details (e.g., secrets, files).
|
/// Abstracts away storage/retrieval details (e.g., secrets, files).
|
||||||
async fn get_replication_certs(&self, config: &PostgreSQLConfig) -> Result<ReplicationCerts, String>;
|
async fn get_replication_certs(
|
||||||
|
&self,
|
||||||
|
config: &PostgreSQLConfig,
|
||||||
|
) -> Result<ReplicationCerts, String>;
|
||||||
|
|
||||||
/// Gets the internal/private endpoint (e.g., k8s service FQDN:5432) for the cluster.
|
/// Gets the internal/private endpoint (e.g., k8s service FQDN:5432) for the cluster.
|
||||||
async fn get_endpoint(&self, config: &PostgreSQLConfig) -> Result<PostgreSQLEndpoint, String>;
|
async fn get_endpoint(&self, config: &PostgreSQLConfig) -> Result<PostgreSQLEndpoint, String>;
|
||||||
|
|||||||
@@ -69,9 +69,7 @@ struct PublicPostgreSQLInterpret {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<T: Topology + PostgreSQL + TlsRouter> Interpret<T>
|
impl<T: Topology + PostgreSQL + TlsRouter> Interpret<T> for PublicPostgreSQLInterpret {
|
||||||
for PublicPostgreSQLInterpret
|
|
||||||
{
|
|
||||||
async fn execute(&self, _inventory: &Inventory, topo: &T) -> Result<Outcome, InterpretError> {
|
async fn execute(&self, _inventory: &Inventory, topo: &T) -> Result<Outcome, InterpretError> {
|
||||||
// Deploy CNPG cluster first (creates -rw service)
|
// Deploy CNPG cluster first (creates -rw service)
|
||||||
topo.deploy(&self.config)
|
topo.deploy(&self.config)
|
||||||
|
|||||||
Reference in New Issue
Block a user