75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package verifier
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_ComputeAnalyzeTimeout_ScalesWithSizeWithinFloorAndCap(t *testing.T) {
|
|
maxTimeout := 10 * time.Minute
|
|
|
|
// Empty DB → exactly the 60s floor; a tiny DB stays close to it.
|
|
assert.Equal(t, analyzeTimeoutMin, computeAnalyzeTimeout(0, maxTimeout))
|
|
tiny := computeAnalyzeTimeout(50*1024*1024, maxTimeout)
|
|
assert.GreaterOrEqual(t, tiny, analyzeTimeoutMin)
|
|
assert.Less(t, tiny, analyzeTimeoutMin+2*time.Second)
|
|
|
|
// 10 GB → 60s + 10*30s = 360s, below the cap.
|
|
assert.Equal(t, 360*time.Second, computeAnalyzeTimeout(10*1024*1024*1024, maxTimeout))
|
|
|
|
// Huge DB → capped at maxTimeout, never unbounded.
|
|
assert.Equal(t, maxTimeout, computeAnalyzeTimeout(500*1024*1024*1024, maxTimeout))
|
|
}
|
|
|
|
func Test_TierQueries_ExcludeSystemSchemas(t *testing.T) {
|
|
for _, sql := range []string{schemaCountSQL, tableCountSQL, tableStatsSQL} {
|
|
assert.Contains(t, sql, "pg_catalog")
|
|
assert.Contains(t, sql, "information_schema")
|
|
assert.Contains(t, sql, "pg_toast")
|
|
assert.Contains(t, sql, excludedSchemaRegex)
|
|
}
|
|
|
|
assert.True(t, strings.HasPrefix(dbSizeSQL, "SELECT pg_database_size"))
|
|
assert.Contains(t, tableCountSQL, "BASE TABLE")
|
|
assert.Contains(t, tableStatsSQL, "LIMIT 100")
|
|
}
|