Skip to content

Commit

Permalink
refactor: add Validate() and Check() (#186)
Browse files Browse the repository at this point in the history
* refactor: add `Validate()` and `Check()`

Signed-off-by: zyy17 <[email protected]>

* test: add unit test for Validate()

---------

Signed-off-by: zyy17 <[email protected]>
  • Loading branch information
zyy17 authored Sep 27, 2024
1 parent abf79b4 commit 7f63235
Show file tree
Hide file tree
Showing 19 changed files with 534 additions and 219 deletions.
4 changes: 2 additions & 2 deletions apis/v1alpha1/defaulting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

func TestClusterSetDefaults(t *testing.T) {
const (
testDir = "testdata/greptimedbcluster"
testDir = "testdata/defaulting/greptimedbcluster"
inputFileName = "input.yaml"
expectFileName = "expect.yaml"
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestClusterSetDefaults(t *testing.T) {

func TestStandaloneSetDefaults(t *testing.T) {
const (
testDir = "testdata/greptimedbstandalone"
testDir = "testdata/defaulting/greptimedbstandalone"
inputFileName = "input.yaml"
expectFileName = "expect.yaml"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBCluster
metadata:
name: test00
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
frontend:
replicas: 1
meta:
etcdEndpoints:
- etcd.etcd-cluster.svc.cluster.local:2379
replicas: 1
datanode:
replicas: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBCluster
metadata:
name: test01-error
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
frontend:
replicas: 1
# This is an error because the config is not a valid toml config.
config: |
It's not a valid toml config----
meta:
etcdEndpoints:
- etcd.etcd-cluster.svc.cluster.local:2379
replicas: 1
datanode:
replicas: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBCluster
metadata:
name: test02-error
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
frontend:
replicas: 1
meta:
etcdEndpoints:
- etcd.etcd-cluster.svc.cluster.local:2379
replicas: 1
datanode:
replicas: 3
# This is an error because multiple objectStorage configs are not allowed.
objectStorage:
s3:
bucket: "greptimedb"
oss:
bucket: "greptimedb"
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBCluster
metadata:
name: test03-error
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
frontend:
replicas: 1
meta:
etcdEndpoints:
- etcd.etcd-cluster.svc.cluster.local:2379
replicas: 1
datanode:
replicas: 3
wal:
# This is an error because multiple wal configs are not allowed.
raftEngine:
fs:
storageClassName: io2 # Use io2 storage class for WAL for better performance.
name: wal
storageSize: 5Gi
mountPath: /wal
kafka:
brokerEndpoints:
- "kafka-bootstrap.kafka.svc.cluster.local:9092"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBStandalone
metadata:
name: test00
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: greptime.io/v1alpha1
kind: GreptimeDBStandalone
metadata:
name: test00-error
namespace: default
spec:
base:
main:
image: greptime/greptimedb:latest
# This is an error because the config is not a valid toml config.
config: |
It's not a valid toml config----
Loading

0 comments on commit 7f63235

Please sign in to comment.