...

Text file src/go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/rs/primary_disconnect_electionid.yml

Documentation: go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/rs

     1description: "Disconnected from primary, reject primary with stale electionId"
     2
     3uri: "mongodb://a/?replicaSet=rs"
     4
     5phases: [
     6
     7    # A is elected, then B.
     8    {
     9        responses: [
    10            ["a:27017", {
    11                ok: 1,
    12                helloOk: true,
    13                isWritablePrimary: true,
    14                hosts: ["a:27017", "b:27017"],
    15                setName: "rs",
    16                setVersion: 1,
    17                electionId: {"$oid": "000000000000000000000001"},
    18                minWireVersion: 0,
    19                maxWireVersion: 6
    20            }],
    21            ["b:27017", {
    22                ok: 1,
    23                helloOk: true,
    24                isWritablePrimary: true,
    25                hosts: ["a:27017", "b:27017"],
    26                setName: "rs",
    27                setVersion: 1,
    28                electionId: {"$oid": "000000000000000000000002"},
    29                minWireVersion: 0,
    30                maxWireVersion: 6
    31            }]
    32        ],
    33
    34        outcome: {
    35            servers: {
    36                "a:27017": {
    37                    type: "Unknown",
    38                    setName: ,
    39                    electionId:
    40                },
    41                "b:27017": {
    42                    type: "RSPrimary",
    43                    setName: "rs",
    44                    setVersion: 1,
    45                    electionId: {"$oid": "000000000000000000000002"}
    46                }
    47            },
    48            topologyType: "ReplicaSetWithPrimary",
    49            logicalSessionTimeoutMinutes: null,
    50            setName: "rs",
    51            maxSetVersion: 1,
    52            maxElectionId: {"$oid": "000000000000000000000002"},
    53        }
    54    },
    55
    56    # Disconnected from B.
    57    {
    58        responses: [
    59            ["b:27017", {}]
    60        ],
    61        outcome: {
    62            servers: {
    63                "a:27017": {
    64                    type: "Unknown",
    65                    setName: ,
    66                    electionId:
    67                },
    68                "b:27017": {
    69                    type: "Unknown",
    70                    setName: ,
    71                    electionId:
    72                }
    73            },
    74            topologyType: "ReplicaSetNoPrimary",
    75            logicalSessionTimeoutMinutes: null,
    76            setName: "rs",
    77            maxSetVersion: 1,
    78            maxElectionId: {"$oid": "000000000000000000000002"},
    79        }
    80    },
    81
    82    # A still claims to be primary but it's ignored.
    83    {
    84        responses: [
    85            ["a:27017", {
    86                ok: 1,
    87                helloOk: true,
    88                isWritablePrimary: true,
    89                hosts: ["a:27017", "b:27017"],
    90                setName: "rs",
    91                setVersion: 1,
    92                electionId: {"$oid": "000000000000000000000001"},
    93                minWireVersion: 0,
    94                maxWireVersion: 6
    95            }]
    96        ],
    97        outcome: {
    98            servers: {
    99                "a:27017": {
   100                    type: "Unknown",
   101                    setName: ,
   102                    electionId:
   103                },
   104                "b:27017": {
   105                    type: "Unknown",
   106                    setName: ,
   107                    electionId:
   108                }
   109            },
   110            topologyType: "ReplicaSetNoPrimary",
   111            logicalSessionTimeoutMinutes: null,
   112            setName: "rs",
   113            maxSetVersion: 1,
   114            maxElectionId: {"$oid": "000000000000000000000002"},
   115        }
   116    },
   117
   118    # Now A is re-elected.
   119    {
   120        responses: [
   121            ["a:27017", {
   122                ok: 1,
   123                helloOk: true,
   124                isWritablePrimary: true,
   125                hosts: ["a:27017", "b:27017"],
   126                setName: "rs",
   127                setVersion: 1,
   128                electionId: {"$oid": "000000000000000000000003"},
   129                minWireVersion: 0,
   130                maxWireVersion: 6
   131            }]
   132        ],
   133        outcome: {
   134            servers: {
   135                "a:27017": {
   136                    type: "RSPrimary",
   137                    setName: "rs",
   138                    setVersion: 1,
   139                    electionId: {"$oid": "000000000000000000000003"}
   140                },
   141                "b:27017": {
   142                    type: "Unknown",
   143                    setName: ,
   144                    electionId:
   145                }
   146            },
   147            topologyType: "ReplicaSetWithPrimary",
   148            logicalSessionTimeoutMinutes: null,
   149            setName: "rs",
   150            maxSetVersion: 1,
   151            maxElectionId: {"$oid": "000000000000000000000003"},
   152        }
   153    },
   154
   155    # B comes back as secondary.
   156    {
   157        responses: [
   158            ["b:27017", {
   159                ok: 1,
   160                helloOk: true,
   161                isWritablePrimary: false,
   162                secondary: true,
   163                hosts: ["a:27017", "b:27017"],
   164                setName: "rs",
   165                minWireVersion: 0,
   166                maxWireVersion: 6
   167            }]
   168        ],
   169        outcome: {
   170            servers: {
   171                "a:27017": {
   172                    type: "RSPrimary",
   173                    setName: "rs",
   174                    setVersion: 1,
   175                    electionId: {"$oid": "000000000000000000000003"}
   176                },
   177                "b:27017": {
   178                    type: "RSSecondary",
   179                    setName: "rs"
   180                }
   181            },
   182            topologyType: "ReplicaSetWithPrimary",
   183            logicalSessionTimeoutMinutes: null,
   184            setName: "rs",
   185            maxSetVersion: 1,
   186            maxElectionId: {"$oid": "000000000000000000000003"},
   187        }
   188    }
   189]

View as plain text