(t *testing.T)
| 727 | } |
| 728 | |
| 729 | func TestConfigMaps_setAllPeersLost(t *testing.T) { |
| 730 | t.Parallel() |
| 731 | ctx := testutil.Context(t, testutil.WaitShort) |
| 732 | logger := testutil.Logger(t) |
| 733 | fEng := newFakeEngineConfigurable() |
| 734 | nodePrivateKey := key.NewNode() |
| 735 | nodeID := tailcfg.NodeID(5) |
| 736 | discoKey := key.NewDisco() |
| 737 | uut := newConfigMaps(logger, fEng, nodeID, nodePrivateKey, discoKey.Public(), CoderDNSSuffixFQDN) |
| 738 | defer uut.close() |
| 739 | mClock := quartz.NewMock(t) |
| 740 | start := mClock.Now() |
| 741 | uut.clock = mClock |
| 742 | |
| 743 | p1ID := uuid.UUID{1} |
| 744 | p1Node := newTestNode(1) |
| 745 | p1n, err := NodeToProto(p1Node) |
| 746 | require.NoError(t, err) |
| 747 | p2ID := uuid.UUID{2} |
| 748 | p2Node := newTestNode(2) |
| 749 | p2n, err := NodeToProto(p2Node) |
| 750 | require.NoError(t, err) |
| 751 | |
| 752 | s1 := expectStatusWithHandshake(ctx, t, fEng, p1Node.Key, start) |
| 753 | |
| 754 | updates := []*proto.CoordinateResponse_PeerUpdate{ |
| 755 | { |
| 756 | Id: p1ID[:], |
| 757 | Kind: proto.CoordinateResponse_PeerUpdate_NODE, |
| 758 | Node: p1n, |
| 759 | }, |
| 760 | { |
| 761 | Id: p2ID[:], |
| 762 | Kind: proto.CoordinateResponse_PeerUpdate_NODE, |
| 763 | Node: p2n, |
| 764 | }, |
| 765 | } |
| 766 | uut.updatePeers(updates) |
| 767 | nm := testutil.TryReceive(ctx, t, fEng.setNetworkMap) |
| 768 | r := testutil.TryReceive(ctx, t, fEng.reconfig) |
| 769 | require.Len(t, nm.Peers, 2) |
| 770 | require.Len(t, r.wg.Peers, 2) |
| 771 | _ = testutil.TryReceive(ctx, t, s1) |
| 772 | |
| 773 | mClock.Advance(5 * time.Second).MustWait(ctx) |
| 774 | uut.setAllPeersLost() |
| 775 | |
| 776 | // No reprogramming yet, since we keep the peer around. |
| 777 | select { |
| 778 | case <-fEng.setNetworkMap: |
| 779 | t.Fatal("should not reprogram") |
| 780 | default: |
| 781 | // OK! |
| 782 | } |
| 783 | |
| 784 | // When we advance the clock, even by a millisecond, the timeout for peer 2 |
| 785 | // pops because our status only includes a handshake for peer 1 |
| 786 | s2 := expectStatusWithHandshake(ctx, t, fEng, p1Node.Key, start) |
nothing calls this directly
no test coverage detected