Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/cluster/command/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func newTemplateCmd() *cobra.Command {
return nil
}

// redner template
// render template

// validate arch
if localOpt.GlobalArch != "amd64" && localOpt.GlobalArch != "arm64" {
Expand Down
14 changes: 13 additions & 1 deletion embed/examples/cluster/topology.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ monitored:
# server_configs:
# tidb:
# tikv:
# tikv-worker:
# pd:
# tiflash:
# tiflash-learner:
Expand Down Expand Up @@ -226,6 +227,17 @@ tikv_servers:
# config:
# log.level: warn

tikv_worker_servers:
- host: 10.0.1.22
# ssh_port: 22
port: 19000
deploy_dir: "/data1/tidb-deploy/tikv-worker-19000"
data_dir: "/data1/tidb-data/tikv-worker-19000"
log_dir: "/data1/tidb-deploy/tikv-worker-19000/log"
# numa_node: "0"
# config:
# schema-manager.enabled: false

# # Server configs are used to specify the configuration of TiFlash Servers.
tiflash_servers:
# # The ip address of the TiFlash Server.
Expand Down Expand Up @@ -356,7 +368,7 @@ monitoring_servers:
# ssh_port: 22
# # Prometheus Service communication port.
# port: 9090
# # ng-monitoring servive communication port
# # ng-monitoring service communication port
# ng_port: 12020
# # Prometheus deployment file, startup script, configuration file storage directory.
# deploy_dir: "/tidb-deploy/prometheus-8249"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/spec/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func FoldMap(ms map[string]any) map[string]any {
return result
}

// FlattenMap convert mutil-layer map to single layer
// FlattenMap convert multi-layer map to single layer
func FlattenMap(ms map[string]any) map[string]any {
result := map[string]any{}
for k, v := range ms {
Expand Down
66 changes: 66 additions & 0 deletions pkg/cluster/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ cdc_servers:
kvcdc_servers:
- host: 172.16.5.244
data_dir: "tikv-cdc-data"
tikv_worker_servers:
- host: 172.16.5.250
data_dir: "tikv-worker-data"
`), &topo)
require.NoError(t, err)
require.Equal(t, "test1", topo.GlobalOptions.User)
Expand All @@ -129,6 +132,10 @@ kvcdc_servers:
require.Equal(t, 220, topo.TiKVCDCServers[0].SSHPort)
require.Equal(t, "test-deploy/tikv-cdc-8600", topo.TiKVCDCServers[0].DeployDir)
require.Equal(t, "tikv-cdc-data", topo.TiKVCDCServers[0].DataDir)

require.Equal(t, 220, topo.TiKVWorkerServers[0].SSHPort)
require.Equal(t, "test-deploy/tikv-worker-19000", topo.TiKVWorkerServers[0].DeployDir)
require.Equal(t, "tikv-worker-data", topo.TiKVWorkerServers[0].DataDir)
}

func TestDataDirAbsolute(t *testing.T) {
Expand All @@ -152,6 +159,11 @@ kvcdc_servers:
data_dir: "tikv-cdc-data"
- host: 172.16.5.245
port: 33333
tikv_worker_servers:
- host: 172.16.5.251
data_dir: "worker-data"
- host: 172.16.5.252
port: 29000
`), &topo)
require.NoError(t, err)

Expand All @@ -163,6 +175,9 @@ kvcdc_servers:

require.Equal(t, "tikv-cdc-data", topo.TiKVCDCServers[0].DataDir)
require.Equal(t, "/test-data/tikv-cdc-33333", topo.TiKVCDCServers[1].DataDir)

require.Equal(t, "worker-data", topo.TiKVWorkerServers[0].DataDir)
require.Equal(t, "/test-data/tikv-worker-29000", topo.TiKVWorkerServers[1].DataDir)
}

func TestGlobalConfig(t *testing.T) {
Expand Down Expand Up @@ -190,6 +205,9 @@ server_configs:
scheduler.max_limit: 20480
kvcdc:
gc-ttl: 43200
tikv_worker:
schema-manager.enabled: false
log.level: info

tidb_servers:
- host: 172.16.5.138
Expand All @@ -209,6 +227,13 @@ kvcdc_servers:
port: 8601
config:
log-level: "debug"

tikv_worker_servers:
- host: 172.16.5.253
- host: 172.16.5.254
port: 19001
config:
log.level: debug
`), &topo)
require.NoError(t, err)
require.Equal(t, map[string]any{
Expand All @@ -220,6 +245,10 @@ kvcdc_servers:
require.Equal(t, map[string]any{
"gc-ttl": 43200,
}, topo.ServerConfigs.TiKVCDC)
require.Equal(t, map[string]any{
"schema-manager.enabled": false,
"log.level": "info",
}, topo.ServerConfigs.TiKVWorker)

expected := map[string]any{
"status": map[string]any{
Expand Down Expand Up @@ -292,6 +321,18 @@ kvcdc_servers:
}
got = FoldMap(topo.TiKVCDCServers[1].Config)
require.Equal(t, expected, got)

expected = map[string]any{}
got = FoldMap(topo.TiKVWorkerServers[0].Config)
require.Equal(t, expected, got)

expected = map[string]any{
"log": map[string]any{
"level": "debug",
},
}
got = FoldMap(topo.TiKVWorkerServers[1].Config)
require.Equal(t, expected, got)
}

func TestGlobalConfigPatch(t *testing.T) {
Expand Down Expand Up @@ -363,6 +404,9 @@ server_configs:
config.item3.item6: 600
kvcdc:
gc-ttl: 43200
tikv_worker:
schema-manager.enabled: false
log.level: info

tikv_servers:
- host: 172.16.5.138
Expand All @@ -375,6 +419,11 @@ kvcdc_servers:
config:
log-level: "debug"

tikv_worker_servers:
- host: 172.16.5.255
config:
log.level: debug

`), &topo)
require.NoError(t, err)
expected := `# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
Expand Down Expand Up @@ -408,6 +457,23 @@ log-level = "debug"
got, err = Merge2Toml("kvcdc", topo.ServerConfigs.TiKVCDC, topo.TiKVCDCServers[0].Config)
require.NoError(t, err)
require.Equal(t, expected, string(got))

expected = `# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
# You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
# All configuration items you want to change can be added to:
# server_configs:
# tikv-worker:
# aa.b1.c3: value
# aa.b2.c4: value
[log]
level = "debug"

[schema-manager]
enabled = false
`
got, err = Merge2Toml("tikv-worker", topo.ServerConfigs.TiKVWorker, topo.TiKVWorkerServers[0].Config)
require.NoError(t, err)
require.Equal(t, expected, string(got))
}

func TestMerge2Toml2(t *testing.T) {
Expand Down
Loading