Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST only] removed test functions that are no longer used #5582

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
196 changes: 0 additions & 196 deletions server/mqtt_ex_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,89 +245,6 @@ func mqttMakeTestServer(tb testing.TB) *mqttTarget {
}
}

func mqttMakeTestServerWithLeafnode(hubd, leafd string, connectSystemAccount bool) func(tb testing.TB) *mqttTarget {
return func(tb testing.TB) *mqttTarget {
tb.Helper()

if hubd != "" {
hubd = "domain: " + hubd + ", "
}
sconf := `
listen: 127.0.0.1:-1

server_name: HUB
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, ` + hubd + `store_dir: '` + tb.TempDir() + `'}

leafnodes {
listen: 127.0.0.1:-1
}

accounts {
ONE { users = [ { user: "one", pass: "p" } ]; jetstream: enabled }
$SYS { users = [ { user: "admin", pass: "s3cr3t!" } ] }
}

mqtt {
listen: 127.0.0.1:-1
}
`
hubConf := createConfFile(tb, []byte(sconf))
hubServer, o := RunServerWithConfig(hubConf)
leafRemoteAddr := fmt.Sprintf("%s:%d", o.LeafNode.Host, o.LeafNode.Port)
tb.Cleanup(func() {
os.Remove(hubConf)
})

sysRemote := ""
if connectSystemAccount {
sysRemote = `{ url: "nats://admin:s3cr3t!@` + leafRemoteAddr + `", account: "$SYS" },` + "\n\t\t"
}
if leafd != "" {
leafd = "domain: " + leafd + ", "
}
leafconf := `
listen: 127.0.0.1:-1

server_name: SPOKE
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, ` + leafd + `store_dir: '` + tb.TempDir() + `'}

leafnodes {
remotes = [
` + sysRemote + `{ url: "nats://one:p@` + leafRemoteAddr + `", account: "ONE" },
]
}

accounts {
ONE { users = [ { user: "one", pass: "p" } ]; jetstream: enabled }
$SYS { users = [ { user: "admin", pass: "s3cr3t!" } ] }
}

mqtt {
listen: 127.0.0.1:-1
}
`
leafConf := createConfFile(tb, []byte(leafconf))
leafServer, _ := RunServerWithConfig(leafConf)
tb.Cleanup(func() {
os.Remove(leafConf)
})

both := []mqttDial{
mqttNewDialForServer(hubServer, "one", "p"),
mqttNewDialForServer(leafServer, "one", "p"),
}
return &mqttTarget{
singleServers: []*Server{hubServer, leafServer},
all: both,
configs: []mqttTestConfig{
{name: "pub to all", pub: both, sub: both},
{name: "pub to SPOKE", pub: both[1:], sub: both},
{name: "pub to HUB", pub: both[:1], sub: both},
},
}
}
}

func mqttMakeTestCluster(size int, domain string) func(tb testing.TB) *mqttTarget {
return func(tb testing.TB) *mqttTarget {
tb.Helper()
Expand Down Expand Up @@ -393,119 +310,6 @@ func mqttMakeTestCluster(size int, domain string) func(tb testing.TB) *mqttTarge
}
}

func mqttMakeTestClusterWithLeafnodeCluster(hubd, leafd string, connectSystemAccount bool) func(tb testing.TB) *mqttTarget {
return func(tb testing.TB) *mqttTarget {
tb.Helper()

// Create HUB cluster.
if hubd != "" {
hubd = "domain: " + hubd + ", "
}
hubConf := `
listen: 127.0.0.1:-1

server_name: %s
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, ` + hubd + `store_dir: '%s'}

leafnodes {
listen: 127.0.0.1:-1
}

cluster {
name: %s
listen: 127.0.0.1:%d
routes = [%s]
}

mqtt {
listen: 127.0.0.1:-1
stream_replicas: 3
}

accounts {
ONE { users = [ { user: "one", pass: "p" } ]; jetstream: enabled }
$SYS { users = [ { user: "admin", pass: "s3cr3t!" } ] }
}
`
hub := createJetStreamClusterWithTemplate(tb, hubConf, "HUB", 3)
hub.waitOnLeader()

// Pick a host to connect leafnodes to
lno := hub.randomNonLeader().getOpts().LeafNode
leafRemoteAddr := fmt.Sprintf("%s:%d", lno.Host, lno.Port)
hubRandom := mqttNewDialForServer(hub.randomNonLeader(), "one", "p")
hubAll := []mqttDial{}
for _, s := range hub.servers {
hubAll = append(hubAll, mqttNewDialForServer(s, "one", "p"))
}

// Create SPOKE (leafnode) cluster.
sysRemote := ""
if connectSystemAccount {
sysRemote = `{ url: "nats://admin:s3cr3t!@` + leafRemoteAddr + `", account: "$SYS" },` + "\n\t\t\t"
}
if leafd != "" {
leafd = "domain: " + leafd + ", "
}
leafConf := `
listen: 127.0.0.1:-1

server_name: %s
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, ` + leafd + `store_dir: '%s'}

leafnodes {
remotes = [
` + sysRemote + `{ url: "nats://one:p@` + leafRemoteAddr + `", account: "ONE" },
]
}

cluster {
name: %s
listen: 127.0.0.1:%d
routes = [%s]
}

mqtt {
listen: 127.0.0.1:-1
stream_replicas: 3
}

accounts {
ONE { users = [ { user: "one", pass: "p" } ]; jetstream: enabled }
$SYS { users = [ { user: "admin", pass: "s3cr3t!" } ] }
}
`
spoke := createJetStreamCluster(tb, leafConf, "SPOKE", "SPOKE-", 3, 22111, false)
expectedConnections := 2
if !connectSystemAccount {
expectedConnections = 1
}
for _, s := range spoke.servers {
checkLeafNodeConnectedCount(tb, s, expectedConnections)
}
spoke.waitOnPeerCount(3)
spokeRandom := mqttNewDialForServer(spoke.randomNonLeader(), "one", "p")
spokeAll := []mqttDial{}
for _, s := range spoke.servers {
spokeAll = append(spokeAll, mqttNewDialForServer(s, "one", "p"))
}

all := append(hubAll, spokeAll...)

return &mqttTarget{
clusters: []*cluster{hub, spoke},
all: all,
configs: []mqttTestConfig{
{name: "publish to all", pub: all, sub: all},
{name: "publish to all hub", pub: hubAll, sub: all},
{name: "publish to random in hub", pub: []mqttDial{hubRandom}, sub: all},
{name: "publish to all spoke", pub: spokeAll, sub: all},
{name: "publish to random in spoke", pub: []mqttDial{spokeRandom}, sub: all},
},
}
}
}

var mqttCLICommandPath = func() string {
p := os.Getenv("MQTT_CLI")
if p == "" {
Expand Down