From cd178993288f47b3cc7b62c8d3a1cc38e276f3d2 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 01:36:21 +0100 Subject: [PATCH] networkmanager: the uplink-names moments test waits on each call, not on the scheduler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test changed check-address while the bundle, running beside it, had not yet read it for its start's call. On a temporary directory in memory with one CPU, as a build step runs, nothing yields before the test's write, so the start's call read the empty address every time (pipeline main.517, asks mwvdrpjpbb0cf9 and mwvdrpjpb6c9b9); on a disk the fsync yielded and it passed. The stood-in resolver now says each uplink-names call, and the test changes the address only after the call before it. Builds: design 08 sign-in-page §13, §25 --- .../networkmanager/cmd/uplink-tools/names_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/networkmanager/cmd/uplink-tools/names_test.go b/modules/networkmanager/cmd/uplink-tools/names_test.go index db58b8952..3d2f6bd3d 100644 --- a/modules/networkmanager/cmd/uplink-tools/names_test.go +++ b/modules/networkmanager/cmd/uplink-tools/names_test.go @@ -19,6 +19,8 @@ type fakeMesh struct { fail error calls []string routes string + // given, when set, hears each uplink-names call once made, so a test acts after it and never on a guess of when. + given chan string } func (m *fakeMesh) ask(key string, body any) (json.RawMessage, error) { @@ -38,6 +40,9 @@ func (m *fakeMesh) ask(key string, body any) (json.RawMessage, error) { case "seat:node-resolver.uplink-names@laptop": raw, _ := json.Marshal(body) m.calls = append(m.calls, string(raw)) + if m.given != nil { + m.given <- string(raw) + } if m.fail != nil { return nil, m.fail } @@ -66,10 +71,13 @@ func TestUplinkNamesIsCalledAtEachMoment(t *testing.T) { if err := f.writeCheckAddress("http://Check.Example.net/connecttest"); err != nil { t.Fatal(err) } - mesh := &fakeMesh{holder: "systemd-resolved"} + mesh := &fakeMesh{holder: "systemd-resolved", given: make(chan string, 16)} b := &bundle{folder: f, pub: &publisher{folder: f, publish: (&fakeStream{}).publish}, names: &namer{folder: f, ask: mesh.ask, now: time.Now}} check := make(chan struct{}) + // The bundle runs beside the test: each check address is changed only once the call made from the one before was + // heard, so the test never races the bundle's read of check-address (a call never made ends the run at its bound). + heard := func() { <-mesh.given } var running func(stdio.Envelope) error var hook func(stdio.Heartbeat) done := make(chan struct{}) @@ -91,10 +99,12 @@ func TestUplinkNamesIsCalledAtEachMoment(t *testing.T) { }}) close(done) }() + heard() if err := f.writeCheckAddress(""); err != nil { t.Fatal(err) } check <- struct{}{} + heard() f.writeCheckAddress("https://other.example.net/") close(check) <-done -- 2.54.0