Skip to content

Commit 0b22dc2

Browse files
committed
Use POST /pub instead deprecated POST /put for tests
1 parent 008e704 commit 0b22dc2

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

test/consumer_test.exs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ defmodule NSQ.ConsumerTest do
4949
NSQ.Consumer.event_manager(consumer)
5050
|> GenEvent.add_handler(NSQ.ConsumerTest.EventForwarder, self())
5151

52-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "hello"])
52+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "hello"])
5353
assert_receive {:message_finished, _}, 2000
5454

55-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "too_slow"])
55+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "too_slow"])
5656
assert_receive {:message_requeued, _}, 2000
5757
end
5858

@@ -75,7 +75,7 @@ defmodule NSQ.ConsumerTest do
7575
NSQ.Consumer.event_manager(consumer)
7676
|> GenEvent.add_handler(NSQ.ConsumerTest.EventForwarder, self())
7777

78-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "hello"])
78+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "hello"])
7979

8080
# Without touch, this message would fail after 1 second. So we test that
8181
# it takes longer than 1 second but succeeds.
@@ -96,12 +96,12 @@ defmodule NSQ.ConsumerTest do
9696
end
9797
})
9898

99-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "hello"])
100-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "hello"])
101-
HTTP.post("http://127.0.0.1:6761/put?topic=#{@test_topic}", [body: "hello"])
102-
HTTP.post("http://127.0.0.1:6761/put?topic=#{@test_topic}", [body: "hello"])
103-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "hello"])
104-
HTTP.post("http://127.0.0.1:6761/put?topic=#{@test_topic}", [body: "hello"])
99+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "hello"])
100+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "hello"])
101+
HTTP.post("http://127.0.0.1:6761/pub?topic=#{@test_topic}", [body: "hello"])
102+
HTTP.post("http://127.0.0.1:6761/pub?topic=#{@test_topic}", [body: "hello"])
103+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "hello"])
104+
HTTP.post("http://127.0.0.1:6761/pub?topic=#{@test_topic}", [body: "hello"])
105105

106106
:timer.sleep(100)
107107
[info1, info2] = NSQ.Consumer.conn_info(consumer) |> Map.values
@@ -135,14 +135,14 @@ defmodule NSQ.ConsumerTest do
135135
end
136136
})
137137

138-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "fast"])
138+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "fast"])
139139
assert_receive(:handled, 2000)
140140

141-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "slow"])
142-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "medium"])
141+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "slow"])
142+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "medium"])
143143
NSQ.Consumer.close(consumer)
144144
:timer.sleep(50)
145-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "fast"])
145+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "fast"])
146146
refute_receive(:handled, 2000)
147147
end
148148

@@ -159,7 +159,7 @@ defmodule NSQ.ConsumerTest do
159159
NSQ.Consumer.event_manager(consumer)
160160
|> GenEvent.add_handler(NSQ.ConsumerTest.EventForwarder, self())
161161

162-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
162+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
163163
assert_receive(:handled, 2000)
164164

165165
assert_receive({:message, %NSQ.Message{}}, 2000)
@@ -189,11 +189,11 @@ defmodule NSQ.ConsumerTest do
189189
previous_timestamp = info.last_msg_timestamp
190190
:timer.sleep(1000)
191191

192-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "ok"])
193-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "req"])
194-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "req2000"])
195-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "fail"])
196-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "backoff"])
192+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "ok"])
193+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "req"])
194+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "req2000"])
195+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "fail"])
196+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "backoff"])
197197

198198
assert_receive({:message, _}, 2000)
199199
assert_receive({:message, _}, 2000)
@@ -230,7 +230,7 @@ defmodule NSQ.ConsumerTest do
230230
})
231231

232232
# Send a message so we can be sure the connection is up and working first.
233-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
233+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
234234
assert_receive(:handled, 2000)
235235

236236
# Abruptly close the connection
@@ -255,7 +255,7 @@ defmodule NSQ.ConsumerTest do
255255
assert conn1 != conn2
256256

257257
# Send another message so we can verify the new connection is working.
258-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
258+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
259259
assert_receive(:handled, 2000)
260260
end
261261

@@ -271,10 +271,10 @@ defmodule NSQ.ConsumerTest do
271271
end
272272
})
273273

274-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
274+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
275275
assert_receive(:handled, 2000)
276276

277-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
277+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
278278
assert_receive(:handled, 2000)
279279
end
280280

@@ -291,8 +291,8 @@ defmodule NSQ.ConsumerTest do
291291
end
292292
})
293293

294-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
295-
HTTP.post("http://127.0.0.1:6761/put?topic=#{@test_topic}", [body: "HTTP message"])
294+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
295+
HTTP.post("http://127.0.0.1:6761/pub?topic=#{@test_topic}", [body: "HTTP message"])
296296

