Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ SHELLSPEC_INCLUDE_PATH := $(shell ./utils/get_shellspec_include_path.sh)
.PHONY: scripts-test-kcov
scripts-test-kcov: install-shellspec ## Run shellspec unit test cases.
@shellspec --load-path $(SHELLSPEC_LOAD_PATH) --default-path $(SHELLSPEC_DEFAULT_PATH) --shell $(SHELLSPEC_DEFAULT_SHELL) --kcov --kcov-options "--include-path=$(SHELLSPEC_INCLUDE_PATH) --path-strip-level=1"

CHART_FOLDER ?=
.PHONY: test-charts
test-charts: ## Run helm template tests for all charts.
@./hack/test-charts.sh $(CHART_FOLDER)
2 changes: 1 addition & 1 deletion addons-cluster/apecloud-mysql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ raftGroup mode: max(replicas, 3)
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.etcd.local.resources.storage }}
storage: {{ print .Values.etcd.local.resources.storage "Gi" }}
{{- end -}}

{{- define "apecloud-mysql-cluster.schedulingPolicy" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu: 0.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu: 0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mode: raftGroup
proxyEnabled: true
etcd:
mode: invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: raftGroup
proxyEnabled: true
etcd:
mode: local
local:
replicas: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: raftGroup
proxyEnabled: true
etcd:
mode: local
local:
replicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: invalid-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory: 0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: raftGroup
replicas: 7
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: raftGroup
replicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage: 10001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage: 0.5
1 change: 1 addition & 0 deletions addons-cluster/apecloud-mysql/tests/pass/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test default values (mode: standalone)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: raftGroup
proxyEnabled: true
etcd:
mode: local
local:
replicas: 3
6 changes: 6 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/etcd-replicas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: raftGroup
proxyEnabled: true
etcd:
mode: local
local:
replicas: 1
4 changes: 4 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/max-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
replicas: 5
cpu: 64
memory: 1000
storage: 10000
4 changes: 4 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/min-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
replicas: 1
cpu: 0.5
memory: 0.5
storage: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mode: raftGroup
replicas: 3
proxyEnabled: true
etcd:
mode: serviceRef
serviceRef:
cluster:
name: my-etcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mode: raftGroup
replicas: 3
proxyEnabled: true
2 changes: 2 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/raftgroup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: raftGroup
replicas: 3
2 changes: 2 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/replicas-max.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: raftGroup
replicas: 5
16 changes: 16 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cpu: 2
memory: 4

asserts:
- equal:
path: ".spec.componentSpecs[0].resources.limits.cpu"
value: "2"
- equal:
path: ".spec.componentSpecs[0].resources.limits.memory"
value: "4Gi"
- equal:
path: ".spec.componentSpecs[0].resources.requests.cpu"
value: "2"
- equal:
path: ".spec.componentSpecs[0].resources.requests.memory"
value: "4Gi"
16 changes: 16 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
storageClassName: "my-storage-class"
proxy:
storageClassName: "my-proxy-storage-class"
mode: raftGroup
proxyEnabled: true

asserts:
- equal:
path: ".spec.componentSpecs[0].volumeClaimTemplates[0].spec.storageClassName"
value: "my-storage-class"
- equal:
path: ".spec.componentSpecs[1].volumeClaimTemplates[0].spec.storageClassName"
value: "my-proxy-storage-class"
- equal:
path: ".spec.componentSpecs[3].volumeClaimTemplates[0].spec.storageClassName"
value: "my-proxy-storage-class"
3 changes: 3 additions & 0 deletions addons-cluster/apecloud-mysql/tests/pass/string-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cpu: "1.5"
memory: "10"
storage: "50"
17 changes: 13 additions & 4 deletions addons-cluster/apecloud-mysql/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"default": 0.5,
"minimum": 0.5,
"maximum": 64,
"pattern": "^[0-9]+(\\.[0-9]+)?$",
"multipleOf": 0.5
},
"memory": {
Expand All @@ -47,7 +48,8 @@
],
"default": 0.5,
"minimum": 0.5,
"maximum": 1000
"maximum": 1000,
"pattern": "^[0-9]+(\\.[0-9]+)?$"
},
"storage": {
"title": "Storage(Gi)",
Expand All @@ -58,7 +60,8 @@
],
"default": 20,
"minimum": 1,
"maximum": 10000
"maximum": 10000,
"pattern": "^[0-9]+(\\.[0-9]+)?$"
},
"storageClassName": {
"title": "Storage Class Name",
Expand Down Expand Up @@ -100,8 +103,14 @@
"type": "object",
"properties": {
"storage": {
"type": "string",
"default": "20Gi"
"type": [
"number",
"string"
],
"default": 20,
"minimum": 1,
"maximum": 10000,
"pattern": "^[0-9]+(\\.[0-9]+)?$"
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion addons-cluster/apecloud-mysql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ requests:
##
storage: 20

## @param storageClassName
storageClassName: ""

## @param proxyEnabled if true, enable the proxy
## if mode is standalone, proxyEnabled is always false
## if mode is raftGroup, proxyEnabled can be true or false
Expand Down Expand Up @@ -60,7 +63,7 @@ etcd:
etcdctlApi: "3" # the etcd tool etcdctl api version
replicas: 3 # no support other num
resources:
storage: 20Gi
storage: 20
serviceRef:
# -- Kubernetes namespace for etcd
# @default default
Expand Down
20 changes: 10 additions & 10 deletions addons-cluster/clickhouse/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Define clickhouse componentSpec with ComponentDefinition.
- name: clickhouse
componentDef: {{ include "clickhouse-cluster.cmpdName" . }}
replicas: {{ $.Values.replicas | default 2 }}
disableExporter: {{ $.Values.disableExporter | default "false" }}
disableExporter: {{ $.Values.extra.disableExporter | default "false" }}
serviceVersion: {{ $.Values.version }}
services:
- name: default
Expand Down Expand Up @@ -128,7 +128,7 @@ Define clickhouse keeper componentSpec with ComponentDefinition.
- name: ch-keeper
componentDef: {{ include "clickhouse-cluster.keeperCmpdName" . }}
replicas: {{ .Values.keeper.replicas }}
disableExporter: {{ $.Values.disableExporter | default "false" }}
disableExporter: {{ $.Values.extra.disableExporter | default "false" }}
serviceVersion: {{ $.Values.version }}
{{- with .Values.keeper.tolerations }}
tolerations: {{ .| toYaml | nindent 4 }}
Expand Down Expand Up @@ -177,9 +177,9 @@ Define clickhouse shardingComponentSpec with ComponentDefinition.
env:
- name: "INIT_CLUSTER_NAME"
value: "{{ .Values.clickhouse.initClusterName }}"
replicas: {{ $.Values.replicas | default 2 }}
disableExporter: {{ $.Values.disableExporter | default "false" }}
serviceVersion: {{ $.Values.version }}
replicas: {{ .Values.replicas | default 2 }}
disableExporter: {{ .Values.extra.disableExporter | default "false" }}
serviceVersion: {{ .Values.version }}
services:
- name: default
serviceType: {{ .Values.service.type | default "NodePort" }}
Expand All @@ -191,7 +191,7 @@ Define clickhouse shardingComponentSpec with ComponentDefinition.
numSymbols: 0
letterCase: MixedCases
seed: {{ include "kblib.clusterName" . }}
{{- with $.Values.tolerations }}
{{- with .Values.tolerations }}
tolerations: {{ .| toYaml | nindent 6 }}
{{- end }}
{{- include "kblib.componentResources" . | indent 4 }}
Expand All @@ -211,16 +211,16 @@ Define clickhouse componentSpec with compatible ComponentDefinition API
- name: {{ $name }}
env:
- name: "INIT_CLUSTER_NAME"
value: "{{ .Values.clickhouse.initClusterName }}"
componentDef: {{ include "clickhouse-cluster.cmpdName" . }}
value: "{{ $.Values.clickhouse.initClusterName }}"
componentDef: {{ include "clickhouse-cluster.cmpdName" $ }}
replicas: {{ $.Values.replicas | default 2 }}
disableExporter: {{ $.Values.disableExporter | default "false" }}
disableExporter: {{ $.Values.extra.disableExporter | default "false" }}
serviceVersion: {{ $.Values.version }}
{{- with $.Values.tolerations }}
tolerations: {{ .| toYaml | nindent 4 }}
services:
- name: default
serviceType: {{ .Values.service.type | default "NodePort" }}
serviceType: {{ $.Values.service.type | default "NodePort" }}
{{- end }}
{{- include "kblib.componentResources" $ | indent 2 }}
{{- include "kblib.componentStorages" $ | indent 2 }}
Expand Down
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/fail/cpu-too-high.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu: 65
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/fail/cpu-too-low.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu: 0.1
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/fail/invalid-mode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service:
type: InvalidType
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tls:
enabled: true
issuer: InvalidIssuer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
cpu: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
cpu: 0.05
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
memory: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
memory: 0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
replicas: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
storage: 10001
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
storage: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory: 1001
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/fail/memory-too-low.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory: 0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replicas: 0
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/fail/shards-too-low.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shards: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage: 10001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage: 0
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/pass/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test default values (mode: cluster, sharding: true)
2 changes: 2 additions & 0 deletions addons-cluster/clickhouse/tests/pass/keeper-replicas-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
replicas: 3
2 changes: 2 additions & 0 deletions addons-cluster/clickhouse/tests/pass/keeper-replicas-5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keeper:
replicas: 5
9 changes: 9 additions & 0 deletions addons-cluster/clickhouse/tests/pass/max-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
replicas: 10
cpu: 64
memory: 1000
storage: 10000
keeper:
replicas: 5
cpu: 64
memory: 1000
storage: 10000
2 changes: 2 additions & 0 deletions addons-cluster/clickhouse/tests/pass/no-sharding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: cluster
sharding: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service:
type: ExternalName
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service:
type: LoadBalancer
2 changes: 2 additions & 0 deletions addons-cluster/clickhouse/tests/pass/service-nodeport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service:
type: NodePort
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sharding: false
shards: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sharding: false
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/pass/shards-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shards: 3
1 change: 1 addition & 0 deletions addons-cluster/clickhouse/tests/pass/standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: standalone
2 changes: 2 additions & 0 deletions addons-cluster/clickhouse/tests/pass/tls-enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tls:
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tls:
enabled: true
issuer: KubeBlocks
Loading