registry_demand_only_test.go RawHistoryFolder

1package broker
2
3import (
4	"context"
5	"testing"
6	"time"
7
8	"github.com/stretchr/testify/require"
9
10	"github.com/bnema/vev/internal/domain"
11	"github.com/bnema/vev/internal/ports"
12)
13
14func TestRegistryObservesOnlyUnderSubscriptionOrExplicitRequest(t *testing.T) {
15	start := time.Unix(100, 0)
16	clock := newManualClock(start)
17	probe := newTestProbe(4)
18	local := newScriptedLocalProbe(4)
19	registry := newLocalTestRegistry(t, newTestStore(), probe, local, clock)
20	reg := registration(t, "example.test", 1)
21	require.NoError(t, registry.setHosts(hostRecords(reg)))
22	// Start Run directly: the test helper's synthetic subscription must not
23	// hide an idle broker probe.
24	ctx, cancel := context.WithCancel(context.Background())
25	done := make(chan struct{})
26	go func() { defer close(done); registry.Run(ctx) }()
27	t.Cleanup(func() { cancel(); <-done })
28	clock.Advance(time.Hour)
29	requireNoProbeWithin(t, probe, probeGrace)
30	requireNoLocalProbeWithin(t, local, probeGrace)
31
32	registry.SetDemand(true)
33	remoteCall := receiveCall(t, probe)
34	localCall := receiveLocalCall(t, local)
35	remoteCall.result <- probeAnswer{snapshot: ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityReachable}}
36	localCall.result <- localProbeAnswer{snapshot: ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnknown}}
37	waitHost(t, registry, reg.Endpoint, func(host ports.BrokerDaemonObservation) bool {
38		return !host.Checking && host.Availability == domain.RemoteAvailabilityReachable
39	})
40	waitLocal(t, registry, func(host ports.BrokerDaemonObservation) bool { return !host.Checking })
41	registry.SetDemand(false)
42	clock.Advance(time.Hour)
43	requireNoProbeWithin(t, probe, probeGrace)
44	requireNoLocalProbeWithin(t, local, probeGrace)
45
46	registry.RequestProbe(reg.Endpoint)
47	receiveCall(t, probe)
48	requireNoLocalProbeWithin(t, local, probeGrace)
49}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close