Skip to content

Commit

Permalink
Make tests more resilient to slow emit stats
Browse files Browse the repository at this point in the history
Without the `eval` instructions, the stats were emitted "too slowly",
and some tests expect metrics to be available sooner. The update to the
Makefile ensures that stats are emitted "quickly". Those instructions
are borrowed from the CI scripts in bin/

The expectations in the test prevent a panic when the stats are not
emitted fast enough.
  • Loading branch information
Zerpet authored and michaelklishin committed Oct 30, 2024
1 parent 952237b commit 5f9eab4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ docker.rabbitmq:
docker exec -ti rabbithole_rabbitmq /bin/bash -c "rabbitmqctl set_permissions -p rabbit/hole guest \".*\" \".*\" \".*\""
docker exec -ti rabbithole_rabbitmq /bin/bash -c "rabbitmqctl set_permissions -p rabbit/hole policymaker \".*\" \".*\" \".*\""
docker exec -ti rabbithole_rabbitmq /bin/bash -c "rabbitmq-plugins enable rabbitmq_federation rabbitmq_federation_management rabbitmq_shovel rabbitmq_shovel_management"
docker exec -ti rabbithole_rabbitmq rabbitmqctl eval 'supervisor2:terminate_child(rabbit_mgmt_sup_sup, rabbit_mgmt_sup), application:set_env(rabbitmq_management, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_sup_sup:start_child().'
docker exec -ti rabbithole_rabbitmq rabbitmqctl eval 'supervisor2:terminate_child(rabbit_mgmt_agent_sup_sup, rabbit_mgmt_agent_sup), application:set_env(rabbitmq_management_agent, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_agent_sup_sup:start_child().'
4 changes: 4 additions & 0 deletions rabbithole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ var _ = Describe("RabbitMQ HTTP API client", func() {
Ω(q.Name).ShouldNot(Equal(""))
Ω(q.Node).ShouldNot(BeNil())
Ω(q.Durable).ShouldNot(BeNil())
Ω(q.MessagesDetails).ShouldNot(BeNil(),
"messages details are nil, this happens when stats are not emitted fast enough. Check docker.rabbitmq Make target for a hint to resolve this")
Ω(q.MessagesDetails.Samples[0]).ShouldNot(BeNil())
})
})
Expand Down Expand Up @@ -861,6 +863,8 @@ var _ = Describe("RabbitMQ HTTP API client", func() {
Ω(q.Node).ShouldNot(BeNil())
Ω(q.Vhost).Should(Equal(vh))
Ω(q.Durable).ShouldNot(BeNil())
Ω(q.MessagesDetails).ShouldNot(BeNil(),
"messages details are nil, this happens when stats are not emitted fast enough. Check docker.rabbitmq Make target for a hint to resolve this")
Ω(q.MessagesDetails.Samples[0]).ShouldNot(BeNil())

rmqc.DeleteQueue(vh, qn)
Expand Down

0 comments on commit 5f9eab4

Please sign in to comment.