description: "Parse logicalSessionTimeoutMinutes from replica set"

uri: "mongodb://a/?replicaSet=rs"

phases: [
    # An RSPrimary responds with a non-null logicalSessionTimeoutMinutes
    {
        responses: [
             ["a:27017", {
                ok: 1,
                ismaster: true,
                hosts: ["a:27017", "b:27017", "c:27017", "d:27017", "e:27017"],
                setName: "rs",
                logicalSessionTimeoutMinutes: 3,
                minWireVersion: 0,
                maxWireVersion: 6
            }],
        ],
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "Unknown",
                },
                "c:27017": {
                    type: "Unknown",
                },
                "d:27017": {
                    type: "Unknown",
                },
                "e:27017": {
                    type: "Unknown",
                }

            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: 3,
            setName: "rs",
        }
    },
    # An RSGhost responds without a logicalSessionTimeoutMinutes
    {
        responses: [
            ["d:27017", {
                ok: 1,
                ismaster: false,
                isreplicaset: true,
                minWireVersion: 0,
                maxWireVersion: 6
            }],
        ],
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "Unknown",
                },
                "c:27017": {
                    type: "Unknown",
                },
                "d:27017": {
                    type: "RSGhost",
                },
                "e:27017": {
                    type: "Unknown",
                }

            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: 3,
            setName: "rs",
        }
    },
    # An RSArbiter responds without a logicalSessionTimeoutMinutes
    {
        responses: [
           ["e:27017", {
                ok: 1,
                ismaster: false,
                hosts: ["a:27017", "b:27017", "c:27017", "d:27017", "e:27017"],
                setName: "rs",
                arbiterOnly: true,
                minWireVersion: 0,
                maxWireVersion: 6
            }]
        ],
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "Unknown",
                },
                "c:27017": {
                    type: "Unknown",
                },
                "d:27017": {
                    type: "RSGhost",
                },
                "e:27017": {
                    type: "RSArbiter",
                    setName: "rs"
                }

            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: 3,
            setName: "rs",
        }
    },
    # An RSSecondary responds with a lower logicalSessionTimeoutMinutes
    {
        responses: [
            ["b:27017", {
                ok: 1,
                ismaster: false,
                secondary: true,
                hosts: ["a:27017", "b:27017", "c:27017", "d:27017", "e:27017"],
                setName: "rs",
                logicalSessionTimeoutMinutes: 2,
                minWireVersion: 0,
                maxWireVersion: 6
            }],
        ],
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "RSSecondary",
                    setName: "rs"
                },
                "c:27017": {
                    type: "Unknown",
                },
                "d:27017": {
                    type: "RSGhost",
                },
                "e:27017": {
                    type: "RSArbiter",
                    setName: "rs"
                }

            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: 2,
            setName: "rs",
        }
    },
    # An RSOther responds with an even lower logicalSessionTimeoutMinutes, which is ignored
    {
        responses: [
            ["c:27017", {
                ok: 1,
                ismaster: false,
                setName: "rs",
                hidden: true,
                logicalSessionTimeoutMinutes: 1,
                minWireVersion: 0,
                maxWireVersion: 6
            }],
        ],
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "RSSecondary",
                    setName: "rs"
                },
                "c:27017": {
                    type: "RSOther",
                    setName: "rs"
                },
                "d:27017": {
                    type: "RSGhost",
                },
                "e:27017": {
                    type: "RSArbiter",
                    setName: "rs"
              }
            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: 2,
            setName: "rs",
        }
    },
    # Now the RSSecondary responds with no logicalSessionTimeoutMinutes
    {
        responses: [
            ["b:27017", {
                ok: 1,
                ismaster: false,
                secondary: true,
                hosts: ["a:27017", "b:27017", "c:27017", "d:27017", "e:27017"],
                setName: "rs",
                logicalSessionTimeoutMinutes: null,
                minWireVersion: 0,
                maxWireVersion: 6
            }]
        ],

        # Sessions aren't supported now
        outcome: {
            servers: {
                "a:27017": {
                    type: "RSPrimary",
                    setName: "rs"
                },
                "b:27017": {
                    type: "RSSecondary",
                    setName: "rs"
                },
                "c:27017": {
                    type: "RSOther",
                    setName: "rs"
                },
                "d:27017": {
                    type: "RSGhost",
                },
                "e:27017": {
                    type: "RSArbiter",
                    setName: "rs"
                }
            },
            topologyType: "ReplicaSetWithPrimary",
            logicalSessionTimeoutMinutes: null,
            setName: "rs",
        }
    }
]
