248 Commits

Author SHA1 Message Date
edb0865caa Chore: Ensure we save correct default admin user in integration test DB setup (#105752)
* fix helper + amend tests

* fix import + remove unused var

* remove more users

* remove unused code

* update test comment
2025-05-28 11:25:01 +01:00
c4d3eb1cd0 Remove support for Google Spanner database. (#105846)
* Remove support for Google Spanner database.
2025-05-23 11:35:59 +02:00
694b9dfe50 Chore: Replace xorm.io/xorm imports (#104458)
* replace xorm.io/xorm imports

* replace xorm from other go.mod files

* clean up workspace

* nolint does not make sense anymore as it is not a module

* try if nolint directive helps

* use nolint:all for xorm

* add more nolints

* try to skip xorm in linter config

* exclude xorm differently

* retrigger ci
2025-05-02 17:13:01 +02:00
047f5edae9 Chore: Add xorm.io/core into xorm (#103700)
* add xorm.io/core into xorm

* update workspace

* format imports

* update workspace
2025-04-16 08:58:50 +02:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
5b5f433a26 spanner: Disable running alerting integration tests when using spanner. (#102730)
* Disable running alerting integration tests when using spanner.

* Disable tests for templategroup.
2025-03-26 10:57:55 +01:00
3d53968ecb spanner-annotationsimpls-fixes (#102622)
* Fix DELETE statements.
* Reset sequence generator when truncating tables.
* Quote "at", since it's a keyword in Spanner.
2025-03-21 16:10:51 +01:00
abe6a3121c spanner: disable recursive queries (#102032) 2025-03-12 15:43:06 +01:00
904d58e936 SQLStore: Introduce new test infra (#101676)
This creates the new testinfra. It is not used anywhere yet.
2025-03-06 11:01:14 +01:00
f05d016ae7 Chore: Remove mysqlParseTime feature toggle (#97761) 2024-12-10 15:13:13 -06:00
ced7a84f8b chore(metrics): Add metrics & traces to DB migration (#97181)
Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-12-05 17:22:19 -05:00
4623a6471b SQLStore: Fix parseTime check (#94175) 2024-10-03 08:58:33 -05:00
a4266df16d SQL Store: Fix parse time setup (#92484) 2024-08-27 17:39:27 +03:00
c59dddf7af MySQL: Add parseTime=true to SQL connections (#92469) 2024-08-27 14:16:04 +03:00
2136fd9a92 Storage: Remove unified storage feature flag (#92192)
remove unified storage flag
2024-08-21 19:28:30 +03:00
522a98c126 Chore: Make Cfg field private in SQLStore (#85593)
* make cfg private in sqlstore

* fix db init in tests

* fix case

* fix folder test init

* fix imports

* make another Cfg private

* remove another Cfg

* remove unused variable

* use store cfg, it has side-effects

* fix mutated cfg in tests
2024-04-24 10:38:40 +02:00
03b795844c SQLStore: Improve recursive CTE support detection (#86397)
sqlstore: improve recursive CTE support detection

Vitess returns a not supported error, not a parse error

Co-authored-by: Derek Perkins <derek@nozzle.io>
2024-04-17 08:37:47 -04:00
5dfe4cf407 Storage: Watch tests (#85496)
* basic watch tests working

* refactor to read previous event within poller

* add watch test files

* cleanup

* watch tests passing

* debug cleanup

* special handling for canceled context

* cleanup

* fix wire

* fix sqlite_sequence cleanup issue

* move watch tests to integration, wait for provisioned dashboards

* handle context deadline exceeded and eof errors

* add comment about sleep
2024-04-08 11:42:12 -04:00
faa1244518 Chore: Replace sqlstore with db interface (#85366)
* replace sqlstore with db interface in a few packages

* remove from stats

* remove sqlstore in admin test

* remove sqlstore from api plugin tests

* fix another createUser

* remove sqlstore in publicdashboards

* remove sqlstore from orgs

* clean up orguser test

* more clean up in sso

* clean up service accounts

* further cleanup

* more cleanup in accesscontrol

* last cleanup in accesscontrol

* clean up teams

* more removals

* split cfg from db in testenv

* few remaining fixes

* fix test with bus

* pass cfg for testing inside db as an option

* set query retries when no opts provided

* revert golden test data

* rebase and rollback
2024-04-04 15:04:47 +02:00
33b653534e SQLStore: Enable migration locking by default (#84983)
* Introduce new configuration for migration locking

* Remove feature toggle

* Fix test and turn it into an integration

* Fix docs
2024-03-22 21:22:29 +02:00
ac84069071 Password policy (#82268)
* add password service interface

* add password service implementation

* add tests for password service

* add password service wiring

* add feature toggle

* Rework from service interface to static function

* Replace previous password validations

* Add codeowners to password service

* add error logs

* update config files


---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2024-02-16 04:58:05 -06:00
b894d26cbc SQLStore: New store without side-effects (#82657) 2024-02-15 14:03:55 -04:00
790e1feb93 Chore: Update test database initialization (#81673)
* streamline initialization of test databases, support on-disk sqlite test db

* clean up test databases

* introduce testsuite helper

* use testsuite everywhere we use a test db

* update documentation

* improve error handling

* disable entity integration test until we can figure out locking error
2024-02-09 09:35:39 -05:00
1fab107e79 FeatureFlags: Avoid using cfg.IsFeatureToggleEnabled (#81407) 2024-01-28 15:22:45 -08:00
20fe0eb173 Chore: Extract DatabaseConfig parsing from SQLStore (#81157)
Extract the parsing/creating of database config/connectiong from SQLStore string 
to a separate DatabaseConfig struct.
2024-01-24 16:49:49 +01:00
c4c9bfaf2e Storage: Unified Storage based on Entity API (#71977)
* first round of entityapi updates

- quote column names and clean up insert/update queries
- replace grn with guid
- streamline table structure

fixes

streamline entity history

move EntitySummary into proto

remove EntitySummary

add guid to json

fix tests

change DB_Uuid to DB_NVarchar

fix folder test

convert interface to any

more cleanup

start entity store under grafana-apiserver dskit target

CRUD working, kind of

rough cut of wiring entity api to kube-apiserver

fake grafana user in context

add key to entity

list working

revert unnecessary changes

move entity storage files to their own package, clean up

use accessor to read/write grafana annotations

implement separate Create and Update functions

* go mod tidy

* switch from Kind to resource

* basic grpc storage server

* basic support for grpc entity store

* don't connect to database unless it's needed, pass user identity over grpc

* support getting user from k8s context, fix some mysql issues

* assign owner to snowflake dependency

* switch from ulid to uuid for guids

* cleanup, rename Search to List

* remove entityListResult

* EntityAPI: remove extra user abstraction (#79033)

* remove extra user abstraction

* add test stub (but

* move grpc context setup into client wrapper, fix lint issue

* remove unused constants

* remove custom json stuff

* basic list filtering, add todo

* change target to storage-server, allow entityStore flag in prod mode

* fix issue with Update

* EntityAPI: make test work, need to resolve expected differences (#79123)

* make test work, need to resolve expected differences

* remove the fields not supported by legacy

* sanitize out the bits legacy does not support

* sanitize out the bits legacy does not support

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* update feature toggle generated files

* remove unused http headers

* update feature flag strategy

* devmode

* update readme

* spelling

* readme

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2023-12-06 15:21:21 -05:00
318f51eaee Chore: Remove unused CacheService dependency from sqlstore (#78507)
remove unused CacheService dependency from sqlstore
2023-12-04 10:00:45 -05:00
a221c1d754 Chore: Remvoe newDBLibrary feature flag (#78074) 2023-11-14 06:51:35 -08:00
dec9a07738 Settings: Actually deprecate access to feature flags (#78073) 2023-11-13 11:39:01 -08:00
15f6e8a500 SQLStore: Fix race condition in RecursiveQueriesAreSupported (#75274) 2023-09-22 11:30:14 +01:00
7197ed9fbb Fix: avoid panics on duplicate metrics registration (#74359) 2023-09-05 10:02:11 +02:00
025b2f3011 Chore: use any rather than interface{} (#74066) 2023-08-30 18:46:47 +03:00
e21872bb15 SQLStore: Fix regression in PostgreSQL connection string (#71368)
* SQLStore: Fix connection string for PostgreSQL

* better testing
2023-07-11 16:47:35 +03:00
b947222bf5 Platform: Add support for Postgresql pgpass file (#61517)
lib/pq has built-in support to use pgpass file for authentication when
no password has been provided. However this requires that the connection
does not contain the password parameter at all.

Removing password parameter when postgresql password is empty in
SQL store.
2023-07-07 11:17:35 +02:00
a6279b2d62 Database: Make dialects independent of xorm Engine (#69955)
* make dialects independent of xorm Engine

* goimports
2023-06-14 16:13:36 -04:00
b43206e26b MySQL: Use transaction_isolation instead of tx_isolation (#68575)
will use the correct system var name for transaction isolation
2023-05-23 09:22:05 -06:00
26658d172f Migrations: Support independent migration log for entity api (#68511) 2023-05-22 11:31:07 -07:00
692bb9ed1a Instrumentation: Add support for instrumenting database queries (#66022)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2023-04-28 15:19:06 +02:00
2136e680c4 Previews: remove dashboard previews backend (#66176)
* remove dashboard previews backend

* remove dashboard previews backend

* bring back the migration

* bring back the migration

* bring back the migration
2023-04-13 21:42:24 +04:00
4ee0be6fdf Chore: Add function for detecting if the SQL driver supported CTEs (#64441)
* Add interface method for detecting if the SQL driver supported CTEs

* Update nested folder store to call RecursiveQueriesAreSupported()
2023-03-20 10:27:08 +02:00
f5cb8c660e SQLStore: Fix setting query tries for integration tests (#64944)
* SQLStore: Pass testinfra database configuration to the test database

* Add test

* Bypass gocyclo check for initTestDB
2023-03-17 17:31:03 +02:00
d5a9a0cea0 Chore: remove comments feature (#64644) 2023-03-11 04:28:12 -08:00
8ea71d37c2 SQLStore: Enable clientFoundRows for MySQL connections (#64070)
Enable clientFoundRows for MySQL connections
2023-03-02 16:31:01 -06:00
efed0151f8 Chore: Remove pkg/models/stats.go (#61613)
* remove pkg/models/stats.go

* rename models package in tests
2023-01-17 14:17:54 +01:00
cc007e9727 chore: sqlstore cleanup (#60415)
* chore: remove unused test helper from sqlstore

TimeNow() is no longer used in any tests in this package.

* chore: move sqlstore.SQLBuilder to the infra/db package

This required some minor refactoring; we need to be a little more explicit about passing around the dialect and engine. On the other hand, that's a few fewer uses of the `dialect` global constant!

* chore: move UserDeletions into the only package using it

* cleanup around moving sqlbuilder

* remove dialect and sqlog global vars

* rename userDeletions to serviceAccountDeletions
2022-12-16 11:09:06 -05:00
e4a877b123 chore: attempt to fix flapping "organization not found" tests (#60418)
we live in hope!
2022-12-16 10:10:59 -05:00
70fbf47022 chore: remove CreateUser from sqlstore & replace with userService.CreateUserForTests (#59910) 2022-12-07 11:03:22 -05:00
b3284a8330 Chore: Make getUserOrgList private to sqlstore (#59654)
* make getUserOrgList private in sqlstore

* make other identifiers private
2022-12-01 15:46:42 +01:00
14a080ec12 EntityStore: Rename ObjectStore to EntityStore (part 2) (#59616) 2022-11-30 17:52:15 -05:00
79f1a7a4fd Database: Adds support for enable/disable SQLite Write-Ahead Logging (WAL) via configuration (#58268)
Adds support for enable/disable SQLite Write-Ahead Logging (WAL) via configuration.
Enables SQLite WAL for E2E tests.
2022-11-16 19:29:33 +01:00