Skip to content

Commit 99c6d86

Browse files
committed
Using the IP address 127.0.0.1 instead of localhost in test cases for zmq to prevent potential name resolution issues
1 parent c3aae8d commit 99c6d86

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/common/publisher_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import (
3030

3131
const (
3232
topic = "test-topic"
33-
endpoint = "tcp://localhost:5557"
33+
subEndpoint = "tcp://*:5557"
34+
pubEndpoint = "tcp://localhost:5557"
3435
data = "Hello"
3536
)
3637

@@ -40,7 +41,7 @@ var _ = Describe("Publisher", func() {
4041
Expect(err).NotTo(HaveOccurred())
4142
sub, err := zctx.NewSocket(zmq.SUB)
4243
Expect(err).NotTo(HaveOccurred())
43-
err = sub.Bind(endpoint)
44+
err = sub.Bind(subEndpoint)
4445
Expect(err).NotTo(HaveOccurred())
4546
err = sub.SetSubscribe(topic)
4647
Expect(err).NotTo(HaveOccurred())
@@ -49,7 +50,7 @@ var _ = Describe("Publisher", func() {
4950

5051
time.Sleep(100 * time.Millisecond)
5152

52-
pub, err := NewPublisher(endpoint)
53+
pub, err := NewPublisher(pubEndpoint)
5354
Expect(err).NotTo(HaveOccurred())
5455

5556
ctx, cancel := context.WithCancel(context.Background())

pkg/kv-cache/kv_cache_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const (
3636
req1ID = "req1"
3737
req2ID = "req2"
3838
req3ID = "req3"
39-
endpoint = "tcp://localhost:5557"
39+
subEndpoint = "tcp://*:5557"
40+
pubEndpoint = "tcp://localhost:5557"
4041
)
4142

4243
type ActionType int
@@ -203,7 +204,7 @@ var _ = Describe("KV cache", Ordered, func() {
203204
Port: 1234,
204205
Model: "model",
205206
KVCacheSize: test.cacheSize,
206-
ZMQEndpoint: endpoint,
207+
ZMQEndpoint: pubEndpoint,
207208
EventBatchSize: 1,
208209
}
209210

@@ -306,7 +307,7 @@ var _ = Describe("KV cache", Ordered, func() {
306307
Port: 1234,
307308
Model: "model",
308309
KVCacheSize: 4,
309-
ZMQEndpoint: endpoint,
310+
ZMQEndpoint: pubEndpoint,
310311
}
311312

312313
sub, topic := createSub(config)
@@ -415,7 +416,7 @@ var _ = Describe("KV cache", Ordered, func() {
415416
Port: 1234,
416417
Model: "model",
417418
KVCacheSize: testCase.cacheSize,
418-
ZMQEndpoint: endpoint,
419+
ZMQEndpoint: pubEndpoint,
419420
}
420421
blockCache, err := newBlockCache(&config, GinkgoLogr)
421422
Expect(err).NotTo(HaveOccurred())
@@ -531,7 +532,7 @@ func createSub(config *common.Configuration) (*zmq.Socket, string) {
531532
Expect(err).NotTo(HaveOccurred())
532533
sub, err := zctx.NewSocket(zmq.SUB)
533534
Expect(err).NotTo(HaveOccurred())
534-
err = sub.Bind(endpoint)
535+
err = sub.Bind(subEndpoint)
535536
Expect(err).NotTo(HaveOccurred())
536537
topic := createTopic(config)
537538
err = sub.SetSubscribe(topic)

0 commit comments

Comments
 (0)