From b17f78be987dd0955222d2be42716ba20f8999e8 Mon Sep 17 00:00:00 2001 From: Iori Mizutani Date: Sat, 26 Oct 2024 15:35:09 +0900 Subject: [PATCH 1/3] test: pass the test with go 1.23 --- .github/workflows/codecov.yml | 27 ++++++++++++++ .github/workflows/test.yml | 22 ++++++++++++ .travis.yml | 22 ------------ README.md | 23 ++++++------ cmd/ale-ec/main.go | 56 ++++++++++++++--------------- cmd/gosstrak-fc/main.go | 34 +++++++++--------- filtering/engine_factory.go | 3 +- filtering/engine_generator.go | 20 ++++++----- filtering/list_test.go | 64 ++++++++++++++++----------------- filtering/subscriptions_test.go | 13 ++++--- go.mod | 19 ++++++++++ go.sum | 31 ++++++++++++++++ tdt/core_test.go | 3 +- test/data/ecspec_sample.csv | 6 ---- 14 files changed, 206 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/codecov.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 test/data/ecspec_sample.csv diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..6e3a104 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,27 @@ +--- +name: Codecov + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.23" + - name: Run coverage + run: go test -race -coverprofile=coverage.txt -covermode=atomic + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f92cc94 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +--- +name: Test + +on: + pull_request: + branches: + - main + +jobs: + test: + strategy: + matrix: + go-version: [1.23.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Test + run: go test ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b1e7201..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: go - -sudo: false - -go: - - tip - -before_install: - # - go get github.com/mattn/goveralls - - go get -t -v ./... - -script: - #- go test -v ./... -covermode=count -coverprofile=coverage.out - #- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=coverage.out - - go test -v ./... -race -covermode=atomic -coverprofile=coverage.txt - -after_success: - - bash <(curl -s https://codecov.io/bash) - -env: - global: - secure: "dl4ClvS2K+g9nTbowtKpV/QkNxOXO/uhYe9e/zENvfaaRKBiK7S2N0QQk6ttREVOZnjYXCpx6DfnIhjkGE4smjn4niY2Dym6K0D88x6tavVUztHJpsOrJZAcM8jk+X9b371RmWznJaKRSj1juPPCvbT4C2yP/D8los10wXxVqEoSIsyAEAdOfb+qBIf2D3P9lYJVnSILa6SYx/smae5cVrbxTAOTRW0JyD2tt7D9E9NQvYwXQud5TkI5gRzwvhTSBPydz5WyqAQ6AdIUIxrlj7UFNrlbaR5awI4/gG2tH+3gBrOXPBEikpK/xCaVKd+LRvABs/VC/LU4XXhq3QFRqQBPXMLaiwKecXb7A2cfyomeTm0JfKfWcrBWqHa8UB/Hkr3X0g6RAdFatqL/+MqFGQ+H7GLkWo+B1+97pVPx0JWMj4HthIMnaopKI82GK6adQVZEcyRRODciZGz/BidsdqzitiEOxSFewSGunN/CtMM67PL472aeuiKT06Ei7Mc9URstY0xcvkensf03IGEHdFTms3tck+fBtqtigxlNNWLDqydXhRXDgzPdrMV9DKiiSO1YBB0AxzIAbwcvIbNUXhnPHgEoeoQic2md6v2PIjmCEligaNztPw25EMR1nAe0z3xlhMneQ3iPefd/uegeXj75gRtyn/wTQHOFb7NX+Yw=" diff --git a/README.md b/README.md index 75403c2..e5c1e1d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ -gosstrak-fc -== +# gosstrak-fc -[![Build Status](https://travis-ci.org/iomz/gosstrak.svg?branch=master)](https://travis-ci.org/iomz/gosstrak) - -[![codecov](https://codecov.io/gh/iomz/gosstrak/branch/master/graph/badge.svg)](https://codecov.io/gh/iomz/gosstrak) +[![Test](https://github.com/iomz/gosstrak/actions/workflows/test.yml/badge.svg)](https://github.com/iomz/gosstrak/actions/workflows/test.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/iomz/gosstrak)](https://goreportcard.com/report/github.com/iomz/gosstrak) +[![codecov](https://codecov.io/gh/iomz/gosstrak/branch/main/graph/badge.svg?token=fN1tyc6ssX)](https://codecov.io/gh/iomz/gosstrak) [![GoDoc](https://godoc.org/github.com/iomz/gosstrak?status.svg)](http://godoc.org/github.com/iomz/gosstrak) +[![License](https://img.shields.io/github/license/iomz/gosstrak.svg)](https://github.com/iomz/gosstrak/blob/main/LICENSE) + +## Stat Monitoring -Stat Monitoring --- gosstrak collects statistical metrics and write them to InfluxDB for visualization in Grafana. For quick start, use the docker-compose file and initialize the InfluxDB. @@ -22,8 +21,7 @@ For quick start, use the docker-compose file and initialize the InfluxDB. Then, run `gosstrak-fc` with `--enableStat` flag. -TDT Benchmark --- +## TDT Benchmark ```bash BenchmarkTranslate100Tags-32 10000 283151 ns/op 34096 B/op 1321 allocs/op @@ -38,11 +36,10 @@ BenchmarkTranslate900Tags-32 1000 2599413 ns/op BenchmarkTranslate1000Tags-32 1000 2938569 ns/op 342385 B/op 13247 allocs/op ``` -Author --- +## Author Iori Mizutani (iomz) -License --- +## License + See `LICENSE` file. diff --git a/cmd/ale-ec/main.go b/cmd/ale-ec/main.go index c38fc9c..4a2c505 100644 --- a/cmd/ale-ec/main.go +++ b/cmd/ale-ec/main.go @@ -6,13 +6,12 @@ package main import ( - "io" "log" "net" "os" - "github.com/docker/libchan/spdy" - "gopkg.in/alecthomas/kingpin.v2" + "github.com/alecthomas/kingpin/v2" + "github.com/moby/spdystream" ) // Notification is the struct to send/receive captured ID @@ -44,35 +43,36 @@ func main() { log.Print(err) break } - p, err := spdy.NewSpdyStreamProvider(c, true) + + spdyConn, err := spdystream.NewConnection(c, true) if err != nil { log.Print(err) - break + continue } - t := spdy.NewTransport(p) + go spdyConn.Serve(spdystream.MirrorStreamHandler) - go func() { - for { - receiver, err := t.WaitReceiveChannel() - if err != nil { - log.Print(err) - break - } + // go func() { + // for { + // receiver, err := t.WaitReceiveChannel() + // if err != nil { + // log.Print(err) + // break + // } - go func() { - for { - noti := &Notification{} - err := receiver.Receive(noti) - if err != nil { - if err != io.EOF { - log.Print(err) - } - break - } - log.Println(noti.ID) - } - }() - } - }() + // go func() { + // for { + // noti := &Notification{} + // err := receiver.Receive(noti) + // if err != nil { + // if err != io.EOF { + // log.Print(err) + // } + // break + // } + // log.Println(noti.ID) + // } + // }() + // } + // }() } } diff --git a/cmd/gosstrak-fc/main.go b/cmd/gosstrak-fc/main.go index 71dc2d2..ff9734e 100644 --- a/cmd/gosstrak-fc/main.go +++ b/cmd/gosstrak-fc/main.go @@ -15,11 +15,11 @@ import ( "runtime" "time" - "github.com/docker/libchan/spdy" + "github.com/alecthomas/kingpin/v2" "github.com/iomz/go-llrp" "github.com/iomz/gosstrak/filtering" "github.com/iomz/gosstrak/monitoring" - "gopkg.in/alecthomas/kingpin.v2" + "github.com/moby/spdystream" ) // Notification is the struct to send/receive captured ID @@ -189,27 +189,27 @@ func run() { log.Fatal(err) break } - p, err := spdy.NewSpdyStreamProvider(c, true) + spdyConn, err := spdystream.NewConnection(c, true) if err != nil { log.Print(err) continue } - t := spdy.NewTransport(p) + go spdyConn.Serve(spdystream.MirrorStreamHandler) - receiver, err := t.WaitReceiveChannel() - if err != nil { - log.Print(err) - continue - } + // receiver, err := t.WaitReceiveChannel() + // if err != nil { + // log.Print(err) + // continue + // } - mm := &filtering.ManagementMessage{} - err = receiver.Receive(mm) - if err != nil { - log.Print(err) - continue - } - log.Print(mm) - mc <- *mm + // mm := &filtering.ManagementMessage{} + // err = receiver.Receive(mm) + // if err != nil { + // log.Print(err) + // continue + // } + // log.Print(mm) + // mc <- *mm } log.Fatalln("managementListener closed in gosstrak-fc") }() diff --git a/filtering/engine_factory.go b/filtering/engine_factory.go index 87d83aa..0bf2319 100644 --- a/filtering/engine_factory.go +++ b/filtering/engine_factory.go @@ -6,6 +6,7 @@ package filtering import ( + "context" "log" "reflect" "sync" @@ -197,6 +198,6 @@ func (ef *EngineFactory) Run() { log.Println("[EngineFactory] initializing engines") for _, eg := range ef.productionSystem { // pass the cloned subscriptions - eg.FSM.Event("init", ef.currentSubscriptions) + eg.FSM.Event(context.Background(), "init", ef.currentSubscriptions) } } diff --git a/filtering/engine_generator.go b/filtering/engine_generator.go index 34dfc43..77f0d4b 100644 --- a/filtering/engine_generator.go +++ b/filtering/engine_generator.go @@ -6,9 +6,11 @@ package filtering import ( + "context" "log" "math" "time" + //"reflect" "github.com/iomz/go-llrp" @@ -54,11 +56,11 @@ func NewEngineGenerator(name string, ec EngineConstructor, statInterval int, mc {Name: "rebuild", Src: []string{"pending"}, Dst: "rebuilding"}, }, fsm.Callbacks{ - "enter_state": func(e *fsm.Event) { eg.enterState(e) }, - "enter_generating": func(e *fsm.Event) { eg.enterGenerating(e) }, - "enter_ready": func(e *fsm.Event) { eg.enterReady(e) }, - "enter_pending": func(e *fsm.Event) { eg.enterPending(e) }, - "enter_rebuilding": func(e *fsm.Event) { eg.enterRebuilding(e) }, + "enter_state": func(_ context.Context, e *fsm.Event) { eg.enterState(e) }, + "enter_generating": func(_ context.Context, e *fsm.Event) { eg.enterGenerating(e) }, + "enter_ready": func(_ context.Context, e *fsm.Event) { eg.enterReady(e) }, + "enter_pending": func(_ context.Context, e *fsm.Event) { eg.enterPending(e) }, + "enter_rebuilding": func(_ context.Context, e *fsm.Event) { eg.enterRebuilding(e) }, }, ) @@ -121,7 +123,7 @@ func (eg *EngineGenerator) enterGenerating(e *fsm.Event) { //log.Printf("[EngineGenerator] start generating %s engine", eg.Name) sub := e.Args[0].(Subscriptions) eg.Engine = AvailableEngines[eg.Name](sub) - eg.FSM.Event("deploy") + eg.FSM.Event(context.Background(), "deploy") }() } @@ -147,18 +149,18 @@ func (eg *EngineGenerator) enterRebuilding(e *fsm.Event) { }) */ } - eg.FSM.Event("deploy") + eg.FSM.Event(context.Background(), "deploy") } func (eg *EngineGenerator) enterReady(e *fsm.Event) { log.Printf("[EngineGenerator] finished gererating %s engine", eg.Name) eg.managementChannel <- ManagementMessage{ - Type: OnEngineGenerated, + Type: OnEngineGenerated, EngineGeneratorInstance: eg, } } func (eg *EngineGenerator) enterPending(e *fsm.Event) { // Wait until the engine finishes the current execution - eg.FSM.Event("rebuild", e.Args[0].(*ManagementMessage)) + eg.FSM.Event(context.Background(), "rebuild", e.Args[0].(*ManagementMessage)) } diff --git a/filtering/list_test.go b/filtering/list_test.go index 5bf0767..8f3387a 100644 --- a/filtering/list_test.go +++ b/filtering/list_test.go @@ -10,13 +10,13 @@ import ( "encoding/binary" "fmt" "math/rand" - "os" "reflect" "testing" "time" "github.com/iomz/go-llrp" "github.com/iomz/go-llrp/binutil" + _ "github.com/iomz/gosstrak/tdt" ) func TestList_MarshalBinary(t *testing.T) { @@ -26,20 +26,20 @@ func TestList_MarshalBinary(t *testing.T) { want []byte wantErr bool }{ - /* - { - "simple marshal", - &List{ - FilterLists{ - &ExactMatch{NewFilter("0011", 0), "http://localhost:8888/3"}, - &ExactMatch{NewFilter("00110000", 0), "http://localhost:8888/3-0"}, + /* + { + "simple marshal", + &List{ + FilterLists{ + ExactMatch{NewFilter("0011", 0), "http://localhost:8888/3"}, + ExactMatch{NewFilter("00110000", 0), "http://localhost:8888/3-0"}, + }, + tdt.NewCore(), }, - tdt.NewCore(), + []byte{}, + false, }, - []byte{}, - false, - }, - */ + */ } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -65,22 +65,22 @@ func TestList_UnmarshalBinary(t *testing.T) { args args wantErr bool }{ - /* - { - "simple unmarshal", - &List{ - FilterLists{ - &ExactMatch{NewFilter("0011", 0), "http://localhost:8888/3"}, - &ExactMatch{NewFilter("00110000", 0), "http://localhost:8888/3-0"}, + /* + { + "simple unmarshal", + &List{ + FilterLists{ + &ExactMatch{NewFilter("0011", 0), "http://localhost:8888/3"}, + &ExactMatch{NewFilter("00110000", 0), "http://localhost:8888/3-0"}, + }, + tdt.NewCore(), }, - tdt.NewCore(), - }, - args{ - []byte{}, + args{ + []byte{}, + }, + false, }, - false, - }, - */ + */ } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -160,11 +160,11 @@ func TestList_Name(t *testing.T) { func benchmarkFilterListNTagsNSubs(nTags int, nSubs int, b *testing.B) { // build the engine - sub := LoadSubscriptionsFromCSVFile(os.Getenv("GOPATH") + fmt.Sprintf("/src/github.com/iomz/gosstrak/test/data/bench-%vsubs-ecspec.csv", nSubs)) + sub := LoadSubscriptionsFromCSVFile(fmt.Sprintf("test/data/bench-%vsubs-ecspec.csv", nSubs)) listEngine := NewList(sub) // prepare the workload - largeTagsGOB := os.Getenv("GOPATH") + fmt.Sprintf("/src/github.com/iomz/gosstrak/test/data/bench-%vsubs-tags.gob", nSubs) + largeTagsGOB := fmt.Sprintf("test/data/bench-%vsubs-tags.gob", nSubs) var largeTags llrp.Tags binutil.Load(largeTagsGOB, &largeTags) @@ -227,8 +227,8 @@ func BenchmarkFilterList100Tags1000Subs(b *testing.B) { benchmarkFilterListNTags func benchmarkAddListNSubs(nSubs int, b *testing.B) { // build the engine - sub := LoadSubscriptionsFromCSVFile(os.Getenv("GOPATH") + fmt.Sprintf("/src/github.com/iomz/gosstrak/test/data/bench-%vsubs-ecspec.csv", nSubs)) - extsub := LoadSubscriptionsFromCSVFile(os.Getenv("GOPATH") + "/src/github.com/iomz/gosstrak/test/data/ecspec.csv") + sub := LoadSubscriptionsFromCSVFile(fmt.Sprintf("test/data/bench-%vsubs-ecspec.csv", nSubs)) + extsub := LoadSubscriptionsFromCSVFile("test/data/ecspec.csv") listEngine := NewList(sub) rand.Seed(time.Now().UTC().UnixNano()) b.ResetTimer() @@ -258,7 +258,7 @@ func BenchmarkAddList1000Subs(b *testing.B) { benchmarkAddListNSubs(1000, b) } func benchmarkDeleteListNSubs(nSubs int, b *testing.B) { // build the engine - sub := LoadSubscriptionsFromCSVFile(os.Getenv("GOPATH") + fmt.Sprintf("/src/github.com/iomz/gosstrak/test/data/bench-%vsubs-ecspec.csv", nSubs)) + sub := LoadSubscriptionsFromCSVFile(fmt.Sprintf("test/data/bench-%vsubs-ecspec.csv", nSubs)) listEngine := NewList(sub) rand.Seed(time.Now().UTC().UnixNano()) b.ResetTimer() diff --git a/filtering/subscriptions_test.go b/filtering/subscriptions_test.go index 7909bc1..f94fdbb 100644 --- a/filtering/subscriptions_test.go +++ b/filtering/subscriptions_test.go @@ -9,7 +9,6 @@ import ( "bytes" "encoding/gob" "fmt" - "os" "reflect" "testing" ) @@ -122,10 +121,10 @@ func TestSubscriptions_ToByteSubscriptions(t *testing.T) { "http://localhost:8888/sscc": []string{"urn:epc:pat:sscc-96:3.00039579721"}, }, ByteSubscriptions{ - "0011000001111011110011111100100011011101100101111000101011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sgtin"}, - "001100010110010000000000010010110111111000001001001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sscc"}, - "001100110111100001111000100100000000000000000000000000000100000000000000000000000000000000000001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/grai"}, - "0011010001100100000100010000010000111100011000100001010010011100100011110001110010001011000011011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/giai"}, + "0011000001111011110011111100100011011101100101111000101011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sgtin"}, + "001100010110010000000000010010110111111000001001001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sscc"}, + "001100110111100001111000100100000000000000000000000000000100000000000000000000000000000000000001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/grai"}, + "0011010001100100000100010000010000111100011000100001010010011100100011110001110010001011000011011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/giai"}, "110010110101010011010101001110000001000010000011110000010100001000000001001110001011110000011001001111010101110000000110001111010010110000010010000101000001000100001001001110000111110000010100001000001001010011110001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/17365"}, "110111000010001101010100010010": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/17363"}, }, @@ -158,7 +157,7 @@ func TestLoadSubscriptionsFromCSVFile(t *testing.T) { }{ { "ecspec_sample.csv", - args{os.Getenv("GOPATH") + "/src/github.com/iomz/gosstrak/test/data/ecspec_sample.csv"}, + args{"ecspec_sample.csv"}, Subscriptions{ "http://localhost:8888/grai": []string{"urn:epc:pat:grai-96:3.123456.1.1"}, "http://localhost:8888/17365": []string{"urn:epc:pat:iso17365:25S.UN.ABC.0THANK0YOU0FOR0READING0THIS1"}, @@ -186,7 +185,7 @@ func TestLoadSubscriptionsFromCSVFile(t *testing.T) { func benchmarkLoadNSubs(nSubs int, b *testing.B) { var sub Subscriptions for i := 0; i < b.N; i++ { - sub = LoadSubscriptionsFromCSVFile(os.Getenv("GOPATH") + fmt.Sprintf("/src/github.com/iomz/gosstrak/test/data/bench-%vsubs-ecspec.csv", nSubs)) + sub = LoadSubscriptionsFromCSVFile(fmt.Sprintf("test/data/bench-%vsubs-ecspec.csv", nSubs)) } b.StopTimer() diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3f98c9a --- /dev/null +++ b/go.mod @@ -0,0 +1,19 @@ +module github.com/iomz/gosstrak + +go 1.23.2 + +require ( + github.com/alecthomas/kingpin/v2 v2.4.0 + github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c + github.com/iomz/go-llrp v0.0.0-20241026054309-699260a49032 + github.com/looplab/fsm v1.0.2 + gopkg.in/alecthomas/kingpin.v2 v2.2.6 +) + +require github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect + +require ( + github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect + github.com/moby/spdystream v0.5.0 + github.com/xhit/go-str2duration/v2 v2.1.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5ab1122 --- /dev/null +++ b/go.sum @@ -0,0 +1,31 @@ +github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= +github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c h1:qSHzRbhzK8RdXOsAdfDgO49TtqC1oZ+acxPrkfTxcCs= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/iomz/go-llrp v0.0.0-20241026054309-699260a49032 h1:3rg+u9QeVXGQaTXa569gvEGjCIdBy1mbDwxwde+f9HM= +github.com/iomz/go-llrp v0.0.0-20241026054309-699260a49032/go.mod h1:OvPX5QaELjVbp80tpZk1rrW0l6hUDT5CvkpCQ7bXkCk= +github.com/looplab/fsm v1.0.2 h1:f0kdMzr4CRpXtaKKRUxwLYJ7PirTdwrtNumeLN+mDx8= +github.com/looplab/fsm v1.0.2/go.mod h1:PmD3fFvQEIsjMEfvZdrCDZ6y8VwKTwWNjlpEr6IKPO4= +github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU= +github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= +github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tdt/core_test.go b/tdt/core_test.go index 0298f79..5cad9eb 100644 --- a/tdt/core_test.go +++ b/tdt/core_test.go @@ -9,7 +9,6 @@ import ( "bytes" "encoding/binary" "math/rand" - "os" "testing" "github.com/iomz/go-llrp" @@ -269,7 +268,7 @@ func Test_core_Translate(t *testing.T) { } func benchmarkTranslateNTags(nTags int, b *testing.B) { - largeTagsGOB := os.Getenv("GOPATH") + "/src/github.com/iomz/gosstrak/test/data/bench-100subs-tags.gob" + largeTagsGOB := "test/data/bench-100subs-tags.gob" // load up the tags from the file var largeTags llrp.Tags binutil.Load(largeTagsGOB, &largeTags) diff --git a/test/data/ecspec_sample.csv b/test/data/ecspec_sample.csv deleted file mode 100644 index b049eac..0000000 --- a/test/data/ecspec_sample.csv +++ /dev/null @@ -1,6 +0,0 @@ -http://localhost:8888/giai,urn:epc:pat:giai-96:3.02283922192.45325296932379 -http://localhost:8888/17363,urn:epc:pat:iso17363:7B.MTR -http://localhost:8888/sgtin,urn:epc:pat:sgtin-96:3.999203.7757355 -http://localhost:8888/sscc,urn:epc:pat:sscc-96:3.00039579721 -http://localhost:8888/grai,urn:epc:pat:grai-96:3.123456.1.1 -http://localhost:8888/17365,urn:epc:pat:iso17365:25S.UN.ABC.0THANK0YOU0FOR0READING0THIS1 From 523e5f45ac5797750c65cc2eac15795f09da5c44 Mon Sep 17 00:00:00 2001 From: Iori Mizutani Date: Sat, 26 Oct 2024 15:40:03 +0900 Subject: [PATCH 2/3] test: add testdata --- testdata/ecspec_sample.csv | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 testdata/ecspec_sample.csv diff --git a/testdata/ecspec_sample.csv b/testdata/ecspec_sample.csv new file mode 100644 index 0000000..b049eac --- /dev/null +++ b/testdata/ecspec_sample.csv @@ -0,0 +1,6 @@ +http://localhost:8888/giai,urn:epc:pat:giai-96:3.02283922192.45325296932379 +http://localhost:8888/17363,urn:epc:pat:iso17363:7B.MTR +http://localhost:8888/sgtin,urn:epc:pat:sgtin-96:3.999203.7757355 +http://localhost:8888/sscc,urn:epc:pat:sscc-96:3.00039579721 +http://localhost:8888/grai,urn:epc:pat:grai-96:3.123456.1.1 +http://localhost:8888/17365,urn:epc:pat:iso17365:25S.UN.ABC.0THANK0YOU0FOR0READING0THIS1 From 1f6ac166018742b3439066d20b07e7620082b022 Mon Sep 17 00:00:00 2001 From: Iori Mizutani Date: Sat, 26 Oct 2024 15:43:06 +0900 Subject: [PATCH 3/3] fix: correct the path to testdata --- .github/workflows/codecov.yml | 2 +- .gitignore | 1 + filtering/subscriptions_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 6e3a104..2f617b8 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -18,7 +18,7 @@ jobs: with: go-version: "1.23" - name: Run coverage - run: go test -race -coverprofile=coverage.txt -covermode=atomic + run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.gitignore b/.gitignore index 7c496e9..9900a12 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ test/* *.csv *.json +coverage.txt # exp dir exp/ diff --git a/filtering/subscriptions_test.go b/filtering/subscriptions_test.go index f94fdbb..8d7b33c 100644 --- a/filtering/subscriptions_test.go +++ b/filtering/subscriptions_test.go @@ -157,7 +157,7 @@ func TestLoadSubscriptionsFromCSVFile(t *testing.T) { }{ { "ecspec_sample.csv", - args{"ecspec_sample.csv"}, + args{"../testdata/ecspec_sample.csv"}, Subscriptions{ "http://localhost:8888/grai": []string{"urn:epc:pat:grai-96:3.123456.1.1"}, "http://localhost:8888/17365": []string{"urn:epc:pat:iso17365:25S.UN.ABC.0THANK0YOU0FOR0READING0THIS1"},