|
| 1 | +package perf |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "maps" |
| 6 | + "strings" |
| 7 | + "testing" |
| 8 | + |
| 9 | + trinodriver "github.com/posthog/duckgres/tests/perf/drivers/trino" |
| 10 | +) |
| 11 | + |
| 12 | +func TestFixtureHoglakeCatalogUsesPodIdentity(t *testing.T) { |
| 13 | + managed := map[string]string{ |
| 14 | + "connector.name": "hoglake", "hoglake.uri": "http://hoglake.example:8080", |
| 15 | + "hoglake.catalog": "org-fixture", "fs.cache.enabled": "false", |
| 16 | + "fs.s3.enabled": "true", "s3.auth-type": "IAM_ROLE", |
| 17 | + "s3.iam-role": "arn:aws:iam::123456789012:role/tenant-fixture", |
| 18 | + "s3.region": "us-east-1", "s3.max-connections": "500", |
| 19 | + } |
| 20 | + before := maps.Clone(managed) |
| 21 | + for _, catalog := range []string{"org-fixture-frozen", "org-fixture-properties", "org-fixture-frozen"} { |
| 22 | + selected, err := fixtureHoglakeProperties(managed, catalog) |
| 23 | + if err != nil { |
| 24 | + t.Fatal(err) |
| 25 | + } |
| 26 | + want := maps.Clone(before) |
| 27 | + delete(want, "s3.iam-role") |
| 28 | + want["hoglake.catalog"] = catalog |
| 29 | + if !maps.Equal(selected, want) { |
| 30 | + t.Fatalf("fixture properties = %v, want %v", selected, want) |
| 31 | + } |
| 32 | + if !maps.Equal(managed, before) { |
| 33 | + t.Fatal("mutated source catalog properties") |
| 34 | + } |
| 35 | + managed, before = selected, maps.Clone(selected) |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func TestFixtureHoglakeCatalogRejectsInvalidBaseline(t *testing.T) { |
| 40 | + for _, change := range []map[string]string{ |
| 41 | + {"connector.name": "ducklake"}, {"hoglake.uri": ""}, {"hoglake.catalog": ""}, |
| 42 | + {"fs.cache.enabled": "true"}, {"s3.auth-type": "STATIC"}, |
| 43 | + } { |
| 44 | + original := map[string]string{"connector.name": "hoglake", "hoglake.uri": "http://hoglake.example:8080", "hoglake.catalog": "org-fixture", "fs.cache.enabled": "false", "s3.auth-type": "IAM_ROLE"} |
| 45 | + maps.Copy(original, change) |
| 46 | + if _, err := fixtureHoglakeProperties(original, "org-fixture-frozen"); err == nil { |
| 47 | + t.Fatalf("accepted invalid baseline %v", change) |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +func TestFixtureHoglakeCatalogRejectsManagedDataset(t *testing.T) { |
| 53 | + original := map[string]string{"connector.name": "hoglake", "hoglake.uri": "http://hoglake.example:8080", "hoglake.catalog": "org-fixture", "fs.cache.enabled": "false", "s3.auth-type": "IAM_ROLE", "s3.iam-role": "tenant-role"} |
| 54 | + if _, err := fixtureHoglakeProperties(original, "org-fixture"); err == nil { |
| 55 | + t.Fatal("accepted managed dataset as a read-only fixture") |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +func TestSelectHoglakeCatalogRequiresIsolatedStore(t *testing.T) { |
| 60 | + for _, factory := range []defaultDriverFactory{{}, {trinoCatalogStoreDSN: "postgres://fixture.example/db"}} { |
| 61 | + err := factory.selectHoglakeCatalog(context.Background(), trinodriver.ConnectionConfig{Catalog: "org_fixture", HoglakeCatalog: "org-fixture-frozen"}) |
| 62 | + if err == nil || !strings.Contains(err.Error(), "explicit isolated benchmark catalog store and cell") { |
| 63 | + t.Fatalf("got %v, want isolated store guard", err) |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments