Skip to content

Commit

Permalink
Ocpp: reduce timeouts during testing (evcc-io#7342)
Browse files Browse the repository at this point in the history
Identifies test using build tags until golang/go#52600 becomes available.
  • Loading branch information
andig authored Apr 10, 2023
1 parent 440fdf7 commit 7803937
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ toml:

test::
@echo "Running testsuite"
CGO_ENABLED=0 go test $(BUILD_TAGS) ./...
CGO_ENABLED=0 go test $(BUILD_TAGS),test ./...

porcelain::
gofmt -w -l $$(find . -name '*.go')
Expand Down
4 changes: 2 additions & 2 deletions charger/ocpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
}{
Connector: 1,
IdTag: defaultIdTag,
ConnectTimeout: 2 * time.Minute,
Timeout: 2 * time.Minute,
ConnectTimeout: ocppConnectTimeout,
Timeout: ocppTimeout,
}

if err := util.DecodeOther(other, &cc); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions charger/ocpp_timeout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !test

package charger

import "time"

const (
ocppConnectTimeout = 5 * time.Minute
ocppTimeout = 2 * time.Minute
)
10 changes: 10 additions & 0 deletions charger/ocpp_timeouttest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build test

package charger

import "time"

const (
ocppConnectTimeout = 1 * time.Second
ocppTimeout = 1 * time.Second
)
10 changes: 10 additions & 0 deletions charger/tags_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !test

package charger

import "log"

// TODO remove when https://github.com/golang/go/issues/52600 becomes available
func init() {
log.Fatal("running a test without -tags test")
}
4 changes: 4 additions & 0 deletions util/templates/includes/ocpp.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ connector: {{ .connector }}
{{- if .idtag }}
idtag: {{ .idtag }}
{{- end }}
{{- if ne .connecttimeout "5m" }}
connecttimeout: {{ .connecttimeout }}
{{- end }}
{{- if ne .timeout "2m" }}
timeout: {{ .timeout }}
{{- end }}
{{- end }}

0 comments on commit 7803937

Please sign in to comment.