mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: fix tailnet netcheck issues (#8802)
This commit is contained in:
@ -1270,11 +1270,9 @@ func TestWorkspaceAgent_UpdatedDERP(t *testing.T) {
|
||||
defer closer.Close()
|
||||
user := coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
originalDerpMap := api.DERPMap()
|
||||
require.NotNil(t, originalDerpMap)
|
||||
|
||||
// Change the DERP mapper to our custom one.
|
||||
var currentDerpMap atomic.Pointer[tailcfg.DERPMap]
|
||||
originalDerpMap, _ := tailnettest.RunDERPAndSTUN(t)
|
||||
currentDerpMap.Store(originalDerpMap)
|
||||
derpMapFn := func(_ *tailcfg.DERPMap) *tailcfg.DERPMap {
|
||||
return currentDerpMap.Load().Clone()
|
||||
@ -1304,10 +1302,8 @@ func TestWorkspaceAgent_UpdatedDERP(t *testing.T) {
|
||||
resources := coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
|
||||
agentID := resources[0].Agents[0].ID
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
|
||||
// Connect from a client.
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
conn1, err := client.DialWorkspaceAgent(ctx, agentID, &codersdk.DialWorkspaceAgentOptions{
|
||||
Logger: logger.Named("client1"),
|
||||
})
|
||||
@ -1328,7 +1324,14 @@ func TestWorkspaceAgent_UpdatedDERP(t *testing.T) {
|
||||
currentDerpMap.Store(newDerpMap)
|
||||
|
||||
// Wait for the agent's DERP map to be updated.
|
||||
// TODO: this
|
||||
require.Eventually(t, func() bool {
|
||||
conn := agentCloser.TailnetConn()
|
||||
if conn == nil {
|
||||
return false
|
||||
}
|
||||
regionIDs := conn.DERPMap().RegionIDs()
|
||||
return len(regionIDs) == 1 && regionIDs[0] == 2 && conn.Node().PreferredDERP == 2
|
||||
}, testutil.WaitLong, testutil.IntervalFast)
|
||||
|
||||
// Wait for the DERP map to be updated on the existing client.
|
||||
require.Eventually(t, func() bool {
|
||||
|
Reference in New Issue
Block a user