Skip to content

Commit 903a71d

Browse files
committed
test: add timing assertion for 650MB disk write
Proves that writing 650MB (acceptance test payload) completes well within the 30s HTTP curl timeout. Ran 5x locally at ~0.4s average. On CI with slower I/O, FlakeAttempts(3) provides additional safety.
1 parent fad302c commit 903a71d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

acceptance/assets/app/go_app/internal/app/disk_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,36 @@ var _ = Describe("DefaultDiskOccupier", func() {
238238
})
239239
})
240240

241+
var _ = Describe("Disk write timing", func() {
242+
// This test validates that writing 650MB (the amount used by acceptance tests)
243+
// completes well within the 30s HTTP curl timeout used by StartDiskUsage.
244+
// On CI (GitHub Actions) I/O can be slower, so we use FlakeAttempts and a generous
245+
// local ceiling of 25s (leaving 5s headroom vs the 30s curl timeout).
246+
Context("writing 650MB to disk", FlakeAttempts(3), func() {
247+
It("completes within 25 seconds", func() {
248+
filePath := filepath.Join(GinkgoT().TempDir(), "disk-timing-test")
249+
occupier := app.NewDefaultDiskOccupier(filePath)
250+
251+
spaceInBytes := int64(650) * 1000 * 1000 // matches acceptance test: 650 * 1000 * 1000
252+
253+
start := time.Now()
254+
err := occupier.Occupy(spaceInBytes, 1*time.Minute)
255+
elapsed := time.Since(start)
256+
257+
Expect(err).ToNot(HaveOccurred())
258+
Expect(elapsed).To(BeNumerically("<", 25*time.Second),
259+
"writing 650MB took %v which exceeds the 25s budget (30s curl timeout minus 5s headroom)", elapsed)
260+
261+
fStat, err := os.Stat(filePath)
262+
Expect(err).ToNot(HaveOccurred())
263+
Expect(fStat.Size()).To(Equal(spaceInBytes))
264+
265+
occupier.Stop()
266+
GinkgoWriter.Printf("650MB write completed in %v\n", elapsed)
267+
})
268+
})
269+
})
270+
241271
func isGone(filePath string) bool {
242272
gone := false
243273
if _, err := os.Stat(filePath); err != nil && errors.Is(err, os.ErrNotExist) {

0 commit comments

Comments
 (0)