(t *testing.T)
| 856 | } |
| 857 | |
| 858 | func TestPGCoordinatorDual_PeerReconnect(t *testing.T) { |
| 859 | t.Parallel() |
| 860 | |
| 861 | store, ps := dbtestutil.NewDB(t) |
| 862 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong) |
| 863 | defer cancel() |
| 864 | logger := testutil.Logger(t) |
| 865 | |
| 866 | // Create two coordinators, 1 for each peer. |
| 867 | c1, err := tailnet.NewPGCoord(ctx, logger, ps, store) |
| 868 | require.NoError(t, err) |
| 869 | c2, err := tailnet.NewPGCoord(ctx, logger, ps, store) |
| 870 | require.NoError(t, err) |
| 871 | |
| 872 | p1 := agpltest.NewPeer(ctx, t, c1, "peer1") |
| 873 | p2 := agpltest.NewPeer(ctx, t, c2, "peer2") |
| 874 | |
| 875 | // Create a binding between the two. |
| 876 | p1.AddTunnel(p2.ID) |
| 877 | |
| 878 | // Ensure that messages pass through. |
| 879 | p1.UpdateDERP(1) |
| 880 | p2.UpdateDERP(2) |
| 881 | p1.AssertEventuallyHasDERP(p2.ID, 2) |
| 882 | p2.AssertEventuallyHasDERP(p1.ID, 1) |
| 883 | |
| 884 | // Close coordinator1. Now we will check that we |
| 885 | // never send a DISCONNECTED update. |
| 886 | err = c1.Close() |
| 887 | require.NoError(t, err) |
| 888 | p1.AssertEventuallyResponsesClosed(agpl.CloseErrCoordinatorClose) |
| 889 | p2.AssertEventuallyLost(p1.ID) |
| 890 | // This basically checks that peer2 had no update |
| 891 | // performed on their status since we are connected |
| 892 | // to coordinator2. |
| 893 | assertEventuallyStatus(ctx, t, store, p2.ID, database.TailnetStatusOk) |
| 894 | |
| 895 | // Connect peer1 to coordinator2. |
| 896 | p1.ConnectToCoordinator(ctx, c2) |
| 897 | // Reestablish binding. |
| 898 | p1.AddTunnel(p2.ID) |
| 899 | // Ensure messages still flow back and forth. |
| 900 | p1.AssertEventuallyHasDERP(p2.ID, 2) |
| 901 | p1.UpdateDERP(3) |
| 902 | p2.UpdateDERP(4) |
| 903 | p2.AssertEventuallyHasDERP(p1.ID, 3) |
| 904 | p1.AssertEventuallyHasDERP(p2.ID, 4) |
| 905 | // Make sure peer2 never got an update about peer1 disconnecting. |
| 906 | p2.AssertNeverUpdateKind(p1.ID, proto.CoordinateResponse_PeerUpdate_DISCONNECTED) |
| 907 | } |
| 908 | |
| 909 | // TestPGCoordinatorPropogatedPeerContext tests that the context for a specific peer |
| 910 | // is propogated through to the `Authorize` method of the coordinatee auth |
nothing calls this directly
no test coverage detected