You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Stevent-fei (via GitHub)" <gi...@apache.org> on 2023/05/24 07:11:22 UTC

[GitHub] [rocketmq-e2e] Stevent-fei opened a new pull request, #32: Add normal and delay test

Stevent-fei opened a new pull request, #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32

   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   <!--
   If this PR fixes a GitHub issue, please add `fixes #<XXX>` or `closes #<XXX>`. Please refer to the documentation for more information:
   https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
   -->
   
   fix #<xxx> <!-- <xxx> replace with issue id -->
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-e2e] fakerpawnno1 commented on a diff in pull request #32: Add message test

Posted by "fakerpawnno1 (via GitHub)" <gi...@apache.org>.
fakerpawnno1 commented on code in PR #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32#discussion_r1211343746


##########
golang/utils/CheckUtils.go:
##########
@@ -75,3 +76,16 @@ func CheckFIFOMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector,
 func CheckTransactionMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
 	CheckMsgsWithMsgId(t, sendMsgsCollector, recvMsgsCollector)
 }
+
+func CheckMsgsWithMsgBody(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
+	var sendMsg string
+	var recvMsg string
+	for _, sed := range sendMsgsCollector.SendMsgs {
+		sendMsg = string(sed.Body)
+	}
+	for _, recv := range recvMsgsCollector.RecvMsgViews {
+		recvMsg = string(recv.GetBody())
+	}
+
+	assert.Equal(t, sendMsg, recvMsg)

Review Comment:
   check逻辑是否合理?看起来好像只check了最后一条消息body



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-e2e] Stevent-fei commented on a diff in pull request #32: Add message test

Posted by "Stevent-fei (via GitHub)" <gi...@apache.org>.
Stevent-fei commented on code in PR #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32#discussion_r1211409240


##########
golang/utils/CheckUtils.go:
##########
@@ -75,3 +76,16 @@ func CheckFIFOMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector,
 func CheckTransactionMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
 	CheckMsgsWithMsgId(t, sendMsgsCollector, recvMsgsCollector)
 }
+
+func CheckMsgsWithMsgBody(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
+	var sendMsg string
+	var recvMsg string
+	for _, sed := range sendMsgsCollector.SendMsgs {
+		sendMsg = string(sed.Body)
+	}
+	for _, recv := range recvMsgsCollector.RecvMsgViews {
+		recvMsg = string(recv.GetBody())
+	}
+
+	assert.Equal(t, sendMsg, recvMsg)

Review Comment:
   check这里后面还会完善



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-e2e] fakerpawnno1 commented on a diff in pull request #32: Add message test

Posted by "fakerpawnno1 (via GitHub)" <gi...@apache.org>.
fakerpawnno1 commented on code in PR #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32#discussion_r1211564113


