Skip to content

Commit

Permalink
try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 8, 2024
1 parent 19c796a commit d2bd693
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
go: ["1.20", "1.21", "1.22"]
go: ["1.21"]

steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 12 additions & 6 deletions node_funcs_master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,21 @@ func TestNodeMasterGetTopics(t *testing.T) {
require.NoError(t, err)
defer n.Close()

res, err := n.MasterGetTopics()
require.NoError(t, err)
for {
res, err := n.MasterGetTopics()
require.NoError(t, err)

topic, ok := res["/myns/test_topic"]
require.True(t, ok)
topic, ok := res["/myns/test_topic"]
if !ok {
time.Sleep(100 * time.Millisecond)
continue
}

require.Equal(t, "nodepub/Mymsg", topic.Type)
require.Equal(t, "nodepub/Mymsg", topic.Type)

require.Equal(t, map[string]struct{}{"/myns/nodepub": {}}, topic.Publishers)
require.Equal(t, map[string]struct{}{"/myns/nodepub": {}}, topic.Publishers)
break
}
}

func TestNodeMasterGetServices(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ func newContainer(t *testing.T, name string, masterIP string) *container {
err := exec.Command(cmd[0], cmd[1:]...).Run()
require.NoError(t, err)

go func() {
cmd := exec.Command("docker", "logs", "-f", "goroslib-test-"+name)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start()

Check failure on line 85 in node_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `cmd.Start` is not checked (errcheck)
}()

// wait for node initialization
time.Sleep(1 * time.Second)

Expand Down
4 changes: 2 additions & 2 deletions scripts/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ test-pkg:
test-root:
$(foreach IMG,$(shell echo testimages/*/ | xargs -n1 basename), \
docker build -q testimages/$(IMG) -t goroslib-test-$(IMG)$(NL))
go test -v -race -coverprofile=coverage-root.txt .
go test -v -race -coverprofile=coverage-root.txt -run=NodeMasterGetTopics .

test-nodocker: test-cmd test-examples test-pkg test-root
test-nodocker: test-root

define DOCKERFILE_TEST
FROM $(BASE_IMAGE)
Expand Down

0 comments on commit d2bd693

Please sign in to comment.