Skip to content

Commit

Permalink
feat: support redis sentinel (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengluodb authored May 17, 2024
1 parent e06a9c8 commit 96046d3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/ycsb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ type YcsbSpec struct {
// +optional
Threads []int `json:"threads,omitempty"`

// TODO: achieve the following fields in target
RedisMode string `json:"redisMode,omitempty"`
MasterName string `json:"masterName,omitempty"`
RedisSentinelUsername string `json:"redisSentinelUsername,omitempty"`
RedisSentinelPassword string `json:"redisSentinelPassword,omitempty"`

BenchCommon `json:",inline"`
}

Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/benchmark.apecloud.io_ycsbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ spec:
maximum: 100
minimum: 0
type: integer
masterName:
type: string
operationCount:
default: 10000
minimum: 1
Expand All @@ -73,6 +75,12 @@ spec:
default: 10000
minimum: 1
type: integer
redisMode:
type: string
redisSentinelPassword:
type: string
redisSentinelUsername:
type: string
requestDistribution:
default: uniform
enum:
Expand Down
8 changes: 8 additions & 0 deletions deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ spec:
maximum: 100
minimum: 0
type: integer
masterName:
type: string
operationCount:
default: 10000
minimum: 1
Expand All @@ -73,6 +75,12 @@ spec:
default: 10000
minimum: 1
type: integer
redisMode:
type: string
redisSentinelPassword:
type: string
redisSentinelUsername:
type: string
requestDistribution:
default: uniform
enum:
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/ycsb_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ func NewYcsbRedisParams(cr *v1alpha1.Ycsb) string {
if cr.Spec.Target.Database != "" {
result = fmt.Sprintf("%s -p redis.db=%s", result, cr.Spec.Target.Database)
}
if cr.Spec.RedisMode == "sentinel" {
result = fmt.Sprintf("%s -p redis.mode=sentinel", result)
result = fmt.Sprintf("%s -p redis.sentinel_master_name=%s", result, cr.Spec.MasterName)
result = fmt.Sprintf("%s -p redis.sentinel_username=%s", result, cr.Spec.RedisSentinelUsername)
result = fmt.Sprintf("%s -p redis.sentinel_password=%s", result, cr.Spec.RedisSentinelPassword)
}
return result
}

Expand Down
5 changes: 3 additions & 2 deletions internal/utils/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ func NewPreCheckJob(name, namespace string, driver string, target *v1alpha1.Targ
return NewPgbenchPreCheckJob(name, namespace, *target)
case constants.MongoDbDriver:
return NewMongodbPreCheckJob(name, namespace, *target)
case constants.RedisDriver:
return NewRedisPreCheckJob(name, namespace, *target)
// TODO: achieve in next kubebench version
//case constants.RedisDriver:
// return NewRedisPreCheckJob(name, namespace, *target)
default:
return nil
}
Expand Down

0 comments on commit 96046d3

Please sign in to comment.