diff --git a/Makefile b/Makefile index a653bef..815884d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker_helpers_test.go b/docker_helpers_test.go index 194cf00..58aef04 100644 --- a/docker_helpers_test.go +++ b/docker_helpers_test.go @@ -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, ) } } diff --git a/docker_test.go b/docker_test.go index 0a54828..85df45b 100644 --- a/docker_test.go +++ b/docker_test.go @@ -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"}, + }) +} diff --git a/fixtures/mqtt.yml b/fixtures/mqtt.yml new file mode 100644 index 0000000..e696b3c --- /dev/null +++ b/fixtures/mqtt.yml @@ -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"