mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 21:32:58 +00:00
test: use EtcdStore in IT cases (#2734)
* test: use EtcdStore in IT cases Signed-off-by: tison <wander4096@gmail.com> * retrigger CI Signed-off-by: tison <wander4096@gmail.com> * refactor: KvPair can take etcd KeyValue Signed-off-by: tison <wander4096@gmail.com> * temporary use fork Signed-off-by: tison <wander4096@gmail.com> * drop cloned Signed-off-by: tison <wander4096@gmail.com> * chroot_key_value Signed-off-by: tison <wander4096@gmail.com> * chroot and prepend in each point Signed-off-by: tison <wander4096@gmail.com> * adjust call points Signed-off-by: tison <wander4096@gmail.com> * cargo clippy Signed-off-by: tison <wander4096@gmail.com> * point to upstream etcd-client Signed-off-by: tison <wander4096@gmail.com> * test etcd chroot Signed-off-by: tison <wander4096@gmail.com> * add NO_CHROOT constant Signed-off-by: tison <wander4096@gmail.com> * check Signed-off-by: tison <wander4096@gmail.com> * handle range end Signed-off-by: tison <wander4096@gmail.com> * handle special encoded key or range_end Signed-off-by: tison <wander4096@gmail.com> * fixup implementation Signed-off-by: tison <wander4096@gmail.com> * clippy Signed-off-by: tison <wander4096@gmail.com> * avoid test name conflict Signed-off-by: tison <wander4096@gmail.com> * chroot to kvbackend level Signed-off-by: tison <wander4096@gmail.com> * fixup all occurances Signed-off-by: tison <wander4096@gmail.com> * fix type Signed-off-by: tison <wander4096@gmail.com> * Update src/common/meta/src/kv_backend/txn.rs * make github happy --------- Signed-off-by: tison <wander4096@gmail.com> Co-authored-by: LFC <990479+MichaelScofield@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
etcd:
|
||||
image: bitnami/etcd:latest
|
||||
ports:
|
||||
- "2379:2379"
|
||||
- "2380:2380"
|
||||
environment:
|
||||
ALLOW_NONE_AUTHENTICATION: "yes"
|
||||
ETCD_NAME: etcd
|
||||
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
|
||||
ETCD_ADVERTISE_CLIENT_URLS: http://etcd:2379
|
||||
ETCD_MAX_REQUEST_BYTES: 10485760
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -21,6 +22,8 @@ use client::client_manager::DatanodeClients;
|
||||
use client::Client;
|
||||
use common_base::Plugins;
|
||||
use common_grpc::channel_manager::{ChannelConfig, ChannelManager};
|
||||
use common_meta::kv_backend::chroot::ChrootKvBackend;
|
||||
use common_meta::kv_backend::etcd::EtcdStore;
|
||||
use common_meta::kv_backend::memory::MemoryKvBackend;
|
||||
use common_meta::kv_backend::KvBackendRef;
|
||||
use common_meta::peer::Peer;
|
||||
@@ -63,10 +66,25 @@ pub struct GreptimeDbClusterBuilder {
|
||||
}
|
||||
|
||||
impl GreptimeDbClusterBuilder {
|
||||
pub fn new(cluster_name: &str) -> Self {
|
||||
pub async fn new(cluster_name: &str) -> Self {
|
||||
let endpoints = env::var("GT_ETCD_ENDPOINTS").unwrap_or_default();
|
||||
|
||||
let kv_backend: KvBackendRef = if endpoints.is_empty() {
|
||||
Arc::new(MemoryKvBackend::new())
|
||||
} else {
|
||||
let endpoints = endpoints
|
||||
.split(',')
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
let backend = EtcdStore::with_endpoints(endpoints)
|
||||
.await
|
||||
.expect("malformed endpoints");
|
||||
Arc::new(ChrootKvBackend::new(cluster_name.into(), backend))
|
||||
};
|
||||
|
||||
Self {
|
||||
cluster_name: cluster_name.to_string(),
|
||||
kv_backend: Arc::new(MemoryKvBackend::new()),
|
||||
kv_backend,
|
||||
store_config: None,
|
||||
datanodes: None,
|
||||
}
|
||||
|
||||
@@ -56,8 +56,10 @@ mod test {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_distributed_put_influxdb_lines_without_time_column() {
|
||||
let instance =
|
||||
tests::create_distributed_instance("test_distributed_put_influxdb_lines").await;
|
||||
let instance = tests::create_distributed_instance(
|
||||
"test_distributed_put_influxdb_lines_without_time_column",
|
||||
)
|
||||
.await;
|
||||
test_put_influxdb_lines_without_time_column(&instance.frontend()).await;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ impl MockDistributedInstance {
|
||||
}
|
||||
|
||||
pub async fn create_distributed_instance(test_name: &str) -> MockDistributedInstance {
|
||||
let cluster = GreptimeDbClusterBuilder::new(test_name).build().await;
|
||||
let builder = GreptimeDbClusterBuilder::new(test_name).await;
|
||||
let cluster = builder.build().await;
|
||||
MockDistributedInstance(cluster)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ pub async fn test_region_failover(store_type: StorageType) {
|
||||
let (store_config, _guard) = get_test_store_config(&store_type);
|
||||
|
||||
let datanodes = 5u64;
|
||||
let cluster = GreptimeDbClusterBuilder::new(cluster_name)
|
||||
let builder = GreptimeDbClusterBuilder::new(cluster_name).await;
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user