mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* RBAC: Make the SplitScope migration concurrent * Benchmark multiple alternatives: (updates in a loop, batch update, concurrent batch update) * Only keep batching since mysql 5.7 does not seem to support concurrent batching * Update pkg/services/accesscontrol/migrator/migrator.go Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> --------- Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
28 lines
727 B
Go
28 lines
727 B
Go
package migrator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
)
|
|
|
|
func benchScopeSplitConcurrent(b *testing.B, count int) {
|
|
store := db.InitTestDB(b)
|
|
// Populate permissions
|
|
require.NoError(b, batchInsertPermissions(count, store), "could not insert permissions")
|
|
logger := log.New("migrator.test")
|
|
b.ResetTimer()
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
err := MigrateScopeSplit(store, logger)
|
|
require.NoError(b, err)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMigrateScopeSplitConcurrent_50K(b *testing.B) { benchScopeSplitConcurrent(b, 50000) }
|
|
|
|
func BenchmarkMigrateScopeSplitConcurrent_100K(b *testing.B) { benchScopeSplitConcurrent(b, 100000) }
|