@@ -35,33 +35,36 @@ import (
35
35
)
36
36
37
37
func TestMain (m * testing.M ) {
38
- paramtable .Init ()
39
- pt := paramtable .Get ()
40
- pt .Save (pt .ServiceParam .MQCfg .EnablePursuitMode .Key , "false" )
41
-
42
- rand .Seed (time .Now ().UnixNano ())
43
- path := "/tmp/milvus/rdb_data"
44
- defer os .RemoveAll (path )
45
- paramtable .Get ().Save ("rocksmq.compressionTypes" , "0,0,0,0,0" )
46
- _ = server2 .InitRocksMQ (path )
47
- exitCode := m .Run ()
48
- defer server2 .CloseRocksMQ ()
38
+ exitCode := func () int {
39
+ paramtable .Init ()
40
+ pt := paramtable .Get ()
41
+ pt .Save (pt .ServiceParam .MQCfg .EnablePursuitMode .Key , "false" )
42
+
43
+ rand .Seed (time .Now ().UnixNano ())
44
+ path := "/tmp/milvus/rdb_data"
45
+ defer os .RemoveAll (path )
46
+ paramtable .Get ().Save ("rocksmq.compressionTypes" , "0,0,0,0,0" )
47
+ _ = server2 .InitRocksMQ (path )
48
+ defer server2 .CloseRocksMQ ()
49
+ return m .Run ()
50
+ }()
51
+
49
52
os .Exit (exitCode )
50
53
}
51
54
52
55
func Test_NewRmqClient (t * testing.T ) {
53
56
client , err := createRmqClient ()
54
- defer client .Close ()
55
57
assert .NoError (t , err )
56
58
assert .NotNil (t , client )
59
+ client .Close ()
57
60
}
58
61
59
62
func TestRmqClient_CreateProducer (t * testing.T ) {
60
63
opts := client3.Options {}
61
64
client , err := NewClient (opts )
62
- defer client .Close ()
63
65
assert .NoError (t , err )
64
66
assert .NotNil (t , client )
67
+ defer client .Close ()
65
68
66
69
topic := "TestRmqClient_CreateProducer"
67
70
proOpts := common.ProducerOptions {Topic : topic }
@@ -143,9 +146,9 @@ func TestRmqClient_GetLatestMsg(t *testing.T) {
143
146
144
147
func TestRmqClient_Subscribe (t * testing.T ) {
145
148
client , err := createRmqClient ()
146
- defer client .Close ()
147
149
assert .NoError (t , err )
148
150
assert .NotNil (t , client )
151
+ defer client .Close ()
149
152
150
153
topic := "TestRmqClient_Subscribe"
151
154
proOpts := common.ProducerOptions {Topic : topic }
@@ -178,9 +181,9 @@ func TestRmqClient_Subscribe(t *testing.T) {
178
181
179
182
consumerOpts .Topic = topic
180
183
consumer , err = client .Subscribe (context .TODO (), consumerOpts )
181
- defer consumer .Close ()
182
184
assert .NoError (t , err )
183
185
assert .NotNil (t , consumer )
186
+ defer consumer .Close ()
184
187
assert .Equal (t , consumer .Subscription (), subName )
185
188
186
189
msg := & common.ProducerMessage {
0 commit comments