1{
2  "runOn": [
3    {
4      "minServerVersion": "4.0",
5      "topology": [
6        "single",
7        "replicaset"
8      ]
9    },
10    {
11      "minServerVersion": "4.1.7",
12      "topology": [
13        "sharded"
14      ]
15    }
16  ],
17  "database_name": "retryable-reads-tests",
18  "bucket_name": "fs",
19  "data": {
20    "fs.files": [
21      {
22        "_id": {
23          "$oid": "000000000000000000000001"
24        },
25        "length": 1,
26        "chunkSize": 4,
27        "uploadDate": {
28          "$date": "1970-01-01T00:00:00.000Z"
29        },
30        "filename": "abc",
31        "metadata": {}
32      }
33    ],
34    "fs.chunks": [
35      {
36        "_id": {
37          "$oid": "000000000000000000000002"
38        },
39        "files_id": {
40          "$oid": "000000000000000000000001"
41        },
42        "n": 0,
43        "data": {
44          "$binary": {
45            "base64": "EQ==",
46            "subType": "00"
47          }
48        }
49      }
50    ]
51  },
52  "tests": [
53    {
54      "description": "Download succeeds on first attempt",
55      "operations": [
56        {
57          "name": "download",
58          "object": "gridfsbucket",
59          "arguments": {
60            "id": {
61              "$oid": "000000000000000000000001"
62            }
63          }
64        }
65      ],
66      "expectations": [
67        {
68          "command_started_event": {
69            "command": {
70              "find": "fs.files",
71              "filter": {
72                "_id": {
73                  "$oid": "000000000000000000000001"
74                }
75              }
76            },
77            "database_name": "retryable-reads-tests"
78          }
79        },
80        {
81          "command_started_event": {
82            "command": {
83              "find": "fs.chunks",
84              "filter": {
85                "files_id": {
86                  "$oid": "000000000000000000000001"
87                }
88              },
89              "sort": {
90                "n": 1
91              }
92            },
93            "database_name": "retryable-reads-tests"
94          }
95        }
96      ]
97    },
98    {
99      "description": "Download succeeds on second attempt",
100      "failPoint": {
101        "configureFailPoint": "failCommand",
102        "mode": {
103          "times": 1
104        },
105        "data": {
106          "failCommands": [
107            "find"
108          ],
109          "closeConnection": true
110        }
111      },
112      "operations": [
113        {
114          "name": "download",
115          "object": "gridfsbucket",
116          "arguments": {
117            "id": {
118              "$oid": "000000000000000000000001"
119            }
120          }
121        }
122      ],
123      "expectations": [
124        {
125          "command_started_event": {
126            "command": {
127              "find": "fs.files",
128              "filter": {
129                "_id": {
130                  "$oid": "000000000000000000000001"
131                }
132              }
133            },
134            "database_name": "retryable-reads-tests"
135          }
136        },
137        {
138          "command_started_event": {
139            "command": {
140              "find": "fs.files",
141              "filter": {
142                "_id": {
143                  "$oid": "000000000000000000000001"
144                }
145              }
146            },
147            "database_name": "retryable-reads-tests"
148          }
149        },
150        {
151          "command_started_event": {
152            "command": {
153              "find": "fs.chunks",
154              "filter": {
155                "files_id": {
156                  "$oid": "000000000000000000000001"
157                }
158              },
159              "sort": {
160                "n": 1
161              }
162            },
163            "database_name": "retryable-reads-tests"
164          }
165        }
166      ]
167    },
168    {
169      "description": "Download fails on first attempt",
170      "clientOptions": {
171        "retryReads": false
172      },
173      "failPoint": {
174        "configureFailPoint": "failCommand",
175        "mode": {
176          "times": 1
177        },
178        "data": {
179          "failCommands": [
180            "find"
181          ],
182          "closeConnection": true
183        }
184      },
185      "operations": [
186        {
187          "name": "download",
188          "object": "gridfsbucket",
189          "arguments": {
190            "id": {
191              "$oid": "000000000000000000000001"
192            }
193          },
194          "error": true
195        }
196      ],
197      "expectations": [
198        {
199          "command_started_event": {
200            "command": {
201              "find": "fs.files",
202              "filter": {
203                "_id": {
204                  "$oid": "000000000000000000000001"
205                }
206              }
207            },
208            "database_name": "retryable-reads-tests"
209          }
210        }
211      ]
212    },
213    {
214      "description": "Download fails on second attempt",
215      "failPoint": {
216        "configureFailPoint": "failCommand",
217        "mode": {
218          "times": 2
219        },
220        "data": {
221          "failCommands": [
222            "find"
223          ],
224          "closeConnection": true
225        }
226      },
227      "operations": [
228        {
229          "name": "download",
230          "object": "gridfsbucket",
231          "arguments": {
232            "id": {
233              "$oid": "000000000000000000000001"
234            }
235          },
236          "error": true
237        }
238      ],
239      "expectations": [
240        {
241          "command_started_event": {
242            "command": {
243              "find": "fs.files",
244              "filter": {
245                "_id": {
246                  "$oid": "000000000000000000000001"
247                }
248              }
249            },
250            "database_name": "retryable-reads-tests"
251          }
252        },
253        {
254          "command_started_event": {
255            "command": {
256              "find": "fs.files",
257              "filter": {
258                "_id": {
259                  "$oid": "000000000000000000000001"
260                }
261              }
262            },
263            "database_name": "retryable-reads-tests"
264          }
265        }
266      ]
267    }
268  ]
269}
270