Skip to content

Commit c63ebc8

Browse files
yangkb09idafurjes
andauthored
Chore: Run integration tests without grabpl (grafana#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 <[email protected]>
1 parent 2edfbb7 commit c63ebc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+48
-224
lines changed

.drone.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ steps:
137137
image: grafana/build-container:1.5.4
138138
name: test-backend
139139
- commands:
140-
- ./bin/grabpl integration-tests --edition oss
140+
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
141141
depends_on:
142142
- wire-install
143143
image: grafana/build-container:1.5.4
@@ -815,7 +815,7 @@ steps:
815815
image: grafana/build-container:1.5.4
816816
name: test-backend
817817
- commands:
818-
- ./bin/grabpl integration-tests --edition oss
818+
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
819819
depends_on:
820820
- wire-install
821821
image: grafana/build-container:1.5.4
@@ -1911,7 +1911,7 @@ steps:
19111911
image: grafana/build-container:1.5.4
19121912
name: test-backend
19131913
- commands:
1914-
- ./bin/grabpl integration-tests --edition oss
1914+
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
19151915
depends_on:
19161916
- wire-install
19171917
image: grafana/build-container:1.5.4
@@ -3707,7 +3707,7 @@ steps:
37073707
image: grafana/build-container:1.5.4
37083708
name: test-backend
37093709
- commands:
3710-
- ./bin/grabpl integration-tests --edition oss
3710+
- go test -run Integration -covermode=atomic -timeout=30m ./pkg/...
37113711
depends_on:
37123712
- wire-install
37133713
image: grafana/build-container:1.5.4
@@ -4725,6 +4725,6 @@ kind: secret
47254725
name: gcp_upload_artifacts_key
47264726
---
47274727
kind: signature
4728-
hmac: f4586777ea98ff85fec51ae5bf344bf549871f73aab2b6ff6611ce979b5bbfa1
4728+
hmac: 766806dc9d5e5585e86671ded45d0048cab66c5dc9aaacb5ecb79b8e6754db18
47294729

47304730
...

pkg/infra/filestorage/fs_integration_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package filestorage
52

63
import (

pkg/infra/filestorage/test_utils.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package filestorage
52

63
import (
@@ -137,7 +134,6 @@ type queryListFiles struct {
137134

138135
type queryListFoldersInput struct {
139136
path string
140-
paging *Paging
141137
options *ListOptions
142138
}
143139

@@ -200,7 +196,7 @@ func handleCommand(t *testing.T, ctx context.Context, cmd interface{}, cmdName s
200196
}
201197

202198
func runChecks(t *testing.T, stepName string, path string, output interface{}, checks []interface{}) {
203-
if checks == nil || len(checks) == 0 {
199+
if len(checks) == 0 {
204200
return
205201
}
206202

@@ -254,7 +250,6 @@ func runChecks(t *testing.T, stepName string, path string, output interface{}, c
254250
default:
255251
t.Fatalf("unrecognized output %s", interfaceName(output))
256252
}
257-
258253
}
259254

260255
func formatPathStructure(files []*File) string {
@@ -360,5 +355,4 @@ func executeTestStep(t *testing.T, ctx context.Context, step interface{}, stepNu
360355
default:
361356
t.Fatalf("unrecognized step %s", name)
362357
}
363-
364358
}

pkg/infra/kvstore/kvstore_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package kvstore
52

63
import (

pkg/infra/serverlock/serverlock_integration_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package serverlock
52

63
import (

pkg/services/alerting/engine_integration_test.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package alerting
52

63
import (
@@ -81,7 +78,11 @@ func (handler *FakeCommonTimeoutHandler) Eval(evalContext *EvalContext) {
8178
url := srv.URL + path
8279
res, err := sendRequest(evalContext.Ctx, url, handler.TransportTimeoutDuration)
8380
if res != nil {
84-
defer res.Body.Close()
81+
defer func() {
82+
if err := res.Body.Close(); err != nil {
83+
logger.Warn("Error", "err", err)
84+
}
85+
}()
8586
}
8687

8788
if err != nil {
@@ -106,7 +107,11 @@ func (handler *FakeCommonTimeoutHandler) handle(evalContext *EvalContext) error
106107
url := srv.URL + path
107108
res, err := sendRequest(evalContext.Ctx, url, handler.TransportTimeoutDuration)
108109
if res != nil {
109-
defer res.Body.Close()
110+
defer func() {
111+
if err := res.Body.Close(); err != nil {
112+
logger.Warn("Error", "err", err)
113+
}
114+
}()
110115
}
111116

112117
if err != nil {

pkg/services/dashboards/database/acl_test.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
//go:build integration
2-
// +build integration
3-
41
package database
52

63
import (
74
"context"
85
"testing"
96

10-
"github.com/stretchr/testify/require"
11-
127
"github.com/grafana/grafana/pkg/models"
138
"github.com/grafana/grafana/pkg/services/sqlstore"
149
"github.com/grafana/grafana/pkg/setting"
10+
"github.com/stretchr/testify/require"
1511
)
1612

1713
func TestIntegrationDashboardAclDataAccess(t *testing.T) {
@@ -85,7 +81,6 @@ func TestIntegrationDashboardAclDataAccess(t *testing.T) {
8581
})
8682

8783
t.Run("Given a dashboard folder and a user", func(t *testing.T) {
88-
8984
t.Run("Given dashboard folder permission", func(t *testing.T) {
9085
setup(t)
9186
err := updateDashboardAcl(t, dashboardStore, savedFolder.Id, models.DashboardAcl{

pkg/services/dashboards/database/database_folder_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package database
52

63
import (

pkg/services/dashboards/database/database_provisioning_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package database
52

63
import (

pkg/services/dashboards/database/database_test.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package database
52

63
import (
@@ -246,7 +243,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
246243
require.NoError(t, err)
247244
require.Equal(t, len(res), 0)
248245

249-
sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
246+
err = sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
250247
var existingRuleID int64
251248
exists, err := sess.Table("alert_rule").Where("namespace_uid = (SELECT uid FROM dashboard WHERE id = ?)", savedFolder.Id).Cols("id").Get(&existingRuleID)
252249
require.NoError(t, err)
@@ -259,6 +256,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
259256

260257
return nil
261258
})
259+
require.NoError(t, err)
262260
})
263261

264262
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) {
541539
require.Len(t, results, 2)
542540
assert.Equal(t, dashB.Id, results[0].ID)
543541
assert.Equal(t, dashA.Id, results[1].ID)
544-
545542
}
546543

547544
func TestIntegrationDashboard_Filter(t *testing.T) {
@@ -583,11 +580,10 @@ func TestIntegrationDashboard_Filter(t *testing.T) {
583580
require.NoError(t, err)
584581
require.Len(t, results, 1)
585582
assert.Equal(t, dashB.Id, results[0].ID)
586-
587583
}
588584

589585
func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64, folderUID string) {
590-
sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
586+
err := sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
591587
type alertQuery struct {
592588
RefID string
593589
DatasourceUID string
@@ -656,6 +652,7 @@ func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64,
656652
require.NoError(t, err)
657653
return err
658654
})
655+
require.NoError(t, err)
659656
}
660657

661658
func CreateUser(t *testing.T, sqlStore *sqlstore.SQLStore, name string, role string, isAdmin bool) models.User {

pkg/services/dashboards/service/dashboard_service_integration_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package service
52

63
import (
@@ -14,7 +11,6 @@ import (
1411
"github.com/grafana/grafana/pkg/models"
1512
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
1613
"github.com/grafana/grafana/pkg/services/alerting"
17-
"github.com/grafana/grafana/pkg/services/dashboards"
1814
dashbboardservice "github.com/grafana/grafana/pkg/services/dashboards"
1915
"github.com/grafana/grafana/pkg/services/dashboards/database"
2016
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -797,7 +793,7 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
797793
type permissionScenarioContext struct {
798794
dashboardGuardianMock *guardian.FakeDashboardGuardian
799795
sqlStore *sqlstore.SQLStore
800-
dashboardStore dashboards.Store
796+
dashboardStore dashbboardservice.Store
801797
savedFolder *models.Dashboard
802798
savedDashInFolder *models.Dashboard
803799
otherSavedFolder *models.Dashboard

pkg/services/dashboards/service/dashboard_service_test.go

-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package service
52

63
import (
@@ -187,7 +184,6 @@ func TestIntegrationDashboardService(t *testing.T) {
187184
})
188185

189186
t.Run("Given non provisioned dashboard", func(t *testing.T) {
190-
191187
t.Run("DeleteProvisionedDashboard should delete the dashboard", func(t *testing.T) {
192188
args := &models.DeleteDashboardCommand{OrgId: 1, Id: 1, ForceDeleteFolderRules: false}
193189
fakeStore.On("DeleteDashboard", mock.Anything, args).Return(nil).Once()
@@ -205,7 +201,3 @@ func TestIntegrationDashboardService(t *testing.T) {
205201
})
206202
})
207203
}
208-
209-
type Result struct {
210-
deleteWasCalled bool
211-
}

pkg/services/dashboards/service/folder_service_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package service
52

63
import (

pkg/services/dashboardversion/dashverimpl/store_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package dashverimpl
52

63
import (
@@ -148,6 +145,7 @@ func insertTestDashboard(t *testing.T, sqlStore *sqlstore.SQLStore, title string
148145

149146
return nil
150147
})
148+
require.NoError(t, err)
151149

152150
return dash
153151
}

pkg/services/live/database/tests/storage_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package tests
52

63
import (

pkg/services/ngalert/store/alertmanager_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package store
52

63
import (

pkg/services/ngalert/store/image_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package store_test
52

63
import (

pkg/services/ngalert/store/instance_database_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package store_test
52

63
import (

pkg/services/preference/prefimpl/store_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package prefimpl
52

63
import (

pkg/services/queryhistory/queryhistory_create_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_delete_stale_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_delete_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_enforce_limit_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_migrate_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_patch_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_search_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_star_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

pkg/services/queryhistory/queryhistory_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package queryhistory
52

63
import (

0 commit comments

Comments
 (0)