From 15d3d007eb5d0aaf53c46d780a07e77afb1cb092 Mon Sep 17 00:00:00 2001 From: Alek Westover Date: Fri, 16 Jun 2023 16:09:02 -0400 Subject: [PATCH] added several imports so that extension_server compiles --- compute_tools/src/extension_server.rs | 20 +++++++++---------- .../regress/test_download_extensions.py | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/compute_tools/src/extension_server.rs b/compute_tools/src/extension_server.rs index b01da48b1e..9e545ed5e3 100644 --- a/compute_tools/src/extension_server.rs +++ b/compute_tools/src/extension_server.rs @@ -1,19 +1,19 @@ +use anyhow::{self, Context}; use remote_storage::*; -use std::io::{Read, Write}; +use std::fs::File; +use std::io::{BufWriter, Read, Write}; use std::net::{TcpListener, TcpStream}; use std::path::Path; use std::str; use std::{fs, thread}; +use tokio::io::AsyncReadExt; use toml_edit; -use BuffWriter; - -use anyhow::Context; use tracing::info; pub fn download_file(mut stream: TcpStream) -> anyhow::Result<()> { let mut buf = [0; 512]; - println!("ALEK: calling download file"); + dbg!("ALEK: calling download file"); // fs.write("world.txt", "hello")?; stream.read(&mut buf).expect("Error reading from stream"); @@ -79,7 +79,7 @@ pub enum ExtensionType { /* separate stroage and compute storage: pageserver stores pages, accepts WAL. communicates with S3. -compute: postgres, runs in kubernetes/ VM, started by compute_ctl. rust service. accepts some spec. +compute: postgres, runs in kubernetes/ VM, started by compute_ctl. rust service. accepts some spec. pass config to compute_ctl */ @@ -103,18 +103,18 @@ pub async fn download_extension( if remote_from_path.extension() == Some("control") { // NOTE: if you run this, it will actually write stuff to your postgress directory // only run if you are ok with that. TODO: delete this comment - download_helper(&remote_storage, &remote_from_path, &sharedir)?; + download_helper(&remote_storage, &remote_from_path, &sharedir).await?; } } } ExtensionType::Tenant(tenant_id) => { // 2. After we have spec, before project start // Download control files from s3-bucket/[tenant-id]/*.control to SHAREDIR/extension - let folder = RemotePath::new(Path::new(format!("{tenant_id}")))?; + let folder = RemotePath::new(Path::new(&format!("{tenant_id}")))?; let from_paths = remote_storage.list_files(Some(&folder)).await?; for remote_from_path in from_paths { if remote_from_path.extension() == Some("control") { - download_helper(&remote_storage, &remote_from_path, &sharedir)?; + download_helper(&remote_storage, &remote_from_path, &sharedir).await?; } } } @@ -123,7 +123,7 @@ pub async fn download_extension( // Download preload_shared_libraries from s3-bucket/public/[library-name].control into LIBDIR/ let from_path = format!("neon-dev-extensions/public/{library_name}.control"); let remote_from_path = RemotePath::new(Path::new(&from_path))?; - download_helper(&remote_storage, &remote_from_path, &libdir)?; + download_helper(&remote_storage, &remote_from_path, &libdir).await?; } } Ok(()) diff --git a/test_runner/regress/test_download_extensions.py b/test_runner/regress/test_download_extensions.py index 94938ae317..55f355e211 100644 --- a/test_runner/regress/test_download_extensions.py +++ b/test_runner/regress/test_download_extensions.py @@ -57,9 +57,11 @@ def test_file_download(neon_env_builder: NeonEnvBuilder): ) content_length = resp["ResponseMetadata"]["HTTPHeaders"]["content-length"] # TODO: this is not the correct path, nor the correct data to write - with open("alek.txt", "w") as f: + with open("pg_install/v15/lib/test_ext.control", "w") as f: f.write(str(resp)) + # env.neon_cli + tenant, _ = env.neon_cli.create_tenant() env.neon_cli.create_timeline("test_file_download", tenant_id=tenant) # 6. Start endpoint and ensure that test_ext is present in select * from pg_available_extensions