Skip to content

Commit 2b31e96

Browse files
committed
Timeout is added as the function parameters to the checkWithTimeout method
1 parent 7fba0a1 commit 2b31e96

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,6 @@ jobs:
9191
export PATH=$PATH:$GOPATH/bin
9292
mkdir $GOPATH/log
9393
go get github.com/DATA-DOG/godog/cmd/godog
94+
# Disable TensorFlow warnings wich pollute example-service log file
95+
export TF_CPP_MIN_LOG_LEVEL=2
9496
godog

publish_example_service_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ethereumNetworkIsRunningOnPort(port int) error {
4343
return err
4444
}
4545

46-
exists, err := checkWithTimeout(checkFileContainsStrings)
46+
exists, err := checkWithTimeout(5000, 500, checkFileContainsStrings)
4747
if err != nil {
4848
return err
4949
}
@@ -128,7 +128,7 @@ func ipfsIsRunning(portAPI int, portGateway int) error {
128128
"server listening on " + addressAPI,
129129
"server listening on " + addressGateway,
130130
}
131-
exists, err := checkWithTimeout(checkFileContainsStrings)
131+
exists, err := checkWithTimeout(5000, 500, checkFileContainsStrings)
132132

133133
if err != nil {
134134
return err
@@ -181,7 +181,7 @@ default_eth_rpc_endpoint = http://localhost:` + toString(endpointEthereumRPC)
181181

182182
outputFile = snetConfigFile
183183
outputContainsStrings = []string{"session"}
184-
exists, e := checkWithTimeout(checkFileContainsStrings)
184+
exists, e := checkWithTimeout(5000, 500, checkFileContainsStrings)
185185

186186
if !exists {
187187
return errors.New("snet config file is not created: " + snetConfigFile)
@@ -332,7 +332,7 @@ func exampleserviceIsRunWithSnetdaemon(table *gherkin.DataTable) error {
332332
return err
333333
}
334334

335-
_, err = checkWithTimeout(checkFileContainsStrings)
335+
_, err = checkWithTimeout(5000, 500, checkFileContainsStrings)
336336

337337
if err != nil {
338338
return err

utils.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,19 @@ func getCmd(execCommad ExecCommand) (*exec.Cmd, error) {
171171
return cmd, nil
172172
}
173173

174-
func checkWithTimeout(f checkWithTimeoutType) (bool, error) {
175-
timeout := time.After(5 * time.Second)
176-
tick := time.Tick(500 * time.Millisecond)
174+
// timeout and tick are measurd in milliseconds units
175+
func checkWithTimeout(timeout time.Duration,
176+
tick time.Duration,
177+
f checkWithTimeoutType) (bool, error) {
178+
179+
_timeout := time.After(timeout * time.Millisecond)
180+
_tick := time.Tick(tick * time.Millisecond)
177181

178182
for {
179183
select {
180-
case <-timeout:
184+
case <-_timeout:
181185
return false, errors.New("timed out")
182-
case <-tick:
186+
case <-_tick:
183187
ok, err := f()
184188
if err != nil {
185189
return false, err

0 commit comments

Comments
 (0)