Skip to content

Commit

Permalink
improve the UX of consul test (#702)
Browse files Browse the repository at this point in the history
The ut will crash with `SIGBUS: bus error` on Mac. Use `defer` solve
this problem.
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Sep 2, 2024
1 parent 7b103a2 commit f92a7b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions controller/registries/consul/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func TestReload(t *testing.T) {
patches.ApplyPrivateMethod(reflect.TypeOf(reg), "unsubscribe", func(_ *Consul, serviceName string) error {
return nil
})
defer patches.Reset()

err := reg.Reload(&consul.Config{})

Expand All @@ -381,8 +382,6 @@ func TestReload(t *testing.T) {
assert.Contains(t, reg.watchingServices, consulService{"test-service", "new-datacenter"})

reg.removeService(service)

patches.Reset()
}

func TestSubscribe(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions controller/tests/testdata/services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ services:
image: nacos/nacos-server:v1.4.6-slim
env_file:
- env/nacos.env
# all services should have this restart policy, so that we don't need to
# restart them manually after the dev machine reboots
restart: unless-stopped
ports:
- "8848:8848"
Expand All @@ -19,6 +21,7 @@ services:
service:
consul:
image: docker.m.daocloud.io/library/consul:1.15.4
restart: unless-stopped
ports:
- "8500:8500"
- "8600:8600"
Expand All @@ -27,6 +30,7 @@ services:
service:
consul1:
image: docker.m.daocloud.io/library/consul:1.15.4
restart: unless-stopped
ports:
- "8501:8500"
- "8601:8600"
Expand Down

0 comments on commit f92a7b8

Please sign in to comment.