Unit tests for SLRU - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Unit tests for SLRU
Date
Msg-id CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com
Whole thread Raw
Responses Re: Unit tests for SLRU  (Daniel Gustafsson <daniel@yesql.se>)
Re: Unit tests for SLRU  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Hi hackers,

I learned from Peter [1] that SLRU test coverage leaves much to be
desired and makes it difficult to refactor it. Here is a draft of a
patch that tries to address it.

I used src/test/modules/test_* modules as an example. While on it, I
moved the Asserts() outside of SimpleLruInit(). It didn't seem to be a
right place to check the IsUnderPostmaster value, and complicated the
test implementation. I also renamed SlruSyncFileTag() to
SlruSyncSegment() and changed its signature. I think it makes the
interface easier to reason about.

I noticed that SLRU uses int's for slotno, while FileTag->slotno is
uint32. Can't this cause us any grief? Finally, I believe
SimpleLruWritePage() name is confusing, because in fact it works with
a slot, not a page. But I didn't change the name in my patch, yet.

If time permits, please take a quick look at the patch and let me know
if I'm moving the right direction. There will be more tests in the
final version, but I would appreciate an early feedback.

[1]: https://postgr.es/m/220fab30-dff0-b055-f803-4338219f1021%40enterprisedb.com

-- 
Best regards,
Aleksander Alekseev

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Correct docs re: rewriting indexes when table rewrite is skipped
Next
From: Robert Haas
Date:
Subject: Re: Commitfest Update