Skip to content
Merged
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: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go 1.24.0

toolchain go1.24.1

replace gopkg.in/yaml.v3 => github.com/WizardWuuu/yaml v0.0.0-20260224063639-09a585130e86

require (
github.com/AstroProfundis/sysinfo v0.0.0-20240112160158-ed54df16e9ce
github.com/BurntSushi/toml v1.5.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1o
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/VoltDB/voltdb-client-go v1.0.15 h1:G7rZxKiemYkaYZLoLamhRnAOGyq5wlyqPefCAAflB/0=
github.com/VoltDB/voltdb-client-go v1.0.15/go.mod h1:mMhb5zwkT46Ef3NvkFqt+kX0j+ltQ2Sdqj9+ICq+Yto=
github.com/WizardWuuu/yaml v0.0.0-20260224063639-09a585130e86 h1:UK3YAyeYxGjOJXAt5RgFE2AtLXIG1IJ2Lnd5TzwOx+M=
github.com/WizardWuuu/yaml v0.0.0-20260224063639-09a585130e86/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
Expand Down Expand Up @@ -840,10 +842,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/bigquery v1.1.0 h1:C2qhkcog12atQ7riLTopiQA2CzWQW8F5TiT8cJi+sGw=
gorm.io/driver/bigquery v1.1.0/go.mod h1:i6a2oUEHBSVWmtzBOiaDjxE5Ctls9G3OBHwcrN44wrg=
honnef.co/go/tools v0.4.3 h1:o/n5/K5gXqk8Gozvs2cnL0F2S1/g1vcGCAx2vETjITw=
Expand Down
61 changes: 55 additions & 6 deletions pkg/cluster/spec/server_config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package spec

import (
"bytes"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -13,23 +12,31 @@ func TestMerge(t *testing.T) {
server_configs:
tidb:
performance.feedback-probability: 12.0
log.level: 0.0
token-limit: 1000.1
`)

topo := new(Specification)

err := yaml.Unmarshal(yamlData, topo)
require.NoError(t, err)

yamlData, err = yaml.Marshal(topo)
// Verify values are parsed as float64
require.Equal(t, float64(12.0), topo.ServerConfigs.TiDB["performance.feedback-probability"])
require.Equal(t, float64(0.0), topo.ServerConfigs.TiDB["log.level"])
require.Equal(t, float64(1000.1), topo.ServerConfigs.TiDB["token-limit"])

// Verify Marshal/Unmarshal round-trip works without error
_, err = yaml.Marshal(topo)
require.NoError(t, err)
decimal := bytes.Contains(yamlData, []byte("12"))
require.True(t, decimal)

get, err := Merge2Toml("tidb", topo.ServerConfigs.TiDB, nil)
require.NoError(t, err)

decimal = bytes.Contains(get, []byte("12.0"))
require.True(t, decimal)
// Verify all float values retain decimal point in TOML output
require.Contains(t, string(get), "12.0")
require.Contains(t, string(get), "0.0")
require.Contains(t, string(get), "1000.1")
}

func TestGetValueFromPath(t *testing.T) {
Expand Down Expand Up @@ -127,6 +134,48 @@ func TestFoldMap(t *testing.T) {
}, r)
}

func TestYAMLFloatSerialization(t *testing.T) {
// Test that float values are serialized with decimal point preserved.
// This ensures the forked yaml.v3 correctly handles float serialization.
// See: https://github.com/go-yaml/yaml/issues/1038
yamlData := []byte(`
server_configs:
tidb:
float_one: 1.0
float_zero: 0.0
float_value: 3.14
`)

topo := new(Specification)
err := yaml.Unmarshal(yamlData, topo)
require.NoError(t, err)

// Verify the values are correctly parsed as float64
require.Equal(t, float64(1.0), topo.ServerConfigs.TiDB["float_one"])
require.Equal(t, float64(0.0), topo.ServerConfigs.TiDB["float_zero"])
require.Equal(t, float64(3.14), topo.ServerConfigs.TiDB["float_value"])

// Marshal back to YAML
marshaled, err := yaml.Marshal(topo)
require.NoError(t, err)

// The forked yaml.v3 should serialize float 1.0 as "1.0" (not "1")
// This preserves the float type during round-trip serialization
require.Contains(t, string(marshaled), "1.0")
require.Contains(t, string(marshaled), "0.0")
require.Contains(t, string(marshaled), "3.14")

// Unmarshal again to verify type is preserved
topo2 := new(Specification)
err = yaml.Unmarshal(marshaled, topo2)
require.NoError(t, err)

// After round-trip, the values should still be float64
require.IsType(t, float64(0), topo2.ServerConfigs.TiDB["float_one"])
require.IsType(t, float64(0), topo2.ServerConfigs.TiDB["float_zero"])
require.IsType(t, float64(0), topo2.ServerConfigs.TiDB["float_value"])
}

func TestEncodeRemoteCfg(t *testing.T) {
yamlData := []byte(`remote_write:
- queue_config:
Expand Down
Loading