replace Redis with an embedded SQLite string->string KV store (group commit, in-tx events, SQL search)
Build and Push Docker Image / build (push) Successful in 2m44s
Build and Push Docker Image / build (push) Successful in 2m44s
This commit is contained in:
@@ -20,7 +20,7 @@ func seedCell(t *testing.T, c *Client, uid, cid, key string) {
|
||||
// forever — and the rows are unreachable through any API, so nothing will ever
|
||||
// clean them up.
|
||||
func TestUDLPurgeUser_RemovesCellsAndBothIndexFamilies(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
seedCell(t, c, "zAlice", "cidOne", "rating")
|
||||
@@ -63,7 +63,7 @@ func TestUDLPurgeUser_RemovesCellsAndBothIndexFamilies(t *testing.T) {
|
||||
// both have an opinion about — where the two share an index set and a careless
|
||||
// DEL of the whole key would take the survivor's membership with it.
|
||||
func TestUDLPurgeUser_LeavesOtherAccountsIntact(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "shared", "rating")
|
||||
seedCell(t, c, "zBob", "shared", "rating")
|
||||
@@ -92,7 +92,7 @@ func TestUDLPurgeUser_LeavesOtherAccountsIntact(t *testing.T) {
|
||||
// The key layout separates them with '/' and ':', so this passes only as long
|
||||
// as the scan patterns keep those separators.
|
||||
func TestUDLPurgeUser_DoesNotMatchUIDsByPrefix(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
seedCell(t, c, "zAliceExtra", "cidOne", "like")
|
||||
@@ -114,7 +114,7 @@ func TestUDLPurgeUser_DoesNotMatchUIDsByPrefix(t *testing.T) {
|
||||
// index instead of the cells would leave every retracted rating behind — the
|
||||
// rows most likely to have accumulated over an account's life.
|
||||
func TestUDLPurgeUser_RemovesTombstonedCellsToo(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
if ok, err := c.UDLUpsertIfNewer("zAlice", "cidOne", "like", 2, 200, "rec-tomb", "", false, true); err != nil || !ok {
|
||||
@@ -140,7 +140,7 @@ func TestUDLPurgeUser_RemovesTombstonedCellsToo(t *testing.T) {
|
||||
// Retry-safe: the delete handler purges before removing the key, so a caller
|
||||
// that retries after a partial failure runs this a second time.
|
||||
func TestUDLPurgeUser_IsIdempotent(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
|
||||
if _, err := c.UDLPurgeUser("zAlice"); err != nil {
|
||||
@@ -156,7 +156,7 @@ func TestUDLPurgeUser_IsIdempotent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUDLPurgeUser_RefusesGlobInjection(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
|
||||
// "*" would otherwise match every account in the keyspace — a wildcard
|
||||
@@ -172,7 +172,7 @@ func TestUDLPurgeUser_RefusesGlobInjection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUDLAllUserStats_CountsEachAccountSeparately(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
seedCell(t, c, "zAlice", "cidOne", "rating")
|
||||
@@ -198,7 +198,7 @@ func TestUDLAllUserStats_CountsEachAccountSeparately(t *testing.T) {
|
||||
// The stats and the purge must agree: the number shown in the delete
|
||||
// confirmation is the number of rows the delete then removes.
|
||||
func TestUDLAllUserStats_AgreesWithWhatPurgeRemoves(t *testing.T) {
|
||||
c, _ := newTestClient(t, "")
|
||||
c := newTestClient(t)
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
seedCell(t, c, "zAlice", "cidTwo", "rating")
|
||||
@@ -217,26 +217,6 @@ func TestUDLAllUserStats_AgreesWithWhatPurgeRemoves(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The key prefix (multi-tenant Redis) must not leak into the parsed uid, or
|
||||
// every account on a prefixed node would be reported under a mangled name and
|
||||
// the purge would find nothing.
|
||||
func TestUDLAdmin_RespectsKeyPrefix(t *testing.T) {
|
||||
c, _ := newTestClient(t, "tenantA:")
|
||||
|
||||
seedCell(t, c, "zAlice", "cidOne", "like")
|
||||
|
||||
stats, err := c.UDLAllUserStats()
|
||||
if err != nil {
|
||||
t.Fatalf("stats: %v", err)
|
||||
}
|
||||
if got := stats["zAlice"]; got.Records != 1 {
|
||||
t.Fatalf("stats under a prefix = %+v, want 1 record for zAlice", stats)
|
||||
}
|
||||
if s, err := c.UDLPurgeUser("zAlice"); err != nil || s.Records != 1 {
|
||||
t.Fatalf("purge under a prefix: %+v err=%v", s, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitUDLRecSuffix_KeepsSlashesInTheKey(t *testing.T) {
|
||||
// A namespaced key arriving later must not be truncated: the purge SREMs
|
||||
// `udl:idx:cid:<cid>:key:<key>`, so a half-read key removes the wrong
|
||||
|
||||
Reference in New Issue
Block a user