Skip to content

Commit

Permalink
Merge pull request #149 from ClickHouse/feat/cht-add-inter-server-host
Browse files Browse the repository at this point in the history
feat(cht): add WithInterServerHost option
  • Loading branch information
ernado authored Jul 6, 2022
2 parents e090aad + 32bc485 commit c76cc66
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- v22.3.7.28-lts
- v22.4.5.9-stable
- v22.5.1.2079-stable
- v22.6.2.12-stable
- v22.6.3.35-stable
steps:
- uses: actions/checkout@v3

Expand Down
25 changes: 16 additions & 9 deletions cht/cht.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ func Ports(t testing.TB, n int) []int {
}

type options struct {
tcp int
http int
httpInternal *int
clusters Clusters
lg *zap.Logger
zooKeeper []ZooKeeperNode
keeper *KeeperConfig
macros Map
ddl *DistributedDDL
tcp int
http int
httpInternal *int
httpInternalHost *string
clusters Clusters
lg *zap.Logger
zooKeeper []ZooKeeperNode
keeper *KeeperConfig
macros Map
ddl *DistributedDDL
}

func WithKeeper(cfg KeeperConfig) Option {
Expand All @@ -126,6 +127,12 @@ func WithInterServerHTTP(port int) Option {
}
}

func WithInterServerHost(host string) Option {
return func(o *options) {
o.httpInternalHost = &host
}
}

type Option func(o *options)

func WithClusters(c Clusters) Option {
Expand Down
13 changes: 11 additions & 2 deletions cht/cht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ func withTableMacros(shard, replica int) cht.Option {
}

func TestCluster(t *testing.T) {
cht.Skip(t)
{
ctx := context.Background()
server := cht.New(t, cht.WithLog(ztest.NewLogger(t)))
client, err := ch.Dial(ctx, ch.Options{Address: server.TCP})
require.NoError(t, err)
if v := client.ServerInfo(); (v.Major < 22) || (v.Major == 22 && v.Minor < 6) {
t.Skip("Skipping (not supported)")
}
}
var (
ports = cht.Ports(t, 3*4)

Expand Down Expand Up @@ -163,6 +171,7 @@ func TestCluster(t *testing.T) {
Profile: "default",
Path: "/nexus/task_queue/ddl",
})
withInterHost = cht.WithInterServerHost(host)
withZooKeeper = cht.WithZooKeeper(nodes)
coordination = cht.CoordinationConfig{
ElectionTimeoutLowerBoundMs: 250,
Expand All @@ -173,7 +182,7 @@ func TestCluster(t *testing.T) {
}
retry = backoff.WithMaxRetries(backoff.NewConstantBackOff(time.Millisecond*20), 20)

withOptions = cht.With(withCluster, withZooKeeper, withDDL)
withOptions = cht.With(withCluster, withZooKeeper, withDDL, withInterHost)
servers = cht.Many(t,
cht.With(
cht.WithKeeper(cht.KeeperConfig{
Expand Down
3 changes: 2 additions & 1 deletion cht/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ type Config struct {
TCP int `xml:"tcp_port"`
Host string `xml:"listen_host"`

InterServerHTTP *int `xml:"interserver_http_port,omitempty"`
InterServerHTTP *int `xml:"interserver_http_port,omitempty"`
InterServerHTTPHost *string `xml:"interserver_http_host,omitempty"`

Path string `xml:"path"`
TempPath string `xml:"tmp_path"`
Expand Down

0 comments on commit c76cc66

Please sign in to comment.