...
1description: "command-logging"
2
3schemaVersion: "1.13"
4
5createEntities:
6 - client:
7 id: &client client
8 observeLogMessages:
9 command: debug
10 - database:
11 id: &database database
12 client: *client
13 databaseName: &databaseName logging-tests
14 - collection:
15 id: &collection collection
16 database: *database
17 collectionName: &collectionName logging-tests-collection
18
19initialData:
20 - collectionName: *collectionName
21 databaseName: *databaseName
22 documents:
23 - { _id: 1, x: 11 }
24
25tests:
26 - description: "A successful command"
27 operations:
28 - name: runCommand
29 object: *database
30 arguments:
31 command: { ping: 1 }
32 commandName: &commandName ping
33 expectLogMessages:
34 - client: *client
35 messages:
36 - level: debug
37 component: command
38 data:
39 message: "Command started"
40 databaseName: *databaseName
41 commandName: *commandName
42 command:
43 $$matchAsDocument:
44 $$matchAsRoot:
45 ping: 1
46 $db: *databaseName
47 requestId: { $$type: [int, long] }
48 serverHost: { $$type: string }
49 serverPort: { $$type: [int, long] }
50
51 - level: debug
52 component: command
53 data:
54 message: "Command succeeded"
55 databaseName: *databaseName
56 commandName: *commandName
57 reply: { $$type: string }
58 requestId: { $$type: [int, long] }
59 serverHost: { $$type: string }
60 serverPort: { $$type: [int, long] }
61 durationMS: { $$type: [double, int, long] }
62
63 - description: "A failed command"
64 operations:
65 - name: &commandName find
66 object: *collection
67 arguments:
68 filter: { $or: true }
69 expectError:
70 isClientError: false
71 expectLogMessages:
72 - client: *client
73 messages:
74 - level: debug
75 component: command
76 data:
77 message: "Command started"
78 databaseName: *databaseName
79 commandName: *commandName
80 command: { $$type: string }
81 requestId: { $$type: [int, long] }
82 serverHost: { $$type: string }
83 serverPort: { $$type: [int, long] }
84
85 - level: debug
86 component: command
87 data:
88 message: "Command failed"
89 databaseName: *databaseName
90 commandName: *commandName
91 failure: { $$exists: true }
92 requestId: { $$type: [int, long] }
93 serverHost: { $$type: string }
94 serverPort: { $$type: [int, long] }
95 durationMS: { $$type: [double, int, long] }
View as plain text