...
1description: "server-selection-logging"
2
3schemaVersion: "1.14"
4
5runOnRequirements:
6 - topologies:
7 - sharded
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 appName: &appName loggingClient
16 serverSelectionTimeoutMS: 2000 # avoid hanging for 30s in test expecting SS failure due to timeout
17 observeLogMessages:
18 serverSelection: debug
19 observeEvents:
20 - serverDescriptionChangedEvent
21 - topologyDescriptionChangedEvent
22 useMultipleMongoses: false
23 - database:
24 id: &database database
25 client: *client
26 databaseName: &databaseName logging-tests
27 - collection:
28 id: &collection collection
29 database: *database
30 collectionName: &collectionName server-selection
31 - client:
32 id: &failPointClient failPointClient
33 useMultipleMongoses: false
34
35tests:
36 - description: "A successful operation"
37 operations:
38 # ensure we've discovered the entire topology before starting.
39 # expected events are initial cluster type change from unknown to sharded, and connect events for one mongos.
40 - name: waitForEvent
41 object: testRunner
42 arguments:
43 client: *client
44 event:
45 topologyDescriptionChangedEvent: {}
46 count: 2
47 - name: insertOne
48 object: *collection
49 arguments:
50 document: { x : 1 }
51 expectLogMessages:
52 - client: *client
53 messages:
54 - level: debug
55 component: serverSelection
56 data:
57 message: "Server selection started"
58 selector: { $$exists: true }
59 operation: insert
60 topologyDescription: { $$exists: true }
61 - level: debug
62 component: serverSelection
63 data:
64 message: "Server selection succeeded"
65 selector: { $$exists: true }
66 operation: insert
67 topologyDescription: { $$exists: true }
68 serverHost: { $$type: string }
69 serverPort: { $$type: [int, long] }
70
71 - description: "Failure due to unreachable server"
72 runOnRequirements:
73 - minServerVersion: "4.4" # failCommand appname support
74 operations:
75 # fail all hello/legacy hello commands for the main client.
76 - name: failPoint
77 object: testRunner
78 arguments:
79 client: *failPointClient
80 failPoint:
81 configureFailPoint: failCommand
82 mode: alwaysOn
83 data:
84 failCommands: ["hello", "ismaster"]
85 appName: *appName
86 closeConnection: true
87 # wait until we've marked the server unknown due
88 # to a failed heartbeat.
89 - name: waitForEvent
90 object: testRunner
91 arguments:
92 client: *client
93 event:
94 serverDescriptionChangedEvent:
95 newDescription:
96 type: Unknown
97 count: 1
98 - name: insertOne
99 object: *collection
100 arguments:
101 document: { x : 1 }
102 expectError:
103 isClientError: true # server selection timeout
104 expectLogMessages:
105 - client: *client
106 messages:
107 - level: debug
108 component: serverSelection
109 data:
110 message: "Server selection started"
111 selector: { $$exists: true }
112 operation: insert
113 topologyDescription: { $$exists: true }
114 - level: info
115 component: serverSelection
116 data:
117 message: "Waiting for suitable server to become available"
118 selector: { $$exists: true }
119 operation: insert
120 topologyDescription: { $$exists: true }
121 remainingTimeMS: { $$type: [int, long] }
122 - level: debug
123 component: serverSelection
124 data:
125 message: "Server selection failed"
126 selector: { $$exists: true }
127 operation: insert
128 topologyDescription: { $$exists: true }
129 failure: { $$exists: true }
View as plain text