MCPcopy Index your code
hub / github.com/coder/coder / TestConfigMaps_fillPeerDiagnostics

Function TestConfigMaps_fillPeerDiagnostics

tailnet/configmaps_internal_test.go:1012–1082  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1010}
1011
1012func TestConfigMaps_fillPeerDiagnostics(t *testing.T) {
1013 t.Parallel()
1014 ctx := testutil.Context(t, testutil.WaitShort)
1015 logger := testutil.Logger(t)
1016 fEng := newFakeEngineConfigurable()
1017 nodePrivateKey := key.NewNode()
1018 nodeID := tailcfg.NodeID(5)
1019 discoKey := key.NewDisco()
1020 uut := newConfigMaps(logger, fEng, nodeID, nodePrivateKey, discoKey.Public(), CoderDNSSuffixFQDN)
1021 defer uut.close()
1022
1023 // Given: DERP Map and peer already set
1024 derpMap := &tailcfg.DERPMap{
1025 HomeParams: &tailcfg.DERPHomeParams{RegionScore: map[int]float64{
1026 1: 0.025,
1027 1001: 0.111,
1028 }},
1029 Regions: map[int]*tailcfg.DERPRegion{
1030 1: {
1031 RegionCode: "AUH",
1032 RegionName: "AUH",
1033 Nodes: []*tailcfg.DERPNode{
1034 {Name: "AUH0"},
1035 },
1036 },
1037 1001: {
1038 RegionCode: "DXB",
1039 RegionName: "DXB",
1040 Nodes: []*tailcfg.DERPNode{
1041 {Name: "DXB0"},
1042 },
1043 },
1044 },
1045 }
1046 p1ID := uuid.UUID{1}
1047 p1Node := newTestNode(1)
1048 p1n, err := NodeToProto(p1Node)
1049 require.NoError(t, err)
1050 p1tcn, err := uut.protoNodeToTailcfg(p1n)
1051 p1tcn.KeepAlive = true
1052 require.NoError(t, err)
1053
1054 hst := time.Date(2024, 1, 7, 12, 0, 10, 0, time.UTC)
1055 uut.L.Lock()
1056 uut.derpMap = derpMap
1057 uut.peers[p1ID] = &peerLifecycle{
1058 peerID: p1ID,
1059 node: p1tcn,
1060 lastHandshake: hst,
1061 }
1062 uut.L.Unlock()
1063
1064 s0 := expectStatusWithHandshake(ctx, t, fEng, p1Node.Key, hst)
1065
1066 // When: call fillPeerDiagnostics
1067 d := PeerDiagnostics{DERPRegionNames: make(map[int]string)}
1068 uut.fillPeerDiagnostics(&d, p1ID)
1069 testutil.TryReceive(ctx, t, s0)

Callers

nothing calls this directly

Calls 14

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newConfigMapsFunction · 0.85
newTestNodeFunction · 0.85
NodeToProtoFunction · 0.85
protoNodeToTailcfgMethod · 0.80
closeMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected