提交 cd8f9a56 编写于 作者: W wenfeng 提交者: dinglei

Adding test_case for volunteers. (#31)

* Adding docs/test_case.md and gofmt

* Update: docs/test_case.md
上级 d1336038
......@@ -18,8 +18,10 @@ package rocketmq
import "fmt"
const GoClientVersion = "Go Client V1.2.0, Support CPP Core:V1.2.X"
func Version() (version string) {
return GetVersion()
return GoClientVersion
}
type ClientConfig struct {
......
......@@ -75,3 +75,14 @@ func TestPushConsumerConfig_String(t *testing.T) {
" MessageBatchMaxSize: 32, MessageModel: Clustering, ]"
assert.Equal(t, expect, pcConfig.String())
}
func TestMessageModel_String(t *testing.T) {
m := BroadCasting
assert.Equal(t, "BroadCasting", m.String())
m = Clustering
assert.Equal(t, "Clustering", m.String())
m = 3
assert.Equal(t, "Unknown", m.String())
}
......@@ -235,12 +235,12 @@ func (p *defaultProducer) SendMessageOrderly(msg *Message, selector MessageQueue
unsafe.Pointer(&key),
C.int(autoRetryTimes),
&sr))
if err != NIL {
log.Warnf("send message orderly error, error is: %s", err.Error())
return nil, err
}
return &SendResult{
Status: SendStatus(sr.sendStatus),
MsgId: C.GoString(&sr.msgId[0]),
......@@ -257,7 +257,7 @@ func (p *defaultProducer) SendMessageOneway(msg *Message) error {
log.Warnf("send message with oneway error, error is: %s", err.Error())
return err
}
log.Debugf("Send Message: %s with oneway success.", msg.String())
return nil
}
......@@ -16,28 +16,3 @@
*/
package rocketmq
//func TestCreateMessage(test *testing.T){
// fmt.Println("-----TestCreateMessage Start----")
// rocketmq.CreateMessage("testTopic")
// fmt.Println("-----TestCreateMessage Finish----")
//}
//
//func TestDestroyMessage(test *testing.T){
// fmt.Println("-----TestCreateMessage Start----")
// msg := rocketmq.CreateMessage("testTopic")
// rocketmq.DestroyMessage(msg)
// fmt.Println("-----TestCreateMessage Finish----")
//}
//func TestSetMessageKeys(test *testing.T){
// fmt.Println("-----TestSetMessageKeys Start----")
// msg := rocketmq.CreateMessage("testTopic")
// len := rocketmq.SetMessageKeys(msg,"testKey")
// fmt.Println("Len:",len)
// rocketmq.DestroyMessage(msg)
// fmt.Println("-----TestCreateMessage Finish----")
//}
//func TestCreateProducer(test *testing.T){
// fmt.Println("-----TestCreateProducer Start----")
// rocketmq.CreateProducer("testGroupId")
// fmt.Println("-----TestCreateProducer Finish----")
//}
......@@ -32,11 +32,11 @@ int callback_cgo(CPushConsumer *consumer, CMessageExt *msg) {
import "C"
import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"sync"
"unsafe"
"errors"
)
type ConsumeStatus int
......
......@@ -14,15 +14,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq
//import "fmt"
//import "testing"
//import "../client"
//
//func TestCreatePushConsumer(test *testing.T){
// fmt.Println("-----TestCreateProducer Start----")
// consumer := rocketmq.CreatePushConsumer("testGroupId")
// rocketmq.DestroyPushConsumer(consumer)
// fmt.Println("-----TestCreateProducer Finish----")
//}
package rocketmq
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq
import "fmt"
// MessageQueue the queue of the message
type MessageQueue struct {
Topic string
Broker string
ID int
}
func (q *MessageQueue) String() string {
return fmt.Sprintf("broker:%s, topic:%s, id:%d", q.Broker, q.Topic, q.ID)
}
......@@ -18,11 +18,23 @@ package rocketmq
import "C"
import (
"fmt"
"strconv"
"sync"
"unsafe"
)
// MessageQueue the queue of the message
type MessageQueue struct {
Topic string
Broker string
ID int
}
func (q *MessageQueue) String() string {
return fmt.Sprintf("broker:%s, topic:%s, id:%d", q.Broker, q.Topic, q.ID)
}
var selectors = selectorHolder{selectors: map[int]*messageQueueSelectorWrapper{}}
//export queueSelectorCallback
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq
const GoClientVersion = "Go Client V1.2.0, Support CPP Core:V1.2.X"
func GetVersion() (version string) {
return GoClientVersion
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq
//import (
// "fmt"
// "testing"
// "../client"
//)
//
//func TestGetVersion(test *testing.T){
// fmt.Println("-----TestGetVersion Start----")
// version := rocketmq.GetVersion();
// fmt.Println(version)
// fmt.Println("-----TestGetVersion Finish----")
//}
# Apache RocketMQ Golang Client Test Case List
## Unit Test
**TODO: How to mock cgo API**
### core package
#### api.go
- [ ] `func (config *ClientConfig) String() string`
- [x] `func (config *ProducerConfig) String() string`
- [x] `func (mode MessageModel) String() string`
- [x] `func (config *PushConsumerConfig) String() string`
- [ ] `func (config *PullConsumerConfig) String() string`
- [ ] `func (session *SessionCredentials) String() string`
- [ ] `func (result *SendResult) String() string`
#### cfuns.go
- [ ] `func consumeMessageCallback(cconsumer *C.CPushConsumer, msg *C.CMessageExt) C.int `
#### error.go
- [ ] `func (e rmqError) Error() string`
#### log.go
- [x] `func (l LogLevel) String() string `
- [x] `func (lc *LogConfig) String() string `
#### message.go
- [ ] `func (msg *Message) String() string`
- [ ] `func goMsgToC(gomsg *Message) *C.struct_CMessage `
- [ ] `func (msgExt *MessageExt) String() string`
- [ ] `func (msgExt *MessageExt) GetProperty(key string) string `
- [ ] `func cmsgExtToGo(cmsg *C.struct_CMessageExt) *MessageExt `
#### producer.go
- [ ] `func (status SendStatus) String() string `
- [ ] `func newDefaultProducer(config *ProducerConfig) (*defaultProducer, error)`
- [ ] `func (p *defaultProducer) String() string `
- [ ] `func (p *defaultProducer) Start() error `
- [ ] `func (p *defaultProducer) Shutdown() error `
- [ ] `func (p *defaultProducer) SendMessageSync(msg *Message) (*SendResult, error)`
- [ ] `func (p *defaultProducer) SendMessageOrderly(msg *Message, selector MessageQueueSelector, arg interface{}, autoRetryTimes int) (*SendResult, error) `
- [ ] `func (p *defaultProducer) SendMessageOneway(msg *Message) error `
#### pull_consumer.go
- [ ] `func (ps PullStatus) String() string `
- [ ] `func (c *defaultPullConsumer) String() string `
- [ ] `func NewPullConsumer(config *PullConsumerConfig) (PullConsumer, error) `
- [ ] `func (c *defaultPullConsumer) Start() error `
- [ ] `func (c *defaultPullConsumer) Shutdown() error `
- [ ] `func (c *defaultPullConsumer) FetchSubscriptionMessageQueues(topic string) []MessageQueue `
- [ ] `func (pr *PullResult) String() string `
- [ ] `func (c *defaultPullConsumer) Pull(mq MessageQueue, subExpression string, offset int64, maxNums int) PullResult `
#### push_consumer.go
- [ ] `func (status ConsumeStatus) String() string `
- [ ] `func (c *defaultPushConsumer) String() string `
- [ ] `func newPushConsumer(config *PushConsumerConfig) (PushConsumer, error) `
- [ ] `func (c *defaultPushConsumer) Start() error `
- [ ] `func (c *defaultPushConsumer) Shutdown() error `
- [ ] `func (c *defaultPushConsumer) Subscribe(topic, expression string, consumeFunc func(msg *MessageExt) ConsumeStatus) error `
#### queue_selector.go
- [ ] `func (q *MessageQueue) String() string `
- [ ] `func queueSelectorCallback(size int, selectorKey unsafe.Pointer) int `
- [x] `func (w *messageQueueSelectorWrapper) Select(size int) int`
- [x] `func (s *selectorHolder) put(selector *messageQueueSelectorWrapper) (key int) `
- [x] `func (s *selectorHolder) getAndDelete(key int) (*messageQueueSelectorWrapper, bool) `
## Integration Test
### Producer
- send message with `DelayTimeLevel`
- send message with `tag`
- send message orderly with `tag`
### Consumer
- consume message delayed through push/pull
- subscribe topic with expression
- pull message with expression
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册