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

Function TestConfigMaps_setDERPMap_same

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

Source from the content-addressed store, hash-verified

941}
942
943func TestConfigMaps_setDERPMap_same(t *testing.T) {
944 t.Parallel()
945 ctx := testutil.Context(t, testutil.WaitShort)
946 logger := testutil.Logger(t)
947 fEng := newFakeEngineConfigurable()
948 nodePrivateKey := key.NewNode()
949 nodeID := tailcfg.NodeID(5)
950 discoKey := key.NewDisco()
951 uut := newConfigMaps(logger, fEng, nodeID, nodePrivateKey, discoKey.Public(), CoderDNSSuffixFQDN)
952 defer uut.close()
953
954 // Given: DERP Map already set
955 derpMap := &tailcfg.DERPMap{
956 HomeParams: &tailcfg.DERPHomeParams{RegionScore: map[int]float64{
957 1: 0.025,
958 1001: 0.111,
959 }},
960 Regions: map[int]*tailcfg.DERPRegion{
961 1: {
962 RegionCode: "AUH",
963 Nodes: []*tailcfg.DERPNode{
964 {Name: "AUH0"},
965 },
966 },
967 1001: {
968 RegionCode: "DXB",
969 Nodes: []*tailcfg.DERPNode{
970 {Name: "DXB0"},
971 },
972 },
973 },
974 }
975 uut.L.Lock()
976 uut.derpMap = derpMap
977 uut.L.Unlock()
978
979 // Then: we don't configure
980 requireNeverConfigures(ctx, t, &uut.phased)
981
982 // When we set the equivalent DERP map, with different ordering
983 uut.setDERPMap(&tailcfg.DERPMap{
984 HomeParams: &tailcfg.DERPHomeParams{RegionScore: map[int]float64{
985 1001: 0.111,
986 1: 0.025,
987 }},
988 Regions: map[int]*tailcfg.DERPRegion{
989 1001: {
990 RegionCode: "DXB",
991 Nodes: []*tailcfg.DERPNode{
992 {Name: "DXB0"},
993 },
994 },
995 1: {
996 RegionCode: "AUH",
997 Nodes: []*tailcfg.DERPNode{
998 {Name: "AUH0"},
999 },
1000 },

Callers

nothing calls this directly

Calls 10

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newConfigMapsFunction · 0.85
requireNeverConfiguresFunction · 0.85
setDERPMapMethod · 0.80
closeMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected