MCPcopy
hub / github.com/alibaba/MongoShake / TestOldestTimestamp

Function TestOldestTimestamp

oplog/txn_test.go:294–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292 }
293}
294func TestOldestTimestamp(t *testing.T) {
295 buffer := NewBuffer()
296 // With no transactions, oldest active is zero value
297 oldest := buffer.OldestOpTime()
298 zeroTimestamp := primitive.Timestamp{}
299 if oldest.Timestamp != zeroTimestamp {
300 t.Errorf("expected zero timestamp, but got %v", oldest.Timestamp)
301 }
302 // Constructing manually requires pointers to int64, so they can't be constants.
303 txnN := []int64{0, 1}
304 ops := []ParsedLog{
305 {
306 Timestamp: primitive.Timestamp{T: 1234, I: 1},
307 LSID: bson.Raw{0, 0, 0, 0, 1},
308 TxnNumber: &txnN[0],
309 Operation: "c",
310 Namespace: "admin.$cmd",
311 Object: bson.D{
312 {"applyOps", bson.A{bson.D{{"op", "n"}}}},
313 {"partialTxn", true},
314 },
315 },
316 {
317 Timestamp: primitive.Timestamp{T: 1235, I: 1},
318 LSID: bson.Raw{0, 0, 0, 0, 2},
319 TxnNumber: &txnN[1],
320 Operation: "c",
321 Namespace: "admin.$cmd",
322 Object: bson.D{
323 {"applyOps", bson.A{bson.D{{"op", "n"}}}},
324 {"partialTxn", true},
325 },
326 },
327 {
328 Timestamp: primitive.Timestamp{T: 1236, I: 1},
329 LSID: bson.Raw{0, 0, 0, 0, 1},
330 TxnNumber: &txnN[0],
331 Operation: "c",
332 Namespace: "admin.$cmd",
333 Object: bson.D{
334 {"applyOps", bson.A{bson.D{{"op", "n"}}}},
335 {"partialTxn", true},
336 },
337 },
338 }
339 for _, v := range ops {
340 meta, err := NewTxnMeta(v)
341 if err != nil {
342 t.Fatal(err)
343 }
344 err = buffer.AddOp(meta, &GenericOplog{
345 Parsed: &PartialLog{
346 ParsedLog: v,
347 },
348 })
349 if err != nil {
350 t.Fatal(err)
351 }

Callers

nothing calls this directly

Calls 7

NewBufferFunction · 0.85
NewTxnMetaFunction · 0.85
OldestOpTimeMethod · 0.80
ErrorfMethod · 0.80
FatalMethod · 0.80
AddOpMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected