Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed Jan 4, 2022
1 parent 79befc2 commit 4c740b4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions e2e/newenemy/newenemy_test.go
Expand Up @@ -162,20 +162,20 @@ func TestNoNewEnemy(t *testing.T) {
protected, attempts = checkSchemaNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, vulnerableSpiceDb, 100)
}
require.False(t, protected)
t.Logf("determined spicedb vulnerable in %d attempts", attempts+1)
t.Logf("determined spicedb vulnerable in %d attempts", attempts)
return attempts
}
protectedFn := func(t *testing.T, count int) {
t.Logf("check spicedb is protected after %d attempts", count+1)
t.Logf("check spicedb is protected after %d attempts", count)
protected := true
var attempts int
for protected {
protected, attempts = checkDataNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, protectedSpiceDb, count)
protected, attempts = checkSchemaNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, protectedSpiceDb, count)
if attempts < count {
continue
}
require.True(t, protected, "protection is enabled, but newenemy detected")
require.Equal(t, attempts, count)
require.Equal(t, count, attempts)
t.Logf("spicedb is protected after %d attempts", count)
return
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestNoNewEnemy(t *testing.T) {
continue
}
require.True(t, protected, "protection is enabled, but newenemy detected")
require.Equal(t, attempts, count)
require.Equal(t, count, attempts)
t.Logf("spicedb is protected after %d attempts", count)
return
}
Expand Down Expand Up @@ -276,7 +276,8 @@ func checkDataNoNewEnemy(ctx context.Context, t testing.TB, schemaData []SchemaD
t.Log("filling with data to span multiple ranges for prefix", prefix)
fill(t, spicedb[0].Client().V0().ACL(), prefix, 4000, 1000)

for attempts := 1; attempts < maxAttempts+1; attempts++ {
attempts := 1
for ; attempts <= maxAttempts; attempts++ {
direct, exclude := generateTuple(prefix, objIdGenerator)

// write to node 1
Expand Down Expand Up @@ -379,7 +380,8 @@ func checkSchemaNoNewEnemy(ctx context.Context, t testing.TB, schemaData []Schem
require.NoError(t, schemaTpl.Execute(&b, SchemaData{Prefixes: []string{prefix}}))
excludeSchema := b.String()

for attempts := 1; attempts < maxAttempts+1; attempts++ {
attempts := 1
for ; attempts <= maxAttempts; attempts++ {
direct, exclude := generateTuple(prefix, objIdGenerator)

// write the "allow" schema
Expand Down Expand Up @@ -448,7 +450,7 @@ func checkSchemaNoNewEnemy(ctx context.Context, t testing.TB, schemaData []Schem
continue
}
}
return true, maxAttempts + 1
return true, maxAttempts
}

func BenchmarkBatchWrites(b *testing.B) {
Expand Down

0 comments on commit 4c740b4

Please sign in to comment.