Move SkipIntegrationTestInShortMode to testutil. (#110750)
* Move SkipIntegrationTestInShortMode to testutil. * make update-workspace
This commit is contained in:
@@ -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=
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user