mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
docker: mssql and mssql tests blocks with common build context
This commit is contained in:
parent
6503e482e3
commit
ef3588c1f8
12
docker/blocks/mssql/build/setup.sh
Executable file
12
docker/blocks/mssql/build/setup.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
#wait for the SQL Server to come up
|
||||||
|
sleep 15s
|
||||||
|
|
||||||
|
cat /usr/setup/setup.sql.template | awk '{
|
||||||
|
gsub(/%%DB%%/,"'$MSSQL_DATABASE'");
|
||||||
|
gsub(/%%USER%%/,"'$MSSQL_USER'");
|
||||||
|
gsub(/%%PWD%%/,"'$MSSQL_PASSWORD'")
|
||||||
|
}1' > /usr/setup/setup.sql
|
||||||
|
|
||||||
|
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -d master -i /usr/setup/setup.sql
|
14
docker/blocks/mssql/build/setup.sql.template
Normal file
14
docker/blocks/mssql/build/setup.sql.template
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
CREATE LOGIN %%USER%% WITH PASSWORD = '%%PWD%%'
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE DATABASE %%DB%%;
|
||||||
|
GO
|
||||||
|
|
||||||
|
USE %%DB%%;
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE USER %%USER%% FOR LOGIN %%USER%%;
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sp_addrolemember 'db_owner', '%%USER%%';
|
||||||
|
GO
|
@ -1,10 +1,13 @@
|
|||||||
mssqltest:
|
mssql:
|
||||||
build:
|
build:
|
||||||
context: blocks/mssql
|
context: blocks/mssql/build
|
||||||
environment:
|
environment:
|
||||||
ACCEPT_EULA: Y
|
ACCEPT_EULA: Y
|
||||||
MSSQL_SA_PASSWORD: Password!
|
MSSQL_SA_PASSWORD: Password!
|
||||||
MSSQL_PID: Express
|
MSSQL_PID: Express
|
||||||
|
MSSQL_DATABASE: grafana
|
||||||
|
MSSQL_USER: grafana
|
||||||
|
MSSQL_PASSWORD: Password!
|
||||||
ports:
|
ports:
|
||||||
- "1433:1433"
|
- "1433:1433"
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#/bin/bash
|
|
||||||
|
|
||||||
#wait for the SQL Server to come up
|
|
||||||
sleep 20s
|
|
||||||
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password! -d master -i /usr/setup/setup.sql
|
|
@ -1,14 +0,0 @@
|
|||||||
CREATE LOGIN grafana WITH PASSWORD = 'Password!'
|
|
||||||
GO
|
|
||||||
|
|
||||||
CREATE DATABASE grafana;
|
|
||||||
GO
|
|
||||||
|
|
||||||
USE grafana;
|
|
||||||
GO
|
|
||||||
|
|
||||||
CREATE USER grafana FOR LOGIN grafana;
|
|
||||||
GO
|
|
||||||
|
|
||||||
EXEC sp_addrolemember 'db_owner', 'grafana';
|
|
||||||
GO
|
|
12
docker/blocks/mssql_tests/docker-compose.yaml
Normal file
12
docker/blocks/mssql_tests/docker-compose.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
mssqltests:
|
||||||
|
build:
|
||||||
|
context: blocks/mssql/build
|
||||||
|
environment:
|
||||||
|
ACCEPT_EULA: Y
|
||||||
|
MSSQL_SA_PASSWORD: Password!
|
||||||
|
MSSQL_PID: Express
|
||||||
|
MSSQL_DATABASE: grafanatest
|
||||||
|
MSSQL_USER: grafana
|
||||||
|
MSSQL_PASSWORD: Password!
|
||||||
|
ports:
|
||||||
|
- "1433:1433"
|
@ -14,7 +14,7 @@ type TestDB struct {
|
|||||||
var TestDB_Sqlite3 = TestDB{DriverName: "sqlite3", ConnStr: ":memory:"}
|
var TestDB_Sqlite3 = TestDB{DriverName: "sqlite3", ConnStr: ":memory:"}
|
||||||
var TestDB_Mysql = TestDB{DriverName: "mysql", ConnStr: "grafana:password@tcp(localhost:3306)/grafana_tests?collation=utf8mb4_unicode_ci"}
|
var TestDB_Mysql = TestDB{DriverName: "mysql", ConnStr: "grafana:password@tcp(localhost:3306)/grafana_tests?collation=utf8mb4_unicode_ci"}
|
||||||
var TestDB_Postgres = TestDB{DriverName: "postgres", ConnStr: "user=grafanatest password=grafanatest host=localhost port=5432 dbname=grafanatest sslmode=disable"}
|
var TestDB_Postgres = TestDB{DriverName: "postgres", ConnStr: "user=grafanatest password=grafanatest host=localhost port=5432 dbname=grafanatest sslmode=disable"}
|
||||||
var TestDB_Mssql = TestDB{DriverName: "mssql", ConnStr: "server=localhost;port=1433;database=grafana_tests;user id=grafana;password=Password!"}
|
var TestDB_Mssql = TestDB{DriverName: "mssql", ConnStr: "server=localhost;port=1433;database=grafanatest;user id=grafana;password=Password!"}
|
||||||
|
|
||||||
func CleanDB(x *xorm.Engine) {
|
func CleanDB(x *xorm.Engine) {
|
||||||
if x.DriverName() == "postgres" {
|
if x.DriverName() == "postgres" {
|
||||||
|
Loading…
Reference in New Issue
Block a user