Skip to content

Commit 21957bc

Browse files
authored
Fix zmq endpoints in test cases (#150)
* Using the IP address 127.0.0.1 instead of localhost in test cases for zmq to prevent potential name resolution issues Signed-off-by: Qifan Deng <[email protected]> * Ignore vscode devcontainer config Signed-off-by: Qifan Deng <[email protected]> * Fix a formatting error introduced by commit 9235047 Signed-off-by: Qifan Deng <[email protected]> --------- Signed-off-by: Qifan Deng <[email protected]>
1 parent ad487ee commit 21957bc

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ bin
22
lib
33
vendor
44
.vscode
5+
.devcontainer
56
# MacOSX
67
.DS_Store

pkg/common/publisher_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ import (
2929
)
3030

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

3738
var _ = Describe("Publisher", func() {
@@ -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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ import (
3333
)
3434

3535
const (
36-
req1ID = "req1"
37-
req2ID = "req2"
38-
req3ID = "req3"
39-
endpoint = "tcp://localhost:5557"
36+
req1ID = "req1"
37+
req2ID = "req2"
38+
req3ID = "req3"
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)