Skip to content

Commit 14d0eaf

Browse files
authored
Merge pull request #467 from wooln/feature-storage-sqlserver
Feature storage sqlserver
2 parents c8c0b3a + e233895 commit 14d0eaf

File tree

14 files changed

+156
-15
lines changed

14 files changed

+156
-15
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ jobs:
4545
- /etc/timezone:/etc/timezone:ro
4646
ports:
4747
- 27017:27017
48+
sqlserver:
49+
image: mcr.microsoft.com/mssql/server:2019-latest
50+
volumes:
51+
- /etc/localtime:/etc/localtime:ro
52+
- /etc/timezone:/etc/timezone:ro
53+
env:
54+
ACCEPT_EULA: Y
55+
MSSQL_SA_PASSWORD: p@ssw0rd
56+
ports:
57+
- '1433:1433'
4858
steps:
4959
- name: Set up Go 1.19
5060
uses: actions/setup-go@v2

client/dtmcli/consts.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const (
3535
DBTypeMysql = dtmimp.DBTypeMysql
3636
// DBTypePostgres const for driver postgres
3737
DBTypePostgres = dtmimp.DBTypePostgres
38+
// DBTypeSQLServer const for driver SQLServer
39+
DBTypeSQLServer = dtmimp.DBTypeSQLServer
3840
)
3941

4042
// MapSuccess HTTP result of SUCCESS

client/dtmcli/dtmimp/consts.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const (
3636
DBTypeMysql = "mysql"
3737
// DBTypePostgres const for driver postgres
3838
DBTypePostgres = "postgres"
39+
// DBTypeSQLServer const for driver SQLServer
40+
DBTypeSQLServer = "sqlserver"
3941
// DBTypeRedis const for driver redis
4042
DBTypeRedis = "redis"
4143
// Jrpc const for json-rpc

client/dtmcli/dtmimp/utils.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ func DBExec(dbType string, db DB, sql string, values ...interface{}) (affected i
207207
return 0, nil
208208
}
209209
began := time.Now()
210-
sql = GetDBSpecial(dbType).GetPlaceHoldSQL(sql)
210+
if len(values) > 0 {
211+
sql = GetDBSpecial(dbType).GetPlaceHoldSQL(sql)
212+
}
211213
r, rerr := db.Exec(sql, values...)
212214
used := time.Since(began) / time.Millisecond
213215
if rerr == nil {
@@ -228,11 +230,26 @@ func GetDsn(conf DBConf) string {
228230
conf.User, conf.Password, host, conf.Port, conf.Db),
229231
"postgres": fmt.Sprintf("host=%s user=%s password=%s dbname='%s' search_path=%s port=%d sslmode=disable",
230232
host, conf.User, conf.Password, conf.Db, conf.Schema, conf.Port),
233+
// sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30
234+
"sqlserver": getSQLServerConnectionString(&conf, &host),
231235
}[driver]
232236
PanicIf(dsn == "", fmt.Errorf("unknow driver: %s", driver))
233237
return dsn
234238
}
235239

240+
func getSQLServerConnectionString(conf *DBConf, host *string) string {
241+
query := url.Values{}
242+
query.Add("database", conf.Db)
243+
u := &url.URL{
244+
Scheme: "sqlserver",
245+
User: url.UserPassword(conf.User, conf.Password),
246+
Host: fmt.Sprintf("%s:%d", *host, conf.Port),
247+
// Path: instance, // if connecting to an instance instead of a port
248+
RawQuery: query.Encode(),
249+
}
250+
return u.String()
251+
}
252+
236253
// RespAsErrorByJSONRPC translate json rpc resty response to error
237254
func RespAsErrorByJSONRPC(resp *resty.Response) error {
238255
str := resp.String()

dtmsvr/config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const (
2020
BoltDb = "boltdb"
2121
// Postgres is postgres driver
2222
Postgres = "postgres"
23+
// SQLServer is SQL Server driver
24+
SQLServer = "sqlserver"
2325
)
2426

2527
// MicroService config type for microservice based grpc
@@ -65,7 +67,7 @@ type Store struct {
6567

6668
// IsDB checks config driver is mysql or postgres
6769
func (s *Store) IsDB() bool {
68-
return s.Driver == dtmcli.DBTypeMysql || s.Driver == dtmcli.DBTypePostgres
70+
return s.Driver == dtmcli.DBTypeMysql || s.Driver == dtmcli.DBTypePostgres || s.Driver == dtmcli.DBTypeSQLServer
6971
}
7072

7173
// GetDBConf returns db conf info

dtmsvr/storage/registry/registry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ var storeFactorys = map[string]StorageFactory{
3737
return &redis.Store{}
3838
},
3939
},
40-
"mysql": sqlFac,
41-
"postgres": sqlFac,
40+
"mysql": sqlFac,
41+
"postgres": sqlFac,
42+
"sqlserver": sqlFac,
4243
}
4344

