Skip to content

Commit 11ae471

Browse files
committed
LOGC-16: Fix E2E test chronological order verification
Fix the chronological order invariant in E2E tests. The tests were incorrectly verifying order across all log objects, but the actual invariant is that logs within each individual object are chronologically ordered.
1 parent e3070ba commit 11ae471

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

test/e2e/helpers_test.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ func fetchAllLogsInBucketSince(ctx *E2ETestContext, since time.Time) ([]*ParsedL
374374
return fetchLogsFromPrefix(ctx.S3Client, ctx.DestinationBucket, "", since)
375375
}
376376

377-
// fetchLogsFromPrefix fetches and parses all log records from a specific prefix since a given time
377+
// fetchLogsFromPrefix fetches and parses all log records from a specific prefix since a given time.
378+
// Verifies that records within each log object are in chronological order.
379+
// Returns all records combined across objects (no ordering guarantee across objects).
378380
func fetchLogsFromPrefix(client *s3.Client, bucket, prefix string, since time.Time) ([]*ParsedLogRecord, error) {
379381
objectKeys, err := findLogObjectsSince(client, bucket, prefix, since)
380382
if err != nil {
@@ -389,6 +391,15 @@ func fetchLogsFromPrefix(client *s3.Client, bucket, prefix string, since time.Ti
389391
}
390392

391393
records := parseLogContent(content)
394+
395+
// Verify chronological order within this object
396+
for i := 1; i < len(records); i++ {
397+
if records[i].Time.Before(records[i-1].Time) {
398+
return nil, fmt.Errorf("object %s: logs not in chronological order: record %d (%v) is before record %d (%v)",
399+
key, i, records[i].Time, i-1, records[i-1].Time)
400+
}
401+
}
402+
392403
allRecords = append(allRecords, records...)
393404
}
394405

@@ -420,7 +431,7 @@ func waitForLogCount(ctx *E2ETestContext, expectedCount int) []*ParsedLogRecord
420431
return waitForLogCountWithPrefix(ctx, ctx.LogPrefix, expectedCount)
421432
}
422433

423-
// VerifyLogs waits for logs, verifies they match expected values, and checks chronological order.
434+
// VerifyLogs waits for logs and verifies they match expected values.
424435
// Returns the logs for additional assertions if needed.
425436
func (ctx *E2ETestContext) VerifyLogs(expected ...ExpectedLogBuilder) []*ParsedLogRecord {
426437
GinkgoHelper()
@@ -431,8 +442,6 @@ func (ctx *E2ETestContext) VerifyLogs(expected ...ExpectedLogBuilder) []*ParsedL
431442
verifyLogRecord(logs[i], exp)
432443
}
433444

434-
verifyChronologicalOrder(logs)
435-
436445
return logs
437446
}
438447

@@ -513,18 +522,6 @@ func verifyLogRecord(actual *ParsedLogRecord, expected ExpectedLogBuilder) {
513522
}
514523
}
515524

516-
// verifyChronologicalOrder verifies logs are in chronological order
517-
func verifyChronologicalOrder(records []*ParsedLogRecord) {
518-
GinkgoHelper()
519-
520-
for i := 1; i < len(records); i++ {
521-
Expect(records[i].Time.After(records[i-1].Time) ||
522-
records[i].Time.Equal(records[i-1].Time)).To(BeTrue(),
523-
"Logs should be in chronological order: record %d (%v) should be after or equal to record %d (%v)",
524-
i, records[i].Time, i-1, records[i-1].Time)
525-
}
526-
}
527-
528525
// verifyLogKeys verifies that logs contain exactly the expected keys with no duplicates.
529526
// It filters logs by bucket and keyPrefix, then checks:
530527
// - Each matching log has the expected operation

test/e2e/log_processing_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ var _ = Describe("Log processing", func() {
4242
}
4343

4444
verifyLogKeys(logs, testCtx.SourceBucket, "batch-object-", expectedKeys, opPutObject)
45-
verifyChronologicalOrder(logs)
4645
})
4746

4847
It("triggers processing by time threshold", func(ctx context.Context) {
@@ -87,7 +86,6 @@ var _ = Describe("Log processing", func() {
8786
Expect(err).NotTo(HaveOccurred())
8887

8988
verifyLogKeys(allLogs, testCtx.SourceBucket, "cycle", expectedKeys, opPutObject)
90-
verifyChronologicalOrder(allLogs)
9189
})
9290

9391
It("processes multiple buckets", func(ctx context.Context) {
@@ -208,7 +206,6 @@ var _ = Describe("Log processing", func() {
208206
Expect(seenPairs).To(HaveLen(totalExpected),
209207
"Expected %d unique bucket/key pairs, got %d", totalExpected, len(seenPairs))
210208

211-
verifyChronologicalOrder(logs)
212209
})
213210

214211
It("delivers logs to new prefix after logging reconfiguration", func(ctx context.Context) {

0 commit comments

Comments
 (0)