Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James committed Mar 20, 2024
1 parent 5a1c22d commit bb7ce8f
Show file tree
Hide file tree
Showing 9 changed files with 726 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
description: "loadbalanced-emit-topology-description-changed-before-close"

schemaVersion: "1.16"

runOnRequirements:
- topologies:
- load-balanced
minServerVersion: "4.4" # awaitable hello

tests:
- description: "Topology lifecycle"
operations:
- name: createEntities
object: testRunner
arguments:
entities:
- client:
id: &client client
observeEvents:
- topologyDescriptionChangedEvent
- topologyOpeningEvent
- topologyClosedEvent
# ensure the topology has been fully discovered before closing the client.
# expected events are initial server discovery and server connect event.
- name: waitForEvent
object: testRunner
arguments:
client: *client
event:
topologyDescriptionChangedEvent: {}
count: 2
- name: close
object: *client
expectEvents:
- client: *client
eventType: sdam
events:
- topologyOpeningEvent: {}
- topologyDescriptionChangedEvent: # unknown -> unknown w disconnected server
previousDescription:
type: "Unknown"
currentDescription: {}
- topologyDescriptionChangedEvent: # unknown w disconnected server -> loadBalanced
newDescription:
type: "LoadBalanced"
- topologyDescriptionChangedEvent: # loadbalanced -> unknown
newDescription:
type: "Unknown"
- topologyClosedEvent: {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
description: "replicaset-emit-topology-description-changed-before-close"

schemaVersion: "1.16"

runOnRequirements:
- topologies:
- replicaset
minServerVersion: "4.4" # awaitable hello

tests:
- description: "Topology lifecycle"
operations:
- name: createEntities
object: testRunner
arguments:
entities:
- client:
id: &client client
observeEvents:
- topologyDescriptionChangedEvent
- topologyOpeningEvent
- topologyClosedEvent
# ensure the topology has been fully discovered before closing the client.
# expected events are initial server discovery and 3 server connect events.
- name: waitForEvent
object: testRunner
arguments:
client: *client
event:
topologyDescriptionChangedEvent: {}
count: 4
- name: close
object: *client
expectEvents:
- client: *client
eventType: sdam
ignoreExtraEvents: true
events:
- topologyOpeningEvent: {}
- topologyDescriptionChangedEvent: # unknown -> replset no primary
previousDescription:
type: "Unknown"
newDescription:
type: "ReplicaSetNoPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetNoPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetWithPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: # server connected
previousDescription:
type: "ReplicaSetWithPrimary"
newDescription:
type: "ReplicaSetWithPrimary"
- topologyDescriptionChangedEvent: # replicaset -> unknown
previousDescription:
type: "ReplicaSetWithPrimary"
newDescription:
type: "Unknown"
- topologyClosedEvent: {}
Loading

0 comments on commit bb7ce8f

Please sign in to comment.