Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestConsumer(t *testing.T) {
}

func TestRequeue(t *testing.T) {
c := &Client{Address: "localhost:4151"}
c := &Client{Address: "127.0.0.1:4151"}

if err := c.Publish("test-requeue", []byte("Hello World!")); err != nil {
t.Error(err)
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestRequeue(t *testing.T) {
func TestDrainAndRequeueOnStop(t *testing.T) {
p, _ := NewProducer(ProducerConfig{
Topic: "test-stop-requeue",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand All @@ -157,7 +157,7 @@ func TestDrainAndRequeueOnStop(t *testing.T) {
consumer, err := NewConsumer(ConsumerConfig{
Topic: "test-stop-requeue",
Channel: "foo",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestDrainAndRequeueOnStop(t *testing.T) {
consumer2, _ := NewConsumer(ConsumerConfig{
Topic: "test-stop-requeue",
Channel: "foo",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestDrainAndRequeueOnStopWithMessageTimeout(t *testing.T) {
numberMessages := 25
p, _ := NewProducer(ProducerConfig{
Topic: TopicName,
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand All @@ -260,7 +260,7 @@ func TestDrainAndRequeueOnStopWithMessageTimeout(t *testing.T) {
consumer, err := NewConsumer(ConsumerConfig{
Topic: TopicName,
Channel: "foo",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand All @@ -283,14 +283,14 @@ func TestDrainAndRequeueOnStopWithMessageTimeout(t *testing.T) {
for msgNum < 5 {
select {
case msg := <-consumer.Messages():
fmt.Printf("start handling message %s\n", string(msg.Body))
fmt.Printf("consumer 1: handling message %s\n", string(msg.Body))
msgNum++
case <-deadline.C:
t.Error("timeout")
return
}
}
fmt.Printf("Allow some time for the nsqd to timeout received messages")
fmt.Printf("Allow some time for the nsqd to timeout received messages\n")
// Allow some time for the nsqd to timeout received messages and send 10+ more messages
// to client to deadlock runConn
time.Sleep(6 * time.Second)
Expand All @@ -306,7 +306,7 @@ func TestDrainAndRequeueOnStopWithMessageTimeout(t *testing.T) {
consumer2, _ := NewConsumer(ConsumerConfig{
Topic: TopicName,
Channel: "foo",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
DialTimeout: time.Second * 60,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
Expand All @@ -322,7 +322,7 @@ func TestDrainAndRequeueOnStopWithMessageTimeout(t *testing.T) {
for msgNum < numberMessages {
select {
case msg := <-consumer2.Messages():
fmt.Printf("handling message %s\n", string(msg.Body))
fmt.Printf("consumer 2: handling message %s\n", string(msg.Body))
msg.Finish()
msgNum++
delete(sentMessages, string(msg.Body))
Expand Down
4 changes: 2 additions & 2 deletions identify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
func TestIdentify(t *testing.T) {
testCommand(t, "IDENTIFY", Identify{
ClientID: "0123456789",
Hostname: "localhost",
Hostname: "127.0.0.1",
UserAgent: "nsq-go/test",
// timeout omitted.
})
testCommand(t, "IDENTIFY", Identify{
ClientID: "0123456789",
Hostname: "localhost",
Hostname: "127.0.0.1",
UserAgent: "nsq-go/test",
MessageTimeout: 10 * time.Minute,
})
Expand Down
12 changes: 6 additions & 6 deletions lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

var (
nsqlookup = []string{
"localhost:4161", // nsqlookup-1
"localhost:4163", // nsqlookup-2
"localhost:4165", // nsqlookup-3
"127.0.0.1:4161", // nsqlookup-1
"127.0.0.1:4163", // nsqlookup-2
"127.0.0.1:4165", // nsqlookup-3
}

nsqd = []string{
"localhost:4151", // nsqd-1
"localhost:4153", // nsqd-2
"localhost:4155", // nsqd-3
"127.0.0.1:4151", // nsqd-1
"127.0.0.1:4153", // nsqd-2
"127.0.0.1:4155", // nsqd-3
}
)

Expand Down
4 changes: 2 additions & 2 deletions producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ func TestProducer(t *testing.T) {
c, _ := StartConsumer(ConsumerConfig{
Topic: topic,
Channel: "channel",
Address: "localhost:4150",
Address: "127.0.0.1:4150",
})
defer c.Stop()

// Give some time for the consumer to connect.
time.Sleep(100 * time.Millisecond)

p, _ := StartProducer(ProducerConfig{
Address: "localhost:4150",
Address: "127.0.0.1:4150",
Topic: topic,
MaxConcurrency: 3,
})
Expand Down