297297
assert_receive(:handled, 2000)
298298
assert_receive(:handled, 2000)
@@ -374,7 +374,7 @@ defmodule NSQ.ConsumerTest do
374374
})
375375

376376
Enum.map 1..1000, fn(_i) ->
377-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
377+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
378378
end
379379

380380
assert_receive_n_times(:handled, 1000, 2000)
@@ -424,11 +424,11 @@ defmodule NSQ.ConsumerTest do
424424

425425
# Send one successful message through so our subsequent timing is more
426426
# predictable.
427-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
427+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
428428
assert_receive({:message_finished, _}, 5000)
429429

430430
# Our message handler enters into backoff mode and requeues the message.
431-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
431+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
432432
assert_receive({:message_requeued, _}, 2000)
433433
assert_receive(:backoff, 1000)
434434

@@ -474,7 +474,7 @@ defmodule NSQ.ConsumerTest do
474474
assert_receive({:message_finished, _}, 2000)
475475

476476
# Send a successful message and leave backoff mode! (I hope!)
477-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
477+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
478478
assert_receive({:message_finished, _}, 2000)
479479
assert_receive(:resume, 100)
480480
cons_state = Cons.get_state(consumer)
@@ -501,7 +501,7 @@ defmodule NSQ.ConsumerTest do
501501
cons = Cons.get(cons_sup_pid)
502502
[conn] = Connections.get(cons)
503503

504-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
504+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
505505
refute_receive :handled, 500
506506
cons_state = Cons.get_state(cons)
507507
assert ConnInfo.fetch(cons_state, conn, :retry_rdy_pid) == nil
@@ -571,10 +571,10 @@ defmodule NSQ.ConsumerTest do
571571
end
572572
})
573573

574-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
574+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
575575
assert_receive(:handled, 2000)
576576

577-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
577+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
578578
assert_receive(:handled, 2000)
579579
end
580580

@@ -596,7 +596,7 @@ defmodule NSQ.ConsumerTest do
596596
end
597597
})
598598

599-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
599+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
600600
refute_receive(:handled, 2000)
601601
end
602602
end
@@ -618,12 +618,12 @@ defmodule NSQ.ConsumerTest do
618618
assert NSQ.Consumer.starved?(consumer) == false
619619

620620
# One message in flight, 50% of last_rdy, not starved
621-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
621+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
622622
assert_receive({:message, _}, 2000)
623623
assert NSQ.Consumer.starved?(consumer) == false
624624

625625
# Two messages in flight, 100% of last_rdy, __starved__
626-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
626+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
627627
assert_receive({:message, _}, 2000)
628628
assert NSQ.Consumer.starved?(consumer) == true
629629

@@ -647,10 +647,10 @@ defmodule NSQ.ConsumerTest do
647647
end
648648
})
649649

650-
HTTP.post("http://127.0.0.1:6766/put?topic=#{@test_topic}", [body: "HTTP message"])
650+
HTTP.post("http://127.0.0.1:6766/pub?topic=#{@test_topic}", [body: "HTTP message"])
651651
assert_receive(:handled, 2000)
652652

653-
HTTP.post("http://127.0.0.1:6766/put?topic=#{@test_topic}", [body: "HTTP message"])
653+
HTTP.post("http://127.0.0.1:6766/pub?topic=#{@test_topic}", [body: "HTTP message"])
654654
assert_receive(:handled, 2000)
655655
end
656656

@@ -667,10 +667,10 @@ defmodule NSQ.ConsumerTest do
667667
end
668668
})
669669

670-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
670+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
671671
assert_receive(:handled, 2000)
672672

673-
HTTP.post("http://127.0.0.1:6751/put?topic=#{@test_topic}", [body: "HTTP message"])
673+
HTTP.post("http://127.0.0.1:6751/pub?topic=#{@test_topic}", [body: "HTTP message"])
674674
assert_receive(:handled, 2000)
675675
end
676676

@@ -693,10 +693,10 @@ defmodule NSQ.ConsumerTest do
693693
end
694694
})
695695

696-
HTTP.post("http://127.0.0.1:6766/put?topic=#{@test_topic}", [body: "HTTP message"])
696+
HTTP.post("http://127.0.0.1:6766/pub?topic=#{@test_topic}", [body: "HTTP message"])
697697
assert_receive(:handled, 2000)
698698

699-
HTTP.post("http://127.0.0.1:6766/put?topic=#{@test_topic}", [body: "HTTP message"])
699+
HTTP.post("http://127.0.0.1:6766/pub?topic=#{@test_topic}", [body: "HTTP message"])
700700
assert_receive(:handled, 2000)
701701
end
702702

0 commit comments

Comments
 (0)