From fcd43ece7cf53d32f9b8bd13fe5c701f8eb7c3a4 Mon Sep 17 00:00:00 2001 From: Kyle Klauss Date: Wed, 8 Nov 2023 14:58:29 -0600 Subject: [PATCH] Added MongoStore to Test Server --- .github/workflows/ci.yaml | 11 +++++++++-- _test/test-server/main.go | 13 +++++++++++++ filestore.go | 1 - 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b7f5edb4..d589126a6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,8 +38,10 @@ jobs: matrix: go: [1.21] store-type: + - - memory - file + - mongo fix-version: - - fix40 @@ -65,10 +67,15 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: '3.0' - - name: Test + - name: Unit test + env: + FIX_TEST: ${{ matrix.fix-version }} + STORE_TYPE: ${{ matrix.store-type }} + run: if [ -z $FIX_TEST ] && [ -z $STORE_TYPE ]; then make build-src && make test-ci; fi + - name: Acceptance test env: GO111MODULE: on MONGODB_TEST_CXN: mongodb://localhost:27017 FIX_TEST: ${{ matrix.fix-version }} STORE_TYPE: ${{ matrix.store-type }} - run: if [ -z $FIX_TEST ]; then make build-src && make test-ci; else make generate-ci && make build && make $FIX_TEST; fi + run: if [ $FIX_TEST ] && [ $STORE_TYPE ]; then make generate-ci && make build && make $FIX_TEST; fi diff --git a/_test/test-server/main.go b/_test/test-server/main.go index 614b487e8..e8a0eff3c 100644 --- a/_test/test-server/main.go +++ b/_test/test-server/main.go @@ -139,10 +139,23 @@ func main() { var acceptor *quickfix.Acceptor switch strings.ToUpper(storeType) { + case "MONGO": + mongoDbCxn := "mongodb://localhost:27017" + mongoDatabase := "automated_testing_database" + mongoReplicaSet := "replicaset" + + appSettings.GlobalSettings().Set(config.MongoStoreConnection, mongoDbCxn) + appSettings.GlobalSettings().Set(config.MongoStoreDatabase, mongoDatabase) + appSettings.GlobalSettings().Set(config.MongoStoreReplicaSet, mongoReplicaSet) + appSettings.GlobalSettings().Set(config.DynamicSessions, "Y") + + acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMongoStoreFactory(appSettings), appSettings, fileLogFactory) case "FILE": fileStoreRootPath := path.Join(os.TempDir(), fmt.Sprintf("FileStoreTestSuite-%d", os.Getpid())) fileStorePath := path.Join(fileStoreRootPath, fmt.Sprintf("%d", time.Now().UnixNano())) appSettings.GlobalSettings().Set(config.FileStorePath, fileStorePath) + appSettings.GlobalSettings().Set(config.DynamicSessions, "Y") + acceptor, err = quickfix.NewAcceptor(app, quickfix.NewFileStoreFactory(appSettings), appSettings, fileLogFactory) case "MEMORY": acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory) diff --git a/filestore.go b/filestore.go index f5ca5d38a..b54e8964f 100644 --- a/filestore.go +++ b/filestore.go @@ -76,7 +76,6 @@ func (f fileStoreFactory) Create(sessionID SessionID) (msgStore MessageStore, er dirname, err := sessionSettings.Setting(config.FileStorePath) if err != nil { - dirname, err = globalSettings.Setting(config.FileStorePath) if err != nil { return nil, err }