@@ -131,19 +131,61 @@ var _ = Describe("Log processing", func() {
131131
132132 // Cleanup all additional buckets after test
133133 defer func () {
134+ // Use a time slightly before the disable calls to avoid flakiness.
135+ timeBeforeDisable := time .Now ().Add (- 2 * time .Second )
136+
137+ // Disable logging on all additional buckets
134138 for i := 1 ; i < numValidBuckets ; i ++ {
135139 _ , _ = testCtx .S3Client .PutBucketLogging (ctx ,
136140 & s3.PutBucketLoggingInput {
137141 Bucket : aws .String (validBuckets [i ]),
138142 BucketLoggingStatus : & types.BucketLoggingStatus {},
139143 })
140- _ = deleteBucketWithRetry (testCtx .S3Client , validBuckets [i ])
141144 }
142145 _ , _ = testCtx .S3Client .PutBucketLogging (ctx ,
143146 & s3.PutBucketLoggingInput {
144147 Bucket : aws .String (failingBucket ),
145148 BucketLoggingStatus : & types.BucketLoggingStatus {},
146149 })
150+
151+ // Wait for all disable logging operations to be logged.
152+ // We need to see REST.PUT.LOGGING_STATUS for the 11 additional valid buckets + 1 failing bucket.
153+ expectedDisableOps := (numValidBuckets - 1 ) + 1 // -1 because validBuckets[0] is cleaned by AfterEach
154+ Eventually (func () int {
155+ logs , fetchErr := fetchAllLogsInBucketSince (testCtx , testCtx .TestStartTime )
156+ if fetchErr != nil {
157+ return 0
158+ }
159+
160+ count := 0
161+ seenBuckets := make (map [string ]bool )
162+ for _ , log := range logs {
163+ if log .Operation == "REST.PUT.LOGGING_STATUS" &&
164+ log .Time .After (timeBeforeDisable ) &&
165+ ! seenBuckets [log .Bucket ] {
166+ // Check if this is from one of our additional buckets
167+ for i := 1 ; i < numValidBuckets ; i ++ {
168+ if log .Bucket == validBuckets [i ] {
169+ seenBuckets [log .Bucket ] = true
170+ count ++
171+ break
172+ }
173+ }
174+ if log .Bucket == failingBucket {
175+ seenBuckets [log .Bucket ] = true
176+ count ++
177+ }
178+ }
179+ }
180+ return count
181+ }).WithTimeout (30 * time .Second ).
182+ WithPolling (2 * time .Second ).
183+ Should (BeNumerically (">=" , expectedDisableOps ))
184+
185+ // Now delete the source buckets
186+ for i := 1 ; i < numValidBuckets ; i ++ {
187+ _ = deleteBucketWithRetry (testCtx .S3Client , validBuckets [i ])
188+ }
147189 _ = deleteBucketWithRetry (testCtx .S3Client , failingBucket )
148190 }()
149191
0 commit comments