Skip to content

Commit

Permalink
Merge branch 'check-clean-expired' into 'master'
Browse files Browse the repository at this point in the history
fix ci test case for config

See merge request paas/zanredisdb!25
  • Loading branch information
absolute8511 committed May 20, 2021
2 parents d9908c3 + 15819a8 commit c38ab46
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions apps/placedriver/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"os"
"path"
"runtime"
"strconv"
"testing"
"time"
Expand All @@ -28,6 +29,11 @@ func TestAppConfigParse(t *testing.T) {
opts.LogDir = path.Join(os.TempDir(), strconv.Itoa(int(time.Now().UnixNano())))
os.MkdirAll(opts.LogDir, 0755)
common.SetZapRotateOptions(false, true, path.Join(opts.LogDir, "test.log"), 0, 0, 0)
if runtime.GOOS == "darwin" {
opts.BroadcastInterface = "lo0"
} else {
opts.BroadcastInterface = "lo"
}
s, err := pdserver.NewServer(opts)
t.Log(err)
assert.Equal(t, "v2", opts.BalanceVer)
Expand Down
9 changes: 8 additions & 1 deletion apps/zankv/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path"
"runtime"
"strconv"
"testing"
"time"
Expand All @@ -24,5 +25,11 @@ func TestAppConfigParse(t *testing.T) {

serverConf := configFile.ServerConf
serverConf.LogDir = path.Join(os.TempDir(), strconv.Itoa(int(time.Now().UnixNano())))
server.NewServer(serverConf)
if runtime.GOOS == "darwin" {
serverConf.BroadcastInterface = "lo0"
} else {
serverConf.BroadcastInterface = "lo"
}
_, err = server.NewServer(serverConf)
assert.Nil(t, err)
}
2 changes: 1 addition & 1 deletion default.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"server_conf": {
"cluster_id": "test-default-alpha-1",
"etcd_cluster_addresses": "http://etcd0.example.com:2379,http://etcd1.example.com:2379",
"etcd_cluster_addresses": "http://127.0.0.1:2379",
"broadcast_interface":"lo0",
"data_dir":"./test1",
"data_rsync_module": "zanredisdb",
Expand Down
2 changes: 1 addition & 1 deletion pdserver/pdconf.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
http_address = "0.0.0.0:18001"

## the network interface for broadcast, the ip will be detected automatically.
broadcast_interface = "lo0"
broadcast_interface = "lo"

## local reverse proxy port, basically used for collecting the stats
# reverse_proxy_port = "18003"
Expand Down
2 changes: 1 addition & 1 deletion pdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewServer(conf *ServerConfig) (*Server, error) {
conf.BroadcastAddr = myNode.NodeIP
}
if myNode.NodeIP == "0.0.0.0" || myNode.NodeIP == "" {
err := fmt.Errorf("can not decide the broadcast ip: %v", myNode.NodeIP)
err := fmt.Errorf("can not decide the broadcast ip: %v , %v", myNode.NodeIP, conf.BroadcastInterface)
sLog.Errorf(err.Error())
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ func NewServer(conf ServerConfig) (*Server, error) {
conf.BroadcastAddr = myNode.NodeIP
}
if myNode.NodeIP == "0.0.0.0" || myNode.NodeIP == "" {
return nil, fmt.Errorf("can not decide the broadcast ip: %v", myNode.NodeIP)
err := fmt.Errorf("can not decide the broadcast ip: %v , %v", myNode.NodeIP, conf.BroadcastInterface)
sLog.Errorf(err.Error())
return nil, err
}
conf.LocalRaftAddr = strings.Replace(conf.LocalRaftAddr, "0.0.0.0", myNode.NodeIP, 1)
myNode.RaftTransportAddr = conf.LocalRaftAddr
Expand Down

0 comments on commit c38ab46

Please sign in to comment.