Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel committed Jun 27, 2024
1 parent f6c81d5 commit ba66617
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions tembo-operator/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,85 @@ mod test {
test.teardown().await;
}

#[tokio::test]
#[ignore]
async fn functional_test_basic_cnpg_assuming_latest_version() {
let test_name = "test-basic-cnpg";
let test = TestCore::new(test_name).await;
let name = test.name.clone();

let kind = "CoreDB";
let replicas = 1;

// Generate basic CoreDB resource to start with
let coredb_json = serde_json::json!({
"apiVersion": API_VERSION,
"kind": kind,
"metadata": {
"name": name
},
"spec": {
"replicas": replicas,
"extensions": [{
// Try including an extension
// without specifying a schema
"name": "pg_jsonschema",
"description": "fake description",
"locations": [{
"enabled": true,
"database": "postgres",
}],
}],
"trunk_installs": [{
"name": "pg_jsonschema"
}]
}
});

let coredb_resource = test.set_cluster_def(&coredb_json).await;

// Wait for CNPG Pod to be created
let pod_name = format!("{}-1", name);

pod_ready_and_running(test.pods.clone(), pod_name.clone()).await;

let _ = wait_until_psql_contains(
test.context.clone(),
coredb_resource.clone(),
"\\dx".to_string(),
"pg_jsonschema".to_string(),
false,
)
.await;

// Wait for pg_jsonschema to be installed before proceeding.
let found_extension = trunk_install_status(&test.coredbs, &name, "pg_jsonschema").await;
assert!(found_extension);

// Check for heartbeat table and values
let sql_result = wait_until_psql_contains(
test.context.clone(),
coredb_resource.clone(),
"SELECT latest_heartbeat FROM tembo.heartbeat_table LIMIT 1".to_string(),
"postgres".to_string(),
true,
)
.await;
assert!(sql_result.success);

let cdb_name = coredb_resource.metadata.name.clone().unwrap();
let metrics_url = format!("https://{}.localhost:8443/metrics", cdb_name);
let response = http_get_with_retry(&metrics_url, None, 100, 5)
.await
.unwrap();
let response_code = response.status();
assert!(response_code.is_success());
let body = response.text().await.unwrap();
assert!(body.contains("cnpg_pg_settings_setting"));

test.teardown().await;
}

#[tokio::test]
#[ignore]
async fn functional_test_basic_cnpg_pg16() {
Expand Down

0 comments on commit ba66617

Please sign in to comment.