ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.65k stars 87 forks source link

[FEATURE] ✅ Snapshot testing for binary payload backward compatibility #155

Closed jodydonetti closed 1 year ago

jodydonetti commented 1 year ago

Scenario

FusionCache always strived to be as backward compatible as possible, even if it currently is in v0.X land (not for long 😏).

Because of this, great care has been put into all sorts of cases, including one that is very delicate and important: making sure that a new version works well with binary payloads generated by an older version and saved in a distributed cache.

When we use a 2nd level distributed cache and we update FusionCache, that distributed cache will be already populated with binary representations of the cached data: that data must be de-serializable from the new version, and everything must work well.

Problem

As of today I made some manual tests to check that this was the case, but I wanted to create something automated than would be able to keep track of older versions' payloads and test them with a new version during the tests run.

Solution

I'll create a new SerializerPayloadGenerator console app that will be used to generate binary payloads of old versions, by referencing the old nuget package versions directly.

WHen run, it will then save the serialized entries' binary payloads, versioned, in a specific "Samples" folder which will then be used as a source for the new tests in the test suite.

The tests will then use the currently in-development version to test if an entry serialized with any old version can be safely deserialized with a new version. For example we can check if an entry serialized with the Protobuf or MemoryPack v0.18.0 serializers can be deserialized with the currently in-development versions without problems.

Nice 😬

jodydonetti commented 1 year ago

Hi all, v0.22.0 has been released and this is included 🎉