...
1description: "replica-set-logging"
2
3schemaVersion: "1.14"
4
5runOnRequirements:
6 - topologies:
7 - replicaset
8
9createEntities:
10 - client:
11 id: &client client
12 uriOptions:
13 retryWrites: false # so we don't retry after hitting a failpoint
14 heartbeatFrequencyMS: 500
15 serverSelectionTimeoutMS: 2000 # avoid hanging for 30s in test expecting SS failure due to timeout
16 observeLogMessages:
17 serverSelection: debug
18 observeEvents:
19 - serverDescriptionChangedEvent
20 - topologyDescriptionChangedEvent
21 - database:
22 id: &database database
23 client: *client
24 databaseName: &databaseName logging-tests
25 - collection:
26 id: &collection collection
27 database: *database
28 collectionName: &collectionName server-selection
29 - client:
30 id: &failPointClient failPointClient
31 - collection:
32 id: &unsatisfiableRPColl unsatisfiableRPColl
33 database: *database
34 collectionName: &unsatisfiableRPColl unsatisfiableRPColl
35 collectionOptions:
36 readPreference:
37 mode: Secondary
38 tagSets:
39 - { nonexistenttag : a }
40
41tests:
42 - description: "A successful operation"
43 operations:
44 # ensure we've discovered the primary before starting, so we don't get an unexpected "waiting" message
45 # when server selection happens for the insert, or have extra logs from the driver performing server
46 # expected events are initial cluster type change from unknown to ReplicaSet, and connect events for each of 3 servers.
47 - name: waitForEvent
48 object: testRunner
49 arguments:
50 client: *client
51 event:
52 topologyDescriptionChangedEvent: {}
53 count: 4
54 - name: insertOne
55 object: *collection
56 arguments:
57 document: { x : 1 }
58 expectLogMessages:
59 - client: *client
60 messages:
61 - level: debug
62 component: serverSelection
63 data:
64 message: "Server selection started"
65 selector: { $$exists: true }
66 operation: insert
67 topologyDescription: { $$exists: true }
68 - level: debug
69 component: serverSelection
70 data:
71 message: "Server selection succeeded"
72 selector: { $$exists: true }
73 operation: insert
74 topologyDescription: { $$exists: true }
75 serverHost: { $$type: string }
76 serverPort: { $$type: [int, long] }
77
78 - description: "Server selection fails due to unsatisfiable read preference"
79 runOnRequirements:
80 - minServerVersion: "4.0" # min version for failCommand on mongod
81 operations:
82 # ensure we've discovered the primary before starting, so we don't get an unexpected "waiting" message
83 # when server selection happens for the insert, or have extra logs from the driver performing server
84 # expected events are initial cluster type change from unknown to ReplicaSet, and connect events for each of 3 servers.
85 - name: waitForEvent
86 object: testRunner
87 arguments:
88 client: *client
89 event:
90 topologyDescriptionChangedEvent: {}
91 count: 4
92 # the `find` should never succeed due to the unsatisfiable read preference.
93 - name: find
94 object: *unsatisfiableRPColl
95 arguments:
96 filter: { x : 1 }
97 expectError:
98 isClientError: true # server selection error
99 expectLogMessages:
100 # the topology won't change during this time, so although we exhaust
101 # serverSelectionTimeoutMS we only expect a single message.
102 - client: *client
103 messages:
104 - level: debug
105 component: serverSelection
106 data:
107 message: "Server selection started"
108 selector: { $$exists: true }
109 operation: find
110 topologyDescription: { $$exists: true }
111 - level: info
112 component: serverSelection
113 data:
114 message: "Waiting for suitable server to become available"
115 selector: { $$exists: true }
116 operation: find
117 topologyDescription: { $$exists: true }
118 remainingTimeMS: { $$type: [int, long] }
119 - level: debug
120 component: serverSelection
121 data:
122 message: "Server selection failed"
123 selector: { $$exists: true }
124 operation: find
125 topologyDescription: { $$exists: true }
126 failure: { $$exists: true }
View as plain text