Skip to content

Commit

Permalink
Adapt to the (more) asynchornous event processing nature in rabbitmq/…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Nov 24, 2016
1 parent 57c1db4 commit b88a9ea
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/test/groovy/com/rabbitmq/http/client/ClientSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class ClientSpec extends Specification {
then: "the response is converted successfully"
res.getNode().startsWith("rabbit@")
res.getErlangVersion() != null
res.getStatisticsDbNode().startsWith("rabbit@")

final msgStats = res.getMessageStats()
msgStats.basicPublish >= 0
Expand Down Expand Up @@ -132,6 +131,7 @@ class ClientSpec extends Specification {
final conn = openConnection()

when: "client retrieves a list of connections"
awaitEventPropagation()
final res = client.getConnections()
final fst = res.first()

Expand All @@ -148,6 +148,7 @@ class ClientSpec extends Specification {
final conn = openConnection()

when: "client retrieves connection info with the correct name"
awaitEventPropagation()
final xs = client.getConnections()
final x = client.getConnection(xs.first().name)

Expand All @@ -164,6 +165,7 @@ class ClientSpec extends Specification {
final conn = openConnection(s)

when: "client retrieves connection info with the correct name"
awaitEventPropagation()
final xs = client.getConnections()
final x = client.getConnection(xs.first().name)

Expand Down Expand Up @@ -209,6 +211,7 @@ class ClientSpec extends Specification {
final ch = conn.createChannel()

when: "client lists channels"
awaitEventPropagation()
final chs = client.getChannels()
final chi = chs.first()

Expand All @@ -227,6 +230,7 @@ class ClientSpec extends Specification {
final ch = conn.createChannel()

when: "client lists channels on that connection"
awaitEventPropagation()
final cn = client.getConnections().first().name
final chs = client.getChannels(cn)
final chi = chs.first()
Expand All @@ -246,6 +250,7 @@ class ClientSpec extends Specification {
final ch = conn.createChannel()

when: "client retrieves channel info"
awaitEventPropagation()
final chs = client.getChannels()
final chi = client.getChannel(chs.first().name)

Expand Down Expand Up @@ -1277,4 +1282,14 @@ class ClientSpec extends Specification {
return Integer.signum(vals1.length - vals2.length);
}
}

/**
* Statistics tables in the server are updated asynchronously,
* in particular starting with rabbitmq/rabbitmq-management#236,
* so in some cases we need to wait before GET'ing e.g. a newly opened connection.
*/
protected void awaitEventPropagation() {
// same number as used in rabbit-hole test suite. Works OK.
Thread.sleep(1000)
}
}

0 comments on commit b88a9ea

Please sign in to comment.