Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileStore TestServer #591

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
strategy:
matrix:
go: [1.21]
store-type:
- memory
- file
fix-version:
-
- fix40
Expand Down Expand Up @@ -67,4 +70,5 @@ jobs:
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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ lint: linters-install
build-test-srv:
cd _test; go build -o echo_server ./test-server/
fix40:
cd _test; ./runat.sh $@.cfg 5001 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5001 $(STORE_TYPE) "definitions/server/$@/*.def"
fix41:
cd _test; ./runat.sh $@.cfg 5002 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5002 $(STORE_TYPE) "definitions/server/$@/*.def"
fix42:
cd _test; ./runat.sh $@.cfg 5003 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5003 $(STORE_TYPE) "definitions/server/$@/*.def"
fix43:
cd _test; ./runat.sh $@.cfg 5004 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5004 $(STORE_TYPE) "definitions/server/$@/*.def"
fix44:
cd _test; ./runat.sh $@.cfg 5005 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5005 $(STORE_TYPE) "definitions/server/$@/*.def"
fix50:
cd _test; ./runat.sh $@.cfg 5006 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5006 $(STORE_TYPE) "definitions/server/$@/*.def"
fix50sp1:
cd _test; ./runat.sh $@.cfg 5007 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5007 $(STORE_TYPE) "definitions/server/$@/*.def"
fix50sp2:
cd _test; ./runat.sh $@.cfg 5008 "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5008 $(STORE_TYPE) "definitions/server/$@/*.def"

ACCEPT_SUITE=fix40 fix41 fix42 fix43 fix44 fix50 fix50sp1 fix50sp2
accept: $(ACCEPT_SUITE)
Expand Down
5 changes: 3 additions & 2 deletions _test/runat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

CFG=$1
PORT=$2
TESTS=$3
STORETYPE=$3
TESTS=$4

./echo_server $CFG &
./echo_server $CFG $STORETYPE &
pid=$!

ruby -I. Runner.rb 127.0.0.1 $PORT $TESTS
Expand Down
20 changes: 19 additions & 1 deletion _test/test-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import (
"log"
"os"
"os/signal"
"path"
"strings"
"time"

"github.com/quickfixgo/quickfix"
"github.com/quickfixgo/quickfix/config"
field "github.com/quickfixgo/quickfix/gen/field"
tag "github.com/quickfixgo/quickfix/gen/tag"
)
Expand Down Expand Up @@ -131,7 +135,21 @@ func main() {
return
}

acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
storeType := os.Args[2]

var acceptor *quickfix.Acceptor
switch strings.ToUpper(storeType) {
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)
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewFileStoreFactory(appSettings), appSettings, fileLogFactory)
case "MEMORY":
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
default:
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
}

if err != nil {
fmt.Println("Unable to create Acceptor: ", err)
return
Expand Down
5 changes: 4 additions & 1 deletion filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func (f fileStoreFactory) Create(sessionID SessionID) (msgStore MessageStore, er

dirname, err := sessionSettings.Setting(config.FileStorePath)
if err != nil {
return nil, err
dirname, err = globalSettings.Setting(config.FileStorePath)
if err != nil {
return nil, err
}
}
var fsync bool
if sessionSettings.HasSetting(config.FileStoreSync) {
Expand Down