mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-29 19:30:37 +00:00
test: s3 manifest (#1755)
* feat: change default manifest options * test: s3 manifest * feat: revert checkpoint_margin to 10 * Update src/object-store/src/test_util.rs Co-authored-by: Lei, HUANG <6406592+v0y4g3r@users.noreply.github.com> --------- Co-authored-by: Lei, HUANG <6406592+v0y4g3r@users.noreply.github.com>
This commit is contained in:
@@ -14,9 +14,9 @@ metrics.workspace = true
|
||||
opendal = { version = "0.36", features = ["layers-tracing", "layers-metrics"] }
|
||||
pin-project = "1.0"
|
||||
tokio.workspace = true
|
||||
uuid.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0"
|
||||
common-telemetry = { path = "../common/telemetry" }
|
||||
common-test-util = { path = "../common/test-util" }
|
||||
uuid.workspace = true
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::env;
|
||||
|
||||
use crate::{ObjectStore, Result};
|
||||
|
||||
/// Temp folder for object store test
|
||||
pub struct TempFolder {
|
||||
store: ObjectStore,
|
||||
// The path under root.
|
||||
@@ -28,7 +31,34 @@ impl TempFolder {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn remove_all(&mut self) -> Result<()> {
|
||||
pub async fn remove_all(&self) -> Result<()> {
|
||||
self.store.remove_all(&self.path).await
|
||||
}
|
||||
}
|
||||
|
||||
/// Test s3 config from environment variables
|
||||
#[derive(Debug)]
|
||||
pub struct TestS3Config {
|
||||
pub root: String,
|
||||
pub access_key_id: String,
|
||||
pub secret_access_key: String,
|
||||
pub bucket: String,
|
||||
pub region: Option<String>,
|
||||
}
|
||||
|
||||
/// Returns s3 test config, return None if not found.
|
||||
pub fn s3_test_config() -> Option<TestS3Config> {
|
||||
if let Ok(b) = env::var("GT_S3_BUCKET") {
|
||||
if !b.is_empty() {
|
||||
return Some(TestS3Config {
|
||||
root: uuid::Uuid::new_v4().to_string(),
|
||||
access_key_id: env::var("GT_S3_ACCESS_KEY_ID").ok()?,
|
||||
secret_access_key: env::var("GT_S3_ACCESS_KEY").ok()?,
|
||||
bucket: env::var("GT_S3_BUCKET").ok()?,
|
||||
region: Some(env::var("GT_S3_REGION").ok()?),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ async fn test_s3_backend() -> Result<()> {
|
||||
|
||||
let store = ObjectStore::new(builder).unwrap().finish();
|
||||
|
||||
let mut guard = TempFolder::new(&store, "/");
|
||||
let guard = TempFolder::new(&store, "/");
|
||||
test_object_crud(&store).await?;
|
||||
test_object_list(&store).await?;
|
||||
guard.remove_all().await?;
|
||||
@@ -148,7 +148,7 @@ async fn test_oss_backend() -> Result<()> {
|
||||
|
||||
let store = ObjectStore::new(builder).unwrap().finish();
|
||||
|
||||
let mut guard = TempFolder::new(&store, "/");
|
||||
let guard = TempFolder::new(&store, "/");
|
||||
test_object_crud(&store).await?;
|
||||
test_object_list(&store).await?;
|
||||
guard.remove_all().await?;
|
||||
@@ -176,7 +176,7 @@ async fn test_azblob_backend() -> Result<()> {
|
||||
|
||||
let store = ObjectStore::new(builder).unwrap().finish();
|
||||
|
||||
let mut guard = TempFolder::new(&store, "/");
|
||||
let guard = TempFolder::new(&store, "/");
|
||||
test_object_crud(&store).await?;
|
||||
test_object_list(&store).await?;
|
||||
guard.remove_all().await?;
|
||||
|
||||
Reference in New Issue
Block a user