From d7b8949ac29b539c8c8ef1f087de8b304a816e75 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Mon, 7 Feb 2022 17:52:14 +0800 Subject: [PATCH] add other StoreHost support --- test/busi/base_types.go | 5 ++++- test/busi/utils.go | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/busi/base_types.go b/test/busi/base_types.go index ced598a..b2a4a32 100644 --- a/test/busi/base_types.go +++ b/test/busi/base_types.go @@ -17,10 +17,13 @@ import ( "go.mongodb.org/mongo-driver/bson" ) +// StoreHost examples will connect to dtm.pub; tests will connect to localhost +var StoreHost = "localhost" + // BusiConf 1 var BusiConf = dtmcli.DBConf{ Driver: "mysql", - Host: "localhost", + Host: StoreHost, Port: 3306, User: "root", } diff --git a/test/busi/utils.go b/test/busi/utils.go index b144e70..8f68373 100644 --- a/test/busi/utils.go +++ b/test/busi/utils.go @@ -5,7 +5,6 @@ import ( "database/sql" "encoding/json" "fmt" - "os" "strings" sync "sync" "time" @@ -130,7 +129,7 @@ func RedisGet() *redis.Client { once.Do(func() { logger.Debugf("connecting to client redis") rdb = redis.NewClient(&redis.Options{ - Addr: dtmimp.OrString(os.Getenv("BUSI_REDIS"), "localhost:6379"), + Addr: fmt.Sprintf("%s:6379", StoreHost), Username: "root", Password: "", }) @@ -146,8 +145,9 @@ var ( // MongoGet get mongo client func MongoGet() *mongo.Client { mongoOnce.Do(func() { + uri := fmt.Sprintf("mongodb://%s:27017/?retryWrites=false", StoreHost) ctx := context.Background() - client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017/?retryWrites=false")) + client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri)) dtmimp.E2P(err) mongoc = client })