...

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

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

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

View as plain text