Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

agent: make TestUnitStatePublisher wait for each goroutine to finish - #1651

Merged
dongsupark merged 1 commit into
coreos:masterfrom
endocode:dongsu/unit-publisher-wait-each
Jul 27, 2016
Merged

agent: make TestUnitStatePublisher wait for each goroutine to finish#1651
dongsupark merged 1 commit into
coreos:masterfrom
endocode:dongsu/unit-publisher-wait-each

Conversation

@dongsupark

Copy link
Copy Markdown

TestUnitStatePublisherRunWithDelays() has not exactly initiated each service sequentially, but let it run in parallel. That's why the unit test sometimes fails with messages like:

--- FAIL: TestUnitStatePublisherRunWithDelays-2 (0.00 seconds)
    unit_state_test.go:626: bad published UnitStates:
    got []string{"0.service", "2.service", "4.service", "1.service", "3.service"},
    want []string{"0.service", "1.service", "2.service", "3.service", "4.service"}
    unit_state_test.go:640: bad published UnitStates:
    got []string{"0.service", "2.service", "4.service", "1.service", "3.service"},
    want []string{"0.service", "1.service", "2.service", "3.service", "4.service"}
    unit_state_test.go:658: bad UnitStates:
    got []string{"foo.service", "baz.service", "bar.service"},
    want []string{"foo.service", "bar.service", "baz.service"}

To fix that, for each goroutine, check that the channel toPublish contains the expected unit name.

Suggested by @jonboulle
Fixes #1248

TestUnitStatePublisherRunWithDelays() has not exactly initiated each
service sequentially, but let it run in parallel. That's why the unit
test sometimes fails with messages like:

```
--- FAIL: TestUnitStatePublisherRunWithDelays-2 (0.00 seconds)
    unit_state_test.go:626: bad published UnitStates:
    got []string{"0.service", "2.service", "4.service", "1.service", "3.service"},
    want []string{"0.service", "1.service", "2.service", "3.service", "4.service"}
    unit_state_test.go:640: bad published UnitStates:
    got []string{"0.service", "2.service", "4.service", "1.service", "3.service"},
    want []string{"0.service", "1.service", "2.service", "3.service", "4.service"}
    unit_state_test.go:658: bad UnitStates:
    got []string{"foo.service", "baz.service", "bar.service"},
    want []string{"foo.service", "bar.service", "baz.service"}
```

To fix that, for each goroutine, check that the channel toPublish
contains the expected unit name.

Suggested by @jonboulle
Fixes coreos#1248
@dongsupark
dongsupark force-pushed the dongsu/unit-publisher-wait-each branch from 00b4aa1 to 8a8d690 Compare July 26, 2016 15:34
@dongsupark
dongsupark merged commit 063e74f into coreos:master Jul 27, 2016
@dongsupark
dongsupark deleted the dongsu/unit-publisher-wait-each branch July 27, 2016 12:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transient test failures

1 participant