Add a local SvxReflector Docker lab for headset testing.
Funknetz needs a protocol 2.0 reflector without production credentials; the compose stack and smoke test prove the station can log in and select a talk group. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package station_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.neitzel.de/konrad/funknetz/station"
|
||||
)
|
||||
|
||||
// Lab defaults match svxlink-docker/.env and config/svxreflector.conf.
|
||||
const (
|
||||
labHost = "127.0.0.1"
|
||||
labPort = 5300
|
||||
labCallsign = "DL0FN-1"
|
||||
labAuthKey = "local-lab-secret-change-me"
|
||||
labTalkGroup = 9
|
||||
)
|
||||
|
||||
func TestConnectsToLabReflector(t *testing.T) {
|
||||
if os.Getenv("FUNKNETZ_LAB") == "0" {
|
||||
t.Skip("FUNKNETZ_LAB=0")
|
||||
}
|
||||
addr := net.JoinHostPort(labHost, strconv.Itoa(labPort))
|
||||
conn, err := net.DialTimeout("tcp", addr, 500*time.Millisecond)
|
||||
if err != nil {
|
||||
t.Skipf("lab reflector not listening on %s: %v", addr, err)
|
||||
}
|
||||
conn.Close()
|
||||
|
||||
path := writeConfigFile(t, configJSON(labHost, labPort, labCallsign, labAuthKey, labTalkGroup))
|
||||
st, err := station.New(station.Options{ConfigPath: path})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 15*time.Second)
|
||||
defer cancel()
|
||||
go func() { _ = st.Run(ctx) }()
|
||||
|
||||
state, err := st.Wait(ctx, func(s station.State) bool {
|
||||
return s.Connection == "Connected"
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("did not reach Connected: %v (last state %#v)", err, st.State())
|
||||
}
|
||||
if state.Callsign != labCallsign {
|
||||
t.Fatalf("callsign = %q, want %q", state.Callsign, labCallsign)
|
||||
}
|
||||
if state.TalkGroup != labTalkGroup {
|
||||
t.Fatalf("talkGroup = %d, want %d", state.TalkGroup, labTalkGroup)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user