Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee7828a

Browse files
authored
chore: fix wsproxy test flake (#12280)
* chore: fix wsproxy test flake* fixup! chore: fix wsproxy test flake
1 parent4cc132c commitee7828a

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

‎enterprise/wsproxy/wsproxy_test.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,29 @@ func TestDERPEndToEnd(t *testing.T) {
367367
returntrue
368368
},testutil.WaitLong,testutil.IntervalMedium)
369369

370-
// Swap out the DERPMapper for a fake one that only returns the proxy. This
371-
// allows us to force the agent to pick the proxy as its preferred region.
372-
oldDERPMapper:=*api.AGPL.DERPMapper.Load()
373-
newDERPMapper:=func(derpMap*tailcfg.DERPMap)*tailcfg.DERPMap {
374-
derpMap=oldDERPMapper(derpMap)
375-
// Strip everything but the proxy, which is region ID 10001.
376-
derpMap.Regions=map[int]*tailcfg.DERPRegion{
377-
10001:derpMap.Regions[10001],
370+
// Wait until the proxy appears in the DERP map, and then swap out the DERP
371+
// map for one that only contains the proxy region. This allows us to force
372+
// the agent to pick the proxy as its preferred region.
373+
varproxyOnlyDERPMap*tailcfg.DERPMap
374+
require.Eventually(t,func()bool {
375+
derpMap:=api.AGPL.DERPMap()
376+
ifderpMap==nil {
377+
returnfalse
378+
}
379+
if_,ok:=derpMap.Regions[10001];!ok {
380+
returnfalse
378381
}
379-
derpMap.OmitDefaultRegions=true
380-
returnderpMap
382+
383+
// Make a DERP map that only contains the proxy region.
384+
proxyOnlyDERPMap=derpMap.Clone()
385+
proxyOnlyDERPMap.Regions=map[int]*tailcfg.DERPRegion{
386+
10001:proxyOnlyDERPMap.Regions[10001],
387+
}
388+
proxyOnlyDERPMap.OmitDefaultRegions=true
389+
returntrue
390+
},testutil.WaitLong,testutil.IntervalMedium)
391+
newDERPMapper:=func(derpMap*tailcfg.DERPMap)*tailcfg.DERPMap {
392+
returnproxyOnlyDERPMap
381393
}
382394
api.AGPL.DERPMapper.Store(&newDERPMapper)
383395

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp