I just finished adding support for Linux and Windows to my Kotlin Multiplatform Couchbase Lite bindings, utilizing the CBL C SDK. (Previously I’ve completed support for Android, JVM, iOS, and macOS via the Java and ObjC SDKs.) All platforms are running the same common tests, based on the Java SDK public API tests. There are just a few tests that are failing, a couple edge cases for blobs, and one other I’d like to clarify if it’s a bug.
The test is DatabaseTest.testDeleteAlreadyDeletedDoc(), which fails here, where doc1b.sequence equals 3 after deletion, instead of the expected 2.
Here's the C code that fails the test (ported from Kotlin, so there may be typos, as I haven't run it directly in C):
All of those tests are run after every build, on all of the platforms (Android, Linux, MacOS, Windows). There are, most definitely, some flaky tests: I track them. I don’t see testDeleteAlreadyDeletedDoc in the list…
Interesting, I found the equivalently named test in the C SDK and it is actually checking for sequence = 3, rather than sequence = 2, as the other SDKs are (Java, ObjC, Swift). It’s using the same doc reference to delete twice though, rather than a mutable copy as the other SDKs and my C code above do.
The test actually looks more like the test testDeleteSameDocTwice() in ObjC and Swift (doesn’t exist in Java). So it does seem correct for the same document reference’s sequence to increment again if deleted a second time. But a mutable copy is expected to only increment by one, not two (or maybe the expectation is for the sequence to be the same as the first deletion, not clear which is the case).
This turns out not a test issue. When looking closely, the test in C and Android are bit different. On Android, the test is using another instance of the doc to delete which is actually causing a conflict internally. As the delete mode is last-write-win, the code optimize that by detecting the conflict and loading the current rev (deleted) instead of doing another revision (deleted) save.