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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-nats"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-ntfy"
|
||||
version = "0.1.0"
|
||||
@@ -1883,6 +1898,36 @@ dependencies = [
|
||||
"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]]
|
||||
name = "example-pxe"
|
||||
version = "0.1.0"
|
||||
@@ -2435,6 +2480,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"serde_yaml",
|
||||
"serial_test",
|
||||
"similar",
|
||||
"sqlx",
|
||||
"strum 0.27.2",
|
||||
@@ -5116,6 +5162,15 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scc"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc"
|
||||
dependencies = [
|
||||
"sdd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.27"
|
||||
@@ -5200,6 +5255,12 @@ dependencies = [
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sdd"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca"
|
||||
|
||||
[[package]]
|
||||
name = "sec1"
|
||||
version = "0.7.3"
|
||||
@@ -5437,6 +5498,32 @@ dependencies = [
|
||||
"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]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
|
||||
@@ -57,5 +57,7 @@ async fn main() {
|
||||
.await
|
||||
.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
|
||||
brocade = { path = "../brocade" }
|
||||
option-ext = "0.2.0"
|
||||
serial_test = "3.3.1"
|
||||
|
||||
[dev-dependencies]
|
||||
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)]
|
||||
mod tests {
|
||||
use serial_test::serial;
|
||||
|
||||
use super::*;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
@@ -1167,6 +1169,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_full() {
|
||||
let (config_var, profile_var) =
|
||||
setup_env_vars(Some("kubeconfig=/foo.kc,context=bar"), Some("testprof"));
|
||||
@@ -1183,6 +1186,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_only_kubeconfig() {
|
||||
let (config_var, profile_var) = setup_env_vars(Some("kubeconfig=/foo.kc"), None);
|
||||
|
||||
@@ -1195,6 +1199,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_only_context() {
|
||||
run_in_isolated_env(|| {
|
||||
unsafe {
|
||||
@@ -1211,6 +1216,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_unknown_key_trim() {
|
||||
run_in_isolated_env(|| {
|
||||
unsafe {
|
||||
@@ -1230,6 +1236,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_empty_malformed() {
|
||||
run_in_isolated_env(|| {
|
||||
unsafe {
|
||||
@@ -1247,6 +1254,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_kubeconfig_fallback() {
|
||||
run_in_isolated_env(|| {
|
||||
unsafe {
|
||||
@@ -1263,6 +1271,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_remote_k8s_from_env_var_kubeconfig_no_fallback_if_provided() {
|
||||
run_in_isolated_env(|| {
|
||||
unsafe {
|
||||
|
||||
@@ -29,7 +29,10 @@ impl PostgreSQL for K8sAnywhereTopology {
|
||||
|
||||
/// Extracts PostgreSQL-specific replication certs (PEM format) from a deployed primary cluster.
|
||||
/// 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 namespace = &config.namespace;
|
||||
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(),
|
||||
/// backend: "postgres-cluster-example-rw".to_string(), // k8s Service or HAProxy upstream
|
||||
/// target_port: 5432,
|
||||
/// namespace: "sample-namespace".to_string(),
|
||||
/// };
|
||||
/// ```
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -115,11 +116,7 @@ pub trait TlsRouter: Send + Sync {
|
||||
/// routed to this cluster.
|
||||
///
|
||||
/// For example, if we have *.apps.nationtech.io pointing to a public load balancer, then this
|
||||
/// function would return
|
||||
///
|
||||
/// ```
|
||||
/// Some(String::new("apps.nationtech.io"))
|
||||
/// ```
|
||||
/// function would install route apps.nationtech.io
|
||||
async fn get_wildcard_domain(&self) -> Result<Option<String>, String>;
|
||||
|
||||
/// Returns the port that this router exposes externally.
|
||||
|
||||
@@ -5,10 +5,14 @@ use crate::topology::{FailoverTopology, TlsRoute, TlsRouter};
|
||||
|
||||
#[async_trait]
|
||||
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.
|
||||
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> {
|
||||
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"
|
||||
|
||||
@@ -25,6 +25,7 @@ use crate::topology::{K8sclient, Topology};
|
||||
/// backend: "postgres-cluster-rw".to_string(),
|
||||
/// hostname: "postgres-rw.example.com".to_string(),
|
||||
/// 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.
|
||||
/// 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.
|
||||
async fn get_endpoint(&self, config: &PostgreSQLConfig) -> Result<PostgreSQLEndpoint, String>;
|
||||
|
||||
@@ -69,9 +69,7 @@ struct PublicPostgreSQLInterpret {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T: Topology + PostgreSQL + TlsRouter> Interpret<T>
|
||||
for PublicPostgreSQLInterpret
|
||||
{
|
||||
impl<T: Topology + PostgreSQL + TlsRouter> Interpret<T> for PublicPostgreSQLInterpret {
|
||||
async fn execute(&self, _inventory: &Inventory, topo: &T) -> Result<Outcome, InterpretError> {
|
||||
// Deploy CNPG cluster first (creates -rw service)
|
||||
topo.deploy(&self.config)
|
||||
|
||||
Reference in New Issue
Block a user