From 73abc87ada32f20c0c3a87ac6a468b78ebb0b36b Mon Sep 17 00:00:00 2001 From: dingben Date: Tue, 23 Jul 2024 10:43:52 +0800 Subject: [PATCH] feat: tpcc support dameng (#71) --- api/v1alpha1/type.go | 2 +- config/crd/bases/benchmark.apecloud.io_pgbenches.yaml | 1 + config/crd/bases/benchmark.apecloud.io_redisbenches.yaml | 1 + config/crd/bases/benchmark.apecloud.io_sysbenches.yaml | 1 + config/crd/bases/benchmark.apecloud.io_tpccs.yaml | 1 + config/crd/bases/benchmark.apecloud.io_tpcds.yaml | 1 + config/crd/bases/benchmark.apecloud.io_tpches.yaml | 1 + config/crd/bases/benchmark.apecloud.io_ycsbs.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_pgbenches.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_redisbenches.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_sysbenches.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_tpccs.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_tpcds.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_tpches.yaml | 1 + deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml | 1 + deploy/helm/values.yaml | 4 ++-- internal/controller/tpcc_job.go | 8 ++++++++ pkg/constants/constants.go | 1 + pkg/constants/env.go | 6 +++--- 19 files changed, 29 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/type.go b/api/v1alpha1/type.go index cd1da75..199452f 100644 --- a/api/v1alpha1/type.go +++ b/api/v1alpha1/type.go @@ -50,7 +50,7 @@ type ResourceList struct { type Target struct { // the driver represents the database type // +optional - // +kubebuilder:validation:Enum={mysql,postgresql,mongodb,redis,oceanbase-oracle} + // +kubebuilder:validation:Enum={mysql,postgresql,mongodb,redis,oceanbase-oracle,dameng} Driver string `json:"driver,omitempty"` // The database server's host name diff --git a/config/crd/bases/benchmark.apecloud.io_pgbenches.yaml b/config/crd/bases/benchmark.apecloud.io_pgbenches.yaml index f25ddb1..47347d0 100644 --- a/config/crd/bases/benchmark.apecloud.io_pgbenches.yaml +++ b/config/crd/bases/benchmark.apecloud.io_pgbenches.yaml @@ -96,6 +96,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_redisbenches.yaml b/config/crd/bases/benchmark.apecloud.io_redisbenches.yaml index 39b1eb2..cb3c8bd 100644 --- a/config/crd/bases/benchmark.apecloud.io_redisbenches.yaml +++ b/config/crd/bases/benchmark.apecloud.io_redisbenches.yaml @@ -100,6 +100,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_sysbenches.yaml b/config/crd/bases/benchmark.apecloud.io_sysbenches.yaml index 4b3ae6e..cb3469c 100644 --- a/config/crd/bases/benchmark.apecloud.io_sysbenches.yaml +++ b/config/crd/bases/benchmark.apecloud.io_sysbenches.yaml @@ -83,6 +83,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_tpccs.yaml b/config/crd/bases/benchmark.apecloud.io_tpccs.yaml index bb5fe43..ab9cbdb 100644 --- a/config/crd/bases/benchmark.apecloud.io_tpccs.yaml +++ b/config/crd/bases/benchmark.apecloud.io_tpccs.yaml @@ -109,6 +109,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_tpcds.yaml b/config/crd/bases/benchmark.apecloud.io_tpcds.yaml index 315b981..b3c3fb8 100644 --- a/config/crd/bases/benchmark.apecloud.io_tpcds.yaml +++ b/config/crd/bases/benchmark.apecloud.io_tpcds.yaml @@ -80,6 +80,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_tpches.yaml b/config/crd/bases/benchmark.apecloud.io_tpches.yaml index 6df4dd7..5d1e970 100644 --- a/config/crd/bases/benchmark.apecloud.io_tpches.yaml +++ b/config/crd/bases/benchmark.apecloud.io_tpches.yaml @@ -80,6 +80,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml b/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml index a2403e8..6c8331d 100644 --- a/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml +++ b/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml @@ -138,6 +138,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_pgbenches.yaml b/deploy/helm/crds/benchmark.apecloud.io_pgbenches.yaml index f25ddb1..47347d0 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_pgbenches.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_pgbenches.yaml @@ -96,6 +96,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_redisbenches.yaml b/deploy/helm/crds/benchmark.apecloud.io_redisbenches.yaml index 39b1eb2..cb3c8bd 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_redisbenches.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_redisbenches.yaml @@ -100,6 +100,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_sysbenches.yaml b/deploy/helm/crds/benchmark.apecloud.io_sysbenches.yaml index 4b3ae6e..cb3469c 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_sysbenches.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_sysbenches.yaml @@ -83,6 +83,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_tpccs.yaml b/deploy/helm/crds/benchmark.apecloud.io_tpccs.yaml index bb5fe43..ab9cbdb 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_tpccs.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_tpccs.yaml @@ -109,6 +109,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_tpcds.yaml b/deploy/helm/crds/benchmark.apecloud.io_tpcds.yaml index 315b981..b3c3fb8 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_tpcds.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_tpcds.yaml @@ -80,6 +80,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_tpches.yaml b/deploy/helm/crds/benchmark.apecloud.io_tpches.yaml index 6df4dd7..5d1e970 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_tpches.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_tpches.yaml @@ -80,6 +80,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml b/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml index a2403e8..6c8331d 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml @@ -138,6 +138,7 @@ spec: - mongodb - redis - oceanbase-oracle + - dameng type: string host: type: string diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 95dd701..848eba8 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -91,5 +91,5 @@ kubebenchImages: ycsb: "registry.cn-hangzhou.aliyuncs.com/apecloud/go-ycsb:latest" fio: "registry.cn-hangzhou.aliyuncs.com/apecloud/fio:latest" redisbench: "registry.cn-hangzhou.aliyuncs.com/apecloud/redis:7.0.5" - exporter: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9" - tools: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9" \ No newline at end of file + exporter: "apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubebench:0.0.10" + tools: "apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubebench:0.0.10" \ No newline at end of file diff --git a/internal/controller/tpcc_job.go b/internal/controller/tpcc_job.go index 459e810..624dcd1 100644 --- a/internal/controller/tpcc_job.go +++ b/internal/controller/tpcc_job.go @@ -152,6 +152,8 @@ func NewTpccWorkLoadParams(cr *v1alpha1.Tpcc) string { return NewTpccPostgresParams(cr) case constants.OceanBaseOracleTenantDriver: return NewOceanBaseOracleTenantParams(cr) + case constants.DamengDriver: + return NewDamengParams(cr) default: return "" } @@ -175,6 +177,12 @@ func NewOceanBaseOracleTenantParams(cr *v1alpha1.Tpcc) string { return result } +func NewDamengParams(cr *v1alpha1.Tpcc) string { + result := fmt.Sprintf("--driver %s", "dm.jdbc.driver.DmDriver") + result = fmt.Sprintf("%s --conn jdbc:dm://%s:%d", result, cr.Spec.Target.Host, cr.Spec.Target.Port) + return result +} + // TpccInitContainers returns the init containers for tpcc // tpcc will fail if database not exists, so we need to create database first func TpccInitContainers(cr *v1alpha1.Tpcc) *corev1.Container { diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 11cfecd..e00e989 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -26,6 +26,7 @@ const ( MongoDbDriver = "mongodb" RedisDriver = "redis" OceanBaseOracleTenantDriver = "oceanbase-oracle" + DamengDriver = "dameng" ) const ( diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 8194ab7..6767975 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -22,14 +22,14 @@ const ( func init() { viper.SetDefault(KubebenchEnvPgbench, "registry.cn-hangzhou.aliyuncs.com/apecloud/spilo:14.8.0") viper.SetDefault(KubebenchEnvSysbench, "registry.cn-hangzhou.aliyuncs.com/apecloud/customsuites:latest") - viper.SetDefault(KubebenchEnvTpcc, "registry.cn-hangzhou.aliyuncs.com/apecloud/benchmarksql:latest") + viper.SetDefault(KubebenchEnvTpcc, "apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/benchmarksql:latest") viper.SetDefault(KubebenchEnvTpcds, "infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/tpcds:latest") viper.SetDefault(KubebenchEnvTpch, "registry.cn-hangzhou.aliyuncs.com/apecloud/customsuites:latest") viper.SetDefault(KubebenchEnvYcsb, "registry.cn-hangzhou.aliyuncs.com/apecloud/go-ycsb:latest") viper.SetDefault(KubebenchEnvFio, "registry.cn-hangzhou.aliyuncs.com/apecloud/fio:latest") viper.SetDefault(KubebenchEnvRedisBench, "registry.cn-hangzhou.aliyuncs.com/apecloud/redis:7.0.5") - viper.SetDefault(KubebenchExporter, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9") - viper.SetDefault(KubebenchTools, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9") + viper.SetDefault(KubebenchExporter, "apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubebench:0.0.10") + viper.SetDefault(KubebenchTools, "apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubebench:0.0.10") } // GetBenchmarkImage get benchmark image