diff --git a/apps/iam/go.sum b/apps/iam/go.sum index f3069e2c824..8accbff7ec3 100644 --- a/apps/iam/go.sum +++ b/apps/iam/go.sum @@ -744,8 +744,6 @@ github.com/grafana/grafana-aws-sdk v1.1.0 h1:G0fvwbQmHw14c5RXPd7Gnw9ZQcgzl139LtM github.com/grafana/grafana-aws-sdk v1.1.0/go.mod h1:7e+47EdHynteYWGoT5Ere9KeOXQObsk8F0vkOLQ1tz8= github.com/grafana/grafana-azure-sdk-go/v2 v2.2.0 h1:0TYrkzAc3u0HX+9GK86cGrLTUAcmQfl3/LEB3tL+SOA= github.com/grafana/grafana-azure-sdk-go/v2 v2.2.0/go.mod h1:H9sVh9A4yg5egMGZeh0mifxT1Q/uqwKe1LBjBJU6pN8= -github.com/grafana/grafana-openapi-client-go v0.0.0-20231213163343-bd475d63fb79 h1:r+mU5bGMzcXCRVAuOrTn54S80qbfVkvTdUJZfSfTNbs= -github.com/grafana/grafana-openapi-client-go v0.0.0-20231213163343-bd475d63fb79/go.mod h1:wc6Hbh3K2TgCUSfBC/BOzabItujtHMESZeFk5ZhdxhQ= github.com/grafana/grafana-plugin-sdk-go v0.278.0 h1:5/rIYparLi02pofdaag8wnjspMMVNCi8cZhC4cdC3Ho= github.com/grafana/grafana-plugin-sdk-go v0.278.0/go.mod h1:+8NXT/XUJ/89GV6FxGQ366NZ3nU+cAXDMd0OUESF9H4= github.com/grafana/grafana/pkg/promlib v0.0.8 h1:VUWsqttdf0wMI4j9OX9oNrykguQpZcruudDAFpJJVw0= diff --git a/pkg/storage/unified/apistore/watcher_test.go b/pkg/storage/unified/apistore/watcher_test.go index ab4d64a6813..b5973d0f447 100644 --- a/pkg/storage/unified/apistore/watcher_test.go +++ b/pkg/storage/unified/apistore/watcher_test.go @@ -40,8 +40,8 @@ import ( "github.com/grafana/grafana/pkg/storage/unified/resourcepb" "github.com/grafana/grafana/pkg/storage/unified/sql" "github.com/grafana/grafana/pkg/storage/unified/sql/db/dbimpl" - "github.com/grafana/grafana/pkg/tests" "github.com/grafana/grafana/pkg/tests/testsuite" + "github.com/grafana/grafana/pkg/util/testutil" ) type StorageType string @@ -135,7 +135,7 @@ func testSetup(t testing.TB, opts ...setupOption) (context.Context, storage.Inte _, err = server.IsHealthy(ctx, &resourcepb.HealthCheckRequest{}) require.NoError(t, err) case StorageTypeUnified: - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) dbstore := infraDB.InitTestDB(t) cfg := setting.NewCfg() diff --git a/pkg/storage/unified/sql/test/benchmark_test.go b/pkg/storage/unified/sql/test/benchmark_test.go index 1fe29d3b594..540b17c0bbf 100644 --- a/pkg/storage/unified/sql/test/benchmark_test.go +++ b/pkg/storage/unified/sql/test/benchmark_test.go @@ -17,7 +17,7 @@ import ( "github.com/grafana/grafana/pkg/storage/unified/sql" "github.com/grafana/grafana/pkg/storage/unified/sql/db/dbimpl" test "github.com/grafana/grafana/pkg/storage/unified/testing" - "github.com/grafana/grafana/pkg/tests" + "github.com/grafana/grafana/pkg/util/testutil" ) func newTestBackend(b testing.TB) resource.StorageBackend { @@ -39,10 +39,7 @@ func newTestBackend(b testing.TB) resource.StorageBackend { } func TestIntegrationBenchmarkSQLStorageBackend(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) opts := test.DefaultBenchmarkOptions() if db.IsTestDbSQLite() { opts.Concurrency = 1 // to avoid SQLite database is locked error @@ -53,10 +50,7 @@ func TestIntegrationBenchmarkSQLStorageBackend(t *testing.T) { func TestIntegrationBenchmarkResourceServer(t *testing.T) { t.Skip("skipping slow test, causing CI to fail due to timeout") - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) ctx := context.Background() opts := &test.BenchmarkOptions{ diff --git a/pkg/storage/unified/sql/test/integration_test.go b/pkg/storage/unified/sql/test/integration_test.go index 159f7b97a83..a72606e586b 100644 --- a/pkg/storage/unified/sql/test/integration_test.go +++ b/pkg/storage/unified/sql/test/integration_test.go @@ -26,7 +26,6 @@ import ( "github.com/grafana/grafana/pkg/storage/unified/sql" "github.com/grafana/grafana/pkg/storage/unified/sql/db/dbimpl" unitest "github.com/grafana/grafana/pkg/storage/unified/testing" - "github.com/grafana/grafana/pkg/tests" "github.com/grafana/grafana/pkg/tests/testsuite" "github.com/grafana/grafana/pkg/util/testutil" ) @@ -102,10 +101,7 @@ func TestIntegrationSQLStorageBackend(t *testing.T) { } func TestIntegrationSearchAndStorage(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) ctx := context.Background() diff --git a/pkg/tests/apis/folder/folders_test.go b/pkg/tests/apis/folder/folders_test.go index ca10b73318a..192222802b5 100644 --- a/pkg/tests/apis/folder/folders_test.go +++ b/pkg/tests/apis/folder/folders_test.go @@ -26,10 +26,10 @@ import ( "github.com/grafana/grafana/pkg/services/org" "github.com/grafana/grafana/pkg/services/user" "github.com/grafana/grafana/pkg/setting" - "github.com/grafana/grafana/pkg/tests" "github.com/grafana/grafana/pkg/tests/apis" "github.com/grafana/grafana/pkg/tests/testinfra" "github.com/grafana/grafana/pkg/tests/testsuite" + "github.com/grafana/grafana/pkg/util/testutil" ) func TestMain(m *testing.M) { @@ -1172,7 +1172,7 @@ func TestIntegrationFoldersGetAPIEndpointK8S(t *testing.T) { // Reproduces a bug where folder deletion does not check for attached library panels. func TestIntegrationFolderDeletionBlockedByLibraryElements(t *testing.T) { - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) if !db.IsTestDbSQLite() { t.Skip("test only on sqlite for now") @@ -1251,7 +1251,7 @@ func TestIntegrationFolderDeletionBlockedByLibraryElements(t *testing.T) { } func TestIntegrationRootFolderDeletionBlockedByLibraryElementsInSubfolder(t *testing.T) { - tests.SkipIntegrationTestInShortMode(t) + testutil.SkipIntegrationTestInShortMode(t) if !db.IsTestDbSQLite() { t.Skip("test only on sqlite for now") diff --git a/pkg/tests/utils.go b/pkg/tests/utils.go index b8eba7b5f39..28ac3a7a2ec 100644 --- a/pkg/tests/utils.go +++ b/pkg/tests/utils.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "net/url" "os" - "strings" "testing" "github.com/go-openapi/strfmt" @@ -25,16 +24,6 @@ import ( "github.com/grafana/grafana/pkg/setting" ) -func SkipIntegrationTestInShortMode(t testing.TB) { - t.Helper() - if !strings.HasPrefix(t.Name(), "TestIntegration") { - t.Fatal("test is not an integration test") - } - if testing.Short() { - t.Skip("skipping integration test in short mode") - } -} - func CreateUser(t *testing.T, db db.DB, cfg *setting.Cfg, cmd user.CreateUserCommand) int64 { t.Helper() diff --git a/pkg/util/testutil/testutil.go b/pkg/util/testutil/testutil.go index 1ca3628a665..596690443d8 100644 --- a/pkg/util/testutil/testutil.go +++ b/pkg/util/testutil/testutil.go @@ -2,6 +2,7 @@ package testutil import ( "embed" + "strings" "testing" "time" ) @@ -28,3 +29,16 @@ func init() { panic("importing testing libraries in runtime code is not allowed") } } + +// SkipIntegrationTestInShortMode skips the integration test if it is running in short mode. +// This function fails is the test is not an integration test as defined in Grafana (i.e. test +// starting with TestIntegration prefix). +func SkipIntegrationTestInShortMode(t testing.TB) { + t.Helper() + if !strings.HasPrefix(t.Name(), "TestIntegration") { + t.Fatal("test is not an integration test") + } + if testing.Short() { + t.Skip("skipping integration test in short mode") + } +}