##########
golang/message/delay_test.go:
##########
@@ -0,0 +1,96 @@
+package rocketmqtest
+
+import (
+	"context"
+	"fmt"
+	. "rocketmq-go-e2e/utils"
+	"testing"
+	"time"
+
+	rmq_client "github.com/apache/rocketmq-clients/golang"
+)
+
+func TestSendDelayMassage(t *testing.T) {
+	type args struct {
+		name, testTopic, nameServer, grpcEndpoint, clusterName, ak, sk, cm, msgtag, keys, body string
+		deliveryTimestamp                                                                      int
+	}
+	tests := []struct {
+		name string
+		args args
+	}{
+		{
+			name: "Send delay messages synchronously with the body size of 4M+1, expect send failed",
+			args: args{
+				testTopic:         GetTopicName(),
+				nameServer:        NAMESERVER,
+				grpcEndpoint:      GRPC_ENDPOINT,
+				clusterName:       CLUSTER_NAME,
+				ak:                "",
+				sk:                "",
+				msgtag:            RandomString(8),
+				keys:              RandomString(8),
+				body:              RandomString(4*1024*1024 + 1),
+				deliveryTimestamp: 10,
+			},
+		},
+		{
+			name: "Send delay messages synchronously with the body size of 4M, expect send success",
+			args: args{
+				testTopic:         GetTopicName(),
+				nameServer:        NAMESERVER,
+				grpcEndpoint:      GRPC_ENDPOINT,
+				clusterName:       CLUSTER_NAME,
+				ak:                "",
+				sk:                "",
+				msgtag:            RandomString(8),
+				keys:              RandomString(8),
+				body:              RandomString(4 * 1024 * 1024),
+				deliveryTimestamp: 10,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			CreateDelayTopic(tt.args.testTopic, "", tt.args.clusterName, tt.args.nameServer)
+
+			// new producer instance
+			producer := BuildProducer(tt.args.grpcEndpoint, tt.args.ak, tt.args.sk, tt.args.testTopic)
+			// graceful stop producer
+			defer producer.GracefulStop()
+
+			msg := &rmq_client.Message{
+				// 为当前消息设置 Topic。
+				Topic: tt.args.testTopic,
+				// 消息体。
+				Body: []byte(tt.args.body),
+			}
+
+			if tt.args.keys != "" {
+				// 设置消息索引键,可根据关键字精确查找某条消息。
+				msg.SetKeys(tt.args.keys)
+			}
+
+			if tt.args.msgtag != "" {
+				// 设置消息 Tag,用于消费端根据指定 Tag 过滤消息。
+				msg.SetTag(tt.args.msgtag)
+			}
+
+			if tt.args.deliveryTimestamp != 0 {
+				// 设置延时时间
+				delay := time.Duration(tt.args.deliveryTimestamp) * time.Second
+				sendTime := time.Now().Add(delay)
+				msg.SetDelayTimestamp(sendTime)
+			}
+
+			// 发送消息,需要关注发送结果,并捕获失败等异常。
+			resp, err := producer.Send(context.TODO(), msg)
+			if err != nil {
+				t.Errorf("failed to send delay message, err:%s", err)
+			}
+			for i := 0; i < len(resp); i++ {
+				fmt.Printf("%#v\n", resp[i])

Review Comment:
   是否有必要打印resp



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-e2e] fakerpawnno1 commented on a diff in pull request #32: Add message test

Posted by "fakerpawnno1 (via GitHub)" <gi...@apache.org>.
fakerpawnno1 commented on code in PR #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32#discussion_r1211561896


##########
golang/message/message_body_content_test.go:
##########
@@ -0,0 +1,116 @@
+package rocketmqtest
+
+import (
+	. "rocketmq-go-e2e/utils"
+	"sync"
+	"testing"
+	"time"
+
+	rmq_client "github.com/apache/rocketmq-clients/golang"
+)
+
+func TestMessageContent(t *testing.T) {
+	type args struct {
+		name, testTopic, nameServer, grpcEndpoint, clusterName, ak, sk, cm, msgtag, keys, body string
+	}
+	tests := []struct {
+		name string
+		args args
+	}{
+		{
+			name: "Send normal message, setting message body with space character, expect consume success",
+			args: args{
+				testTopic:    GetTopicName(),
+				nameServer:   NAMESERVER,
+				grpcEndpoint: GRPC_ENDPOINT,
+				clusterName:  CLUSTER_NAME,
+				ak:           "",
+				sk:           "",
+				cm:           GetGroupName(),
+				msgtag:       RandomString(8),
+				keys:         RandomString(8),
+				body:         " ",
+			},
+		},
+		{
+			name: "Send normal message, setting message body with chinese character, expect consume success",
+			args: args{
+				testTopic:    GetTopicName(),
+				nameServer:   NAMESERVER,
+				grpcEndpoint: GRPC_ENDPOINT,
+				clusterName:  CLUSTER_NAME,
+				ak:           "",
+				sk:           "",
+				cm:           GetGroupName(),
+				msgtag:       RandomString(8),
+				keys:         RandomString(8),
+				body:         "中文字符",
+			},
+		},
+		{
+			name: "Send normal message, setting message body with emoji(😱) character, expect consume success",
+			args: args{
+				testTopic:    GetTopicName(),
+				nameServer:   NAMESERVER,
+				grpcEndpoint: GRPC_ENDPOINT,
+				clusterName:  CLUSTER_NAME,
+				ak:           "",
+				sk:           "",
+				cm:           GetGroupName(),
+				msgtag:       RandomString(8),
+				keys:         RandomString(8),
+				body:         "😱",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			var wg sync.WaitGroup
+			// maximum number of messages received at one time
+			var maxMessageNum int32 = 32
+			// invisibleDuration should > 20s
+			var invisibleDuration = time.Second * 20
+			var msgCount = 10
+
+			CreateTopic(tt.args.testTopic, "", tt.args.clusterName, tt.args.nameServer)
+			simpleConsumer := BuildSimpleConsumer(tt.args.grpcEndpoint, tt.args.cm, tt.args.msgtag, tt.args.ak, tt.args.sk, tt.args.testTopic)
+
+			// new producer instance
+			producer := BuildProducer(tt.args.grpcEndpoint, tt.args.ak, tt.args.sk, tt.args.testTopic)
+			// graceful stop producer
+			defer producer.GracefulStop()
+
+			msg := &rmq_client.Message{
+				// 为当前消息设置 Topic。
+				Topic: tt.args.testTopic,
+				// 消息体。
+				Body: []byte(tt.args.body),
+			}
+
+			if tt.args.keys != "" {
+				// 设置消息索引键,可根据关键字精确查找某条消息。

Review Comment:
   这个判断是否有必要?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-e2e] fakerpawnno1 commented on a diff in pull request #32: Add message test

Posted by "fakerpawnno1 (via GitHub)" <gi...@apache.org>.
fakerpawnno1 commented on code in PR #32:
URL: https://github.com/apache/rocketmq-e2e/pull/32#discussion_r1211554662


##########
golang/utils/CheckUtils.go:
##########
@@ -75,3 +76,16 @@ func CheckFIFOMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector,
 func CheckTransactionMsgsWithMsgId(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
 	CheckMsgsWithMsgId(t, sendMsgsCollector, recvMsgsCollector)
 }
+
+func CheckMsgsWithMsgBody(t *testing.T, sendMsgsCollector *SendMsgsCollector, recvMsgsCollector *RecvMsgsCollector) {
+	var sendMsg string
+	var recvMsg string
+	for _, sed := range sendMsgsCollector.SendMsgs {
+		sendMsg = string(sed.Body)
+	}
+	for _, recv := range recvMsgsCollector.RecvMsgViews {
+		recvMsg = string(recv.GetBody())
+	}
+
+	assert.Equal(t, sendMsg, recvMsg)

Review Comment:
   没有完善的代码不应该提交pr。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org