diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index bfff7340d8d87..2e2bc7b946ca8 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -35,7 +35,6 @@ use remote_storage::{DownloadError, RemotePath}; use crate::checker::create_availability_check_data; use crate::local_proxy; -use crate::installed_extensions::log_installed_extensions; use crate::logger::inlinify; use crate::pg_helpers::*; use crate::spec::*; diff --git a/compute_tools/src/http/openapi_spec.yaml b/compute_tools/src/http/openapi_spec.yaml index d4c9444468d97..ce1cc1a74d41f 100644 --- a/compute_tools/src/http/openapi_spec.yaml +++ b/compute_tools/src/http/openapi_spec.yaml @@ -420,10 +420,10 @@ components: properties: name: type: string - lowest_version: - type: string - highest_version: - type: string + versions: + type: array + items: + type: string n_databases: type: integer diff --git a/compute_tools/src/installed_extensions.rs b/compute_tools/src/installed_extensions.rs index 799f6941dea04..3d8b22a8a39d0 100644 --- a/compute_tools/src/installed_extensions.rs +++ b/compute_tools/src/installed_extensions.rs @@ -1,12 +1,11 @@ -use compute_api::responses::{InstalledExtension, InstalledExtenstions}; +use compute_api::responses::{InstalledExtension, InstalledExtensions}; use std::collections::HashMap; use std::collections::HashSet; use url::Url; -use anyhow::{anyhow, Result}; +use anyhow::Result; use postgres::{Client, NoTls}; use tokio::task; -use tracing::info; /// We don't reuse get_existing_dbs() just for code clarity /// and to make database listing query here more explicit. @@ -36,7 +35,7 @@ fn list_dbs(client: &mut Client) -> Result> { /// Connect to every database (see list_dbs above) and get the list of installed extensions. /// Same extension can be installed in multiple databases with different versions, /// we only keep the highest and lowest version across all databases. -pub async fn get_installed_extensions(connstr: Url) -> Result { +pub async fn get_installed_extensions(connstr: Url) -> Result { let mut connstr = connstr.clone(); task::spawn_blocking(move || { @@ -73,28 +72,9 @@ pub async fn get_installed_extensions(connstr: Url) -> Result Result<()> { - let connstr = connstr.clone(); - - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .expect("failed to create runtime"); - let result = rt - .block_on(get_installed_extensions(connstr)) - .map_err(|e| anyhow!("failed to get installed extensions: {:?}", e))?; - - info!( - "[INSTALLED_EXTENSIONS]: {}", - serde_json::to_string(&result) - .map_err(|e| anyhow!("failed to deserialize installed extensions: {:?}", e))? - ); - Ok(()) -} diff --git a/libs/compute_api/src/responses.rs b/libs/compute_api/src/responses.rs index 07978942e1bc9..2978ceef77fbd 100644 --- a/libs/compute_api/src/responses.rs +++ b/libs/compute_api/src/responses.rs @@ -149,6 +149,6 @@ pub struct InstalledExtension { } #[derive(Clone, Debug, Default, Serialize)] -pub struct InstalledExtenstions { +pub struct InstalledExtensions { pub extensions: Vec, } diff --git a/test_runner/regress/test_installed_extensions.py b/test_runner/regress/test_installed_extensions.py index 8329e567af3b7..e56c782c58cbf 100644 --- a/test_runner/regress/test_installed_extensions.py +++ b/test_runner/regress/test_installed_extensions.py @@ -8,7 +8,7 @@ def test_installed_extensions(neon_simple_env: NeonEnv): env = neon_simple_env - env.neon_cli.create_branch("test_installed_extensions") + env.create_branch("test_installed_extensions") endpoint = env.endpoints.create_start("test_installed_extensions") @@ -33,6 +33,8 @@ def test_installed_extensions(neon_simple_env: NeonEnv): pg_conn = endpoint.connect(dbname="test_installed_extensions") with pg_conn.cursor() as cur: cur.execute("CREATE EXTENSION neon_test_utils") + cur.execute("SELECT default_version FROM pg_available_extensions WHERE name = 'neon_test_utils'"); + neon_test_utilsn_version = cur.fetchone()[0] with pg_conn.cursor() as cur: cur.execute("CREATE EXTENSION neon version '1.1'") @@ -47,25 +49,26 @@ def test_installed_extensions(neon_simple_env: NeonEnv): info("Extensions: %s", res["extensions"]) # check that the neon_test_utils extension is installed only in 1 database + # and has the expected version assert any( ext["extname"] == "neon_test_utils" - and ext["versions"] == ["1.3"] + and ext["versions"] == [neon_test_utilsn_version] and ext["n_databases"] == 1 for ext in res["extensions"] - ), "The 'neon_test_utils' extension is missing" + ) # check that the plpgsql extension is installed in all databases # this is a default extension that is always installed assert any( ext["extname"] == "plpgsql" and ext["n_databases"] == 4 for ext in res["extensions"] - ), "The 'plpgsql' extension is missing" + ) # check that the neon extension is installed and has expected versions for ext in res["extensions"]: if ext["extname"] == "neon": - assert ext["n_databases"] == 2, "The 'neon' extension is missing" + assert ext["n_databases"] == 2 ext["versions"].sort() - assert ext["versions"] == ["1.1", "1.2"], "The 'neon' extension is missing" + assert ext["versions"] == ["1.1", "1.2"] with pg_conn.cursor() as cur: cur.execute("ALTER EXTENSION neon UPDATE TO '1.3'") @@ -78,6 +81,6 @@ def test_installed_extensions(neon_simple_env: NeonEnv): # check that the neon_test_utils extension is updated for ext in res["extensions"]: if ext["extname"] == "neon": - assert ext["n_databases"] == 2, "The 'neon' extension is missing" + assert ext["n_databases"] == 2 ext["versions"].sort() - assert ext["versions"] == ["1.2", "1.3"], "The 'neon' extension is missing" + assert ext["versions"] == ["1.2", "1.3"]