Skip to content

Commit

Permalink
Merge pull request dtm-labs#170 from Leizhengzi/main
Browse files Browse the repository at this point in the history
fix bench ci error and enable ci lint github action
  • Loading branch information
yedf2 authored Jan 7, 2022
2 parents a44ab00 + b725c21 commit b70b188
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ jobs:
run: |
go mod download
- name: Run CI lint
run: make lint

- name: Run test cover
run: sh helper/test-cover.sh
run: sh helper/test-cover.sh
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
run:
deadline: 5m
# skip-dirs:
# - test
# - examples
skip-dirs:
- test
# - bench

linter-settings:
goconst:
Expand Down
2 changes: 1 addition & 1 deletion bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ usage:
`

func hintAndExit() {
fmt.Printf(usage)
fmt.Print(usage)
os.Exit(0)
}

Expand Down
19 changes: 12 additions & 7 deletions bench/svr/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func reloadData() {
logger.Debugf("%d users inserted. used: %dms", total, time.Since(began).Milliseconds())
}

var uidCounter int32 = 0
var mode string = ""
var sqls int = 1
var uidCounter int32
var mode string
var sqls = 1

// PrepareBenchDB prepares db data for bench
func PrepareBenchDB() {
db := pdbGet()
_, err := dtmimp.DBExec(db, "drop table if exists dtm_busi.user_account_log")
Expand All @@ -95,7 +96,9 @@ func StartSvr() {
app := dtmutil.GetGinApp()
benchAddRoute(app)
logger.Debugf("bench listening at %d", benchPort)
go app.Run(fmt.Sprintf(":%s", benchPort))
go func() {
_ = app.Run(fmt.Sprintf(":%s", benchPort))
}()
}

func qsAdjustBalance(uid int, amount int, c *gin.Context) (interface{}, error) {
Expand All @@ -116,11 +119,13 @@ func qsAdjustBalance(uid int, amount int, c *gin.Context) (interface{}, error) {
if strings.Contains(mode, "barrier") {
barrier, err := dtmcli.BarrierFromQuery(c.Request.URL.Query())
logger.FatalIfError(err)
barrier.Call(txGet(), f)
err = barrier.Call(txGet(), f)
logger.FatalIfError(err)
} else {
tx := txGet()
f(tx)
err := tx.Commit()
err := f(tx)
logger.FatalIfError(err)
err = tx.Commit()
logger.FatalIfError(err)
}

Expand Down

0 comments on commit b70b188

Please sign in to comment.