diff --git a/pkg/service/setup/migration_summary_telnet_test.go b/pkg/service/setup/migration_summary_telnet_test.go index c159728..332ff62 100644 --- a/pkg/service/setup/migration_summary_telnet_test.go +++ b/pkg/service/setup/migration_summary_telnet_test.go @@ -18,6 +18,7 @@ import ( // so the live-info call works; the SSH and telnet clients ignore the addr // and return whatever the fakes are scripted to return. func telnetSummaryEnv(t *testing.T, ssh *mockSSH, ft *fakeTelnet) (*Manager, string, func()) { + t.Helper() return telnetSummaryEnvWithInfo(t, ssh, ft, `Test`) } diff --git a/pkg/service/setup/setup.go b/pkg/service/setup/setup.go index 31424fe..919a013 100644 --- a/pkg/service/setup/setup.go +++ b/pkg/service/setup/setup.go @@ -274,6 +274,7 @@ func (m *Manager) GetMigrationSummary(deviceIP, targetURL, proxyURL string, opti go func() { var local MigrationSummary m.telnetPreflight(&local, deviceIP) + telnetCh <- local }() diff --git a/pkg/service/setup/telnet_probe.go b/pkg/service/setup/telnet_probe.go index fb0021d..0bd749a 100644 --- a/pkg/service/setup/telnet_probe.go +++ b/pkg/service/setup/telnet_probe.go @@ -87,8 +87,8 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar var logs strings.Builder t := m.NewTelnet(deviceIP) - if err := t.Dial(); err != nil { - return nil, fmt.Errorf("telnet dial %s:17000 failed: %w", deviceIP, err) + if dialErr := t.Dial(); dialErr != nil { + return nil, fmt.Errorf("telnet dial %s:17000 failed: %w", deviceIP, dialErr) } defer func() { _ = t.Close() }() @@ -147,10 +147,12 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar restoreCmd := "sys configuration swUpdateUrl " + originalURL if rresp, rerr := t.SendCommand(restoreCmd); rerr == nil && !isCommandNotFound(rresp) { result.Restored = true + fmt.Fprintf(&logs, "→ %s (restored)\n%s\n", restoreCmd, strings.TrimRight(rresp, "\r\n")) } else if rerr != nil { fmt.Fprintf(&logs, "Restore failed: %v (envswitch persistence will heal on next reboot)\n", rerr) } + result.Logs = logs.String() }() @@ -158,6 +160,7 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar // HTTP call is fire-and-forget — we don't need its response, only // that the device fans out to the probe URL we just set. swCheckURL := fmt.Sprintf("http://%s:8090/swUpdateCheck", deviceIP) + go func() { if m.HTTPGet == nil { return @@ -177,9 +180,11 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar select { case <-probeCh: result.Reached = true + fmt.Fprintf(&logs, "Probe inbound observed after %v\n", time.Since(start)) case <-time.After(timeout): result.Reached = false + fmt.Fprintf(&logs, "Probe timed out after %v\n", timeout) } diff --git a/pkg/service/setup/telnet_urls_test.go b/pkg/service/setup/telnet_urls_test.go index ac4227c..3b3e37f 100644 --- a/pkg/service/setup/telnet_urls_test.go +++ b/pkg/service/setup/telnet_urls_test.go @@ -115,10 +115,10 @@ func TestMigrateViaTelnet_SoundcorkMargeSuffixPropagatesToEnvswitch(t *testing.T // Build a happy-path responder that matches the *new* command set. resp := map[string]string{ - "sys configuration bmxRegistryUrl " + urls.BmxRegistry: "OK\n", - "sys configuration statsServerUrl " + urls.Stats: "OK\n", - "sys configuration margeServerUrl " + urls.Marge: "OK\n", - "sys configuration swUpdateUrl " + urls.SwUpdate: "OK\n", + "sys configuration bmxRegistryUrl " + urls.BmxRegistry: "OK\n", + "sys configuration statsServerUrl " + urls.Stats: "OK\n", + "sys configuration margeServerUrl " + urls.Marge: "OK\n", + "sys configuration swUpdateUrl " + urls.SwUpdate: "OK\n", "envswitch boseurls set " + urls.Marge + " " + urls.SwUpdate: "OK\n", "getpdo CurrentSystemConfiguration": "margeServerUrl=" + urls.Marge + "\n", }