description: Repeated isWritablePrimary response must be processed

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

phases:
  # Phase 1 - a says it's not primary and suggests c may be the primary
  - responses:
    -
      - "a:27017"
      - ok: 1
        helloOk: true
        isWritablePrimary: false
        secondary: true
        hidden: true
        hosts: ["a:27017", "c:27017"]
        setName: "rs"
        minWireVersion: 0
        maxWireVersion: 6
    outcome:
      servers:
        "a:27017":
          type: "RSOther"
          setName: "rs"
        
        "b:27017":
          type: Unknown
        
        "c:27017":
          type: Unknown
      topologyType: "ReplicaSetNoPrimary"
      logicalSessionTimeoutMinutes: ~
      setName: "rs"

  # Phase 2 - c says it's a standalone, is removed
  - responses:
    -
      - "c:27017"
      - ok: 1
        helloOk: true
        isWritablePrimary: true
        minWireVersion: 0
        maxWireVersion: 6
    outcome:
      servers:
        "a:27017":
          type: "RSOther"
          setName: "rs"
        
        "b:27017":
          type: Unknown
      topologyType: "ReplicaSetNoPrimary"
      logicalSessionTimeoutMinutes: ~
      setName: "rs"

  # Phase 3 - response from a is repeated, and must be processed; c added again
  - responses:
    -
      - "a:27017"
      - ok: 1
        helloOk: true
        isWritablePrimary: false
        secondary: true
        hidden: true
        hosts: ["a:27017", "c:27017"]
        setName: "rs"
        minWireVersion: 0
        maxWireVersion: 6
    outcome:
      servers:
        "a:27017":
          type: "RSOther"
          setName: "rs"
        
        "b:27017":
          type: Unknown
        
        "c:27017":
          type: Unknown
      topologyType: "ReplicaSetNoPrimary"
      logicalSessionTimeoutMinutes: ~
      setName: "rs"

  # Phase 4 - c is now a primary
  - responses:
    -
      - "c:27017"
      - ok: 1
        helloOk: true
        isWritablePrimary: true
        hosts: ["a:27017", "c:27017"]
        setName: "rs"
        minWireVersion: 0
        maxWireVersion: 6
    outcome:
      servers:
        "a:27017":
          type: "RSOther"
          setName: "rs"
        
        "c:27017":
          type: RSPrimary
          setName: rs
      topologyType: "ReplicaSetWithPrimary"
      logicalSessionTimeoutMinutes: ~
      setName: "rs"
