Skip to content

Commit

Permalink
test: addtional tcp test from bug report
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan committed Jun 30, 2024
1 parent c174b75 commit 215e73f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ cover:
watch:
watchexec -e go,yml "make test"

watch-cover:
watchexec -e go,yml "make cover"

clean:
rm -rf dist/
rm -f traefik-kop
Expand Down
5 changes: 4 additions & 1 deletion docker_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,12 @@ func assertServiceIPs(t *testing.T, store *testStore, svcs map[string]svc) {
if svc.proto != "http" {
path = "address"
}
key := fmt.Sprintf("traefik/%s/services/%s/loadBalancer/servers/0/%s", svc.proto, serviceName, path)
assert.Equal(t,
svc.ip,
store.kv[fmt.Sprintf("traefik/%s/services/%s/loadBalancer/servers/0/%s", svc.proto, serviceName, path)],
store.kv[key],
"service has wrong IP at key: %s",
key,
)
}
}
9 changes: 9 additions & 0 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,12 @@ func Test_TCP(t *testing.T) {
"gitea-ssh": {"tcp", "192.168.100.100:20022"},
})
}

func Test_TCPMQTT(t *testing.T) {
// from https://github.com/jittering/traefik-kop/issues/35
store := doTest(t, "mqtt.yml")
assertServiceIPs(t, store, map[string]svc{
"mqtt-http": {"http", "http://192.168.100.100:9001"},
"mqtt-tcp": {"tcp", "192.168.100.100:1883"},
})
}
12 changes: 12 additions & 0 deletions fixtures/mqtt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
gitea:
image: gitea/gitea
labels:
- "traefik.enable=true"
- "traefik.http.routers.mqtt-http.rule=Host(`mqtt.local`)"
- "traefik.http.services.mqtt-http.loadbalancer.server.port=9001"
# MQTT routing
- "traefik.tcp.routers.mqtt-tcp.rule=HostSNI(`*`)"
- "traefik.tcp.routers.mqtt-tcp.entrypoints=mqtt"
- "traefik.tcp.routers.mqtt-tcp.service=service-broker-mqtt"
- "traefik.tcp.services.mqtt-tcp.loadbalancer.server.port=1883"

0 comments on commit 215e73f

Please sign in to comment.