4445
// GetStore returns storage.Store

dtmsvr/storage/sql/sql.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ func (s *Store) ScanTransGlobalStores(position *string, limit int64, condition s
6969
query = query.Where("trans_type = ?", condition.TransType)
7070
}
7171
if !condition.CreateTimeStart.IsZero() {
72-
query = query.Where("create_time >= ?", condition.CreateTimeStart.Format("2006-01-02 15:04:05"))
72+
query = query.Where("create_time >= ?", condition.CreateTimeStart)
7373
}
7474
if !condition.CreateTimeEnd.IsZero() {
75-
query = query.Where("create_time <= ?", condition.CreateTimeEnd.Format("2006-01-02 15:04:05"))
75+
query = query.Where("create_time <= ?", condition.CreateTimeEnd)
7676
}
7777

7878
dbr := query.Order("id desc").Limit(int(limit)).Find(&globals)
@@ -105,7 +105,13 @@ func (s *Store) UpdateBranches(branches []storage.TransBranchStore, updates []st
105105
func (s *Store) LockGlobalSaveBranches(gid string, status string, branches []storage.TransBranchStore, branchStart int) {
106106
err := dbGet().Transaction(func(tx *gorm.DB) error {
107107
g := &storage.TransGlobalStore{}
108-
dbr := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Model(g).Where("gid=? and status=?", gid, status).First(g)
108+
var dbr *gorm.DB
109+
// sqlserver sql should be: SELECT * FROM "trans_global" with(RowLock,UpdLock) ,but gorm generates "FOR UPDATE" at the back, raw sql instead.
110+
if conf.Store.Driver == config.SQLServer {
111+
dbr = tx.Raw("SELECT * FROM trans_global with(RowLock,UpdLock) WHERE gid=? and status=? ORDER BY id OFFSET 0 ROW FETCH NEXT 1 ROWS ONLY ", gid, status).First(g)
112+
} else {
113+
dbr = tx.Clauses(clause.Locking{Strength: "UPDATE"}).Model(g).Where("gid=? and status=?", gid, status).First(g)
114+
}
109115
if dbr.Error == nil {
110116
if branchStart == -1 {
111117
dbr = tx.Create(branches)
@@ -163,12 +169,11 @@ func (s *Store) LockOneGlobalTrans(expireIn time.Duration) *storage.TransGlobalS
163169
nextCronTime := getTimeStr(int64(expireIn / time.Second))
164170
where := fmt.Sprintf(`next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted')`, nextCronTime)
165171

166-
order := map[string]string{
167-
dtmimp.DBTypeMysql: `order by rand()`,
168-
dtmimp.DBTypePostgres: `order by random()`,
172+
ssql := map[string]string{
173+
dtmimp.DBTypeMysql: fmt.Sprintf(`select id from trans_global where %s order by rand() limit 1`, where),
174+
dtmimp.DBTypePostgres: fmt.Sprintf(`select id from trans_global where %s order by random() limit 1`, where),
175+
dtmimp.DBTypeSQLServer: fmt.Sprintf(`select top 1 id from trans_global where %s order by rand()`, where),
169176
}[conf.Store.Driver]
170-
171-
ssql := fmt.Sprintf(`select id from trans_global where %s %s limit 1`, where, order)
172177
var id int64
173178
err := db.ToSQLDB().QueryRow(ssql).Scan(&id)
174179
if errors.Is(err, sql.ErrNoRows) {
@@ -198,8 +203,9 @@ func (s *Store) LockOneGlobalTrans(expireIn time.Duration) *storage.TransGlobalS
198203
func (s *Store) ResetCronTime(after time.Duration, limit int64) (succeedCount int64, hasRemaining bool, err error) {
199204
nextCronTime := getTimeStr(int64(after / time.Second))
200205
where := map[string]string{
201-
dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d`, nextCronTime, limit),
202-
dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d )`, nextCronTime, limit),
206+
dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d`, nextCronTime, limit),
207+
dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d )`, nextCronTime, limit),
208+
dtmimp.DBTypeSQLServer: fmt.Sprintf(`id in (select top %d id from trans_global where next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') )`, limit, nextCronTime),
203209
}[conf.Store.Driver]
204210

205211
sql := fmt.Sprintf(`UPDATE trans_global SET update_time='%s',next_cron_time='%s' WHERE %s`,
@@ -317,5 +323,8 @@ func wrapError(err error) error {
317323
}
318324

319325
func getTimeStr(afterSecond int64) string {
326+
if conf.Store.Driver == config.SQLServer {
327+
return dtmutil.GetNextTime(afterSecond).Format(time.RFC3339)
328+
}
320329
return dtmutil.GetNextTime(afterSecond).Format("2006-01-02 15:04:05")
321330
}

dtmutil/db.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
"github.com/dtm-labs/logger"
1212
_ "github.com/go-sql-driver/mysql" // register mysql driver
1313
_ "github.com/lib/pq" // register postgres driver
14+
15+
// _ "github.com/microsoft/go-mssqldb" // Microsoft's package conflicts with gorm's package: panic: sql: Register called twice for driver mssql
1416
"gorm.io/driver/mysql"
1517
"gorm.io/driver/postgres"
18+
"gorm.io/driver/sqlserver" // register sqlserver driver,
1619
"gorm.io/gorm"
1720
)
1821

@@ -27,6 +30,9 @@ func getGormDialetor(driver string, dsn string) gorm.Dialector {
2730
if driver == dtmcli.DBTypePostgres {
2831
return postgres.Open(dsn)
2932
}
33+
if driver == dtmcli.DBTypeSQLServer {
34+
return sqlserver.Open(dsn)
35+
}
3036
dtmimp.PanicIf(driver != dtmcli.DBTypeMysql, fmt.Errorf("unknown driver: %s", driver))
3137
return mysql.Open(dsn)
3238
}

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ require (
3030
gopkg.in/yaml.v3 v3.0.1
3131
gorm.io/driver/mysql v1.0.3
3232
gorm.io/driver/postgres v1.2.1
33+
gorm.io/driver/sqlserver v1.1.2
3334
gorm.io/gorm v1.22.2
3435
)
3536

@@ -46,6 +47,7 @@ require (
4647
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
4748
github.com/dapr/dapr v1.10.9 // indirect
4849
github.com/davecgh/go-spew v1.1.1 // indirect
50+
github.com/denisenkom/go-mssqldb v0.12.3 // indirect
4951
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
5052
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
5153
github.com/fatih/color v1.14.1 // indirect
@@ -66,6 +68,8 @@ require (
6668
github.com/go-playground/validator/v10 v10.14.0 // indirect
6769
github.com/goccy/go-json v0.10.2 // indirect
6870
github.com/gogo/protobuf v1.3.2 // indirect
71+
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
72+
github.com/golang-sql/sqlexp v0.1.0 // indirect
6973
github.com/golang/mock v1.6.0 // indirect
7074
github.com/golang/protobuf v1.5.3 // indirect
7175
github.com/golang/snappy v0.0.4 // indirect

go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,14 @@ github.com/Azure/azure-sdk-for-go v37.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9mo
415415
github.com/Azure/azure-sdk-for-go v51.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
416416
github.com/Azure/azure-sdk-for-go v56.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
417417
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
418+
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
418419
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
419420
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
421+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
420422
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM=
421423
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
422424
github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.0.1/go.mod h1:l3wvZkG9oW07GLBW5Cd0WwG5asOfJ8aqE8raUvNzLpk=
425+
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
423426
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
424427
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.7.1/go.mod h1:WcC2Tk6JyRlqjn2byvinNnZzgdXmZ1tOiIOWNh1u0uA=
425428
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.5.0/go.mod h1:9V2j0jn9jDEkCkv8w/bKTNppX/d0FVA1ud77xCIP4KA=
@@ -902,6 +905,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
902905
github.com/deepmap/oapi-codegen v1.3.6/go.mod h1:aBozjEveG+33xPiP55Iw/XbVkhtZHEGLq3nxlX0+hfU=
903906
github.com/deepmap/oapi-codegen v1.8.1/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
904907
github.com/denisenkom/go-mssqldb v0.0.0-20210411162248-d9abbec934ba/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
908+
github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
909+
github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw=
910+
github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo=
905911
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
906912
github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY=
907913
github.com/dghubble/go-twitter v0.0.0-20190719072343-39e5462e111f/go.mod h1:xfg4uS5LEzOj8PgZV7SQYRHbG7jPUnelEiaAVJxmhJE=
@@ -923,6 +929,7 @@ github.com/dimfeld/httptreemux v5.0.1+incompatible/go.mod h1:rbUlSV+CCpv/SuqUTP/
923929
github.com/distribution/distribution/v3 v3.0.0-20211118083504-a29a3c99a684/go.mod h1:UfCu3YXJJCI+IdnqGgYP82dk2+Joxmv+mUTVBES6wac=
924930
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
925931
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
932+
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
926933
github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
927934
github.com/docker/cli v20.10.11+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
928935
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
@@ -1227,7 +1234,10 @@ github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw
12271234
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
12281235
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
12291236
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
1237+
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
12301238
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
1239+
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
1240+
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
12311241
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
12321242
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
12331243
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
@@ -1999,6 +2009,7 @@ github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi
19992009
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
20002010
github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
20012011
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
2012+
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
20022013
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
20032014
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
20042015
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -2562,6 +2573,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
25622573
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
25632574
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
25642575
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
2576+
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
25652577
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
25662578
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
25672579
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
@@ -2698,6 +2710,7 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
26982710
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
26992711
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
27002712
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
2713+
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
27012714
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
27022715
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
27032716
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
@@ -3454,6 +3467,8 @@ gorm.io/driver/mysql v1.0.3 h1:+JKBYPfn1tygR1/of/Fh2T8iwuVwzt+PEJmKaXzMQXg=
34543467
gorm.io/driver/mysql v1.0.3/go.mod h1:twGxftLBlFgNVNakL7F+P/x9oYqoymG3YYT8cAfI9oI=
34553468
gorm.io/driver/postgres v1.2.1 h1:JDQKnF7MC51dgL09Vbydc5kl83KkVDlcXfSPJ+xhh68=
34563469
gorm.io/driver/postgres v1.2.1/go.mod h1:SHRZhu+D0tLOHV5qbxZRUM6kBcf3jp/kxPz2mYMTsNY=
3470+
gorm.io/driver/sqlserver v1.1.2 h1:MmOAvxnfqGMYS/I9jMwrMlc1+62S0clG3RUEvfEkTVo=
3471+
gorm.io/driver/sqlserver v1.1.2/go.mod h1:mEmVwRbwsgY+EmU7MWypjefdbX5uFgbE07kklGvLmcg=
34573472
gorm.io/gorm v1.20.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
34583473
gorm.io/gorm v1.22.0/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
34593474
gorm.io/gorm v1.22.2 h1:1iKcvyJnR5bHydBhDqTwasOkoo6+o4Ms5cknSt6qP7I=

helper/compose.store.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ services:
3636
- /etc/localtime:/etc/localtime:ro
3737
ports:
3838
- '27017:27017'
39+
sqlserver2019:
40+
image: mcr.microsoft.com/mssql/server:2019-latest
41+
volumes:
42+
- /etc/localtime:/etc/localtime:ro
43+
ports:
44+
- 1433:1433
45+
environment:
46+
- ACCEPT_EULA=Y
47+
- MSSQL_SA_PASSWORD=p@ssw0rd

helper/test-cover.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set -x
22
export DTM_DEBUG=1
33
echo "mode: count" > coverage.txt
4-
for store in redis boltdb mysql postgres; do
4+
for store in redis boltdb mysql postgres sqlserver; do
55
TEST_STORE=$store go test -failfast -covermode count -coverprofile=profile.out -coverpkg=github.com/dtm-labs/dtm/client/dtmcli,github.com/dtm-labs/dtm/client/dtmcli/dtmimp,github.com/dtm-labs/logger,github.com/dtm-labs/dtm/client/dtmgrpc,github.com/dtm-labs/dtm/client/workflow,github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp,github.com/dtm-labs/dtm/dtmsvr,dtmsvr/config,github.com/dtm-labs/dtm/dtmsvr/storage,github.com/dtm-labs/dtm/dtmsvr/storage/boltdb,github.com/dtm-labs/dtm/dtmsvr/storage/redis,github.com/dtm-labs/dtm/dtmsvr/storage/registry,github.com/dtm-labs/dtm/dtmsvr/storage/sql,github.com/dtm-labs/dtm/dtmutil -gcflags=-l ./... || exit 1
66
echo "TEST_STORE=$store finished"
77
if [ -f profile.out ]; then

0 commit comments

Comments
 (0)