Chore: Run integration tests without grabpl (#49448)

* Chore: Run integration tests without grabpl

* Add new step for integration tests in lib.star

* Remove old integration test step from lib.star

* Change drone signature

* Fix: Edit starlark integration step to not affect enterprise

* Remove all build tags & rename starlark integration test step

* Resync .drone.yml with .drone.star

* Fix lint errors

* Fix lint errors

* Fix lint errors

* Fix more lint errors

* Fix another lint error

* Rename integration test step

* Fix last lint error

* Recomment enterprise step

* Remove comment from Makefile

Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
pull/50055/head
Kat Yang 4 years ago committed by GitHub
parent 2edfbb7767
commit c63ebc887b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .drone.yml
  2. 3
      pkg/infra/filestorage/fs_integration_test.go
  3. 8
      pkg/infra/filestorage/test_utils.go
  4. 3
      pkg/infra/kvstore/kvstore_test.go
  5. 3
      pkg/infra/serverlock/serverlock_integration_test.go
  6. 15
      pkg/services/alerting/engine_integration_test.go
  7. 7
      pkg/services/dashboards/database/acl_test.go
  8. 3
      pkg/services/dashboards/database/database_folder_test.go
  9. 3
      pkg/services/dashboards/database/database_provisioning_test.go
  10. 11
      pkg/services/dashboards/database/database_test.go
  11. 6
      pkg/services/dashboards/service/dashboard_service_integration_test.go
  12. 8
      pkg/services/dashboards/service/dashboard_service_test.go
  13. 3
      pkg/services/dashboards/service/folder_service_test.go
  14. 4
      pkg/services/dashboardversion/dashverimpl/store_test.go
  15. 3
      pkg/services/live/database/tests/storage_test.go
  16. 3
      pkg/services/ngalert/store/alertmanager_test.go
  17. 3
      pkg/services/ngalert/store/image_test.go
  18. 3
      pkg/services/ngalert/store/instance_database_test.go
  19. 3
      pkg/services/preference/prefimpl/store_test.go
  20. 3
      pkg/services/queryhistory/queryhistory_create_test.go
  21. 3
      pkg/services/queryhistory/queryhistory_delete_stale_test.go
  22. 3
      pkg/services/queryhistory/queryhistory_delete_test.go
  23. 3
      pkg/services/queryhistory/queryhistory_enforce_limit_test.go
  24. 3
      pkg/services/queryhistory/queryhistory_migrate_test.go
  25. 3
      pkg/services/queryhistory/queryhistory_patch_test.go
  26. 3
      pkg/services/queryhistory/queryhistory_search_test.go
  27. 3
      pkg/services/queryhistory/queryhistory_star_test.go
  28. 3
      pkg/services/queryhistory/queryhistory_test.go
  29. 3
      pkg/services/queryhistory/queryhistory_unstar_test.go
  30. 3
      pkg/services/sqlstore/alert_notification_test.go
  31. 3
      pkg/services/sqlstore/alert_test.go
  32. 3
      pkg/services/sqlstore/annotation_test.go
  33. 3
      pkg/services/sqlstore/apikey_test.go
  34. 3
      pkg/services/sqlstore/dashboard_snapshot_test.go
  35. 4
      pkg/services/sqlstore/dashboard_thumbs_test.go
  36. 20
      pkg/services/sqlstore/dashboard_version_test.go
  37. 3
      pkg/services/sqlstore/datasource_test.go
  38. 3
      pkg/services/sqlstore/health_test.go
  39. 3
      pkg/services/sqlstore/login_attempt_test.go
  40. 4
      pkg/services/sqlstore/org_test.go
  41. 3
      pkg/services/sqlstore/playlist_test.go
  42. 3
      pkg/services/sqlstore/plugin_setting_test.go
  43. 3
      pkg/services/sqlstore/quota_test.go
  44. 3
      pkg/services/sqlstore/sqlbuilder_test.go
  45. 3
      pkg/services/sqlstore/sqlstore_test.go
  46. 3
      pkg/services/sqlstore/stats_integration_test.go
  47. 3
      pkg/services/sqlstore/stats_test.go
  48. 3
      pkg/services/sqlstore/tags_test.go
  49. 5
      pkg/services/sqlstore/team_test.go
  50. 3
      pkg/services/sqlstore/temp_user_test.go
  51. 3
      pkg/services/sqlstore/transactions_test.go
  52. 6
      pkg/services/sqlstore/user_test.go
  53. 3
      pkg/services/star/starimpl/store_test.go
  54. 4
      pkg/services/store/entity_events_test.go
  55. 3
      pkg/tsdb/mysql/mysql_test.go
  56. 3
      pkg/tsdb/postgres/postgres_test.go
  57. 34
      scripts/drone/steps/lib.star

@ -137,7 +137,7 @@ steps:
image: grafana/build-container:1.5.4
name: test-backend
- commands:
- ./bin/grabpl integration-tests --edition oss
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
depends_on:
- wire-install
image: grafana/build-container:1.5.4
@ -815,7 +815,7 @@ steps:
image: grafana/build-container:1.5.4
name: test-backend
- commands:
- ./bin/grabpl integration-tests --edition oss
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
depends_on:
- wire-install
image: grafana/build-container:1.5.4
@ -1911,7 +1911,7 @@ steps:
image: grafana/build-container:1.5.4
name: test-backend
- commands:
- ./bin/grabpl integration-tests --edition oss
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
depends_on:
- wire-install
image: grafana/build-container:1.5.4
@ -3707,7 +3707,7 @@ steps:
image: grafana/build-container:1.5.4
name: test-backend
- commands:
- ./bin/grabpl integration-tests --edition oss
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
depends_on:
- wire-install
image: grafana/build-container:1.5.4
@ -4725,6 +4725,6 @@ kind: secret
name: gcp_upload_artifacts_key
---
kind: signature
hmac: f4586777ea98ff85fec51ae5bf344bf549871f73aab2b6ff6611ce979b5bbfa1
hmac: 766806dc9d5e5585e86671ded45d0048cab66c5dc9aaacb5ecb79b8e6754db18
...

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package filestorage
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package filestorage
import (
@ -137,7 +134,6 @@ type queryListFiles struct {
type queryListFoldersInput struct {
path string
paging *Paging
options *ListOptions
}
@ -200,7 +196,7 @@ func handleCommand(t *testing.T, ctx context.Context, cmd interface{}, cmdName s
}
func runChecks(t *testing.T, stepName string, path string, output interface{}, checks []interface{}) {
if checks == nil || len(checks) == 0 {
if len(checks) == 0 {
return
}
@ -254,7 +250,6 @@ func runChecks(t *testing.T, stepName string, path string, output interface{}, c
default:
t.Fatalf("unrecognized output %s", interfaceName(output))
}
}
func formatPathStructure(files []*File) string {
@ -360,5 +355,4 @@ func executeTestStep(t *testing.T, ctx context.Context, step interface{}, stepNu
default:
t.Fatalf("unrecognized step %s", name)
}
}

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package kvstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package serverlock
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package alerting
import (
@ -81,7 +78,11 @@ func (handler *FakeCommonTimeoutHandler) Eval(evalContext *EvalContext) {
url := srv.URL + path
res, err := sendRequest(evalContext.Ctx, url, handler.TransportTimeoutDuration)
if res != nil {
defer res.Body.Close()
defer func() {
if err := res.Body.Close(); err != nil {
logger.Warn("Error", "err", err)
}
}()
}
if err != nil {
@ -106,7 +107,11 @@ func (handler *FakeCommonTimeoutHandler) handle(evalContext *EvalContext) error
url := srv.URL + path
res, err := sendRequest(evalContext.Ctx, url, handler.TransportTimeoutDuration)
if res != nil {
defer res.Body.Close()
defer func() {
if err := res.Body.Close(); err != nil {
logger.Warn("Error", "err", err)
}
}()
}
if err != nil {

@ -1,17 +1,13 @@
//go:build integration
// +build integration
package database
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/require"
)
func TestIntegrationDashboardAclDataAccess(t *testing.T) {
@ -85,7 +81,6 @@ func TestIntegrationDashboardAclDataAccess(t *testing.T) {
})
t.Run("Given a dashboard folder and a user", func(t *testing.T) {
t.Run("Given dashboard folder permission", func(t *testing.T) {
setup(t)
err := updateDashboardAcl(t, dashboardStore, savedFolder.Id, models.DashboardAcl{

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package database
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package database
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package database
import (
@ -246,7 +243,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
require.NoError(t, err)
require.Equal(t, len(res), 0)
sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
err = sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
var existingRuleID int64
exists, err := sess.Table("alert_rule").Where("namespace_uid = (SELECT uid FROM dashboard WHERE id = ?)", savedFolder.Id).Cols("id").Get(&existingRuleID)
require.NoError(t, err)
@ -259,6 +256,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
return nil
})
require.NoError(t, err)
})
t.Run("Should return error if no dashboard is found for update when dashboard id is greater than zero", func(t *testing.T) {
@ -541,7 +539,6 @@ func TestIntegrationDashboard_SortingOptions(t *testing.T) {
require.Len(t, results, 2)
assert.Equal(t, dashB.Id, results[0].ID)
assert.Equal(t, dashA.Id, results[1].ID)
}
func TestIntegrationDashboard_Filter(t *testing.T) {
@ -583,11 +580,10 @@ func TestIntegrationDashboard_Filter(t *testing.T) {
require.NoError(t, err)
require.Len(t, results, 1)
assert.Equal(t, dashB.Id, results[0].ID)
}
func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64, folderUID string) {
sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
err := sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
type alertQuery struct {
RefID string
DatasourceUID string
@ -656,6 +652,7 @@ func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64,
require.NoError(t, err)
return err
})
require.NoError(t, err)
}
func CreateUser(t *testing.T, sqlStore *sqlstore.SQLStore, name string, role string, isAdmin bool) models.User {

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package service
import (
@ -14,7 +11,6 @@ import (
"github.com/grafana/grafana/pkg/models"
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
"github.com/grafana/grafana/pkg/services/alerting"
"github.com/grafana/grafana/pkg/services/dashboards"
dashbboardservice "github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/dashboards/database"
"github.com/grafana/grafana/pkg/services/featuremgmt"
@ -797,7 +793,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
type permissionScenarioContext struct {
dashboardGuardianMock *guardian.FakeDashboardGuardian
sqlStore *sqlstore.SQLStore
dashboardStore dashboards.Store
dashboardStore dashbboardservice.Store
savedFolder *models.Dashboard
savedDashInFolder *models.Dashboard
otherSavedFolder *models.Dashboard

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package service
import (
@ -187,7 +184,6 @@ func TestIntegrationDashboardService(t *testing.T) {
})
t.Run("Given non provisioned dashboard", func(t *testing.T) {
t.Run("DeleteProvisionedDashboard should delete the dashboard", func(t *testing.T) {
args := &models.DeleteDashboardCommand{OrgId: 1, Id: 1, ForceDeleteFolderRules: false}
fakeStore.On("DeleteDashboard", mock.Anything, args).Return(nil).Once()
@ -205,7 +201,3 @@ func TestIntegrationDashboardService(t *testing.T) {
})
})
}
type Result struct {
deleteWasCalled bool
}

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package service
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package dashverimpl
import (
@ -148,6 +145,7 @@ func insertTestDashboard(t *testing.T, sqlStore *sqlstore.SQLStore, title string
return nil
})
require.NoError(t, err)
return dash
}

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package tests
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package store
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package store_test
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package store_test
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package prefimpl
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package queryhistory
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore_test
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (
@ -15,7 +12,6 @@ var theme = models.ThemeDark
var kind = models.ThumbnailKindDefault
func TestIntegrationSqlStorage(t *testing.T) {
var sqlStore *SQLStore
var savedFolder *models.Dashboard

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (
@ -108,20 +105,3 @@ func TestIntegrationGetDashboardVersions(t *testing.T) {
require.Equal(t, 2, len(query.Result))
})
}
func getDashboard(t *testing.T, sqlStore *SQLStore, dashboard *models.Dashboard) error {
t.Helper()
return sqlStore.WithDbSession(context.Background(), func(sess *DBSession) error {
has, err := sess.Get(dashboard)
if err != nil {
return err
} else if !has {
return models.ErrDashboardNotFound
}
dashboard.SetId(dashboard.Id)
dashboard.SetUid(dashboard.Uid)
return nil
})
}

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (
@ -465,6 +462,7 @@ func insertTestDashboard(t *testing.T, sqlStore *SQLStore, title string, orgId i
return nil
})
require.NoError(t, err)
return dash
}

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (
@ -396,7 +393,6 @@ func TestIntegrationTeamCommandsAndQueries(t *testing.T) {
// should not receive service account from query
require.Equal(t, len(teamMembersQuery.Result), 1)
})
})
})
}
@ -480,7 +476,6 @@ func TestIntegrationSQLStore_GetTeamMembers_ACFilter(t *testing.T) {
// Seed 2 teams with 2 members
setup := func(store *SQLStore) {
team1, errCreateTeam := store.CreateTeam("group1 name", "test1@example.org", testOrgID)
require.NoError(t, errCreateTeam)
team2, errCreateTeam := store.CreateTeam("group2 name", "test2@example.org", testOrgID)

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package sqlstore
import (
@ -15,7 +12,6 @@ import (
)
func TestIntegrationUserDataAccess(t *testing.T) {
ss := InitTestDB(t)
user := &models.SignedInUser{
OrgId: 1,
@ -364,7 +360,6 @@ func TestIntegrationUserDataAccess(t *testing.T) {
ss = InitTestDB(t)
t.Run("Testing DB - enable all users", func(t *testing.T) {
users := createFiveTestUsers(t, ss, func(i int) *models.CreateUserCommand {
return &models.CreateUserCommand{
Email: fmt.Sprint("user", i, "@test.com"),
@ -452,7 +447,6 @@ func TestIntegrationUserDataAccess(t *testing.T) {
})
t.Run("Testing DB - grafana admin users", func(t *testing.T) {
ss = InitTestDB(t)
createUserCmd := models.CreateUserCommand{

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package starimpl
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package store
import (
@ -78,6 +75,7 @@ func TestIntegrationEntityEventsService(t *testing.T) {
})
require.NoError(t, err)
firstEv, err := service.GetLastEvent(ctx)
require.NoError(t, err)
firstEvId := firstEv.Id
err = service.SaveEvent(ctx, SaveEventCmd{

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package mysql
import (

@ -1,6 +1,3 @@
//go:build integration
// +build integration
package postgres
import (

@ -510,18 +510,30 @@ def test_backend_step(edition):
],
}
def test_backend_integration_step(edition):
return {
'name': 'test-backend-integration' + enterprise2_suffix(edition),
'image': build_image,
'depends_on': [
'wire-install',
],
'commands': [
'./bin/grabpl integration-tests --edition {}'.format(edition),
],
}
if edition == 'oss':
return {
'name': 'test-backend-integration',
'image': build_image,
'depends_on': [
'wire-install',
],
'commands': [
'go test -run Integration -covermode=atomic -timeout=30m ./pkg/...',
],
}
else:
return {
'name': 'test-backend-integration' + enterprise2_suffix(edition),
'image': build_image,
'depends_on': [
'wire-install',
],
'commands': [
'./bin/grabpl integration-tests --edition {}'.format(edition),
],
}
def test_frontend_step():

Loading…
Cancel
Save